babylon.module.d.ts 5.5 MB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761257622576325764257652576625767257682576925770257712577225773257742577525776257772577825779257802578125782257832578425785257862578725788257892579025791257922579325794257952579625797257982579925800258012580225803258042580525806258072580825809258102581125812258132581425815258162581725818258192582025821258222582325824258252582625827258282582925830258312583225833258342583525836258372583825839258402584125842258432584425845258462584725848258492585025851258522585325854258552585625857258582585925860258612586225863258642586525866258672586825869258702587125872258732587425875258762587725878258792588025881258822588325884258852588625887258882588925890258912589225893258942589525896258972589825899259002590125902259032590425905259062590725908259092591025911259122591325914259152591625917259182591925920259212592225923259242592525926259272592825929259302593125932259332593425935259362593725938259392594025941259422594325944259452594625947259482594925950259512595225953259542595525956259572595825959259602596125962259632596425965259662596725968259692597025971259722597325974259752597625977259782597925980259812598225983259842598525986259872598825989259902599125992259932599425995259962599725998259992600026001260022600326004260052600626007260082600926010260112601226013260142601526016260172601826019260202602126022260232602426025260262602726028260292603026031260322603326034260352603626037260382603926040260412604226043260442604526046260472604826049260502605126052260532605426055260562605726058260592606026061260622606326064260652606626067260682606926070260712607226073260742607526076260772607826079260802608126082260832608426085260862608726088260892609026091260922609326094260952609626097260982609926100261012610226103261042610526106261072610826109261102611126112261132611426115261162611726118261192612026121261222612326124261252612626127261282612926130261312613226133261342613526136261372613826139261402614126142261432614426145261462614726148261492615026151261522615326154261552615626157261582615926160261612616226163261642616526166261672616826169261702617126172261732617426175261762617726178261792618026181261822618326184261852618626187261882618926190261912619226193261942619526196261972619826199262002620126202262032620426205262062620726208262092621026211262122621326214262152621626217262182621926220262212622226223262242622526226262272622826229262302623126232262332623426235262362623726238262392624026241262422624326244262452624626247262482624926250262512625226253262542625526256262572625826259262602626126262262632626426265262662626726268262692627026271262722627326274262752627626277262782627926280262812628226283262842628526286262872628826289262902629126292262932629426295262962629726298262992630026301263022630326304263052630626307263082630926310263112631226313263142631526316263172631826319263202632126322263232632426325263262632726328263292633026331263322633326334263352633626337263382633926340263412634226343263442634526346263472634826349263502635126352263532635426355263562635726358263592636026361263622636326364263652636626367263682636926370263712637226373263742637526376263772637826379263802638126382263832638426385263862638726388263892639026391263922639326394263952639626397263982639926400264012640226403264042640526406264072640826409264102641126412264132641426415264162641726418264192642026421264222642326424264252642626427264282642926430264312643226433264342643526436264372643826439264402644126442264432644426445264462644726448264492645026451264522645326454264552645626457264582645926460264612646226463264642646526466264672646826469264702647126472264732647426475264762647726478264792648026481264822648326484264852648626487264882648926490264912649226493264942649526496264972649826499265002650126502265032650426505265062650726508265092651026511265122651326514265152651626517265182651926520265212652226523265242652526526265272652826529265302653126532265332653426535265362653726538265392654026541265422654326544265452654626547265482654926550265512655226553265542655526556265572655826559265602656126562265632656426565265662656726568265692657026571265722657326574265752657626577265782657926580265812658226583265842658526586265872658826589265902659126592265932659426595265962659726598265992660026601266022660326604266052660626607266082660926610266112661226613266142661526616266172661826619266202662126622266232662426625266262662726628266292663026631266322663326634266352663626637266382663926640266412664226643266442664526646266472664826649266502665126652266532665426655266562665726658266592666026661266622666326664266652666626667266682666926670266712667226673266742667526676266772667826679266802668126682266832668426685266862668726688266892669026691266922669326694266952669626697266982669926700267012670226703267042670526706267072670826709267102671126712267132671426715267162671726718267192672026721267222672326724267252672626727267282672926730267312673226733267342673526736267372673826739267402674126742267432674426745267462674726748267492675026751267522675326754267552675626757267582675926760267612676226763267642676526766267672676826769267702677126772267732677426775267762677726778267792678026781267822678326784267852678626787267882678926790267912679226793267942679526796267972679826799268002680126802268032680426805268062680726808268092681026811268122681326814268152681626817268182681926820268212682226823268242682526826268272682826829268302683126832268332683426835268362683726838268392684026841268422684326844268452684626847268482684926850268512685226853268542685526856268572685826859268602686126862268632686426865268662686726868268692687026871268722687326874268752687626877268782687926880268812688226883268842688526886268872688826889268902689126892268932689426895268962689726898268992690026901269022690326904269052690626907269082690926910269112691226913269142691526916269172691826919269202692126922269232692426925269262692726928269292693026931269322693326934269352693626937269382693926940269412694226943269442694526946269472694826949269502695126952269532695426955269562695726958269592696026961269622696326964269652696626967269682696926970269712697226973269742697526976269772697826979269802698126982269832698426985269862698726988269892699026991269922699326994269952699626997269982699927000270012700227003270042700527006270072700827009270102701127012270132701427015270162701727018270192702027021270222702327024270252702627027270282702927030270312703227033270342703527036270372703827039270402704127042270432704427045270462704727048270492705027051270522705327054270552705627057270582705927060270612706227063270642706527066270672706827069270702707127072270732707427075270762707727078270792708027081270822708327084270852708627087270882708927090270912709227093270942709527096270972709827099271002710127102271032710427105271062710727108271092711027111271122711327114271152711627117271182711927120271212712227123271242712527126271272712827129271302713127132271332713427135271362713727138271392714027141271422714327144271452714627147271482714927150271512715227153271542715527156271572715827159271602716127162271632716427165271662716727168271692717027171271722717327174271752717627177271782717927180271812718227183271842718527186271872718827189271902719127192271932719427195271962719727198271992720027201272022720327204272052720627207272082720927210272112721227213272142721527216272172721827219272202722127222272232722427225272262722727228272292723027231272322723327234272352723627237272382723927240272412724227243272442724527246272472724827249272502725127252272532725427255272562725727258272592726027261272622726327264272652726627267272682726927270272712727227273272742727527276272772727827279272802728127282272832728427285272862728727288272892729027291272922729327294272952729627297272982729927300273012730227303273042730527306273072730827309273102731127312273132731427315273162731727318273192732027321273222732327324273252732627327273282732927330273312733227333273342733527336273372733827339273402734127342273432734427345273462734727348273492735027351273522735327354273552735627357273582735927360273612736227363273642736527366273672736827369273702737127372273732737427375273762737727378273792738027381273822738327384273852738627387273882738927390273912739227393273942739527396273972739827399274002740127402274032740427405274062740727408274092741027411274122741327414274152741627417274182741927420274212742227423274242742527426274272742827429274302743127432274332743427435274362743727438274392744027441274422744327444274452744627447274482744927450274512745227453274542745527456274572745827459274602746127462274632746427465274662746727468274692747027471274722747327474274752747627477274782747927480274812748227483274842748527486274872748827489274902749127492274932749427495274962749727498274992750027501275022750327504275052750627507275082750927510275112751227513275142751527516275172751827519275202752127522275232752427525275262752727528275292753027531275322753327534275352753627537275382753927540275412754227543275442754527546275472754827549275502755127552275532755427555275562755727558275592756027561275622756327564275652756627567275682756927570275712757227573275742757527576275772757827579275802758127582275832758427585275862758727588275892759027591275922759327594275952759627597275982759927600276012760227603276042760527606276072760827609276102761127612276132761427615276162761727618276192762027621276222762327624276252762627627276282762927630276312763227633276342763527636276372763827639276402764127642276432764427645276462764727648276492765027651276522765327654276552765627657276582765927660276612766227663276642766527666276672766827669276702767127672276732767427675276762767727678276792768027681276822768327684276852768627687276882768927690276912769227693276942769527696276972769827699277002770127702277032770427705277062770727708277092771027711277122771327714277152771627717277182771927720277212772227723277242772527726277272772827729277302773127732277332773427735277362773727738277392774027741277422774327744277452774627747277482774927750277512775227753277542775527756277572775827759277602776127762277632776427765277662776727768277692777027771277722777327774277752777627777277782777927780277812778227783277842778527786277872778827789277902779127792277932779427795277962779727798277992780027801278022780327804278052780627807278082780927810278112781227813278142781527816278172781827819278202782127822278232782427825278262782727828278292783027831278322783327834278352783627837278382783927840278412784227843278442784527846278472784827849278502785127852278532785427855278562785727858278592786027861278622786327864278652786627867278682786927870278712787227873278742787527876278772787827879278802788127882278832788427885278862788727888278892789027891278922789327894278952789627897278982789927900279012790227903279042790527906279072790827909279102791127912279132791427915279162791727918279192792027921279222792327924279252792627927279282792927930279312793227933279342793527936279372793827939279402794127942279432794427945279462794727948279492795027951279522795327954279552795627957279582795927960279612796227963279642796527966279672796827969279702797127972279732797427975279762797727978279792798027981279822798327984279852798627987279882798927990279912799227993279942799527996279972799827999280002800128002280032800428005280062800728008280092801028011280122801328014280152801628017280182801928020280212802228023280242802528026280272802828029280302803128032280332803428035280362803728038280392804028041280422804328044280452804628047280482804928050280512805228053280542805528056280572805828059280602806128062280632806428065280662806728068280692807028071280722807328074280752807628077280782807928080280812808228083280842808528086280872808828089280902809128092280932809428095280962809728098280992810028101281022810328104281052810628107281082810928110281112811228113281142811528116281172811828119281202812128122281232812428125281262812728128281292813028131281322813328134281352813628137281382813928140281412814228143281442814528146281472814828149281502815128152281532815428155281562815728158281592816028161281622816328164281652816628167281682816928170281712817228173281742817528176281772817828179281802818128182281832818428185281862818728188281892819028191281922819328194281952819628197281982819928200282012820228203282042820528206282072820828209282102821128212282132821428215282162821728218282192822028221282222822328224282252822628227282282822928230282312823228233282342823528236282372823828239282402824128242282432824428245282462824728248282492825028251282522825328254282552825628257282582825928260282612826228263282642826528266282672826828269282702827128272282732827428275282762827728278282792828028281282822828328284282852828628287282882828928290282912829228293282942829528296282972829828299283002830128302283032830428305283062830728308283092831028311283122831328314283152831628317283182831928320283212832228323283242832528326283272832828329283302833128332283332833428335283362833728338283392834028341283422834328344283452834628347283482834928350283512835228353283542835528356283572835828359283602836128362283632836428365283662836728368283692837028371283722837328374283752837628377283782837928380283812838228383283842838528386283872838828389283902839128392283932839428395283962839728398283992840028401284022840328404284052840628407284082840928410284112841228413284142841528416284172841828419284202842128422284232842428425284262842728428284292843028431284322843328434284352843628437284382843928440284412844228443284442844528446284472844828449284502845128452284532845428455284562845728458284592846028461284622846328464284652846628467284682846928470284712847228473284742847528476284772847828479284802848128482284832848428485284862848728488284892849028491284922849328494284952849628497284982849928500285012850228503285042850528506285072850828509285102851128512285132851428515285162851728518285192852028521285222852328524285252852628527285282852928530285312853228533285342853528536285372853828539285402854128542285432854428545285462854728548285492855028551285522855328554285552855628557285582855928560285612856228563285642856528566285672856828569285702857128572285732857428575285762857728578285792858028581285822858328584285852858628587285882858928590285912859228593285942859528596285972859828599286002860128602286032860428605286062860728608286092861028611286122861328614286152861628617286182861928620286212862228623286242862528626286272862828629286302863128632286332863428635286362863728638286392864028641286422864328644286452864628647286482864928650286512865228653286542865528656286572865828659286602866128662286632866428665286662866728668286692867028671286722867328674286752867628677286782867928680286812868228683286842868528686286872868828689286902869128692286932869428695286962869728698286992870028701287022870328704287052870628707287082870928710287112871228713287142871528716287172871828719287202872128722287232872428725287262872728728287292873028731287322873328734287352873628737287382873928740287412874228743287442874528746287472874828749287502875128752287532875428755287562875728758287592876028761287622876328764287652876628767287682876928770287712877228773287742877528776287772877828779287802878128782287832878428785287862878728788287892879028791287922879328794287952879628797287982879928800288012880228803288042880528806288072880828809288102881128812288132881428815288162881728818288192882028821288222882328824288252882628827288282882928830288312883228833288342883528836288372883828839288402884128842288432884428845288462884728848288492885028851288522885328854288552885628857288582885928860288612886228863288642886528866288672886828869288702887128872288732887428875288762887728878288792888028881288822888328884288852888628887288882888928890288912889228893288942889528896288972889828899289002890128902289032890428905289062890728908289092891028911289122891328914289152891628917289182891928920289212892228923289242892528926289272892828929289302893128932289332893428935289362893728938289392894028941289422894328944289452894628947289482894928950289512895228953289542895528956289572895828959289602896128962289632896428965289662896728968289692897028971289722897328974289752897628977289782897928980289812898228983289842898528986289872898828989289902899128992289932899428995289962899728998289992900029001290022900329004290052900629007290082900929010290112901229013290142901529016290172901829019290202902129022290232902429025290262902729028290292903029031290322903329034290352903629037290382903929040290412904229043290442904529046290472904829049290502905129052290532905429055290562905729058290592906029061290622906329064290652906629067290682906929070290712907229073290742907529076290772907829079290802908129082290832908429085290862908729088290892909029091290922909329094290952909629097290982909929100291012910229103291042910529106291072910829109291102911129112291132911429115291162911729118291192912029121291222912329124291252912629127291282912929130291312913229133291342913529136291372913829139291402914129142291432914429145291462914729148291492915029151291522915329154291552915629157291582915929160291612916229163291642916529166291672916829169291702917129172291732917429175291762917729178291792918029181291822918329184291852918629187291882918929190291912919229193291942919529196291972919829199292002920129202292032920429205292062920729208292092921029211292122921329214292152921629217292182921929220292212922229223292242922529226292272922829229292302923129232292332923429235292362923729238292392924029241292422924329244292452924629247292482924929250292512925229253292542925529256292572925829259292602926129262292632926429265292662926729268292692927029271292722927329274292752927629277292782927929280292812928229283292842928529286292872928829289292902929129292292932929429295292962929729298292992930029301293022930329304293052930629307293082930929310293112931229313293142931529316293172931829319293202932129322293232932429325293262932729328293292933029331293322933329334293352933629337293382933929340293412934229343293442934529346293472934829349293502935129352293532935429355293562935729358293592936029361293622936329364293652936629367293682936929370293712937229373293742937529376293772937829379293802938129382293832938429385293862938729388293892939029391293922939329394293952939629397293982939929400294012940229403294042940529406294072940829409294102941129412294132941429415294162941729418294192942029421294222942329424294252942629427294282942929430294312943229433294342943529436294372943829439294402944129442294432944429445294462944729448294492945029451294522945329454294552945629457294582945929460294612946229463294642946529466294672946829469294702947129472294732947429475294762947729478294792948029481294822948329484294852948629487294882948929490294912949229493294942949529496294972949829499295002950129502295032950429505295062950729508295092951029511295122951329514295152951629517295182951929520295212952229523295242952529526295272952829529295302953129532295332953429535295362953729538295392954029541295422954329544295452954629547295482954929550295512955229553295542955529556295572955829559295602956129562295632956429565295662956729568295692957029571295722957329574295752957629577295782957929580295812958229583295842958529586295872958829589295902959129592295932959429595295962959729598295992960029601296022960329604296052960629607296082960929610296112961229613296142961529616296172961829619296202962129622296232962429625296262962729628296292963029631296322963329634296352963629637296382963929640296412964229643296442964529646296472964829649296502965129652296532965429655296562965729658296592966029661296622966329664296652966629667296682966929670296712967229673296742967529676296772967829679296802968129682296832968429685296862968729688296892969029691296922969329694296952969629697296982969929700297012970229703297042970529706297072970829709297102971129712297132971429715297162971729718297192972029721297222972329724297252972629727297282972929730297312973229733297342973529736297372973829739297402974129742297432974429745297462974729748297492975029751297522975329754297552975629757297582975929760297612976229763297642976529766297672976829769297702977129772297732977429775297762977729778297792978029781297822978329784297852978629787297882978929790297912979229793297942979529796297972979829799298002980129802298032980429805298062980729808298092981029811298122981329814298152981629817298182981929820298212982229823298242982529826298272982829829298302983129832298332983429835298362983729838298392984029841298422984329844298452984629847298482984929850298512985229853298542985529856298572985829859298602986129862298632986429865298662986729868298692987029871298722987329874298752987629877298782987929880298812988229883298842988529886298872988829889298902989129892298932989429895298962989729898298992990029901299022990329904299052990629907299082990929910299112991229913299142991529916299172991829919299202992129922299232992429925299262992729928299292993029931299322993329934299352993629937299382993929940299412994229943299442994529946299472994829949299502995129952299532995429955299562995729958299592996029961299622996329964299652996629967299682996929970299712997229973299742997529976299772997829979299802998129982299832998429985299862998729988299892999029991299922999329994299952999629997299982999930000300013000230003300043000530006300073000830009300103001130012300133001430015300163001730018300193002030021300223002330024300253002630027300283002930030300313003230033300343003530036300373003830039300403004130042300433004430045300463004730048300493005030051300523005330054300553005630057300583005930060300613006230063300643006530066300673006830069300703007130072300733007430075300763007730078300793008030081300823008330084300853008630087300883008930090300913009230093300943009530096300973009830099301003010130102301033010430105301063010730108301093011030111301123011330114301153011630117301183011930120301213012230123301243012530126301273012830129301303013130132301333013430135301363013730138301393014030141301423014330144301453014630147301483014930150301513015230153301543015530156301573015830159301603016130162301633016430165301663016730168301693017030171301723017330174301753017630177301783017930180301813018230183301843018530186301873018830189301903019130192301933019430195301963019730198301993020030201302023020330204302053020630207302083020930210302113021230213302143021530216302173021830219302203022130222302233022430225302263022730228302293023030231302323023330234302353023630237302383023930240302413024230243302443024530246302473024830249302503025130252302533025430255302563025730258302593026030261302623026330264302653026630267302683026930270302713027230273302743027530276302773027830279302803028130282302833028430285302863028730288302893029030291302923029330294302953029630297302983029930300303013030230303303043030530306303073030830309303103031130312303133031430315303163031730318303193032030321303223032330324303253032630327303283032930330303313033230333303343033530336303373033830339303403034130342303433034430345303463034730348303493035030351303523035330354303553035630357303583035930360303613036230363303643036530366303673036830369303703037130372303733037430375303763037730378303793038030381303823038330384303853038630387303883038930390303913039230393303943039530396303973039830399304003040130402304033040430405304063040730408304093041030411304123041330414304153041630417304183041930420304213042230423304243042530426304273042830429304303043130432304333043430435304363043730438304393044030441304423044330444304453044630447304483044930450304513045230453304543045530456304573045830459304603046130462304633046430465304663046730468304693047030471304723047330474304753047630477304783047930480304813048230483304843048530486304873048830489304903049130492304933049430495304963049730498304993050030501305023050330504305053050630507305083050930510305113051230513305143051530516305173051830519305203052130522305233052430525305263052730528305293053030531305323053330534305353053630537305383053930540305413054230543305443054530546305473054830549305503055130552305533055430555305563055730558305593056030561305623056330564305653056630567305683056930570305713057230573305743057530576305773057830579305803058130582305833058430585305863058730588305893059030591305923059330594305953059630597305983059930600306013060230603306043060530606306073060830609306103061130612306133061430615306163061730618306193062030621306223062330624306253062630627306283062930630306313063230633306343063530636306373063830639306403064130642306433064430645306463064730648306493065030651306523065330654306553065630657306583065930660306613066230663306643066530666306673066830669306703067130672306733067430675306763067730678306793068030681306823068330684306853068630687306883068930690306913069230693306943069530696306973069830699307003070130702307033070430705307063070730708307093071030711307123071330714307153071630717307183071930720307213072230723307243072530726307273072830729307303073130732307333073430735307363073730738307393074030741307423074330744307453074630747307483074930750307513075230753307543075530756307573075830759307603076130762307633076430765307663076730768307693077030771307723077330774307753077630777307783077930780307813078230783307843078530786307873078830789307903079130792307933079430795307963079730798307993080030801308023080330804308053080630807308083080930810308113081230813308143081530816308173081830819308203082130822308233082430825308263082730828308293083030831308323083330834308353083630837308383083930840308413084230843308443084530846308473084830849308503085130852308533085430855308563085730858308593086030861308623086330864308653086630867308683086930870308713087230873308743087530876308773087830879308803088130882308833088430885308863088730888308893089030891308923089330894308953089630897308983089930900309013090230903309043090530906309073090830909309103091130912309133091430915309163091730918309193092030921309223092330924309253092630927309283092930930309313093230933309343093530936309373093830939309403094130942309433094430945309463094730948309493095030951309523095330954309553095630957309583095930960309613096230963309643096530966309673096830969309703097130972309733097430975309763097730978309793098030981309823098330984309853098630987309883098930990309913099230993309943099530996309973099830999310003100131002310033100431005310063100731008310093101031011310123101331014310153101631017310183101931020310213102231023310243102531026310273102831029310303103131032310333103431035310363103731038310393104031041310423104331044310453104631047310483104931050310513105231053310543105531056310573105831059310603106131062310633106431065310663106731068310693107031071310723107331074310753107631077310783107931080310813108231083310843108531086310873108831089310903109131092310933109431095310963109731098310993110031101311023110331104311053110631107311083110931110311113111231113311143111531116311173111831119311203112131122311233112431125311263112731128311293113031131311323113331134311353113631137311383113931140311413114231143311443114531146311473114831149311503115131152311533115431155311563115731158311593116031161311623116331164311653116631167311683116931170311713117231173311743117531176311773117831179311803118131182311833118431185311863118731188311893119031191311923119331194311953119631197311983119931200312013120231203312043120531206312073120831209312103121131212312133121431215312163121731218312193122031221312223122331224312253122631227312283122931230312313123231233312343123531236312373123831239312403124131242312433124431245312463124731248312493125031251312523125331254312553125631257312583125931260312613126231263312643126531266312673126831269312703127131272312733127431275312763127731278312793128031281312823128331284312853128631287312883128931290312913129231293312943129531296312973129831299313003130131302313033130431305313063130731308313093131031311313123131331314313153131631317313183131931320313213132231323313243132531326313273132831329313303133131332313333133431335313363133731338313393134031341313423134331344313453134631347313483134931350313513135231353313543135531356313573135831359313603136131362313633136431365313663136731368313693137031371313723137331374313753137631377313783137931380313813138231383313843138531386313873138831389313903139131392313933139431395313963139731398313993140031401314023140331404314053140631407314083140931410314113141231413314143141531416314173141831419314203142131422314233142431425314263142731428314293143031431314323143331434314353143631437314383143931440314413144231443314443144531446314473144831449314503145131452314533145431455314563145731458314593146031461314623146331464314653146631467314683146931470314713147231473314743147531476314773147831479314803148131482314833148431485314863148731488314893149031491314923149331494314953149631497314983149931500315013150231503315043150531506315073150831509315103151131512315133151431515315163151731518315193152031521315223152331524315253152631527315283152931530315313153231533315343153531536315373153831539315403154131542315433154431545315463154731548315493155031551315523155331554315553155631557315583155931560315613156231563315643156531566315673156831569315703157131572315733157431575315763157731578315793158031581315823158331584315853158631587315883158931590315913159231593315943159531596315973159831599316003160131602316033160431605316063160731608316093161031611316123161331614316153161631617316183161931620316213162231623316243162531626316273162831629316303163131632316333163431635316363163731638316393164031641316423164331644316453164631647316483164931650316513165231653316543165531656316573165831659316603166131662316633166431665316663166731668316693167031671316723167331674316753167631677316783167931680316813168231683316843168531686316873168831689316903169131692316933169431695316963169731698316993170031701317023170331704317053170631707317083170931710317113171231713317143171531716317173171831719317203172131722317233172431725317263172731728317293173031731317323173331734317353173631737317383173931740317413174231743317443174531746317473174831749317503175131752317533175431755317563175731758317593176031761317623176331764317653176631767317683176931770317713177231773317743177531776317773177831779317803178131782317833178431785317863178731788317893179031791317923179331794317953179631797317983179931800318013180231803318043180531806318073180831809318103181131812318133181431815318163181731818318193182031821318223182331824318253182631827318283182931830318313183231833318343183531836318373183831839318403184131842318433184431845318463184731848318493185031851318523185331854318553185631857318583185931860318613186231863318643186531866318673186831869318703187131872318733187431875318763187731878318793188031881318823188331884318853188631887318883188931890318913189231893318943189531896318973189831899319003190131902319033190431905319063190731908319093191031911319123191331914319153191631917319183191931920319213192231923319243192531926319273192831929319303193131932319333193431935319363193731938319393194031941319423194331944319453194631947319483194931950319513195231953319543195531956319573195831959319603196131962319633196431965319663196731968319693197031971319723197331974319753197631977319783197931980319813198231983319843198531986319873198831989319903199131992319933199431995319963199731998319993200032001320023200332004320053200632007320083200932010320113201232013320143201532016320173201832019320203202132022320233202432025320263202732028320293203032031320323203332034320353203632037320383203932040320413204232043320443204532046320473204832049320503205132052320533205432055320563205732058320593206032061320623206332064320653206632067320683206932070320713207232073320743207532076320773207832079320803208132082320833208432085320863208732088320893209032091320923209332094320953209632097320983209932100321013210232103321043210532106321073210832109321103211132112321133211432115321163211732118321193212032121321223212332124321253212632127321283212932130321313213232133321343213532136321373213832139321403214132142321433214432145321463214732148321493215032151321523215332154321553215632157321583215932160321613216232163321643216532166321673216832169321703217132172321733217432175321763217732178321793218032181321823218332184321853218632187321883218932190321913219232193321943219532196321973219832199322003220132202322033220432205322063220732208322093221032211322123221332214322153221632217322183221932220322213222232223322243222532226322273222832229322303223132232322333223432235322363223732238322393224032241322423224332244322453224632247322483224932250322513225232253322543225532256322573225832259322603226132262322633226432265322663226732268322693227032271322723227332274322753227632277322783227932280322813228232283322843228532286322873228832289322903229132292322933229432295322963229732298322993230032301323023230332304323053230632307323083230932310323113231232313323143231532316323173231832319323203232132322323233232432325323263232732328323293233032331323323233332334323353233632337323383233932340323413234232343323443234532346323473234832349323503235132352323533235432355323563235732358323593236032361323623236332364323653236632367323683236932370323713237232373323743237532376323773237832379323803238132382323833238432385323863238732388323893239032391323923239332394323953239632397323983239932400324013240232403324043240532406324073240832409324103241132412324133241432415324163241732418324193242032421324223242332424324253242632427324283242932430324313243232433324343243532436324373243832439324403244132442324433244432445324463244732448324493245032451324523245332454324553245632457324583245932460324613246232463324643246532466324673246832469324703247132472324733247432475324763247732478324793248032481324823248332484324853248632487324883248932490324913249232493324943249532496324973249832499325003250132502325033250432505325063250732508325093251032511325123251332514325153251632517325183251932520325213252232523325243252532526325273252832529325303253132532325333253432535325363253732538325393254032541325423254332544325453254632547325483254932550325513255232553325543255532556325573255832559325603256132562325633256432565325663256732568325693257032571325723257332574325753257632577325783257932580325813258232583325843258532586325873258832589325903259132592325933259432595325963259732598325993260032601326023260332604326053260632607326083260932610326113261232613326143261532616326173261832619326203262132622326233262432625326263262732628326293263032631326323263332634326353263632637326383263932640326413264232643326443264532646326473264832649326503265132652326533265432655326563265732658326593266032661326623266332664326653266632667326683266932670326713267232673326743267532676326773267832679326803268132682326833268432685326863268732688326893269032691326923269332694326953269632697326983269932700327013270232703327043270532706327073270832709327103271132712327133271432715327163271732718327193272032721327223272332724327253272632727327283272932730327313273232733327343273532736327373273832739327403274132742327433274432745327463274732748327493275032751327523275332754327553275632757327583275932760327613276232763327643276532766327673276832769327703277132772327733277432775327763277732778327793278032781327823278332784327853278632787327883278932790327913279232793327943279532796327973279832799328003280132802328033280432805328063280732808328093281032811328123281332814328153281632817328183281932820328213282232823328243282532826328273282832829328303283132832328333283432835328363283732838328393284032841328423284332844328453284632847328483284932850328513285232853328543285532856328573285832859328603286132862328633286432865328663286732868328693287032871328723287332874328753287632877328783287932880328813288232883328843288532886328873288832889328903289132892328933289432895328963289732898328993290032901329023290332904329053290632907329083290932910329113291232913329143291532916329173291832919329203292132922329233292432925329263292732928329293293032931329323293332934329353293632937329383293932940329413294232943329443294532946329473294832949329503295132952329533295432955329563295732958329593296032961329623296332964329653296632967329683296932970329713297232973329743297532976329773297832979329803298132982329833298432985329863298732988329893299032991329923299332994329953299632997329983299933000330013300233003330043300533006330073300833009330103301133012330133301433015330163301733018330193302033021330223302333024330253302633027330283302933030330313303233033330343303533036330373303833039330403304133042330433304433045330463304733048330493305033051330523305333054330553305633057330583305933060330613306233063330643306533066330673306833069330703307133072330733307433075330763307733078330793308033081330823308333084330853308633087330883308933090330913309233093330943309533096330973309833099331003310133102331033310433105331063310733108331093311033111331123311333114331153311633117331183311933120331213312233123331243312533126331273312833129331303313133132331333313433135331363313733138331393314033141331423314333144331453314633147331483314933150331513315233153331543315533156331573315833159331603316133162331633316433165331663316733168331693317033171331723317333174331753317633177331783317933180331813318233183331843318533186331873318833189331903319133192331933319433195331963319733198331993320033201332023320333204332053320633207332083320933210332113321233213332143321533216332173321833219332203322133222332233322433225332263322733228332293323033231332323323333234332353323633237332383323933240332413324233243332443324533246332473324833249332503325133252332533325433255332563325733258332593326033261332623326333264332653326633267332683326933270332713327233273332743327533276332773327833279332803328133282332833328433285332863328733288332893329033291332923329333294332953329633297332983329933300333013330233303333043330533306333073330833309333103331133312333133331433315333163331733318333193332033321333223332333324333253332633327333283332933330333313333233333333343333533336333373333833339333403334133342333433334433345333463334733348333493335033351333523335333354333553335633357333583335933360333613336233363333643336533366333673336833369333703337133372333733337433375333763337733378333793338033381333823338333384333853338633387333883338933390333913339233393333943339533396333973339833399334003340133402334033340433405334063340733408334093341033411334123341333414334153341633417334183341933420334213342233423334243342533426334273342833429334303343133432334333343433435334363343733438334393344033441334423344333444334453344633447334483344933450334513345233453334543345533456334573345833459334603346133462334633346433465334663346733468334693347033471334723347333474334753347633477334783347933480334813348233483334843348533486334873348833489334903349133492334933349433495334963349733498334993350033501335023350333504335053350633507335083350933510335113351233513335143351533516335173351833519335203352133522335233352433525335263352733528335293353033531335323353333534335353353633537335383353933540335413354233543335443354533546335473354833549335503355133552335533355433555335563355733558335593356033561335623356333564335653356633567335683356933570335713357233573335743357533576335773357833579335803358133582335833358433585335863358733588335893359033591335923359333594335953359633597335983359933600336013360233603336043360533606336073360833609336103361133612336133361433615336163361733618336193362033621336223362333624336253362633627336283362933630336313363233633336343363533636336373363833639336403364133642336433364433645336463364733648336493365033651336523365333654336553365633657336583365933660336613366233663336643366533666336673366833669336703367133672336733367433675336763367733678336793368033681336823368333684336853368633687336883368933690336913369233693336943369533696336973369833699337003370133702337033370433705337063370733708337093371033711337123371333714337153371633717337183371933720337213372233723337243372533726337273372833729337303373133732337333373433735337363373733738337393374033741337423374333744337453374633747337483374933750337513375233753337543375533756337573375833759337603376133762337633376433765337663376733768337693377033771337723377333774337753377633777337783377933780337813378233783337843378533786337873378833789337903379133792337933379433795337963379733798337993380033801338023380333804338053380633807338083380933810338113381233813338143381533816338173381833819338203382133822338233382433825338263382733828338293383033831338323383333834338353383633837338383383933840338413384233843338443384533846338473384833849338503385133852338533385433855338563385733858338593386033861338623386333864338653386633867338683386933870338713387233873338743387533876338773387833879338803388133882338833388433885338863388733888338893389033891338923389333894338953389633897338983389933900339013390233903339043390533906339073390833909339103391133912339133391433915339163391733918339193392033921339223392333924339253392633927339283392933930339313393233933339343393533936339373393833939339403394133942339433394433945339463394733948339493395033951339523395333954339553395633957339583395933960339613396233963339643396533966339673396833969339703397133972339733397433975339763397733978339793398033981339823398333984339853398633987339883398933990339913399233993339943399533996339973399833999340003400134002340033400434005340063400734008340093401034011340123401334014340153401634017340183401934020340213402234023340243402534026340273402834029340303403134032340333403434035340363403734038340393404034041340423404334044340453404634047340483404934050340513405234053340543405534056340573405834059340603406134062340633406434065340663406734068340693407034071340723407334074340753407634077340783407934080340813408234083340843408534086340873408834089340903409134092340933409434095340963409734098340993410034101341023410334104341053410634107341083410934110341113411234113341143411534116341173411834119341203412134122341233412434125341263412734128341293413034131341323413334134341353413634137341383413934140341413414234143341443414534146341473414834149341503415134152341533415434155341563415734158341593416034161341623416334164341653416634167341683416934170341713417234173341743417534176341773417834179341803418134182341833418434185341863418734188341893419034191341923419334194341953419634197341983419934200342013420234203342043420534206342073420834209342103421134212342133421434215342163421734218342193422034221342223422334224342253422634227342283422934230342313423234233342343423534236342373423834239342403424134242342433424434245342463424734248342493425034251342523425334254342553425634257342583425934260342613426234263342643426534266342673426834269342703427134272342733427434275342763427734278342793428034281342823428334284342853428634287342883428934290342913429234293342943429534296342973429834299343003430134302343033430434305343063430734308343093431034311343123431334314343153431634317343183431934320343213432234323343243432534326343273432834329343303433134332343333433434335343363433734338343393434034341343423434334344343453434634347343483434934350343513435234353343543435534356343573435834359343603436134362343633436434365343663436734368343693437034371343723437334374343753437634377343783437934380343813438234383343843438534386343873438834389343903439134392343933439434395343963439734398343993440034401344023440334404344053440634407344083440934410344113441234413344143441534416344173441834419344203442134422344233442434425344263442734428344293443034431344323443334434344353443634437344383443934440344413444234443344443444534446344473444834449344503445134452344533445434455344563445734458344593446034461344623446334464344653446634467344683446934470344713447234473344743447534476344773447834479344803448134482344833448434485344863448734488344893449034491344923449334494344953449634497344983449934500345013450234503345043450534506345073450834509345103451134512345133451434515345163451734518345193452034521345223452334524345253452634527345283452934530345313453234533345343453534536345373453834539345403454134542345433454434545345463454734548345493455034551345523455334554345553455634557345583455934560345613456234563345643456534566345673456834569345703457134572345733457434575345763457734578345793458034581345823458334584345853458634587345883458934590345913459234593345943459534596345973459834599346003460134602346033460434605346063460734608346093461034611346123461334614346153461634617346183461934620346213462234623346243462534626346273462834629346303463134632346333463434635346363463734638346393464034641346423464334644346453464634647346483464934650346513465234653346543465534656346573465834659346603466134662346633466434665346663466734668346693467034671346723467334674346753467634677346783467934680346813468234683346843468534686346873468834689346903469134692346933469434695346963469734698346993470034701347023470334704347053470634707347083470934710347113471234713347143471534716347173471834719347203472134722347233472434725347263472734728347293473034731347323473334734347353473634737347383473934740347413474234743347443474534746347473474834749347503475134752347533475434755347563475734758347593476034761347623476334764347653476634767347683476934770347713477234773347743477534776347773477834779347803478134782347833478434785347863478734788347893479034791347923479334794347953479634797347983479934800348013480234803348043480534806348073480834809348103481134812348133481434815348163481734818348193482034821348223482334824348253482634827348283482934830348313483234833348343483534836348373483834839348403484134842348433484434845348463484734848348493485034851348523485334854348553485634857348583485934860348613486234863348643486534866348673486834869348703487134872348733487434875348763487734878348793488034881348823488334884348853488634887348883488934890348913489234893348943489534896348973489834899349003490134902349033490434905349063490734908349093491034911349123491334914349153491634917349183491934920349213492234923349243492534926349273492834929349303493134932349333493434935349363493734938349393494034941349423494334944349453494634947349483494934950349513495234953349543495534956349573495834959349603496134962349633496434965349663496734968349693497034971349723497334974349753497634977349783497934980349813498234983349843498534986349873498834989349903499134992349933499434995349963499734998349993500035001350023500335004350053500635007350083500935010350113501235013350143501535016350173501835019350203502135022350233502435025350263502735028350293503035031350323503335034350353503635037350383503935040350413504235043350443504535046350473504835049350503505135052350533505435055350563505735058350593506035061350623506335064350653506635067350683506935070350713507235073350743507535076350773507835079350803508135082350833508435085350863508735088350893509035091350923509335094350953509635097350983509935100351013510235103351043510535106351073510835109351103511135112351133511435115351163511735118351193512035121351223512335124351253512635127351283512935130351313513235133351343513535136351373513835139351403514135142351433514435145351463514735148351493515035151351523515335154351553515635157351583515935160351613516235163351643516535166351673516835169351703517135172351733517435175351763517735178351793518035181351823518335184351853518635187351883518935190351913519235193351943519535196351973519835199352003520135202352033520435205352063520735208352093521035211352123521335214352153521635217352183521935220352213522235223352243522535226352273522835229352303523135232352333523435235352363523735238352393524035241352423524335244352453524635247352483524935250352513525235253352543525535256352573525835259352603526135262352633526435265352663526735268352693527035271352723527335274352753527635277352783527935280352813528235283352843528535286352873528835289352903529135292352933529435295352963529735298352993530035301353023530335304353053530635307353083530935310353113531235313353143531535316353173531835319353203532135322353233532435325353263532735328353293533035331353323533335334353353533635337353383533935340353413534235343353443534535346353473534835349353503535135352353533535435355353563535735358353593536035361353623536335364353653536635367353683536935370353713537235373353743537535376353773537835379353803538135382353833538435385353863538735388353893539035391353923539335394353953539635397353983539935400354013540235403354043540535406354073540835409354103541135412354133541435415354163541735418354193542035421354223542335424354253542635427354283542935430354313543235433354343543535436354373543835439354403544135442354433544435445354463544735448354493545035451354523545335454354553545635457354583545935460354613546235463354643546535466354673546835469354703547135472354733547435475354763547735478354793548035481354823548335484354853548635487354883548935490354913549235493354943549535496354973549835499355003550135502355033550435505355063550735508355093551035511355123551335514355153551635517355183551935520355213552235523355243552535526355273552835529355303553135532355333553435535355363553735538355393554035541355423554335544355453554635547355483554935550355513555235553355543555535556355573555835559355603556135562355633556435565355663556735568355693557035571355723557335574355753557635577355783557935580355813558235583355843558535586355873558835589355903559135592355933559435595355963559735598355993560035601356023560335604356053560635607356083560935610356113561235613356143561535616356173561835619356203562135622356233562435625356263562735628356293563035631356323563335634356353563635637356383563935640356413564235643356443564535646356473564835649356503565135652356533565435655356563565735658356593566035661356623566335664356653566635667356683566935670356713567235673356743567535676356773567835679356803568135682356833568435685356863568735688356893569035691356923569335694356953569635697356983569935700357013570235703357043570535706357073570835709357103571135712357133571435715357163571735718357193572035721357223572335724357253572635727357283572935730357313573235733357343573535736357373573835739357403574135742357433574435745357463574735748357493575035751357523575335754357553575635757357583575935760357613576235763357643576535766357673576835769357703577135772357733577435775357763577735778357793578035781357823578335784357853578635787357883578935790357913579235793357943579535796357973579835799358003580135802358033580435805358063580735808358093581035811358123581335814358153581635817358183581935820358213582235823358243582535826358273582835829358303583135832358333583435835358363583735838358393584035841358423584335844358453584635847358483584935850358513585235853358543585535856358573585835859358603586135862358633586435865358663586735868358693587035871358723587335874358753587635877358783587935880358813588235883358843588535886358873588835889358903589135892358933589435895358963589735898358993590035901359023590335904359053590635907359083590935910359113591235913359143591535916359173591835919359203592135922359233592435925359263592735928359293593035931359323593335934359353593635937359383593935940359413594235943359443594535946359473594835949359503595135952359533595435955359563595735958359593596035961359623596335964359653596635967359683596935970359713597235973359743597535976359773597835979359803598135982359833598435985359863598735988359893599035991359923599335994359953599635997359983599936000360013600236003360043600536006360073600836009360103601136012360133601436015360163601736018360193602036021360223602336024360253602636027360283602936030360313603236033360343603536036360373603836039360403604136042360433604436045360463604736048360493605036051360523605336054360553605636057360583605936060360613606236063360643606536066360673606836069360703607136072360733607436075360763607736078360793608036081360823608336084360853608636087360883608936090360913609236093360943609536096360973609836099361003610136102361033610436105361063610736108361093611036111361123611336114361153611636117361183611936120361213612236123361243612536126361273612836129361303613136132361333613436135361363613736138361393614036141361423614336144361453614636147361483614936150361513615236153361543615536156361573615836159361603616136162361633616436165361663616736168361693617036171361723617336174361753617636177361783617936180361813618236183361843618536186361873618836189361903619136192361933619436195361963619736198361993620036201362023620336204362053620636207362083620936210362113621236213362143621536216362173621836219362203622136222362233622436225362263622736228362293623036231362323623336234362353623636237362383623936240362413624236243362443624536246362473624836249362503625136252362533625436255362563625736258362593626036261362623626336264362653626636267362683626936270362713627236273362743627536276362773627836279362803628136282362833628436285362863628736288362893629036291362923629336294362953629636297362983629936300363013630236303363043630536306363073630836309363103631136312363133631436315363163631736318363193632036321363223632336324363253632636327363283632936330363313633236333363343633536336363373633836339363403634136342363433634436345363463634736348363493635036351363523635336354363553635636357363583635936360363613636236363363643636536366363673636836369363703637136372363733637436375363763637736378363793638036381363823638336384363853638636387363883638936390363913639236393363943639536396363973639836399364003640136402364033640436405364063640736408364093641036411364123641336414364153641636417364183641936420364213642236423364243642536426364273642836429364303643136432364333643436435364363643736438364393644036441364423644336444364453644636447364483644936450364513645236453364543645536456364573645836459364603646136462364633646436465364663646736468364693647036471364723647336474364753647636477364783647936480364813648236483364843648536486364873648836489364903649136492364933649436495364963649736498364993650036501365023650336504365053650636507365083650936510365113651236513365143651536516365173651836519365203652136522365233652436525365263652736528365293653036531365323653336534365353653636537365383653936540365413654236543365443654536546365473654836549365503655136552365533655436555365563655736558365593656036561365623656336564365653656636567365683656936570365713657236573365743657536576365773657836579365803658136582365833658436585365863658736588365893659036591365923659336594365953659636597365983659936600366013660236603366043660536606366073660836609366103661136612366133661436615366163661736618366193662036621366223662336624366253662636627366283662936630366313663236633366343663536636366373663836639366403664136642366433664436645366463664736648366493665036651366523665336654366553665636657366583665936660366613666236663366643666536666366673666836669366703667136672366733667436675366763667736678366793668036681366823668336684366853668636687366883668936690366913669236693366943669536696366973669836699367003670136702367033670436705367063670736708367093671036711367123671336714367153671636717367183671936720367213672236723367243672536726367273672836729367303673136732367333673436735367363673736738367393674036741367423674336744367453674636747367483674936750367513675236753367543675536756367573675836759367603676136762367633676436765367663676736768367693677036771367723677336774367753677636777367783677936780367813678236783367843678536786367873678836789367903679136792367933679436795367963679736798367993680036801368023680336804368053680636807368083680936810368113681236813368143681536816368173681836819368203682136822368233682436825368263682736828368293683036831368323683336834368353683636837368383683936840368413684236843368443684536846368473684836849368503685136852368533685436855368563685736858368593686036861368623686336864368653686636867368683686936870368713687236873368743687536876368773687836879368803688136882368833688436885368863688736888368893689036891368923689336894368953689636897368983689936900369013690236903369043690536906369073690836909369103691136912369133691436915369163691736918369193692036921369223692336924369253692636927369283692936930369313693236933369343693536936369373693836939369403694136942369433694436945369463694736948369493695036951369523695336954369553695636957369583695936960369613696236963369643696536966369673696836969369703697136972369733697436975369763697736978369793698036981369823698336984369853698636987369883698936990369913699236993369943699536996369973699836999370003700137002370033700437005370063700737008370093701037011370123701337014370153701637017370183701937020370213702237023370243702537026370273702837029370303703137032370333703437035370363703737038370393704037041370423704337044370453704637047370483704937050370513705237053370543705537056370573705837059370603706137062370633706437065370663706737068370693707037071370723707337074370753707637077370783707937080370813708237083370843708537086370873708837089370903709137092370933709437095370963709737098370993710037101371023710337104371053710637107371083710937110371113711237113371143711537116371173711837119371203712137122371233712437125371263712737128371293713037131371323713337134371353713637137371383713937140371413714237143371443714537146371473714837149371503715137152371533715437155371563715737158371593716037161371623716337164371653716637167371683716937170371713717237173371743717537176371773717837179371803718137182371833718437185371863718737188371893719037191371923719337194371953719637197371983719937200372013720237203372043720537206372073720837209372103721137212372133721437215372163721737218372193722037221372223722337224372253722637227372283722937230372313723237233372343723537236372373723837239372403724137242372433724437245372463724737248372493725037251372523725337254372553725637257372583725937260372613726237263372643726537266372673726837269372703727137272372733727437275372763727737278372793728037281372823728337284372853728637287372883728937290372913729237293372943729537296372973729837299373003730137302373033730437305373063730737308373093731037311373123731337314373153731637317373183731937320373213732237323373243732537326373273732837329373303733137332373333733437335373363733737338373393734037341373423734337344373453734637347373483734937350373513735237353373543735537356373573735837359373603736137362373633736437365373663736737368373693737037371373723737337374373753737637377373783737937380373813738237383373843738537386373873738837389373903739137392373933739437395373963739737398373993740037401374023740337404374053740637407374083740937410374113741237413374143741537416374173741837419374203742137422374233742437425374263742737428374293743037431374323743337434374353743637437374383743937440374413744237443374443744537446374473744837449374503745137452374533745437455374563745737458374593746037461374623746337464374653746637467374683746937470374713747237473374743747537476374773747837479374803748137482374833748437485374863748737488374893749037491374923749337494374953749637497374983749937500375013750237503375043750537506375073750837509375103751137512375133751437515375163751737518375193752037521375223752337524375253752637527375283752937530375313753237533375343753537536375373753837539375403754137542375433754437545375463754737548375493755037551375523755337554375553755637557375583755937560375613756237563375643756537566375673756837569375703757137572375733757437575375763757737578375793758037581375823758337584375853758637587375883758937590375913759237593375943759537596375973759837599376003760137602376033760437605376063760737608376093761037611376123761337614376153761637617376183761937620376213762237623376243762537626376273762837629376303763137632376333763437635376363763737638376393764037641376423764337644376453764637647376483764937650376513765237653376543765537656376573765837659376603766137662376633766437665376663766737668376693767037671376723767337674376753767637677376783767937680376813768237683376843768537686376873768837689376903769137692376933769437695376963769737698376993770037701377023770337704377053770637707377083770937710377113771237713377143771537716377173771837719377203772137722377233772437725377263772737728377293773037731377323773337734377353773637737377383773937740377413774237743377443774537746377473774837749377503775137752377533775437755377563775737758377593776037761377623776337764377653776637767377683776937770377713777237773377743777537776377773777837779377803778137782377833778437785377863778737788377893779037791377923779337794377953779637797377983779937800378013780237803378043780537806378073780837809378103781137812378133781437815378163781737818378193782037821378223782337824378253782637827378283782937830378313783237833378343783537836378373783837839378403784137842378433784437845378463784737848378493785037851378523785337854378553785637857378583785937860378613786237863378643786537866378673786837869378703787137872378733787437875378763787737878378793788037881378823788337884378853788637887378883788937890378913789237893378943789537896378973789837899379003790137902379033790437905379063790737908379093791037911379123791337914379153791637917379183791937920379213792237923379243792537926379273792837929379303793137932379333793437935379363793737938379393794037941379423794337944379453794637947379483794937950379513795237953379543795537956379573795837959379603796137962379633796437965379663796737968379693797037971379723797337974379753797637977379783797937980379813798237983379843798537986379873798837989379903799137992379933799437995379963799737998379993800038001380023800338004380053800638007380083800938010380113801238013380143801538016380173801838019380203802138022380233802438025380263802738028380293803038031380323803338034380353803638037380383803938040380413804238043380443804538046380473804838049380503805138052380533805438055380563805738058380593806038061380623806338064380653806638067380683806938070380713807238073380743807538076380773807838079380803808138082380833808438085380863808738088380893809038091380923809338094380953809638097380983809938100381013810238103381043810538106381073810838109381103811138112381133811438115381163811738118381193812038121381223812338124381253812638127381283812938130381313813238133381343813538136381373813838139381403814138142381433814438145381463814738148381493815038151381523815338154381553815638157381583815938160381613816238163381643816538166381673816838169381703817138172381733817438175381763817738178381793818038181381823818338184381853818638187381883818938190381913819238193381943819538196381973819838199382003820138202382033820438205382063820738208382093821038211382123821338214382153821638217382183821938220382213822238223382243822538226382273822838229382303823138232382333823438235382363823738238382393824038241382423824338244382453824638247382483824938250382513825238253382543825538256382573825838259382603826138262382633826438265382663826738268382693827038271382723827338274382753827638277382783827938280382813828238283382843828538286382873828838289382903829138292382933829438295382963829738298382993830038301383023830338304383053830638307383083830938310383113831238313383143831538316383173831838319383203832138322383233832438325383263832738328383293833038331383323833338334383353833638337383383833938340383413834238343383443834538346383473834838349383503835138352383533835438355383563835738358383593836038361383623836338364383653836638367383683836938370383713837238373383743837538376383773837838379383803838138382383833838438385383863838738388383893839038391383923839338394383953839638397383983839938400384013840238403384043840538406384073840838409384103841138412384133841438415384163841738418384193842038421384223842338424384253842638427384283842938430384313843238433384343843538436384373843838439384403844138442384433844438445384463844738448384493845038451384523845338454384553845638457384583845938460384613846238463384643846538466384673846838469384703847138472384733847438475384763847738478384793848038481384823848338484384853848638487384883848938490384913849238493384943849538496384973849838499385003850138502385033850438505385063850738508385093851038511385123851338514385153851638517385183851938520385213852238523385243852538526385273852838529385303853138532385333853438535385363853738538385393854038541385423854338544385453854638547385483854938550385513855238553385543855538556385573855838559385603856138562385633856438565385663856738568385693857038571385723857338574385753857638577385783857938580385813858238583385843858538586385873858838589385903859138592385933859438595385963859738598385993860038601386023860338604386053860638607386083860938610386113861238613386143861538616386173861838619386203862138622386233862438625386263862738628386293863038631386323863338634386353863638637386383863938640386413864238643386443864538646386473864838649386503865138652386533865438655386563865738658386593866038661386623866338664386653866638667386683866938670386713867238673386743867538676386773867838679386803868138682386833868438685386863868738688386893869038691386923869338694386953869638697386983869938700387013870238703387043870538706387073870838709387103871138712387133871438715387163871738718387193872038721387223872338724387253872638727387283872938730387313873238733387343873538736387373873838739387403874138742387433874438745387463874738748387493875038751387523875338754387553875638757387583875938760387613876238763387643876538766387673876838769387703877138772387733877438775387763877738778387793878038781387823878338784387853878638787387883878938790387913879238793387943879538796387973879838799388003880138802388033880438805388063880738808388093881038811388123881338814388153881638817388183881938820388213882238823388243882538826388273882838829388303883138832388333883438835388363883738838388393884038841388423884338844388453884638847388483884938850388513885238853388543885538856388573885838859388603886138862388633886438865388663886738868388693887038871388723887338874388753887638877388783887938880388813888238883388843888538886388873888838889388903889138892388933889438895388963889738898388993890038901389023890338904389053890638907389083890938910389113891238913389143891538916389173891838919389203892138922389233892438925389263892738928389293893038931389323893338934389353893638937389383893938940389413894238943389443894538946389473894838949389503895138952389533895438955389563895738958389593896038961389623896338964389653896638967389683896938970389713897238973389743897538976389773897838979389803898138982389833898438985389863898738988389893899038991389923899338994389953899638997389983899939000390013900239003390043900539006390073900839009390103901139012390133901439015390163901739018390193902039021390223902339024390253902639027390283902939030390313903239033390343903539036390373903839039390403904139042390433904439045390463904739048390493905039051390523905339054390553905639057390583905939060390613906239063390643906539066390673906839069390703907139072390733907439075390763907739078390793908039081390823908339084390853908639087390883908939090390913909239093390943909539096390973909839099391003910139102391033910439105391063910739108391093911039111391123911339114391153911639117391183911939120391213912239123391243912539126391273912839129391303913139132391333913439135391363913739138391393914039141391423914339144391453914639147391483914939150391513915239153391543915539156391573915839159391603916139162391633916439165391663916739168391693917039171391723917339174391753917639177391783917939180391813918239183391843918539186391873918839189391903919139192391933919439195391963919739198391993920039201392023920339204392053920639207392083920939210392113921239213392143921539216392173921839219392203922139222392233922439225392263922739228392293923039231392323923339234392353923639237392383923939240392413924239243392443924539246392473924839249392503925139252392533925439255392563925739258392593926039261392623926339264392653926639267392683926939270392713927239273392743927539276392773927839279392803928139282392833928439285392863928739288392893929039291392923929339294392953929639297392983929939300393013930239303393043930539306393073930839309393103931139312393133931439315393163931739318393193932039321393223932339324393253932639327393283932939330393313933239333393343933539336393373933839339393403934139342393433934439345393463934739348393493935039351393523935339354393553935639357393583935939360393613936239363393643936539366393673936839369393703937139372393733937439375393763937739378393793938039381393823938339384393853938639387393883938939390393913939239393393943939539396393973939839399394003940139402394033940439405394063940739408394093941039411394123941339414394153941639417394183941939420394213942239423394243942539426394273942839429394303943139432394333943439435394363943739438394393944039441394423944339444394453944639447394483944939450394513945239453394543945539456394573945839459394603946139462394633946439465394663946739468394693947039471394723947339474394753947639477394783947939480394813948239483394843948539486394873948839489394903949139492394933949439495394963949739498394993950039501395023950339504395053950639507395083950939510395113951239513395143951539516395173951839519395203952139522395233952439525395263952739528395293953039531395323953339534395353953639537395383953939540395413954239543395443954539546395473954839549395503955139552395533955439555395563955739558395593956039561395623956339564395653956639567395683956939570395713957239573395743957539576395773957839579395803958139582395833958439585395863958739588395893959039591395923959339594395953959639597395983959939600396013960239603396043960539606396073960839609396103961139612396133961439615396163961739618396193962039621396223962339624396253962639627396283962939630396313963239633396343963539636396373963839639396403964139642396433964439645396463964739648396493965039651396523965339654396553965639657396583965939660396613966239663396643966539666396673966839669396703967139672396733967439675396763967739678396793968039681396823968339684396853968639687396883968939690396913969239693396943969539696396973969839699397003970139702397033970439705397063970739708397093971039711397123971339714397153971639717397183971939720397213972239723397243972539726397273972839729397303973139732397333973439735397363973739738397393974039741397423974339744397453974639747397483974939750397513975239753397543975539756397573975839759397603976139762397633976439765397663976739768397693977039771397723977339774397753977639777397783977939780397813978239783397843978539786397873978839789397903979139792397933979439795397963979739798397993980039801398023980339804398053980639807398083980939810398113981239813398143981539816398173981839819398203982139822398233982439825398263982739828398293983039831398323983339834398353983639837398383983939840398413984239843398443984539846398473984839849398503985139852398533985439855398563985739858398593986039861398623986339864398653986639867398683986939870398713987239873398743987539876398773987839879398803988139882398833988439885398863988739888398893989039891398923989339894398953989639897398983989939900399013990239903399043990539906399073990839909399103991139912399133991439915399163991739918399193992039921399223992339924399253992639927399283992939930399313993239933399343993539936399373993839939399403994139942399433994439945399463994739948399493995039951399523995339954399553995639957399583995939960399613996239963399643996539966399673996839969399703997139972399733997439975399763997739978399793998039981399823998339984399853998639987399883998939990399913999239993399943999539996399973999839999400004000140002400034000440005400064000740008400094001040011400124001340014400154001640017400184001940020400214002240023400244002540026400274002840029400304003140032400334003440035400364003740038400394004040041400424004340044400454004640047400484004940050400514005240053400544005540056400574005840059400604006140062400634006440065400664006740068400694007040071400724007340074400754007640077400784007940080400814008240083400844008540086400874008840089400904009140092400934009440095400964009740098400994010040101401024010340104401054010640107401084010940110401114011240113401144011540116401174011840119401204012140122401234012440125401264012740128401294013040131401324013340134401354013640137401384013940140401414014240143401444014540146401474014840149401504015140152401534015440155401564015740158401594016040161401624016340164401654016640167401684016940170401714017240173401744017540176401774017840179401804018140182401834018440185401864018740188401894019040191401924019340194401954019640197401984019940200402014020240203402044020540206402074020840209402104021140212402134021440215402164021740218402194022040221402224022340224402254022640227402284022940230402314023240233402344023540236402374023840239402404024140242402434024440245402464024740248402494025040251402524025340254402554025640257402584025940260402614026240263402644026540266402674026840269402704027140272402734027440275402764027740278402794028040281402824028340284402854028640287402884028940290402914029240293402944029540296402974029840299403004030140302403034030440305403064030740308403094031040311403124031340314403154031640317403184031940320403214032240323403244032540326403274032840329403304033140332403334033440335403364033740338403394034040341403424034340344403454034640347403484034940350403514035240353403544035540356403574035840359403604036140362403634036440365403664036740368403694037040371403724037340374403754037640377403784037940380403814038240383403844038540386403874038840389403904039140392403934039440395403964039740398403994040040401404024040340404404054040640407404084040940410404114041240413404144041540416404174041840419404204042140422404234042440425404264042740428404294043040431404324043340434404354043640437404384043940440404414044240443404444044540446404474044840449404504045140452404534045440455404564045740458404594046040461404624046340464404654046640467404684046940470404714047240473404744047540476404774047840479404804048140482404834048440485404864048740488404894049040491404924049340494404954049640497404984049940500405014050240503405044050540506405074050840509405104051140512405134051440515405164051740518405194052040521405224052340524405254052640527405284052940530405314053240533405344053540536405374053840539405404054140542405434054440545405464054740548405494055040551405524055340554405554055640557405584055940560405614056240563405644056540566405674056840569405704057140572405734057440575405764057740578405794058040581405824058340584405854058640587405884058940590405914059240593405944059540596405974059840599406004060140602406034060440605406064060740608406094061040611406124061340614406154061640617406184061940620406214062240623406244062540626406274062840629406304063140632406334063440635406364063740638406394064040641406424064340644406454064640647406484064940650406514065240653406544065540656406574065840659406604066140662406634066440665406664066740668406694067040671406724067340674406754067640677406784067940680406814068240683406844068540686406874068840689406904069140692406934069440695406964069740698406994070040701407024070340704407054070640707407084070940710407114071240713407144071540716407174071840719407204072140722407234072440725407264072740728407294073040731407324073340734407354073640737407384073940740407414074240743407444074540746407474074840749407504075140752407534075440755407564075740758407594076040761407624076340764407654076640767407684076940770407714077240773407744077540776407774077840779407804078140782407834078440785407864078740788407894079040791407924079340794407954079640797407984079940800408014080240803408044080540806408074080840809408104081140812408134081440815408164081740818408194082040821408224082340824408254082640827408284082940830408314083240833408344083540836408374083840839408404084140842408434084440845408464084740848408494085040851408524085340854408554085640857408584085940860408614086240863408644086540866408674086840869408704087140872408734087440875408764087740878408794088040881408824088340884408854088640887408884088940890408914089240893408944089540896408974089840899409004090140902409034090440905409064090740908409094091040911409124091340914409154091640917409184091940920409214092240923409244092540926409274092840929409304093140932409334093440935409364093740938409394094040941409424094340944409454094640947409484094940950409514095240953409544095540956409574095840959409604096140962409634096440965409664096740968409694097040971409724097340974409754097640977409784097940980409814098240983409844098540986409874098840989409904099140992409934099440995409964099740998409994100041001410024100341004410054100641007410084100941010410114101241013410144101541016410174101841019410204102141022410234102441025410264102741028410294103041031410324103341034410354103641037410384103941040410414104241043410444104541046410474104841049410504105141052410534105441055410564105741058410594106041061410624106341064410654106641067410684106941070410714107241073410744107541076410774107841079410804108141082410834108441085410864108741088410894109041091410924109341094410954109641097410984109941100411014110241103411044110541106411074110841109411104111141112411134111441115411164111741118411194112041121411224112341124411254112641127411284112941130411314113241133411344113541136411374113841139411404114141142411434114441145411464114741148411494115041151411524115341154411554115641157411584115941160411614116241163411644116541166411674116841169411704117141172411734117441175411764117741178411794118041181411824118341184411854118641187411884118941190411914119241193411944119541196411974119841199412004120141202412034120441205412064120741208412094121041211412124121341214412154121641217412184121941220412214122241223412244122541226412274122841229412304123141232412334123441235412364123741238412394124041241412424124341244412454124641247412484124941250412514125241253412544125541256412574125841259412604126141262412634126441265412664126741268412694127041271412724127341274412754127641277412784127941280412814128241283412844128541286412874128841289412904129141292412934129441295412964129741298412994130041301413024130341304413054130641307413084130941310413114131241313413144131541316413174131841319413204132141322413234132441325413264132741328413294133041331413324133341334413354133641337413384133941340413414134241343413444134541346413474134841349413504135141352413534135441355413564135741358413594136041361413624136341364413654136641367413684136941370413714137241373413744137541376413774137841379413804138141382413834138441385413864138741388413894139041391413924139341394413954139641397413984139941400414014140241403414044140541406414074140841409414104141141412414134141441415414164141741418414194142041421414224142341424414254142641427414284142941430414314143241433414344143541436414374143841439414404144141442414434144441445414464144741448414494145041451414524145341454414554145641457414584145941460414614146241463414644146541466414674146841469414704147141472414734147441475414764147741478414794148041481414824148341484414854148641487414884148941490414914149241493414944149541496414974149841499415004150141502415034150441505415064150741508415094151041511415124151341514415154151641517415184151941520415214152241523415244152541526415274152841529415304153141532415334153441535415364153741538415394154041541415424154341544415454154641547415484154941550415514155241553415544155541556415574155841559415604156141562415634156441565415664156741568415694157041571415724157341574415754157641577415784157941580415814158241583415844158541586415874158841589415904159141592415934159441595415964159741598415994160041601416024160341604416054160641607416084160941610416114161241613416144161541616416174161841619416204162141622416234162441625416264162741628416294163041631416324163341634416354163641637416384163941640416414164241643416444164541646416474164841649416504165141652416534165441655416564165741658416594166041661416624166341664416654166641667416684166941670416714167241673416744167541676416774167841679416804168141682416834168441685416864168741688416894169041691416924169341694416954169641697416984169941700417014170241703417044170541706417074170841709417104171141712417134171441715417164171741718417194172041721417224172341724417254172641727417284172941730417314173241733417344173541736417374173841739417404174141742417434174441745417464174741748417494175041751417524175341754417554175641757417584175941760417614176241763417644176541766417674176841769417704177141772417734177441775417764177741778417794178041781417824178341784417854178641787417884178941790417914179241793417944179541796417974179841799418004180141802418034180441805418064180741808418094181041811418124181341814418154181641817418184181941820418214182241823418244182541826418274182841829418304183141832418334183441835418364183741838418394184041841418424184341844418454184641847418484184941850418514185241853418544185541856418574185841859418604186141862418634186441865418664186741868418694187041871418724187341874418754187641877418784187941880418814188241883418844188541886418874188841889418904189141892418934189441895418964189741898418994190041901419024190341904419054190641907419084190941910419114191241913419144191541916419174191841919419204192141922419234192441925419264192741928419294193041931419324193341934419354193641937419384193941940419414194241943419444194541946419474194841949419504195141952419534195441955419564195741958419594196041961419624196341964419654196641967419684196941970419714197241973419744197541976419774197841979419804198141982419834198441985419864198741988419894199041991419924199341994419954199641997419984199942000420014200242003420044200542006420074200842009420104201142012420134201442015420164201742018420194202042021420224202342024420254202642027420284202942030420314203242033420344203542036420374203842039420404204142042420434204442045420464204742048420494205042051420524205342054420554205642057420584205942060420614206242063420644206542066420674206842069420704207142072420734207442075420764207742078420794208042081420824208342084420854208642087420884208942090420914209242093420944209542096420974209842099421004210142102421034210442105421064210742108421094211042111421124211342114421154211642117421184211942120421214212242123421244212542126421274212842129421304213142132421334213442135421364213742138421394214042141421424214342144421454214642147421484214942150421514215242153421544215542156421574215842159421604216142162421634216442165421664216742168421694217042171421724217342174421754217642177421784217942180421814218242183421844218542186421874218842189421904219142192421934219442195421964219742198421994220042201422024220342204422054220642207422084220942210422114221242213422144221542216422174221842219422204222142222422234222442225422264222742228422294223042231422324223342234422354223642237422384223942240422414224242243422444224542246422474224842249422504225142252422534225442255422564225742258422594226042261422624226342264422654226642267422684226942270422714227242273422744227542276422774227842279422804228142282422834228442285422864228742288422894229042291422924229342294422954229642297422984229942300423014230242303423044230542306423074230842309423104231142312423134231442315423164231742318423194232042321423224232342324423254232642327423284232942330423314233242333423344233542336423374233842339423404234142342423434234442345423464234742348423494235042351423524235342354423554235642357423584235942360423614236242363423644236542366423674236842369423704237142372423734237442375423764237742378423794238042381423824238342384423854238642387423884238942390423914239242393423944239542396423974239842399424004240142402424034240442405424064240742408424094241042411424124241342414424154241642417424184241942420424214242242423424244242542426424274242842429424304243142432424334243442435424364243742438424394244042441424424244342444424454244642447424484244942450424514245242453424544245542456424574245842459424604246142462424634246442465424664246742468424694247042471424724247342474424754247642477424784247942480424814248242483424844248542486424874248842489424904249142492424934249442495424964249742498424994250042501425024250342504425054250642507425084250942510425114251242513425144251542516425174251842519425204252142522425234252442525425264252742528425294253042531425324253342534425354253642537425384253942540425414254242543425444254542546425474254842549425504255142552425534255442555425564255742558425594256042561425624256342564425654256642567425684256942570425714257242573425744257542576425774257842579425804258142582425834258442585425864258742588425894259042591425924259342594425954259642597425984259942600426014260242603426044260542606426074260842609426104261142612426134261442615426164261742618426194262042621426224262342624426254262642627426284262942630426314263242633426344263542636426374263842639426404264142642426434264442645426464264742648426494265042651426524265342654426554265642657426584265942660426614266242663426644266542666426674266842669426704267142672426734267442675426764267742678426794268042681426824268342684426854268642687426884268942690426914269242693426944269542696426974269842699427004270142702427034270442705427064270742708427094271042711427124271342714427154271642717427184271942720427214272242723427244272542726427274272842729427304273142732427334273442735427364273742738427394274042741427424274342744427454274642747427484274942750427514275242753427544275542756427574275842759427604276142762427634276442765427664276742768427694277042771427724277342774427754277642777427784277942780427814278242783427844278542786427874278842789427904279142792427934279442795427964279742798427994280042801428024280342804428054280642807428084280942810428114281242813428144281542816428174281842819428204282142822428234282442825428264282742828428294283042831428324283342834428354283642837428384283942840428414284242843428444284542846428474284842849428504285142852428534285442855428564285742858428594286042861428624286342864428654286642867428684286942870428714287242873428744287542876428774287842879428804288142882428834288442885428864288742888428894289042891428924289342894428954289642897428984289942900429014290242903429044290542906429074290842909429104291142912429134291442915429164291742918429194292042921429224292342924429254292642927429284292942930429314293242933429344293542936429374293842939429404294142942429434294442945429464294742948429494295042951429524295342954429554295642957429584295942960429614296242963429644296542966429674296842969429704297142972429734297442975429764297742978429794298042981429824298342984429854298642987429884298942990429914299242993429944299542996429974299842999430004300143002430034300443005430064300743008430094301043011430124301343014430154301643017430184301943020430214302243023430244302543026430274302843029430304303143032430334303443035430364303743038430394304043041430424304343044430454304643047430484304943050430514305243053430544305543056430574305843059430604306143062430634306443065430664306743068430694307043071430724307343074430754307643077430784307943080430814308243083430844308543086430874308843089430904309143092430934309443095430964309743098430994310043101431024310343104431054310643107431084310943110431114311243113431144311543116431174311843119431204312143122431234312443125431264312743128431294313043131431324313343134431354313643137431384313943140431414314243143431444314543146431474314843149431504315143152431534315443155431564315743158431594316043161431624316343164431654316643167431684316943170431714317243173431744317543176431774317843179431804318143182431834318443185431864318743188431894319043191431924319343194431954319643197431984319943200432014320243203432044320543206432074320843209432104321143212432134321443215432164321743218432194322043221432224322343224432254322643227432284322943230432314323243233432344323543236432374323843239432404324143242432434324443245432464324743248432494325043251432524325343254432554325643257432584325943260432614326243263432644326543266432674326843269432704327143272432734327443275432764327743278432794328043281432824328343284432854328643287432884328943290432914329243293432944329543296432974329843299433004330143302433034330443305433064330743308433094331043311433124331343314433154331643317433184331943320433214332243323433244332543326433274332843329433304333143332433334333443335433364333743338433394334043341433424334343344433454334643347433484334943350433514335243353433544335543356433574335843359433604336143362433634336443365433664336743368433694337043371433724337343374433754337643377433784337943380433814338243383433844338543386433874338843389433904339143392433934339443395433964339743398433994340043401434024340343404434054340643407434084340943410434114341243413434144341543416434174341843419434204342143422434234342443425434264342743428434294343043431434324343343434434354343643437434384343943440434414344243443434444344543446434474344843449434504345143452434534345443455434564345743458434594346043461434624346343464434654346643467434684346943470434714347243473434744347543476434774347843479434804348143482434834348443485434864348743488434894349043491434924349343494434954349643497434984349943500435014350243503435044350543506435074350843509435104351143512435134351443515435164351743518435194352043521435224352343524435254352643527435284352943530435314353243533435344353543536435374353843539435404354143542435434354443545435464354743548435494355043551435524355343554435554355643557435584355943560435614356243563435644356543566435674356843569435704357143572435734357443575435764357743578435794358043581435824358343584435854358643587435884358943590435914359243593435944359543596435974359843599436004360143602436034360443605436064360743608436094361043611436124361343614436154361643617436184361943620436214362243623436244362543626436274362843629436304363143632436334363443635436364363743638436394364043641436424364343644436454364643647436484364943650436514365243653436544365543656436574365843659436604366143662436634366443665436664366743668436694367043671436724367343674436754367643677436784367943680436814368243683436844368543686436874368843689436904369143692436934369443695436964369743698436994370043701437024370343704437054370643707437084370943710437114371243713437144371543716437174371843719437204372143722437234372443725437264372743728437294373043731437324373343734437354373643737437384373943740437414374243743437444374543746437474374843749437504375143752437534375443755437564375743758437594376043761437624376343764437654376643767437684376943770437714377243773437744377543776437774377843779437804378143782437834378443785437864378743788437894379043791437924379343794437954379643797437984379943800438014380243803438044380543806438074380843809438104381143812438134381443815438164381743818438194382043821438224382343824438254382643827438284382943830438314383243833438344383543836438374383843839438404384143842438434384443845438464384743848438494385043851438524385343854438554385643857438584385943860438614386243863438644386543866438674386843869438704387143872438734387443875438764387743878438794388043881438824388343884438854388643887438884388943890438914389243893438944389543896438974389843899439004390143902439034390443905439064390743908439094391043911439124391343914439154391643917439184391943920439214392243923439244392543926439274392843929439304393143932439334393443935439364393743938439394394043941439424394343944439454394643947439484394943950439514395243953439544395543956439574395843959439604396143962439634396443965439664396743968439694397043971439724397343974439754397643977439784397943980439814398243983439844398543986439874398843989439904399143992439934399443995439964399743998439994400044001440024400344004440054400644007440084400944010440114401244013440144401544016440174401844019440204402144022440234402444025440264402744028440294403044031440324403344034440354403644037440384403944040440414404244043440444404544046440474404844049440504405144052440534405444055440564405744058440594406044061440624406344064440654406644067440684406944070440714407244073440744407544076440774407844079440804408144082440834408444085440864408744088440894409044091440924409344094440954409644097440984409944100441014410244103441044410544106441074410844109441104411144112441134411444115441164411744118441194412044121441224412344124441254412644127441284412944130441314413244133441344413544136441374413844139441404414144142441434414444145441464414744148441494415044151441524415344154441554415644157441584415944160441614416244163441644416544166441674416844169441704417144172441734417444175441764417744178441794418044181441824418344184441854418644187441884418944190441914419244193441944419544196441974419844199442004420144202442034420444205442064420744208442094421044211442124421344214442154421644217442184421944220442214422244223442244422544226442274422844229442304423144232442334423444235442364423744238442394424044241442424424344244442454424644247442484424944250442514425244253442544425544256442574425844259442604426144262442634426444265442664426744268442694427044271442724427344274442754427644277442784427944280442814428244283442844428544286442874428844289442904429144292442934429444295442964429744298442994430044301443024430344304443054430644307443084430944310443114431244313443144431544316443174431844319443204432144322443234432444325443264432744328443294433044331443324433344334443354433644337443384433944340443414434244343443444434544346443474434844349443504435144352443534435444355443564435744358443594436044361443624436344364443654436644367443684436944370443714437244373443744437544376443774437844379443804438144382443834438444385443864438744388443894439044391443924439344394443954439644397443984439944400444014440244403444044440544406444074440844409444104441144412444134441444415444164441744418444194442044421444224442344424444254442644427444284442944430444314443244433444344443544436444374443844439444404444144442444434444444445444464444744448444494445044451444524445344454444554445644457444584445944460444614446244463444644446544466444674446844469444704447144472444734447444475444764447744478444794448044481444824448344484444854448644487444884448944490444914449244493444944449544496444974449844499445004450144502445034450444505445064450744508445094451044511445124451344514445154451644517445184451944520445214452244523445244452544526445274452844529445304453144532445334453444535445364453744538445394454044541445424454344544445454454644547445484454944550445514455244553445544455544556445574455844559445604456144562445634456444565445664456744568445694457044571445724457344574445754457644577445784457944580445814458244583445844458544586445874458844589445904459144592445934459444595445964459744598445994460044601446024460344604446054460644607446084460944610446114461244613446144461544616446174461844619446204462144622446234462444625446264462744628446294463044631446324463344634446354463644637446384463944640446414464244643446444464544646446474464844649446504465144652446534465444655446564465744658446594466044661446624466344664446654466644667446684466944670446714467244673446744467544676446774467844679446804468144682446834468444685446864468744688446894469044691446924469344694446954469644697446984469944700447014470244703447044470544706447074470844709447104471144712447134471444715447164471744718447194472044721447224472344724447254472644727447284472944730447314473244733447344473544736447374473844739447404474144742447434474444745447464474744748447494475044751447524475344754447554475644757447584475944760447614476244763447644476544766447674476844769447704477144772447734477444775447764477744778447794478044781447824478344784447854478644787447884478944790447914479244793447944479544796447974479844799448004480144802448034480444805448064480744808448094481044811448124481344814448154481644817448184481944820448214482244823448244482544826448274482844829448304483144832448334483444835448364483744838448394484044841448424484344844448454484644847448484484944850448514485244853448544485544856448574485844859448604486144862448634486444865448664486744868448694487044871448724487344874448754487644877448784487944880448814488244883448844488544886448874488844889448904489144892448934489444895448964489744898448994490044901449024490344904449054490644907449084490944910449114491244913449144491544916449174491844919449204492144922449234492444925449264492744928449294493044931449324493344934449354493644937449384493944940449414494244943449444494544946449474494844949449504495144952449534495444955449564495744958449594496044961449624496344964449654496644967449684496944970449714497244973449744497544976449774497844979449804498144982449834498444985449864498744988449894499044991449924499344994449954499644997449984499945000450014500245003450044500545006450074500845009450104501145012450134501445015450164501745018450194502045021450224502345024450254502645027450284502945030450314503245033450344503545036450374503845039450404504145042450434504445045450464504745048450494505045051450524505345054450554505645057450584505945060450614506245063450644506545066450674506845069450704507145072450734507445075450764507745078450794508045081450824508345084450854508645087450884508945090450914509245093450944509545096450974509845099451004510145102451034510445105451064510745108451094511045111451124511345114451154511645117451184511945120451214512245123451244512545126451274512845129451304513145132451334513445135451364513745138451394514045141451424514345144451454514645147451484514945150451514515245153451544515545156451574515845159451604516145162451634516445165451664516745168451694517045171451724517345174451754517645177451784517945180451814518245183451844518545186451874518845189451904519145192451934519445195451964519745198451994520045201452024520345204452054520645207452084520945210452114521245213452144521545216452174521845219452204522145222452234522445225452264522745228452294523045231452324523345234452354523645237452384523945240452414524245243452444524545246452474524845249452504525145252452534525445255452564525745258452594526045261452624526345264452654526645267452684526945270452714527245273452744527545276452774527845279452804528145282452834528445285452864528745288452894529045291452924529345294452954529645297452984529945300453014530245303453044530545306453074530845309453104531145312453134531445315453164531745318453194532045321453224532345324453254532645327453284532945330453314533245333453344533545336453374533845339453404534145342453434534445345453464534745348453494535045351453524535345354453554535645357453584535945360453614536245363453644536545366453674536845369453704537145372453734537445375453764537745378453794538045381453824538345384453854538645387453884538945390453914539245393453944539545396453974539845399454004540145402454034540445405454064540745408454094541045411454124541345414454154541645417454184541945420454214542245423454244542545426454274542845429454304543145432454334543445435454364543745438454394544045441454424544345444454454544645447454484544945450454514545245453454544545545456454574545845459454604546145462454634546445465454664546745468454694547045471454724547345474454754547645477454784547945480454814548245483454844548545486454874548845489454904549145492454934549445495454964549745498454994550045501455024550345504455054550645507455084550945510455114551245513455144551545516455174551845519455204552145522455234552445525455264552745528455294553045531455324553345534455354553645537455384553945540455414554245543455444554545546455474554845549455504555145552455534555445555455564555745558455594556045561455624556345564455654556645567455684556945570455714557245573455744557545576455774557845579455804558145582455834558445585455864558745588455894559045591455924559345594455954559645597455984559945600456014560245603456044560545606456074560845609456104561145612456134561445615456164561745618456194562045621456224562345624456254562645627456284562945630456314563245633456344563545636456374563845639456404564145642456434564445645456464564745648456494565045651456524565345654456554565645657456584565945660456614566245663456644566545666456674566845669456704567145672456734567445675456764567745678456794568045681456824568345684456854568645687456884568945690456914569245693456944569545696456974569845699457004570145702457034570445705457064570745708457094571045711457124571345714457154571645717457184571945720457214572245723457244572545726457274572845729457304573145732457334573445735457364573745738457394574045741457424574345744457454574645747457484574945750457514575245753457544575545756457574575845759457604576145762457634576445765457664576745768457694577045771457724577345774457754577645777457784577945780457814578245783457844578545786457874578845789457904579145792457934579445795457964579745798457994580045801458024580345804458054580645807458084580945810458114581245813458144581545816458174581845819458204582145822458234582445825458264582745828458294583045831458324583345834458354583645837458384583945840458414584245843458444584545846458474584845849458504585145852458534585445855458564585745858458594586045861458624586345864458654586645867458684586945870458714587245873458744587545876458774587845879458804588145882458834588445885458864588745888458894589045891458924589345894458954589645897458984589945900459014590245903459044590545906459074590845909459104591145912459134591445915459164591745918459194592045921459224592345924459254592645927459284592945930459314593245933459344593545936459374593845939459404594145942459434594445945459464594745948459494595045951459524595345954459554595645957459584595945960459614596245963459644596545966459674596845969459704597145972459734597445975459764597745978459794598045981459824598345984459854598645987459884598945990459914599245993459944599545996459974599845999460004600146002460034600446005460064600746008460094601046011460124601346014460154601646017460184601946020460214602246023460244602546026460274602846029460304603146032460334603446035460364603746038460394604046041460424604346044460454604646047460484604946050460514605246053460544605546056460574605846059460604606146062460634606446065460664606746068460694607046071460724607346074460754607646077460784607946080460814608246083460844608546086460874608846089460904609146092460934609446095460964609746098460994610046101461024610346104461054610646107461084610946110461114611246113461144611546116461174611846119461204612146122461234612446125461264612746128461294613046131461324613346134461354613646137461384613946140461414614246143461444614546146461474614846149461504615146152461534615446155461564615746158461594616046161461624616346164461654616646167461684616946170461714617246173461744617546176461774617846179461804618146182461834618446185461864618746188461894619046191461924619346194461954619646197461984619946200462014620246203462044620546206462074620846209462104621146212462134621446215462164621746218462194622046221462224622346224462254622646227462284622946230462314623246233462344623546236462374623846239462404624146242462434624446245462464624746248462494625046251462524625346254462554625646257462584625946260462614626246263462644626546266462674626846269462704627146272462734627446275462764627746278462794628046281462824628346284462854628646287462884628946290462914629246293462944629546296462974629846299463004630146302463034630446305463064630746308463094631046311463124631346314463154631646317463184631946320463214632246323463244632546326463274632846329463304633146332463334633446335463364633746338463394634046341463424634346344463454634646347463484634946350463514635246353463544635546356463574635846359463604636146362463634636446365463664636746368463694637046371463724637346374463754637646377463784637946380463814638246383463844638546386463874638846389463904639146392463934639446395463964639746398463994640046401464024640346404464054640646407464084640946410464114641246413464144641546416464174641846419464204642146422464234642446425464264642746428464294643046431464324643346434464354643646437464384643946440464414644246443464444644546446464474644846449464504645146452464534645446455464564645746458464594646046461464624646346464464654646646467464684646946470464714647246473464744647546476464774647846479464804648146482464834648446485464864648746488464894649046491464924649346494464954649646497464984649946500465014650246503465044650546506465074650846509465104651146512465134651446515465164651746518465194652046521465224652346524465254652646527465284652946530465314653246533465344653546536465374653846539465404654146542465434654446545465464654746548465494655046551465524655346554465554655646557465584655946560465614656246563465644656546566465674656846569465704657146572465734657446575465764657746578465794658046581465824658346584465854658646587465884658946590465914659246593465944659546596465974659846599466004660146602466034660446605466064660746608466094661046611466124661346614466154661646617466184661946620466214662246623466244662546626466274662846629466304663146632466334663446635466364663746638466394664046641466424664346644466454664646647466484664946650466514665246653466544665546656466574665846659466604666146662466634666446665466664666746668466694667046671466724667346674466754667646677466784667946680466814668246683466844668546686466874668846689466904669146692466934669446695466964669746698466994670046701467024670346704467054670646707467084670946710467114671246713467144671546716467174671846719467204672146722467234672446725467264672746728467294673046731467324673346734467354673646737467384673946740467414674246743467444674546746467474674846749467504675146752467534675446755467564675746758467594676046761467624676346764467654676646767467684676946770467714677246773467744677546776467774677846779467804678146782467834678446785467864678746788467894679046791467924679346794467954679646797467984679946800468014680246803468044680546806468074680846809468104681146812468134681446815468164681746818468194682046821468224682346824468254682646827468284682946830468314683246833468344683546836468374683846839468404684146842468434684446845468464684746848468494685046851468524685346854468554685646857468584685946860468614686246863468644686546866468674686846869468704687146872468734687446875468764687746878468794688046881468824688346884468854688646887468884688946890468914689246893468944689546896468974689846899469004690146902469034690446905469064690746908469094691046911469124691346914469154691646917469184691946920469214692246923469244692546926469274692846929469304693146932469334693446935469364693746938469394694046941469424694346944469454694646947469484694946950469514695246953469544695546956469574695846959469604696146962469634696446965469664696746968469694697046971469724697346974469754697646977469784697946980469814698246983469844698546986469874698846989469904699146992469934699446995469964699746998469994700047001470024700347004470054700647007470084700947010470114701247013470144701547016470174701847019470204702147022470234702447025470264702747028470294703047031470324703347034470354703647037470384703947040470414704247043470444704547046470474704847049470504705147052470534705447055470564705747058470594706047061470624706347064470654706647067470684706947070470714707247073470744707547076470774707847079470804708147082470834708447085470864708747088470894709047091470924709347094470954709647097470984709947100471014710247103471044710547106471074710847109471104711147112471134711447115471164711747118471194712047121471224712347124471254712647127471284712947130471314713247133471344713547136471374713847139471404714147142471434714447145471464714747148471494715047151471524715347154471554715647157471584715947160471614716247163471644716547166471674716847169471704717147172471734717447175471764717747178471794718047181471824718347184471854718647187471884718947190471914719247193471944719547196471974719847199472004720147202472034720447205472064720747208472094721047211472124721347214472154721647217472184721947220472214722247223472244722547226472274722847229472304723147232472334723447235472364723747238472394724047241472424724347244472454724647247472484724947250472514725247253472544725547256472574725847259472604726147262472634726447265472664726747268472694727047271472724727347274472754727647277472784727947280472814728247283472844728547286472874728847289472904729147292472934729447295472964729747298472994730047301473024730347304473054730647307473084730947310473114731247313473144731547316473174731847319473204732147322473234732447325473264732747328473294733047331473324733347334473354733647337473384733947340473414734247343473444734547346473474734847349473504735147352473534735447355473564735747358473594736047361473624736347364473654736647367473684736947370473714737247373473744737547376473774737847379473804738147382473834738447385473864738747388473894739047391473924739347394473954739647397473984739947400474014740247403474044740547406474074740847409474104741147412474134741447415474164741747418474194742047421474224742347424474254742647427474284742947430474314743247433474344743547436474374743847439474404744147442474434744447445474464744747448474494745047451474524745347454474554745647457474584745947460474614746247463474644746547466474674746847469474704747147472474734747447475474764747747478474794748047481474824748347484474854748647487474884748947490474914749247493474944749547496474974749847499475004750147502475034750447505475064750747508475094751047511475124751347514475154751647517475184751947520475214752247523475244752547526475274752847529475304753147532475334753447535475364753747538475394754047541475424754347544475454754647547475484754947550475514755247553475544755547556475574755847559475604756147562475634756447565475664756747568475694757047571475724757347574475754757647577475784757947580475814758247583475844758547586475874758847589475904759147592475934759447595475964759747598475994760047601476024760347604476054760647607476084760947610476114761247613476144761547616476174761847619476204762147622476234762447625476264762747628476294763047631476324763347634476354763647637476384763947640476414764247643476444764547646476474764847649476504765147652476534765447655476564765747658476594766047661476624766347664476654766647667476684766947670476714767247673476744767547676476774767847679476804768147682476834768447685476864768747688476894769047691476924769347694476954769647697476984769947700477014770247703477044770547706477074770847709477104771147712477134771447715477164771747718477194772047721477224772347724477254772647727477284772947730477314773247733477344773547736477374773847739477404774147742477434774447745477464774747748477494775047751477524775347754477554775647757477584775947760477614776247763477644776547766477674776847769477704777147772477734777447775477764777747778477794778047781477824778347784477854778647787477884778947790477914779247793477944779547796477974779847799478004780147802478034780447805478064780747808478094781047811478124781347814478154781647817478184781947820478214782247823478244782547826478274782847829478304783147832478334783447835478364783747838478394784047841478424784347844478454784647847478484784947850478514785247853478544785547856478574785847859478604786147862478634786447865478664786747868478694787047871478724787347874478754787647877478784787947880478814788247883478844788547886478874788847889478904789147892478934789447895478964789747898478994790047901479024790347904479054790647907479084790947910479114791247913479144791547916479174791847919479204792147922479234792447925479264792747928479294793047931479324793347934479354793647937479384793947940479414794247943479444794547946479474794847949479504795147952479534795447955479564795747958479594796047961479624796347964479654796647967479684796947970479714797247973479744797547976479774797847979479804798147982479834798447985479864798747988479894799047991479924799347994479954799647997479984799948000480014800248003480044800548006480074800848009480104801148012480134801448015480164801748018480194802048021480224802348024480254802648027480284802948030480314803248033480344803548036480374803848039480404804148042480434804448045480464804748048480494805048051480524805348054480554805648057480584805948060480614806248063480644806548066480674806848069480704807148072480734807448075480764807748078480794808048081480824808348084480854808648087480884808948090480914809248093480944809548096480974809848099481004810148102481034810448105481064810748108481094811048111481124811348114481154811648117481184811948120481214812248123481244812548126481274812848129481304813148132481334813448135481364813748138481394814048141481424814348144481454814648147481484814948150481514815248153481544815548156481574815848159481604816148162481634816448165481664816748168481694817048171481724817348174481754817648177481784817948180481814818248183481844818548186481874818848189481904819148192481934819448195481964819748198481994820048201482024820348204482054820648207482084820948210482114821248213482144821548216482174821848219482204822148222482234822448225482264822748228482294823048231482324823348234482354823648237482384823948240482414824248243482444824548246482474824848249482504825148252482534825448255482564825748258482594826048261482624826348264482654826648267482684826948270482714827248273482744827548276482774827848279482804828148282482834828448285482864828748288482894829048291482924829348294482954829648297482984829948300483014830248303483044830548306483074830848309483104831148312483134831448315483164831748318483194832048321483224832348324483254832648327483284832948330483314833248333483344833548336483374833848339483404834148342483434834448345483464834748348483494835048351483524835348354483554835648357483584835948360483614836248363483644836548366483674836848369483704837148372483734837448375483764837748378483794838048381483824838348384483854838648387483884838948390483914839248393483944839548396483974839848399484004840148402484034840448405484064840748408484094841048411484124841348414484154841648417484184841948420484214842248423484244842548426484274842848429484304843148432484334843448435484364843748438484394844048441484424844348444484454844648447484484844948450484514845248453484544845548456484574845848459484604846148462484634846448465484664846748468484694847048471484724847348474484754847648477484784847948480484814848248483484844848548486484874848848489484904849148492484934849448495484964849748498484994850048501485024850348504485054850648507485084850948510485114851248513485144851548516485174851848519485204852148522485234852448525485264852748528485294853048531485324853348534485354853648537485384853948540485414854248543485444854548546485474854848549485504855148552485534855448555485564855748558485594856048561485624856348564485654856648567485684856948570485714857248573485744857548576485774857848579485804858148582485834858448585485864858748588485894859048591485924859348594485954859648597485984859948600486014860248603486044860548606486074860848609486104861148612486134861448615486164861748618486194862048621486224862348624486254862648627486284862948630486314863248633486344863548636486374863848639486404864148642486434864448645486464864748648486494865048651486524865348654486554865648657486584865948660486614866248663486644866548666486674866848669486704867148672486734867448675486764867748678486794868048681486824868348684486854868648687486884868948690486914869248693486944869548696486974869848699487004870148702487034870448705487064870748708487094871048711487124871348714487154871648717487184871948720487214872248723487244872548726487274872848729487304873148732487334873448735487364873748738487394874048741487424874348744487454874648747487484874948750487514875248753487544875548756487574875848759487604876148762487634876448765487664876748768487694877048771487724877348774487754877648777487784877948780487814878248783487844878548786487874878848789487904879148792487934879448795487964879748798487994880048801488024880348804488054880648807488084880948810488114881248813488144881548816488174881848819488204882148822488234882448825488264882748828488294883048831488324883348834488354883648837488384883948840488414884248843488444884548846488474884848849488504885148852488534885448855488564885748858488594886048861488624886348864488654886648867488684886948870488714887248873488744887548876488774887848879488804888148882488834888448885488864888748888488894889048891488924889348894488954889648897488984889948900489014890248903489044890548906489074890848909489104891148912489134891448915489164891748918489194892048921489224892348924489254892648927489284892948930489314893248933489344893548936489374893848939489404894148942489434894448945489464894748948489494895048951489524895348954489554895648957489584895948960489614896248963489644896548966489674896848969489704897148972489734897448975489764897748978489794898048981489824898348984489854898648987489884898948990489914899248993489944899548996489974899848999490004900149002490034900449005490064900749008490094901049011490124901349014490154901649017490184901949020490214902249023490244902549026490274902849029490304903149032490334903449035490364903749038490394904049041490424904349044490454904649047490484904949050490514905249053490544905549056490574905849059490604906149062490634906449065490664906749068490694907049071490724907349074490754907649077490784907949080490814908249083490844908549086490874908849089490904909149092490934909449095490964909749098490994910049101491024910349104491054910649107491084910949110491114911249113491144911549116491174911849119491204912149122491234912449125491264912749128491294913049131491324913349134491354913649137491384913949140491414914249143491444914549146491474914849149491504915149152491534915449155491564915749158491594916049161491624916349164491654916649167491684916949170491714917249173491744917549176491774917849179491804918149182491834918449185491864918749188491894919049191491924919349194491954919649197491984919949200492014920249203492044920549206492074920849209492104921149212492134921449215492164921749218492194922049221492224922349224492254922649227492284922949230492314923249233492344923549236492374923849239492404924149242492434924449245492464924749248492494925049251492524925349254492554925649257492584925949260492614926249263492644926549266492674926849269492704927149272492734927449275492764927749278492794928049281492824928349284492854928649287492884928949290492914929249293492944929549296492974929849299493004930149302493034930449305493064930749308493094931049311493124931349314493154931649317493184931949320493214932249323493244932549326493274932849329493304933149332493334933449335493364933749338493394934049341493424934349344493454934649347493484934949350493514935249353493544935549356493574935849359493604936149362493634936449365493664936749368493694937049371493724937349374493754937649377493784937949380493814938249383493844938549386493874938849389493904939149392493934939449395493964939749398493994940049401494024940349404494054940649407494084940949410494114941249413494144941549416494174941849419494204942149422494234942449425494264942749428494294943049431494324943349434494354943649437494384943949440494414944249443494444944549446494474944849449494504945149452494534945449455494564945749458494594946049461494624946349464494654946649467494684946949470494714947249473494744947549476494774947849479494804948149482494834948449485494864948749488494894949049491494924949349494494954949649497494984949949500495014950249503495044950549506495074950849509495104951149512495134951449515495164951749518495194952049521495224952349524495254952649527495284952949530495314953249533495344953549536495374953849539495404954149542495434954449545495464954749548495494955049551495524955349554495554955649557495584955949560495614956249563495644956549566495674956849569495704957149572495734957449575495764957749578495794958049581495824958349584495854958649587495884958949590495914959249593495944959549596495974959849599496004960149602496034960449605496064960749608496094961049611496124961349614496154961649617496184961949620496214962249623496244962549626496274962849629496304963149632496334963449635496364963749638496394964049641496424964349644496454964649647496484964949650496514965249653496544965549656496574965849659496604966149662496634966449665496664966749668496694967049671496724967349674496754967649677496784967949680496814968249683496844968549686496874968849689496904969149692496934969449695496964969749698496994970049701497024970349704497054970649707497084970949710497114971249713497144971549716497174971849719497204972149722497234972449725497264972749728497294973049731497324973349734497354973649737497384973949740497414974249743497444974549746497474974849749497504975149752497534975449755497564975749758497594976049761497624976349764497654976649767497684976949770497714977249773497744977549776497774977849779497804978149782497834978449785497864978749788497894979049791497924979349794497954979649797497984979949800498014980249803498044980549806498074980849809498104981149812498134981449815498164981749818498194982049821498224982349824498254982649827498284982949830498314983249833498344983549836498374983849839498404984149842498434984449845498464984749848498494985049851498524985349854498554985649857498584985949860498614986249863498644986549866498674986849869498704987149872498734987449875498764987749878498794988049881498824988349884498854988649887498884988949890498914989249893498944989549896498974989849899499004990149902499034990449905499064990749908499094991049911499124991349914499154991649917499184991949920499214992249923499244992549926499274992849929499304993149932499334993449935499364993749938499394994049941499424994349944499454994649947499484994949950499514995249953499544995549956499574995849959499604996149962499634996449965499664996749968499694997049971499724997349974499754997649977499784997949980499814998249983499844998549986499874998849989499904999149992499934999449995499964999749998499995000050001500025000350004500055000650007500085000950010500115001250013500145001550016500175001850019500205002150022500235002450025500265002750028500295003050031500325003350034500355003650037500385003950040500415004250043500445004550046500475004850049500505005150052500535005450055500565005750058500595006050061500625006350064500655006650067500685006950070500715007250073500745007550076500775007850079500805008150082500835008450085500865008750088500895009050091500925009350094500955009650097500985009950100501015010250103501045010550106501075010850109501105011150112501135011450115501165011750118501195012050121501225012350124501255012650127501285012950130501315013250133501345013550136501375013850139501405014150142501435014450145501465014750148501495015050151501525015350154501555015650157501585015950160501615016250163501645016550166501675016850169501705017150172501735017450175501765017750178501795018050181501825018350184501855018650187501885018950190501915019250193501945019550196501975019850199502005020150202502035020450205502065020750208502095021050211502125021350214502155021650217502185021950220502215022250223502245022550226502275022850229502305023150232502335023450235502365023750238502395024050241502425024350244502455024650247502485024950250502515025250253502545025550256502575025850259502605026150262502635026450265502665026750268502695027050271502725027350274502755027650277502785027950280502815028250283502845028550286502875028850289502905029150292502935029450295502965029750298502995030050301503025030350304503055030650307503085030950310503115031250313503145031550316503175031850319503205032150322503235032450325503265032750328503295033050331503325033350334503355033650337503385033950340503415034250343503445034550346503475034850349503505035150352503535035450355503565035750358503595036050361503625036350364503655036650367503685036950370503715037250373503745037550376503775037850379503805038150382503835038450385503865038750388503895039050391503925039350394503955039650397503985039950400504015040250403504045040550406504075040850409504105041150412504135041450415504165041750418504195042050421504225042350424504255042650427504285042950430504315043250433504345043550436504375043850439504405044150442504435044450445504465044750448504495045050451504525045350454504555045650457504585045950460504615046250463504645046550466504675046850469504705047150472504735047450475504765047750478504795048050481504825048350484504855048650487504885048950490504915049250493504945049550496504975049850499505005050150502505035050450505505065050750508505095051050511505125051350514505155051650517505185051950520505215052250523505245052550526505275052850529505305053150532505335053450535505365053750538505395054050541505425054350544505455054650547505485054950550505515055250553505545055550556505575055850559505605056150562505635056450565505665056750568505695057050571505725057350574505755057650577505785057950580505815058250583505845058550586505875058850589505905059150592505935059450595505965059750598505995060050601506025060350604506055060650607506085060950610506115061250613506145061550616506175061850619506205062150622506235062450625506265062750628506295063050631506325063350634506355063650637506385063950640506415064250643506445064550646506475064850649506505065150652506535065450655506565065750658506595066050661506625066350664506655066650667506685066950670506715067250673506745067550676506775067850679506805068150682506835068450685506865068750688506895069050691506925069350694506955069650697506985069950700507015070250703507045070550706507075070850709507105071150712507135071450715507165071750718507195072050721507225072350724507255072650727507285072950730507315073250733507345073550736507375073850739507405074150742507435074450745507465074750748507495075050751507525075350754507555075650757507585075950760507615076250763507645076550766507675076850769507705077150772507735077450775507765077750778507795078050781507825078350784507855078650787507885078950790507915079250793507945079550796507975079850799508005080150802508035080450805508065080750808508095081050811508125081350814508155081650817508185081950820508215082250823508245082550826508275082850829508305083150832508335083450835508365083750838508395084050841508425084350844508455084650847508485084950850508515085250853508545085550856508575085850859508605086150862508635086450865508665086750868508695087050871508725087350874508755087650877508785087950880508815088250883508845088550886508875088850889508905089150892508935089450895508965089750898508995090050901509025090350904509055090650907509085090950910509115091250913509145091550916509175091850919509205092150922509235092450925509265092750928509295093050931509325093350934509355093650937509385093950940509415094250943509445094550946509475094850949509505095150952509535095450955509565095750958509595096050961509625096350964509655096650967509685096950970509715097250973509745097550976509775097850979509805098150982509835098450985509865098750988509895099050991509925099350994509955099650997509985099951000510015100251003510045100551006510075100851009510105101151012510135101451015510165101751018510195102051021510225102351024510255102651027510285102951030510315103251033510345103551036510375103851039510405104151042510435104451045510465104751048510495105051051510525105351054510555105651057510585105951060510615106251063510645106551066510675106851069510705107151072510735107451075510765107751078510795108051081510825108351084510855108651087510885108951090510915109251093510945109551096510975109851099511005110151102511035110451105511065110751108511095111051111511125111351114511155111651117511185111951120511215112251123511245112551126511275112851129511305113151132511335113451135511365113751138511395114051141511425114351144511455114651147511485114951150511515115251153511545115551156511575115851159511605116151162511635116451165511665116751168511695117051171511725117351174511755117651177511785117951180511815118251183511845118551186511875118851189511905119151192511935119451195511965119751198511995120051201512025120351204512055120651207512085120951210512115121251213512145121551216512175121851219512205122151222512235122451225512265122751228512295123051231512325123351234512355123651237512385123951240512415124251243512445124551246512475124851249512505125151252512535125451255512565125751258512595126051261512625126351264512655126651267512685126951270512715127251273512745127551276512775127851279512805128151282512835128451285512865128751288512895129051291512925129351294512955129651297512985129951300513015130251303513045130551306513075130851309513105131151312513135131451315513165131751318513195132051321513225132351324513255132651327513285132951330513315133251333513345133551336513375133851339513405134151342513435134451345513465134751348513495135051351513525135351354513555135651357513585135951360513615136251363513645136551366513675136851369513705137151372513735137451375513765137751378513795138051381513825138351384513855138651387513885138951390513915139251393513945139551396513975139851399514005140151402514035140451405514065140751408514095141051411514125141351414514155141651417514185141951420514215142251423514245142551426514275142851429514305143151432514335143451435514365143751438514395144051441514425144351444514455144651447514485144951450514515145251453514545145551456514575145851459514605146151462514635146451465514665146751468514695147051471514725147351474514755147651477514785147951480514815148251483514845148551486514875148851489514905149151492514935149451495514965149751498514995150051501515025150351504515055150651507515085150951510515115151251513515145151551516515175151851519515205152151522515235152451525515265152751528515295153051531515325153351534515355153651537515385153951540515415154251543515445154551546515475154851549515505155151552515535155451555515565155751558515595156051561515625156351564515655156651567515685156951570515715157251573515745157551576515775157851579515805158151582515835158451585515865158751588515895159051591515925159351594515955159651597515985159951600516015160251603516045160551606516075160851609516105161151612516135161451615516165161751618516195162051621516225162351624516255162651627516285162951630516315163251633516345163551636516375163851639516405164151642516435164451645516465164751648516495165051651516525165351654516555165651657516585165951660516615166251663516645166551666516675166851669516705167151672516735167451675516765167751678516795168051681516825168351684516855168651687516885168951690516915169251693516945169551696516975169851699517005170151702517035170451705517065170751708517095171051711517125171351714517155171651717517185171951720517215172251723517245172551726517275172851729517305173151732517335173451735517365173751738517395174051741517425174351744517455174651747517485174951750517515175251753517545175551756517575175851759517605176151762517635176451765517665176751768517695177051771517725177351774517755177651777517785177951780517815178251783517845178551786517875178851789517905179151792517935179451795517965179751798517995180051801518025180351804518055180651807518085180951810518115181251813518145181551816518175181851819518205182151822518235182451825518265182751828518295183051831518325183351834518355183651837518385183951840518415184251843518445184551846518475184851849518505185151852518535185451855518565185751858518595186051861518625186351864518655186651867518685186951870518715187251873518745187551876518775187851879518805188151882518835188451885518865188751888518895189051891518925189351894518955189651897518985189951900519015190251903519045190551906519075190851909519105191151912519135191451915519165191751918519195192051921519225192351924519255192651927519285192951930519315193251933519345193551936519375193851939519405194151942519435194451945519465194751948519495195051951519525195351954519555195651957519585195951960519615196251963519645196551966519675196851969519705197151972519735197451975519765197751978519795198051981519825198351984519855198651987519885198951990519915199251993519945199551996519975199851999520005200152002520035200452005520065200752008520095201052011520125201352014520155201652017520185201952020520215202252023520245202552026520275202852029520305203152032520335203452035520365203752038520395204052041520425204352044520455204652047520485204952050520515205252053520545205552056520575205852059520605206152062520635206452065520665206752068520695207052071520725207352074520755207652077520785207952080520815208252083520845208552086520875208852089520905209152092520935209452095520965209752098520995210052101521025210352104521055210652107521085210952110521115211252113521145211552116521175211852119521205212152122521235212452125521265212752128521295213052131521325213352134521355213652137521385213952140521415214252143521445214552146521475214852149521505215152152521535215452155521565215752158521595216052161521625216352164521655216652167521685216952170521715217252173521745217552176521775217852179521805218152182521835218452185521865218752188521895219052191521925219352194521955219652197521985219952200522015220252203522045220552206522075220852209522105221152212522135221452215522165221752218522195222052221522225222352224522255222652227522285222952230522315223252233522345223552236522375223852239522405224152242522435224452245522465224752248522495225052251522525225352254522555225652257522585225952260522615226252263522645226552266522675226852269522705227152272522735227452275522765227752278522795228052281522825228352284522855228652287522885228952290522915229252293522945229552296522975229852299523005230152302523035230452305523065230752308523095231052311523125231352314523155231652317523185231952320523215232252323523245232552326523275232852329523305233152332523335233452335523365233752338523395234052341523425234352344523455234652347523485234952350523515235252353523545235552356523575235852359523605236152362523635236452365523665236752368523695237052371523725237352374523755237652377523785237952380523815238252383523845238552386523875238852389523905239152392523935239452395523965239752398523995240052401524025240352404524055240652407524085240952410524115241252413524145241552416524175241852419524205242152422524235242452425524265242752428524295243052431524325243352434524355243652437524385243952440524415244252443524445244552446524475244852449524505245152452524535245452455524565245752458524595246052461524625246352464524655246652467524685246952470524715247252473524745247552476524775247852479524805248152482524835248452485524865248752488524895249052491524925249352494524955249652497524985249952500525015250252503525045250552506525075250852509525105251152512525135251452515525165251752518525195252052521525225252352524525255252652527525285252952530525315253252533525345253552536525375253852539525405254152542525435254452545525465254752548525495255052551525525255352554525555255652557525585255952560525615256252563525645256552566525675256852569525705257152572525735257452575525765257752578525795258052581525825258352584525855258652587525885258952590525915259252593525945259552596525975259852599526005260152602526035260452605526065260752608526095261052611526125261352614526155261652617526185261952620526215262252623526245262552626526275262852629526305263152632526335263452635526365263752638526395264052641526425264352644526455264652647526485264952650526515265252653526545265552656526575265852659526605266152662526635266452665526665266752668526695267052671526725267352674526755267652677526785267952680526815268252683526845268552686526875268852689526905269152692526935269452695526965269752698526995270052701527025270352704527055270652707527085270952710527115271252713527145271552716527175271852719527205272152722527235272452725527265272752728527295273052731527325273352734527355273652737527385273952740527415274252743527445274552746527475274852749527505275152752527535275452755527565275752758527595276052761527625276352764527655276652767527685276952770527715277252773527745277552776527775277852779527805278152782527835278452785527865278752788527895279052791527925279352794527955279652797527985279952800528015280252803528045280552806528075280852809528105281152812528135281452815528165281752818528195282052821528225282352824528255282652827528285282952830528315283252833528345283552836528375283852839528405284152842528435284452845528465284752848528495285052851528525285352854528555285652857528585285952860528615286252863528645286552866528675286852869528705287152872528735287452875528765287752878528795288052881528825288352884528855288652887528885288952890528915289252893528945289552896528975289852899529005290152902529035290452905529065290752908529095291052911529125291352914529155291652917529185291952920529215292252923529245292552926529275292852929529305293152932529335293452935529365293752938529395294052941529425294352944529455294652947529485294952950529515295252953529545295552956529575295852959529605296152962529635296452965529665296752968529695297052971529725297352974529755297652977529785297952980529815298252983529845298552986529875298852989529905299152992529935299452995529965299752998529995300053001530025300353004530055300653007530085300953010530115301253013530145301553016530175301853019530205302153022530235302453025530265302753028530295303053031530325303353034530355303653037530385303953040530415304253043530445304553046530475304853049530505305153052530535305453055530565305753058530595306053061530625306353064530655306653067530685306953070530715307253073530745307553076530775307853079530805308153082530835308453085530865308753088530895309053091530925309353094530955309653097530985309953100531015310253103531045310553106531075310853109531105311153112531135311453115531165311753118531195312053121531225312353124531255312653127531285312953130531315313253133531345313553136531375313853139531405314153142531435314453145531465314753148531495315053151531525315353154531555315653157531585315953160531615316253163531645316553166531675316853169531705317153172531735317453175531765317753178531795318053181531825318353184531855318653187531885318953190531915319253193531945319553196531975319853199532005320153202532035320453205532065320753208532095321053211532125321353214532155321653217532185321953220532215322253223532245322553226532275322853229532305323153232532335323453235532365323753238532395324053241532425324353244532455324653247532485324953250532515325253253532545325553256532575325853259532605326153262532635326453265532665326753268532695327053271532725327353274532755327653277532785327953280532815328253283532845328553286532875328853289532905329153292532935329453295532965329753298532995330053301533025330353304533055330653307533085330953310533115331253313533145331553316533175331853319533205332153322533235332453325533265332753328533295333053331533325333353334533355333653337533385333953340533415334253343533445334553346533475334853349533505335153352533535335453355533565335753358533595336053361533625336353364533655336653367533685336953370533715337253373533745337553376533775337853379533805338153382533835338453385533865338753388533895339053391533925339353394533955339653397533985339953400534015340253403534045340553406534075340853409534105341153412534135341453415534165341753418534195342053421534225342353424534255342653427534285342953430534315343253433534345343553436534375343853439534405344153442534435344453445534465344753448534495345053451534525345353454534555345653457534585345953460534615346253463534645346553466534675346853469534705347153472534735347453475534765347753478534795348053481534825348353484534855348653487534885348953490534915349253493534945349553496534975349853499535005350153502535035350453505535065350753508535095351053511535125351353514535155351653517535185351953520535215352253523535245352553526535275352853529535305353153532535335353453535535365353753538535395354053541535425354353544535455354653547535485354953550535515355253553535545355553556535575355853559535605356153562535635356453565535665356753568535695357053571535725357353574535755357653577535785357953580535815358253583535845358553586535875358853589535905359153592535935359453595535965359753598535995360053601536025360353604536055360653607536085360953610536115361253613536145361553616536175361853619536205362153622536235362453625536265362753628536295363053631536325363353634536355363653637536385363953640536415364253643536445364553646536475364853649536505365153652536535365453655536565365753658536595366053661536625366353664536655366653667536685366953670536715367253673536745367553676536775367853679536805368153682536835368453685536865368753688536895369053691536925369353694536955369653697536985369953700537015370253703537045370553706537075370853709537105371153712537135371453715537165371753718537195372053721537225372353724537255372653727537285372953730537315373253733537345373553736537375373853739537405374153742537435374453745537465374753748537495375053751537525375353754537555375653757537585375953760537615376253763537645376553766537675376853769537705377153772537735377453775537765377753778537795378053781537825378353784537855378653787537885378953790537915379253793537945379553796537975379853799538005380153802538035380453805538065380753808538095381053811538125381353814538155381653817538185381953820538215382253823538245382553826538275382853829538305383153832538335383453835538365383753838538395384053841538425384353844538455384653847538485384953850538515385253853538545385553856538575385853859538605386153862538635386453865538665386753868538695387053871538725387353874538755387653877538785387953880538815388253883538845388553886538875388853889538905389153892538935389453895538965389753898538995390053901539025390353904539055390653907539085390953910539115391253913539145391553916539175391853919539205392153922539235392453925539265392753928539295393053931539325393353934539355393653937539385393953940539415394253943539445394553946539475394853949539505395153952539535395453955539565395753958539595396053961539625396353964539655396653967539685396953970539715397253973539745397553976539775397853979539805398153982539835398453985539865398753988539895399053991539925399353994539955399653997539985399954000540015400254003540045400554006540075400854009540105401154012540135401454015540165401754018540195402054021540225402354024540255402654027540285402954030540315403254033540345403554036540375403854039540405404154042540435404454045540465404754048540495405054051540525405354054540555405654057540585405954060540615406254063540645406554066540675406854069540705407154072540735407454075540765407754078540795408054081540825408354084540855408654087540885408954090540915409254093540945409554096540975409854099541005410154102541035410454105541065410754108541095411054111541125411354114541155411654117541185411954120541215412254123541245412554126541275412854129541305413154132541335413454135541365413754138541395414054141541425414354144541455414654147541485414954150541515415254153541545415554156541575415854159541605416154162541635416454165541665416754168541695417054171541725417354174541755417654177541785417954180541815418254183541845418554186541875418854189541905419154192541935419454195541965419754198541995420054201542025420354204542055420654207542085420954210542115421254213542145421554216542175421854219542205422154222542235422454225542265422754228542295423054231542325423354234542355423654237542385423954240542415424254243542445424554246542475424854249542505425154252542535425454255542565425754258542595426054261542625426354264542655426654267542685426954270542715427254273542745427554276542775427854279542805428154282542835428454285542865428754288542895429054291542925429354294542955429654297542985429954300543015430254303543045430554306543075430854309543105431154312543135431454315543165431754318543195432054321543225432354324543255432654327543285432954330543315433254333543345433554336543375433854339543405434154342543435434454345543465434754348543495435054351543525435354354543555435654357543585435954360543615436254363543645436554366543675436854369543705437154372543735437454375543765437754378543795438054381543825438354384543855438654387543885438954390543915439254393543945439554396543975439854399544005440154402544035440454405544065440754408544095441054411544125441354414544155441654417544185441954420544215442254423544245442554426544275442854429544305443154432544335443454435544365443754438544395444054441544425444354444544455444654447544485444954450544515445254453544545445554456544575445854459544605446154462544635446454465544665446754468544695447054471544725447354474544755447654477544785447954480544815448254483544845448554486544875448854489544905449154492544935449454495544965449754498544995450054501545025450354504545055450654507545085450954510545115451254513545145451554516545175451854519545205452154522545235452454525545265452754528545295453054531545325453354534545355453654537545385453954540545415454254543545445454554546545475454854549545505455154552545535455454555545565455754558545595456054561545625456354564545655456654567545685456954570545715457254573545745457554576545775457854579545805458154582545835458454585545865458754588545895459054591545925459354594545955459654597545985459954600546015460254603546045460554606546075460854609546105461154612546135461454615546165461754618546195462054621546225462354624546255462654627546285462954630546315463254633546345463554636546375463854639546405464154642546435464454645546465464754648546495465054651546525465354654546555465654657546585465954660546615466254663546645466554666546675466854669546705467154672546735467454675546765467754678546795468054681546825468354684546855468654687546885468954690546915469254693546945469554696546975469854699547005470154702547035470454705547065470754708547095471054711547125471354714547155471654717547185471954720547215472254723547245472554726547275472854729547305473154732547335473454735547365473754738547395474054741547425474354744547455474654747547485474954750547515475254753547545475554756547575475854759547605476154762547635476454765547665476754768547695477054771547725477354774547755477654777547785477954780547815478254783547845478554786547875478854789547905479154792547935479454795547965479754798547995480054801548025480354804548055480654807548085480954810548115481254813548145481554816548175481854819548205482154822548235482454825548265482754828548295483054831548325483354834548355483654837548385483954840548415484254843548445484554846548475484854849548505485154852548535485454855548565485754858548595486054861548625486354864548655486654867548685486954870548715487254873548745487554876548775487854879548805488154882548835488454885548865488754888548895489054891548925489354894548955489654897548985489954900549015490254903549045490554906549075490854909549105491154912549135491454915549165491754918549195492054921549225492354924549255492654927549285492954930549315493254933549345493554936549375493854939549405494154942549435494454945549465494754948549495495054951549525495354954549555495654957549585495954960549615496254963549645496554966549675496854969549705497154972549735497454975549765497754978549795498054981549825498354984549855498654987549885498954990549915499254993549945499554996549975499854999550005500155002550035500455005550065500755008550095501055011550125501355014550155501655017550185501955020550215502255023550245502555026550275502855029550305503155032550335503455035550365503755038550395504055041550425504355044550455504655047550485504955050550515505255053550545505555056550575505855059550605506155062550635506455065550665506755068550695507055071550725507355074550755507655077550785507955080550815508255083550845508555086550875508855089550905509155092550935509455095550965509755098550995510055101551025510355104551055510655107551085510955110551115511255113551145511555116551175511855119551205512155122551235512455125551265512755128551295513055131551325513355134551355513655137551385513955140551415514255143551445514555146551475514855149551505515155152551535515455155551565515755158551595516055161551625516355164551655516655167551685516955170551715517255173551745517555176551775517855179551805518155182551835518455185551865518755188551895519055191551925519355194551955519655197551985519955200552015520255203552045520555206552075520855209552105521155212552135521455215552165521755218552195522055221552225522355224552255522655227552285522955230552315523255233552345523555236552375523855239552405524155242552435524455245552465524755248552495525055251552525525355254552555525655257552585525955260552615526255263552645526555266552675526855269552705527155272552735527455275552765527755278552795528055281552825528355284552855528655287552885528955290552915529255293552945529555296552975529855299553005530155302553035530455305553065530755308553095531055311553125531355314553155531655317553185531955320553215532255323553245532555326553275532855329553305533155332553335533455335553365533755338553395534055341553425534355344553455534655347553485534955350553515535255353553545535555356553575535855359553605536155362553635536455365553665536755368553695537055371553725537355374553755537655377553785537955380553815538255383553845538555386553875538855389553905539155392553935539455395553965539755398553995540055401554025540355404554055540655407554085540955410554115541255413554145541555416554175541855419554205542155422554235542455425554265542755428554295543055431554325543355434554355543655437554385543955440554415544255443554445544555446554475544855449554505545155452554535545455455554565545755458554595546055461554625546355464554655546655467554685546955470554715547255473554745547555476554775547855479554805548155482554835548455485554865548755488554895549055491554925549355494554955549655497554985549955500555015550255503555045550555506555075550855509555105551155512555135551455515555165551755518555195552055521555225552355524555255552655527555285552955530555315553255533555345553555536555375553855539555405554155542555435554455545555465554755548555495555055551555525555355554555555555655557555585555955560555615556255563555645556555566555675556855569555705557155572555735557455575555765557755578555795558055581555825558355584555855558655587555885558955590555915559255593555945559555596555975559855599556005560155602556035560455605556065560755608556095561055611556125561355614556155561655617556185561955620556215562255623556245562555626556275562855629556305563155632556335563455635556365563755638556395564055641556425564355644556455564655647556485564955650556515565255653556545565555656556575565855659556605566155662556635566455665556665566755668556695567055671556725567355674556755567655677556785567955680556815568255683556845568555686556875568855689556905569155692556935569455695556965569755698556995570055701557025570355704557055570655707557085570955710557115571255713557145571555716557175571855719557205572155722557235572455725557265572755728557295573055731557325573355734557355573655737557385573955740557415574255743557445574555746557475574855749557505575155752557535575455755557565575755758557595576055761557625576355764557655576655767557685576955770557715577255773557745577555776557775577855779557805578155782557835578455785557865578755788557895579055791557925579355794557955579655797557985579955800558015580255803558045580555806558075580855809558105581155812558135581455815558165581755818558195582055821558225582355824558255582655827558285582955830558315583255833558345583555836558375583855839558405584155842558435584455845558465584755848558495585055851558525585355854558555585655857558585585955860558615586255863558645586555866558675586855869558705587155872558735587455875558765587755878558795588055881558825588355884558855588655887558885588955890558915589255893558945589555896558975589855899559005590155902559035590455905559065590755908559095591055911559125591355914559155591655917559185591955920559215592255923559245592555926559275592855929559305593155932559335593455935559365593755938559395594055941559425594355944559455594655947559485594955950559515595255953559545595555956559575595855959559605596155962559635596455965559665596755968559695597055971559725597355974559755597655977559785597955980559815598255983559845598555986559875598855989559905599155992559935599455995559965599755998559995600056001560025600356004560055600656007560085600956010560115601256013560145601556016560175601856019560205602156022560235602456025560265602756028560295603056031560325603356034560355603656037560385603956040560415604256043560445604556046560475604856049560505605156052560535605456055560565605756058560595606056061560625606356064560655606656067560685606956070560715607256073560745607556076560775607856079560805608156082560835608456085560865608756088560895609056091560925609356094560955609656097560985609956100561015610256103561045610556106561075610856109561105611156112561135611456115561165611756118561195612056121561225612356124561255612656127561285612956130561315613256133561345613556136561375613856139561405614156142561435614456145561465614756148561495615056151561525615356154561555615656157561585615956160561615616256163561645616556166561675616856169561705617156172561735617456175561765617756178561795618056181561825618356184561855618656187561885618956190561915619256193561945619556196561975619856199562005620156202562035620456205562065620756208562095621056211562125621356214562155621656217562185621956220562215622256223562245622556226562275622856229562305623156232562335623456235562365623756238562395624056241562425624356244562455624656247562485624956250562515625256253562545625556256562575625856259562605626156262562635626456265562665626756268562695627056271562725627356274562755627656277562785627956280562815628256283562845628556286562875628856289562905629156292562935629456295562965629756298562995630056301563025630356304563055630656307563085630956310563115631256313563145631556316563175631856319563205632156322563235632456325563265632756328563295633056331563325633356334563355633656337563385633956340563415634256343563445634556346563475634856349563505635156352563535635456355563565635756358563595636056361563625636356364563655636656367563685636956370563715637256373563745637556376563775637856379563805638156382563835638456385563865638756388563895639056391563925639356394563955639656397563985639956400564015640256403564045640556406564075640856409564105641156412564135641456415564165641756418564195642056421564225642356424564255642656427564285642956430564315643256433564345643556436564375643856439564405644156442564435644456445564465644756448564495645056451564525645356454564555645656457564585645956460564615646256463564645646556466564675646856469564705647156472564735647456475564765647756478564795648056481564825648356484564855648656487564885648956490564915649256493564945649556496564975649856499565005650156502565035650456505565065650756508565095651056511565125651356514565155651656517565185651956520565215652256523565245652556526565275652856529565305653156532565335653456535565365653756538565395654056541565425654356544565455654656547565485654956550565515655256553565545655556556565575655856559565605656156562565635656456565565665656756568565695657056571565725657356574565755657656577565785657956580565815658256583565845658556586565875658856589565905659156592565935659456595565965659756598565995660056601566025660356604566055660656607566085660956610566115661256613566145661556616566175661856619566205662156622566235662456625566265662756628566295663056631566325663356634566355663656637566385663956640566415664256643566445664556646566475664856649566505665156652566535665456655566565665756658566595666056661566625666356664566655666656667566685666956670566715667256673566745667556676566775667856679566805668156682566835668456685566865668756688566895669056691566925669356694566955669656697566985669956700567015670256703567045670556706567075670856709567105671156712567135671456715567165671756718567195672056721567225672356724567255672656727567285672956730567315673256733567345673556736567375673856739567405674156742567435674456745567465674756748567495675056751567525675356754567555675656757567585675956760567615676256763567645676556766567675676856769567705677156772567735677456775567765677756778567795678056781567825678356784567855678656787567885678956790567915679256793567945679556796567975679856799568005680156802568035680456805568065680756808568095681056811568125681356814568155681656817568185681956820568215682256823568245682556826568275682856829568305683156832568335683456835568365683756838568395684056841568425684356844568455684656847568485684956850568515685256853568545685556856568575685856859568605686156862568635686456865568665686756868568695687056871568725687356874568755687656877568785687956880568815688256883568845688556886568875688856889568905689156892568935689456895568965689756898568995690056901569025690356904569055690656907569085690956910569115691256913569145691556916569175691856919569205692156922569235692456925569265692756928569295693056931569325693356934569355693656937569385693956940569415694256943569445694556946569475694856949569505695156952569535695456955569565695756958569595696056961569625696356964569655696656967569685696956970569715697256973569745697556976569775697856979569805698156982569835698456985569865698756988569895699056991569925699356994569955699656997569985699957000570015700257003570045700557006570075700857009570105701157012570135701457015570165701757018570195702057021570225702357024570255702657027570285702957030570315703257033570345703557036570375703857039570405704157042570435704457045570465704757048570495705057051570525705357054570555705657057570585705957060570615706257063570645706557066570675706857069570705707157072570735707457075570765707757078570795708057081570825708357084570855708657087570885708957090570915709257093570945709557096570975709857099571005710157102571035710457105571065710757108571095711057111571125711357114571155711657117571185711957120571215712257123571245712557126571275712857129571305713157132571335713457135571365713757138571395714057141571425714357144571455714657147571485714957150571515715257153571545715557156571575715857159571605716157162571635716457165571665716757168571695717057171571725717357174571755717657177571785717957180571815718257183571845718557186571875718857189571905719157192571935719457195571965719757198571995720057201572025720357204572055720657207572085720957210572115721257213572145721557216572175721857219572205722157222572235722457225572265722757228572295723057231572325723357234572355723657237572385723957240572415724257243572445724557246572475724857249572505725157252572535725457255572565725757258572595726057261572625726357264572655726657267572685726957270572715727257273572745727557276572775727857279572805728157282572835728457285572865728757288572895729057291572925729357294572955729657297572985729957300573015730257303573045730557306573075730857309573105731157312573135731457315573165731757318573195732057321573225732357324573255732657327573285732957330573315733257333573345733557336573375733857339573405734157342573435734457345573465734757348573495735057351573525735357354573555735657357573585735957360573615736257363573645736557366573675736857369573705737157372573735737457375573765737757378573795738057381573825738357384573855738657387573885738957390573915739257393573945739557396573975739857399574005740157402574035740457405574065740757408574095741057411574125741357414574155741657417574185741957420574215742257423574245742557426574275742857429574305743157432574335743457435574365743757438574395744057441574425744357444574455744657447574485744957450574515745257453574545745557456574575745857459574605746157462574635746457465574665746757468574695747057471574725747357474574755747657477574785747957480574815748257483574845748557486574875748857489574905749157492574935749457495574965749757498574995750057501575025750357504575055750657507575085750957510575115751257513575145751557516575175751857519575205752157522575235752457525575265752757528575295753057531575325753357534575355753657537575385753957540575415754257543575445754557546575475754857549575505755157552575535755457555575565755757558575595756057561575625756357564575655756657567575685756957570575715757257573575745757557576575775757857579575805758157582575835758457585575865758757588575895759057591575925759357594575955759657597575985759957600576015760257603576045760557606576075760857609576105761157612576135761457615576165761757618576195762057621576225762357624576255762657627576285762957630576315763257633576345763557636576375763857639576405764157642576435764457645576465764757648576495765057651576525765357654576555765657657576585765957660576615766257663576645766557666576675766857669576705767157672576735767457675576765767757678576795768057681576825768357684576855768657687576885768957690576915769257693576945769557696576975769857699577005770157702577035770457705577065770757708577095771057711577125771357714577155771657717577185771957720577215772257723577245772557726577275772857729577305773157732577335773457735577365773757738577395774057741577425774357744577455774657747577485774957750577515775257753577545775557756577575775857759577605776157762577635776457765577665776757768577695777057771577725777357774577755777657777577785777957780577815778257783577845778557786577875778857789577905779157792577935779457795577965779757798577995780057801578025780357804578055780657807578085780957810578115781257813578145781557816578175781857819578205782157822578235782457825578265782757828578295783057831578325783357834578355783657837578385783957840578415784257843578445784557846578475784857849578505785157852578535785457855578565785757858578595786057861578625786357864578655786657867578685786957870578715787257873578745787557876578775787857879578805788157882578835788457885578865788757888578895789057891578925789357894578955789657897578985789957900579015790257903579045790557906579075790857909579105791157912579135791457915579165791757918579195792057921579225792357924579255792657927579285792957930579315793257933579345793557936579375793857939579405794157942579435794457945579465794757948579495795057951579525795357954579555795657957579585795957960579615796257963579645796557966579675796857969579705797157972579735797457975579765797757978579795798057981579825798357984579855798657987579885798957990579915799257993579945799557996579975799857999580005800158002580035800458005580065800758008580095801058011580125801358014580155801658017580185801958020580215802258023580245802558026580275802858029580305803158032580335803458035580365803758038580395804058041580425804358044580455804658047580485804958050580515805258053580545805558056580575805858059580605806158062580635806458065580665806758068580695807058071580725807358074580755807658077580785807958080580815808258083580845808558086580875808858089580905809158092580935809458095580965809758098580995810058101581025810358104581055810658107581085810958110581115811258113581145811558116581175811858119581205812158122581235812458125581265812758128581295813058131581325813358134581355813658137581385813958140581415814258143581445814558146581475814858149581505815158152581535815458155581565815758158581595816058161581625816358164581655816658167581685816958170581715817258173581745817558176581775817858179581805818158182581835818458185581865818758188581895819058191581925819358194581955819658197581985819958200582015820258203582045820558206582075820858209582105821158212582135821458215582165821758218582195822058221582225822358224582255822658227582285822958230582315823258233582345823558236582375823858239582405824158242582435824458245582465824758248582495825058251582525825358254582555825658257582585825958260582615826258263582645826558266582675826858269582705827158272582735827458275582765827758278582795828058281582825828358284582855828658287582885828958290582915829258293582945829558296582975829858299583005830158302583035830458305583065830758308583095831058311583125831358314583155831658317583185831958320583215832258323583245832558326583275832858329583305833158332583335833458335583365833758338583395834058341583425834358344583455834658347583485834958350583515835258353583545835558356583575835858359583605836158362583635836458365583665836758368583695837058371583725837358374583755837658377583785837958380583815838258383583845838558386583875838858389583905839158392583935839458395583965839758398583995840058401584025840358404584055840658407584085840958410584115841258413584145841558416584175841858419584205842158422584235842458425584265842758428584295843058431584325843358434584355843658437584385843958440584415844258443584445844558446584475844858449584505845158452584535845458455584565845758458584595846058461584625846358464584655846658467584685846958470584715847258473584745847558476584775847858479584805848158482584835848458485584865848758488584895849058491584925849358494584955849658497584985849958500585015850258503585045850558506585075850858509585105851158512585135851458515585165851758518585195852058521585225852358524585255852658527585285852958530585315853258533585345853558536585375853858539585405854158542585435854458545585465854758548585495855058551585525855358554585555855658557585585855958560585615856258563585645856558566585675856858569585705857158572585735857458575585765857758578585795858058581585825858358584585855858658587585885858958590585915859258593585945859558596585975859858599586005860158602586035860458605586065860758608586095861058611586125861358614586155861658617586185861958620586215862258623586245862558626586275862858629586305863158632586335863458635586365863758638586395864058641586425864358644586455864658647586485864958650586515865258653586545865558656586575865858659586605866158662586635866458665586665866758668586695867058671586725867358674586755867658677586785867958680586815868258683586845868558686586875868858689586905869158692586935869458695586965869758698586995870058701587025870358704587055870658707587085870958710587115871258713587145871558716587175871858719587205872158722587235872458725587265872758728587295873058731587325873358734587355873658737587385873958740587415874258743587445874558746587475874858749587505875158752587535875458755587565875758758587595876058761587625876358764587655876658767587685876958770587715877258773587745877558776587775877858779587805878158782587835878458785587865878758788587895879058791587925879358794587955879658797587985879958800588015880258803588045880558806588075880858809588105881158812588135881458815588165881758818588195882058821588225882358824588255882658827588285882958830588315883258833588345883558836588375883858839588405884158842588435884458845588465884758848588495885058851588525885358854588555885658857588585885958860588615886258863588645886558866588675886858869588705887158872588735887458875588765887758878588795888058881588825888358884588855888658887588885888958890588915889258893588945889558896588975889858899589005890158902589035890458905589065890758908589095891058911589125891358914589155891658917589185891958920589215892258923589245892558926589275892858929589305893158932589335893458935589365893758938589395894058941589425894358944589455894658947589485894958950589515895258953589545895558956589575895858959589605896158962589635896458965589665896758968589695897058971589725897358974589755897658977589785897958980589815898258983589845898558986589875898858989589905899158992589935899458995589965899758998589995900059001590025900359004590055900659007590085900959010590115901259013590145901559016590175901859019590205902159022590235902459025590265902759028590295903059031590325903359034590355903659037590385903959040590415904259043590445904559046590475904859049590505905159052590535905459055590565905759058590595906059061590625906359064590655906659067590685906959070590715907259073590745907559076590775907859079590805908159082590835908459085590865908759088590895909059091590925909359094590955909659097590985909959100591015910259103591045910559106591075910859109591105911159112591135911459115591165911759118591195912059121591225912359124591255912659127591285912959130591315913259133591345913559136591375913859139591405914159142591435914459145591465914759148591495915059151591525915359154591555915659157591585915959160591615916259163591645916559166591675916859169591705917159172591735917459175591765917759178591795918059181591825918359184591855918659187591885918959190591915919259193591945919559196591975919859199592005920159202592035920459205592065920759208592095921059211592125921359214592155921659217592185921959220592215922259223592245922559226592275922859229592305923159232592335923459235592365923759238592395924059241592425924359244592455924659247592485924959250592515925259253592545925559256592575925859259592605926159262592635926459265592665926759268592695927059271592725927359274592755927659277592785927959280592815928259283592845928559286592875928859289592905929159292592935929459295592965929759298592995930059301593025930359304593055930659307593085930959310593115931259313593145931559316593175931859319593205932159322593235932459325593265932759328593295933059331593325933359334593355933659337593385933959340593415934259343593445934559346593475934859349593505935159352593535935459355593565935759358593595936059361593625936359364593655936659367593685936959370593715937259373593745937559376593775937859379593805938159382593835938459385593865938759388593895939059391593925939359394593955939659397593985939959400594015940259403594045940559406594075940859409594105941159412594135941459415594165941759418594195942059421594225942359424594255942659427594285942959430594315943259433594345943559436594375943859439594405944159442594435944459445594465944759448594495945059451594525945359454594555945659457594585945959460594615946259463594645946559466594675946859469594705947159472594735947459475594765947759478594795948059481594825948359484594855948659487594885948959490594915949259493594945949559496594975949859499595005950159502595035950459505595065950759508595095951059511595125951359514595155951659517595185951959520595215952259523595245952559526595275952859529595305953159532595335953459535595365953759538595395954059541595425954359544595455954659547595485954959550595515955259553595545955559556595575955859559595605956159562595635956459565595665956759568595695957059571595725957359574595755957659577595785957959580595815958259583595845958559586595875958859589595905959159592595935959459595595965959759598595995960059601596025960359604596055960659607596085960959610596115961259613596145961559616596175961859619596205962159622596235962459625596265962759628596295963059631596325963359634596355963659637596385963959640596415964259643596445964559646596475964859649596505965159652596535965459655596565965759658596595966059661596625966359664596655966659667596685966959670596715967259673596745967559676596775967859679596805968159682596835968459685596865968759688596895969059691596925969359694596955969659697596985969959700597015970259703597045970559706597075970859709597105971159712597135971459715597165971759718597195972059721597225972359724597255972659727597285972959730597315973259733597345973559736597375973859739597405974159742597435974459745597465974759748597495975059751597525975359754597555975659757597585975959760597615976259763597645976559766597675976859769597705977159772597735977459775597765977759778597795978059781597825978359784597855978659787597885978959790597915979259793597945979559796597975979859799598005980159802598035980459805598065980759808598095981059811598125981359814598155981659817598185981959820598215982259823598245982559826598275982859829598305983159832598335983459835598365983759838598395984059841598425984359844598455984659847598485984959850598515985259853598545985559856598575985859859598605986159862598635986459865598665986759868598695987059871598725987359874598755987659877598785987959880598815988259883598845988559886598875988859889598905989159892598935989459895598965989759898598995990059901599025990359904599055990659907599085990959910599115991259913599145991559916599175991859919599205992159922599235992459925599265992759928599295993059931599325993359934599355993659937599385993959940599415994259943599445994559946599475994859949599505995159952599535995459955599565995759958599595996059961599625996359964599655996659967599685996959970599715997259973599745997559976599775997859979599805998159982599835998459985599865998759988599895999059991599925999359994599955999659997599985999960000600016000260003600046000560006600076000860009600106001160012600136001460015600166001760018600196002060021600226002360024600256002660027600286002960030600316003260033600346003560036600376003860039600406004160042600436004460045600466004760048600496005060051600526005360054600556005660057600586005960060600616006260063600646006560066600676006860069600706007160072600736007460075600766007760078600796008060081600826008360084600856008660087600886008960090600916009260093600946009560096600976009860099601006010160102601036010460105601066010760108601096011060111601126011360114601156011660117601186011960120601216012260123601246012560126601276012860129601306013160132601336013460135601366013760138601396014060141601426014360144601456014660147601486014960150601516015260153601546015560156601576015860159601606016160162601636016460165601666016760168601696017060171601726017360174601756017660177601786017960180601816018260183601846018560186601876018860189601906019160192601936019460195601966019760198601996020060201602026020360204602056020660207602086020960210602116021260213602146021560216602176021860219602206022160222602236022460225602266022760228602296023060231602326023360234602356023660237602386023960240602416024260243602446024560246602476024860249602506025160252602536025460255602566025760258602596026060261602626026360264602656026660267602686026960270602716027260273602746027560276602776027860279602806028160282602836028460285602866028760288602896029060291602926029360294602956029660297602986029960300603016030260303603046030560306603076030860309603106031160312603136031460315603166031760318603196032060321603226032360324603256032660327603286032960330603316033260333603346033560336603376033860339603406034160342603436034460345603466034760348603496035060351603526035360354603556035660357603586035960360603616036260363603646036560366603676036860369603706037160372603736037460375603766037760378603796038060381603826038360384603856038660387603886038960390603916039260393603946039560396603976039860399604006040160402604036040460405604066040760408604096041060411604126041360414604156041660417604186041960420604216042260423604246042560426604276042860429604306043160432604336043460435604366043760438604396044060441604426044360444604456044660447604486044960450604516045260453604546045560456604576045860459604606046160462604636046460465604666046760468604696047060471604726047360474604756047660477604786047960480604816048260483604846048560486604876048860489604906049160492604936049460495604966049760498604996050060501605026050360504605056050660507605086050960510605116051260513605146051560516605176051860519605206052160522605236052460525605266052760528605296053060531605326053360534605356053660537605386053960540605416054260543605446054560546605476054860549605506055160552605536055460555605566055760558605596056060561605626056360564605656056660567605686056960570605716057260573605746057560576605776057860579605806058160582605836058460585605866058760588605896059060591605926059360594605956059660597605986059960600606016060260603606046060560606606076060860609606106061160612606136061460615606166061760618606196062060621606226062360624606256062660627606286062960630606316063260633606346063560636606376063860639606406064160642606436064460645606466064760648606496065060651606526065360654606556065660657606586065960660606616066260663606646066560666606676066860669606706067160672606736067460675606766067760678606796068060681606826068360684606856068660687606886068960690606916069260693606946069560696606976069860699607006070160702607036070460705607066070760708607096071060711607126071360714607156071660717607186071960720607216072260723607246072560726607276072860729607306073160732607336073460735607366073760738607396074060741607426074360744607456074660747607486074960750607516075260753607546075560756607576075860759607606076160762607636076460765607666076760768607696077060771607726077360774607756077660777607786077960780607816078260783607846078560786607876078860789607906079160792607936079460795607966079760798607996080060801608026080360804608056080660807608086080960810608116081260813608146081560816608176081860819608206082160822608236082460825608266082760828608296083060831608326083360834608356083660837608386083960840608416084260843608446084560846608476084860849608506085160852608536085460855608566085760858608596086060861608626086360864608656086660867608686086960870608716087260873608746087560876608776087860879608806088160882608836088460885608866088760888608896089060891608926089360894608956089660897608986089960900609016090260903609046090560906609076090860909609106091160912609136091460915609166091760918609196092060921609226092360924609256092660927609286092960930609316093260933609346093560936609376093860939609406094160942609436094460945609466094760948609496095060951609526095360954609556095660957609586095960960609616096260963609646096560966609676096860969609706097160972609736097460975609766097760978609796098060981609826098360984609856098660987609886098960990609916099260993609946099560996609976099860999610006100161002610036100461005610066100761008610096101061011610126101361014610156101661017610186101961020610216102261023610246102561026610276102861029610306103161032610336103461035610366103761038610396104061041610426104361044610456104661047610486104961050610516105261053610546105561056610576105861059610606106161062610636106461065610666106761068610696107061071610726107361074610756107661077610786107961080610816108261083610846108561086610876108861089610906109161092610936109461095610966109761098610996110061101611026110361104611056110661107611086110961110611116111261113611146111561116611176111861119611206112161122611236112461125611266112761128611296113061131611326113361134611356113661137611386113961140611416114261143611446114561146611476114861149611506115161152611536115461155611566115761158611596116061161611626116361164611656116661167611686116961170611716117261173611746117561176611776117861179611806118161182611836118461185611866118761188611896119061191611926119361194611956119661197611986119961200612016120261203612046120561206612076120861209612106121161212612136121461215612166121761218612196122061221612226122361224612256122661227612286122961230612316123261233612346123561236612376123861239612406124161242612436124461245612466124761248612496125061251612526125361254612556125661257612586125961260612616126261263612646126561266612676126861269612706127161272612736127461275612766127761278612796128061281612826128361284612856128661287612886128961290612916129261293612946129561296612976129861299613006130161302613036130461305613066130761308613096131061311613126131361314613156131661317613186131961320613216132261323613246132561326613276132861329613306133161332613336133461335613366133761338613396134061341613426134361344613456134661347613486134961350613516135261353613546135561356613576135861359613606136161362613636136461365613666136761368613696137061371613726137361374613756137661377613786137961380613816138261383613846138561386613876138861389613906139161392613936139461395613966139761398613996140061401614026140361404614056140661407614086140961410614116141261413614146141561416614176141861419614206142161422614236142461425614266142761428614296143061431614326143361434614356143661437614386143961440614416144261443614446144561446614476144861449614506145161452614536145461455614566145761458614596146061461614626146361464614656146661467614686146961470614716147261473614746147561476614776147861479614806148161482614836148461485614866148761488614896149061491614926149361494614956149661497614986149961500615016150261503615046150561506615076150861509615106151161512615136151461515615166151761518615196152061521615226152361524615256152661527615286152961530615316153261533615346153561536615376153861539615406154161542615436154461545615466154761548615496155061551615526155361554615556155661557615586155961560615616156261563615646156561566615676156861569615706157161572615736157461575615766157761578615796158061581615826158361584615856158661587615886158961590615916159261593615946159561596615976159861599616006160161602616036160461605616066160761608616096161061611616126161361614616156161661617616186161961620616216162261623616246162561626616276162861629616306163161632616336163461635616366163761638616396164061641616426164361644616456164661647616486164961650616516165261653616546165561656616576165861659616606166161662616636166461665616666166761668616696167061671616726167361674616756167661677616786167961680616816168261683616846168561686616876168861689616906169161692616936169461695616966169761698616996170061701617026170361704617056170661707617086170961710617116171261713617146171561716617176171861719617206172161722617236172461725617266172761728617296173061731617326173361734617356173661737617386173961740617416174261743617446174561746617476174861749617506175161752617536175461755617566175761758617596176061761617626176361764617656176661767617686176961770617716177261773617746177561776617776177861779617806178161782617836178461785617866178761788617896179061791617926179361794617956179661797617986179961800618016180261803618046180561806618076180861809618106181161812618136181461815618166181761818618196182061821618226182361824618256182661827618286182961830618316183261833618346183561836618376183861839618406184161842618436184461845618466184761848618496185061851618526185361854618556185661857618586185961860618616186261863618646186561866618676186861869618706187161872618736187461875618766187761878618796188061881618826188361884618856188661887618886188961890618916189261893618946189561896618976189861899619006190161902619036190461905619066190761908619096191061911619126191361914619156191661917619186191961920619216192261923619246192561926619276192861929619306193161932619336193461935619366193761938619396194061941619426194361944619456194661947619486194961950619516195261953619546195561956619576195861959619606196161962619636196461965619666196761968619696197061971619726197361974619756197661977619786197961980619816198261983619846198561986619876198861989619906199161992619936199461995619966199761998619996200062001620026200362004620056200662007620086200962010620116201262013620146201562016620176201862019620206202162022620236202462025620266202762028620296203062031620326203362034620356203662037620386203962040620416204262043620446204562046620476204862049620506205162052620536205462055620566205762058620596206062061620626206362064620656206662067620686206962070620716207262073620746207562076620776207862079620806208162082620836208462085620866208762088620896209062091620926209362094620956209662097620986209962100621016210262103621046210562106621076210862109621106211162112621136211462115621166211762118621196212062121621226212362124621256212662127621286212962130621316213262133621346213562136621376213862139621406214162142621436214462145621466214762148621496215062151621526215362154621556215662157621586215962160621616216262163621646216562166621676216862169621706217162172621736217462175621766217762178621796218062181621826218362184621856218662187621886218962190621916219262193621946219562196621976219862199622006220162202622036220462205622066220762208622096221062211622126221362214622156221662217622186221962220622216222262223622246222562226622276222862229622306223162232622336223462235622366223762238622396224062241622426224362244622456224662247622486224962250622516225262253622546225562256622576225862259622606226162262622636226462265622666226762268622696227062271622726227362274622756227662277622786227962280622816228262283622846228562286622876228862289622906229162292622936229462295622966229762298622996230062301623026230362304623056230662307623086230962310623116231262313623146231562316623176231862319623206232162322623236232462325623266232762328623296233062331623326233362334623356233662337623386233962340623416234262343623446234562346623476234862349623506235162352623536235462355623566235762358623596236062361623626236362364623656236662367623686236962370623716237262373623746237562376623776237862379623806238162382623836238462385623866238762388623896239062391623926239362394623956239662397623986239962400624016240262403624046240562406624076240862409624106241162412624136241462415624166241762418624196242062421624226242362424624256242662427624286242962430624316243262433624346243562436624376243862439624406244162442624436244462445624466244762448624496245062451624526245362454624556245662457624586245962460624616246262463624646246562466624676246862469624706247162472624736247462475624766247762478624796248062481624826248362484624856248662487624886248962490624916249262493624946249562496624976249862499625006250162502625036250462505625066250762508625096251062511625126251362514625156251662517625186251962520625216252262523625246252562526625276252862529625306253162532625336253462535625366253762538625396254062541625426254362544625456254662547625486254962550625516255262553625546255562556625576255862559625606256162562625636256462565625666256762568625696257062571625726257362574625756257662577625786257962580625816258262583625846258562586625876258862589625906259162592625936259462595625966259762598625996260062601626026260362604626056260662607626086260962610626116261262613626146261562616626176261862619626206262162622626236262462625626266262762628626296263062631626326263362634626356263662637626386263962640626416264262643626446264562646626476264862649626506265162652626536265462655626566265762658626596266062661626626266362664626656266662667626686266962670626716267262673626746267562676626776267862679626806268162682626836268462685626866268762688626896269062691626926269362694626956269662697626986269962700627016270262703627046270562706627076270862709627106271162712627136271462715627166271762718627196272062721627226272362724627256272662727627286272962730627316273262733627346273562736627376273862739627406274162742627436274462745627466274762748627496275062751627526275362754627556275662757627586275962760627616276262763627646276562766627676276862769627706277162772627736277462775627766277762778627796278062781627826278362784627856278662787627886278962790627916279262793627946279562796627976279862799628006280162802628036280462805628066280762808628096281062811628126281362814628156281662817628186281962820628216282262823628246282562826628276282862829628306283162832628336283462835628366283762838628396284062841628426284362844628456284662847628486284962850628516285262853628546285562856628576285862859628606286162862628636286462865628666286762868628696287062871628726287362874628756287662877628786287962880628816288262883628846288562886628876288862889628906289162892628936289462895628966289762898628996290062901629026290362904629056290662907629086290962910629116291262913629146291562916629176291862919629206292162922629236292462925629266292762928629296293062931629326293362934629356293662937629386293962940629416294262943629446294562946629476294862949629506295162952629536295462955629566295762958629596296062961629626296362964629656296662967629686296962970629716297262973629746297562976629776297862979629806298162982629836298462985629866298762988629896299062991629926299362994629956299662997629986299963000630016300263003630046300563006630076300863009630106301163012630136301463015630166301763018630196302063021630226302363024630256302663027630286302963030630316303263033630346303563036630376303863039630406304163042630436304463045630466304763048630496305063051630526305363054630556305663057630586305963060630616306263063630646306563066630676306863069630706307163072630736307463075630766307763078630796308063081630826308363084630856308663087630886308963090630916309263093630946309563096630976309863099631006310163102631036310463105631066310763108631096311063111631126311363114631156311663117631186311963120631216312263123631246312563126631276312863129631306313163132631336313463135631366313763138631396314063141631426314363144631456314663147631486314963150631516315263153631546315563156631576315863159631606316163162631636316463165631666316763168631696317063171631726317363174631756317663177631786317963180631816318263183631846318563186631876318863189631906319163192631936319463195631966319763198631996320063201632026320363204632056320663207632086320963210632116321263213632146321563216632176321863219632206322163222632236322463225632266322763228632296323063231632326323363234632356323663237632386323963240632416324263243632446324563246632476324863249632506325163252632536325463255632566325763258632596326063261632626326363264632656326663267632686326963270632716327263273632746327563276632776327863279632806328163282632836328463285632866328763288632896329063291632926329363294632956329663297632986329963300633016330263303633046330563306633076330863309633106331163312633136331463315633166331763318633196332063321633226332363324633256332663327633286332963330633316333263333633346333563336633376333863339633406334163342633436334463345633466334763348633496335063351633526335363354633556335663357633586335963360633616336263363633646336563366633676336863369633706337163372633736337463375633766337763378633796338063381633826338363384633856338663387633886338963390633916339263393633946339563396633976339863399634006340163402634036340463405634066340763408634096341063411634126341363414634156341663417634186341963420634216342263423634246342563426634276342863429634306343163432634336343463435634366343763438634396344063441634426344363444634456344663447634486344963450634516345263453634546345563456634576345863459634606346163462634636346463465634666346763468634696347063471634726347363474634756347663477634786347963480634816348263483634846348563486634876348863489634906349163492634936349463495634966349763498634996350063501635026350363504635056350663507635086350963510635116351263513635146351563516635176351863519635206352163522635236352463525635266352763528635296353063531635326353363534635356353663537635386353963540635416354263543635446354563546635476354863549635506355163552635536355463555635566355763558635596356063561635626356363564635656356663567635686356963570635716357263573635746357563576635776357863579635806358163582635836358463585635866358763588635896359063591635926359363594635956359663597635986359963600636016360263603636046360563606636076360863609636106361163612636136361463615636166361763618636196362063621636226362363624636256362663627636286362963630636316363263633636346363563636636376363863639636406364163642636436364463645636466364763648636496365063651636526365363654636556365663657636586365963660636616366263663636646366563666636676366863669636706367163672636736367463675636766367763678636796368063681636826368363684636856368663687636886368963690636916369263693636946369563696636976369863699637006370163702637036370463705637066370763708637096371063711637126371363714637156371663717637186371963720637216372263723637246372563726637276372863729637306373163732637336373463735637366373763738637396374063741637426374363744637456374663747637486374963750637516375263753637546375563756637576375863759637606376163762637636376463765637666376763768637696377063771637726377363774637756377663777637786377963780637816378263783637846378563786637876378863789637906379163792637936379463795637966379763798637996380063801638026380363804638056380663807638086380963810638116381263813638146381563816638176381863819638206382163822638236382463825638266382763828638296383063831638326383363834638356383663837638386383963840638416384263843638446384563846638476384863849638506385163852638536385463855638566385763858638596386063861638626386363864638656386663867638686386963870638716387263873638746387563876638776387863879638806388163882638836388463885638866388763888638896389063891638926389363894638956389663897638986389963900639016390263903639046390563906639076390863909639106391163912639136391463915639166391763918639196392063921639226392363924639256392663927639286392963930639316393263933639346393563936639376393863939639406394163942639436394463945639466394763948639496395063951639526395363954639556395663957639586395963960639616396263963639646396563966639676396863969639706397163972639736397463975639766397763978639796398063981639826398363984639856398663987639886398963990639916399263993639946399563996639976399863999640006400164002640036400464005640066400764008640096401064011640126401364014640156401664017640186401964020640216402264023640246402564026640276402864029640306403164032640336403464035640366403764038640396404064041640426404364044640456404664047640486404964050640516405264053640546405564056640576405864059640606406164062640636406464065640666406764068640696407064071640726407364074640756407664077640786407964080640816408264083640846408564086640876408864089640906409164092640936409464095640966409764098640996410064101641026410364104641056410664107641086410964110641116411264113641146411564116641176411864119641206412164122641236412464125641266412764128641296413064131641326413364134641356413664137641386413964140641416414264143641446414564146641476414864149641506415164152641536415464155641566415764158641596416064161641626416364164641656416664167641686416964170641716417264173641746417564176641776417864179641806418164182641836418464185641866418764188641896419064191641926419364194641956419664197641986419964200642016420264203642046420564206642076420864209642106421164212642136421464215642166421764218642196422064221642226422364224642256422664227642286422964230642316423264233642346423564236642376423864239642406424164242642436424464245642466424764248642496425064251642526425364254642556425664257642586425964260642616426264263642646426564266642676426864269642706427164272642736427464275642766427764278642796428064281642826428364284642856428664287642886428964290642916429264293642946429564296642976429864299643006430164302643036430464305643066430764308643096431064311643126431364314643156431664317643186431964320643216432264323643246432564326643276432864329643306433164332643336433464335643366433764338643396434064341643426434364344643456434664347643486434964350643516435264353643546435564356643576435864359643606436164362643636436464365643666436764368643696437064371643726437364374643756437664377643786437964380643816438264383643846438564386643876438864389643906439164392643936439464395643966439764398643996440064401644026440364404644056440664407644086440964410644116441264413644146441564416644176441864419644206442164422644236442464425644266442764428644296443064431644326443364434644356443664437644386443964440644416444264443644446444564446644476444864449644506445164452644536445464455644566445764458644596446064461644626446364464644656446664467644686446964470644716447264473644746447564476644776447864479644806448164482644836448464485644866448764488644896449064491644926449364494644956449664497644986449964500645016450264503645046450564506645076450864509645106451164512645136451464515645166451764518645196452064521645226452364524645256452664527645286452964530645316453264533645346453564536645376453864539645406454164542645436454464545645466454764548645496455064551645526455364554645556455664557645586455964560645616456264563645646456564566645676456864569645706457164572645736457464575645766457764578645796458064581645826458364584645856458664587645886458964590645916459264593645946459564596645976459864599646006460164602646036460464605646066460764608646096461064611646126461364614646156461664617646186461964620646216462264623646246462564626646276462864629646306463164632646336463464635646366463764638646396464064641646426464364644646456464664647646486464964650646516465264653646546465564656646576465864659646606466164662646636466464665646666466764668646696467064671646726467364674646756467664677646786467964680646816468264683646846468564686646876468864689646906469164692646936469464695646966469764698646996470064701647026470364704647056470664707647086470964710647116471264713647146471564716647176471864719647206472164722647236472464725647266472764728647296473064731647326473364734647356473664737647386473964740647416474264743647446474564746647476474864749647506475164752647536475464755647566475764758647596476064761647626476364764647656476664767647686476964770647716477264773647746477564776647776477864779647806478164782647836478464785647866478764788647896479064791647926479364794647956479664797647986479964800648016480264803648046480564806648076480864809648106481164812648136481464815648166481764818648196482064821648226482364824648256482664827648286482964830648316483264833648346483564836648376483864839648406484164842648436484464845648466484764848648496485064851648526485364854648556485664857648586485964860648616486264863648646486564866648676486864869648706487164872648736487464875648766487764878648796488064881648826488364884648856488664887648886488964890648916489264893648946489564896648976489864899649006490164902649036490464905649066490764908649096491064911649126491364914649156491664917649186491964920649216492264923649246492564926649276492864929649306493164932649336493464935649366493764938649396494064941649426494364944649456494664947649486494964950649516495264953649546495564956649576495864959649606496164962649636496464965649666496764968649696497064971649726497364974649756497664977649786497964980649816498264983649846498564986649876498864989649906499164992649936499464995649966499764998649996500065001650026500365004650056500665007650086500965010650116501265013650146501565016650176501865019650206502165022650236502465025650266502765028650296503065031650326503365034650356503665037650386503965040650416504265043650446504565046650476504865049650506505165052650536505465055650566505765058650596506065061650626506365064650656506665067650686506965070650716507265073650746507565076650776507865079650806508165082650836508465085650866508765088650896509065091650926509365094650956509665097650986509965100651016510265103651046510565106651076510865109651106511165112651136511465115651166511765118651196512065121651226512365124651256512665127651286512965130651316513265133651346513565136651376513865139651406514165142651436514465145651466514765148651496515065151651526515365154651556515665157651586515965160651616516265163651646516565166651676516865169651706517165172651736517465175651766517765178651796518065181651826518365184651856518665187651886518965190651916519265193651946519565196651976519865199652006520165202652036520465205652066520765208652096521065211652126521365214652156521665217652186521965220652216522265223652246522565226652276522865229652306523165232652336523465235652366523765238652396524065241652426524365244652456524665247652486524965250652516525265253652546525565256652576525865259652606526165262652636526465265652666526765268652696527065271652726527365274652756527665277652786527965280652816528265283652846528565286652876528865289652906529165292652936529465295652966529765298652996530065301653026530365304653056530665307653086530965310653116531265313653146531565316653176531865319653206532165322653236532465325653266532765328653296533065331653326533365334653356533665337653386533965340653416534265343653446534565346653476534865349653506535165352653536535465355653566535765358653596536065361653626536365364653656536665367653686536965370653716537265373653746537565376653776537865379653806538165382653836538465385653866538765388653896539065391653926539365394653956539665397653986539965400654016540265403654046540565406654076540865409654106541165412654136541465415654166541765418654196542065421654226542365424654256542665427654286542965430654316543265433654346543565436654376543865439654406544165442654436544465445654466544765448654496545065451654526545365454654556545665457654586545965460654616546265463654646546565466654676546865469654706547165472654736547465475654766547765478654796548065481654826548365484654856548665487654886548965490654916549265493654946549565496654976549865499655006550165502655036550465505655066550765508655096551065511655126551365514655156551665517655186551965520655216552265523655246552565526655276552865529655306553165532655336553465535655366553765538655396554065541655426554365544655456554665547655486554965550655516555265553655546555565556655576555865559655606556165562655636556465565655666556765568655696557065571655726557365574655756557665577655786557965580655816558265583655846558565586655876558865589655906559165592655936559465595655966559765598655996560065601656026560365604656056560665607656086560965610656116561265613656146561565616656176561865619656206562165622656236562465625656266562765628656296563065631656326563365634656356563665637656386563965640656416564265643656446564565646656476564865649656506565165652656536565465655656566565765658656596566065661656626566365664656656566665667656686566965670656716567265673656746567565676656776567865679656806568165682656836568465685656866568765688656896569065691656926569365694656956569665697656986569965700657016570265703657046570565706657076570865709657106571165712657136571465715657166571765718657196572065721657226572365724657256572665727657286572965730657316573265733657346573565736657376573865739657406574165742657436574465745657466574765748657496575065751657526575365754657556575665757657586575965760657616576265763657646576565766657676576865769657706577165772657736577465775657766577765778657796578065781657826578365784657856578665787657886578965790657916579265793657946579565796657976579865799658006580165802658036580465805658066580765808658096581065811658126581365814658156581665817658186581965820658216582265823658246582565826658276582865829658306583165832658336583465835658366583765838658396584065841658426584365844658456584665847658486584965850658516585265853658546585565856658576585865859658606586165862658636586465865658666586765868658696587065871658726587365874658756587665877658786587965880658816588265883658846588565886658876588865889658906589165892658936589465895658966589765898658996590065901659026590365904659056590665907659086590965910659116591265913659146591565916659176591865919659206592165922659236592465925659266592765928659296593065931659326593365934659356593665937659386593965940659416594265943659446594565946659476594865949659506595165952659536595465955659566595765958659596596065961659626596365964659656596665967659686596965970659716597265973659746597565976659776597865979659806598165982659836598465985659866598765988659896599065991659926599365994659956599665997659986599966000660016600266003660046600566006660076600866009660106601166012660136601466015660166601766018660196602066021660226602366024660256602666027660286602966030660316603266033660346603566036660376603866039660406604166042660436604466045660466604766048660496605066051660526605366054660556605666057660586605966060660616606266063660646606566066660676606866069660706607166072660736607466075660766607766078660796608066081660826608366084660856608666087660886608966090660916609266093660946609566096660976609866099661006610166102661036610466105661066610766108661096611066111661126611366114661156611666117661186611966120661216612266123661246612566126661276612866129661306613166132661336613466135661366613766138661396614066141661426614366144661456614666147661486614966150661516615266153661546615566156661576615866159661606616166162661636616466165661666616766168661696617066171661726617366174661756617666177661786617966180661816618266183661846618566186661876618866189661906619166192661936619466195661966619766198661996620066201662026620366204662056620666207662086620966210662116621266213662146621566216662176621866219662206622166222662236622466225662266622766228662296623066231662326623366234662356623666237662386623966240662416624266243662446624566246662476624866249662506625166252662536625466255662566625766258662596626066261662626626366264662656626666267662686626966270662716627266273662746627566276662776627866279662806628166282662836628466285662866628766288662896629066291662926629366294662956629666297662986629966300663016630266303663046630566306663076630866309663106631166312663136631466315663166631766318663196632066321663226632366324663256632666327663286632966330663316633266333663346633566336663376633866339663406634166342663436634466345663466634766348663496635066351663526635366354663556635666357663586635966360663616636266363663646636566366663676636866369663706637166372663736637466375663766637766378663796638066381663826638366384663856638666387663886638966390663916639266393663946639566396663976639866399664006640166402664036640466405664066640766408664096641066411664126641366414664156641666417664186641966420664216642266423664246642566426664276642866429664306643166432664336643466435664366643766438664396644066441664426644366444664456644666447664486644966450664516645266453664546645566456664576645866459664606646166462664636646466465664666646766468664696647066471664726647366474664756647666477664786647966480664816648266483664846648566486664876648866489664906649166492664936649466495664966649766498664996650066501665026650366504665056650666507665086650966510665116651266513665146651566516665176651866519665206652166522665236652466525665266652766528665296653066531665326653366534665356653666537665386653966540665416654266543665446654566546665476654866549665506655166552665536655466555665566655766558665596656066561665626656366564665656656666567665686656966570665716657266573665746657566576665776657866579665806658166582665836658466585665866658766588665896659066591665926659366594665956659666597665986659966600666016660266603666046660566606666076660866609666106661166612666136661466615666166661766618666196662066621666226662366624666256662666627666286662966630666316663266633666346663566636666376663866639666406664166642666436664466645666466664766648666496665066651666526665366654666556665666657666586665966660666616666266663666646666566666666676666866669666706667166672666736667466675666766667766678666796668066681666826668366684666856668666687666886668966690666916669266693666946669566696666976669866699667006670166702667036670466705667066670766708667096671066711667126671366714667156671666717667186671966720667216672266723667246672566726667276672866729667306673166732667336673466735667366673766738667396674066741667426674366744667456674666747667486674966750667516675266753667546675566756667576675866759667606676166762667636676466765667666676766768667696677066771667726677366774667756677666777667786677966780667816678266783667846678566786667876678866789667906679166792667936679466795667966679766798667996680066801668026680366804668056680666807668086680966810668116681266813668146681566816668176681866819668206682166822668236682466825668266682766828668296683066831668326683366834668356683666837668386683966840668416684266843668446684566846668476684866849668506685166852668536685466855668566685766858668596686066861668626686366864668656686666867668686686966870668716687266873668746687566876668776687866879668806688166882668836688466885668866688766888668896689066891668926689366894668956689666897668986689966900669016690266903669046690566906669076690866909669106691166912669136691466915669166691766918669196692066921669226692366924669256692666927669286692966930669316693266933669346693566936669376693866939669406694166942669436694466945669466694766948669496695066951669526695366954669556695666957669586695966960669616696266963669646696566966669676696866969669706697166972669736697466975669766697766978669796698066981669826698366984669856698666987669886698966990669916699266993669946699566996669976699866999670006700167002670036700467005670066700767008670096701067011670126701367014670156701667017670186701967020670216702267023670246702567026670276702867029670306703167032670336703467035670366703767038670396704067041670426704367044670456704667047670486704967050670516705267053670546705567056670576705867059670606706167062670636706467065670666706767068670696707067071670726707367074670756707667077670786707967080670816708267083670846708567086670876708867089670906709167092670936709467095670966709767098670996710067101671026710367104671056710667107671086710967110671116711267113671146711567116671176711867119671206712167122671236712467125671266712767128671296713067131671326713367134671356713667137671386713967140671416714267143671446714567146671476714867149671506715167152671536715467155671566715767158671596716067161671626716367164671656716667167671686716967170671716717267173671746717567176671776717867179671806718167182671836718467185671866718767188671896719067191671926719367194671956719667197671986719967200672016720267203672046720567206672076720867209672106721167212672136721467215672166721767218672196722067221672226722367224672256722667227672286722967230672316723267233672346723567236672376723867239672406724167242672436724467245672466724767248672496725067251672526725367254672556725667257672586725967260672616726267263672646726567266672676726867269672706727167272672736727467275672766727767278672796728067281672826728367284672856728667287672886728967290672916729267293672946729567296672976729867299673006730167302673036730467305673066730767308673096731067311673126731367314673156731667317673186731967320673216732267323673246732567326673276732867329673306733167332673336733467335673366733767338673396734067341673426734367344673456734667347673486734967350673516735267353673546735567356673576735867359673606736167362673636736467365673666736767368673696737067371673726737367374673756737667377673786737967380673816738267383673846738567386673876738867389673906739167392673936739467395673966739767398673996740067401674026740367404674056740667407674086740967410674116741267413674146741567416674176741867419674206742167422674236742467425674266742767428674296743067431674326743367434674356743667437674386743967440674416744267443674446744567446674476744867449674506745167452674536745467455674566745767458674596746067461674626746367464674656746667467674686746967470674716747267473674746747567476674776747867479674806748167482674836748467485674866748767488674896749067491674926749367494674956749667497674986749967500675016750267503675046750567506675076750867509675106751167512675136751467515675166751767518675196752067521675226752367524675256752667527675286752967530675316753267533675346753567536675376753867539675406754167542675436754467545675466754767548675496755067551675526755367554675556755667557675586755967560675616756267563675646756567566675676756867569675706757167572675736757467575675766757767578675796758067581675826758367584675856758667587675886758967590675916759267593675946759567596675976759867599676006760167602676036760467605676066760767608676096761067611676126761367614676156761667617676186761967620676216762267623676246762567626676276762867629676306763167632676336763467635676366763767638676396764067641676426764367644676456764667647676486764967650676516765267653676546765567656676576765867659676606766167662676636766467665676666766767668676696767067671676726767367674676756767667677676786767967680676816768267683676846768567686676876768867689676906769167692676936769467695676966769767698676996770067701677026770367704677056770667707677086770967710677116771267713677146771567716677176771867719677206772167722677236772467725677266772767728677296773067731677326773367734677356773667737677386773967740677416774267743677446774567746677476774867749677506775167752677536775467755677566775767758677596776067761677626776367764677656776667767677686776967770677716777267773677746777567776677776777867779677806778167782677836778467785677866778767788677896779067791677926779367794677956779667797677986779967800678016780267803678046780567806678076780867809678106781167812678136781467815678166781767818678196782067821678226782367824678256782667827678286782967830678316783267833678346783567836678376783867839678406784167842678436784467845678466784767848678496785067851678526785367854678556785667857678586785967860678616786267863678646786567866678676786867869678706787167872678736787467875678766787767878678796788067881678826788367884678856788667887678886788967890678916789267893678946789567896678976789867899679006790167902679036790467905679066790767908679096791067911679126791367914679156791667917679186791967920679216792267923679246792567926679276792867929679306793167932679336793467935679366793767938679396794067941679426794367944679456794667947679486794967950679516795267953679546795567956679576795867959679606796167962679636796467965679666796767968679696797067971679726797367974679756797667977679786797967980679816798267983679846798567986679876798867989679906799167992679936799467995679966799767998679996800068001680026800368004680056800668007680086800968010680116801268013680146801568016680176801868019680206802168022680236802468025680266802768028680296803068031680326803368034680356803668037680386803968040680416804268043680446804568046680476804868049680506805168052680536805468055680566805768058680596806068061680626806368064680656806668067680686806968070680716807268073680746807568076680776807868079680806808168082680836808468085680866808768088680896809068091680926809368094680956809668097680986809968100681016810268103681046810568106681076810868109681106811168112681136811468115681166811768118681196812068121681226812368124681256812668127681286812968130681316813268133681346813568136681376813868139681406814168142681436814468145681466814768148681496815068151681526815368154681556815668157681586815968160681616816268163681646816568166681676816868169681706817168172681736817468175681766817768178681796818068181681826818368184681856818668187681886818968190681916819268193681946819568196681976819868199682006820168202682036820468205682066820768208682096821068211682126821368214682156821668217682186821968220682216822268223682246822568226682276822868229682306823168232682336823468235682366823768238682396824068241682426824368244682456824668247682486824968250682516825268253682546825568256682576825868259682606826168262682636826468265682666826768268682696827068271682726827368274682756827668277682786827968280682816828268283682846828568286682876828868289682906829168292682936829468295682966829768298682996830068301683026830368304683056830668307683086830968310683116831268313683146831568316683176831868319683206832168322683236832468325683266832768328683296833068331683326833368334683356833668337683386833968340683416834268343683446834568346683476834868349683506835168352683536835468355683566835768358683596836068361683626836368364683656836668367683686836968370683716837268373683746837568376683776837868379683806838168382683836838468385683866838768388683896839068391683926839368394683956839668397683986839968400684016840268403684046840568406684076840868409684106841168412684136841468415684166841768418684196842068421684226842368424684256842668427684286842968430684316843268433684346843568436684376843868439684406844168442684436844468445684466844768448684496845068451684526845368454684556845668457684586845968460684616846268463684646846568466684676846868469684706847168472684736847468475684766847768478684796848068481684826848368484684856848668487684886848968490684916849268493684946849568496684976849868499685006850168502685036850468505685066850768508685096851068511685126851368514685156851668517685186851968520685216852268523685246852568526685276852868529685306853168532685336853468535685366853768538685396854068541685426854368544685456854668547685486854968550685516855268553685546855568556685576855868559685606856168562685636856468565685666856768568685696857068571685726857368574685756857668577685786857968580685816858268583685846858568586685876858868589685906859168592685936859468595685966859768598685996860068601686026860368604686056860668607686086860968610686116861268613686146861568616686176861868619686206862168622686236862468625686266862768628686296863068631686326863368634686356863668637686386863968640686416864268643686446864568646686476864868649686506865168652686536865468655686566865768658686596866068661686626866368664686656866668667686686866968670686716867268673686746867568676686776867868679686806868168682686836868468685686866868768688686896869068691686926869368694686956869668697686986869968700687016870268703687046870568706687076870868709687106871168712687136871468715687166871768718687196872068721687226872368724687256872668727687286872968730687316873268733687346873568736687376873868739687406874168742687436874468745687466874768748687496875068751687526875368754687556875668757687586875968760687616876268763687646876568766687676876868769687706877168772687736877468775687766877768778687796878068781687826878368784687856878668787687886878968790687916879268793687946879568796687976879868799688006880168802688036880468805688066880768808688096881068811688126881368814688156881668817688186881968820688216882268823688246882568826688276882868829688306883168832688336883468835688366883768838688396884068841688426884368844688456884668847688486884968850688516885268853688546885568856688576885868859688606886168862688636886468865688666886768868688696887068871688726887368874688756887668877688786887968880688816888268883688846888568886688876888868889688906889168892688936889468895688966889768898688996890068901689026890368904689056890668907689086890968910689116891268913689146891568916689176891868919689206892168922689236892468925689266892768928689296893068931689326893368934689356893668937689386893968940689416894268943689446894568946689476894868949689506895168952689536895468955689566895768958689596896068961689626896368964689656896668967689686896968970689716897268973689746897568976689776897868979689806898168982689836898468985689866898768988689896899068991689926899368994689956899668997689986899969000690016900269003690046900569006690076900869009690106901169012690136901469015690166901769018690196902069021690226902369024690256902669027690286902969030690316903269033690346903569036690376903869039690406904169042690436904469045690466904769048690496905069051690526905369054690556905669057690586905969060690616906269063690646906569066690676906869069690706907169072690736907469075690766907769078690796908069081690826908369084690856908669087690886908969090690916909269093690946909569096690976909869099691006910169102691036910469105691066910769108691096911069111691126911369114691156911669117691186911969120691216912269123691246912569126691276912869129691306913169132691336913469135691366913769138691396914069141691426914369144691456914669147691486914969150691516915269153691546915569156691576915869159691606916169162691636916469165691666916769168691696917069171691726917369174691756917669177691786917969180691816918269183691846918569186691876918869189691906919169192691936919469195691966919769198691996920069201692026920369204692056920669207692086920969210692116921269213692146921569216692176921869219692206922169222692236922469225692266922769228692296923069231692326923369234692356923669237692386923969240692416924269243692446924569246692476924869249692506925169252692536925469255692566925769258692596926069261692626926369264692656926669267692686926969270692716927269273692746927569276692776927869279692806928169282692836928469285692866928769288692896929069291692926929369294692956929669297692986929969300693016930269303693046930569306693076930869309693106931169312693136931469315693166931769318693196932069321693226932369324693256932669327693286932969330693316933269333693346933569336693376933869339693406934169342693436934469345693466934769348693496935069351693526935369354693556935669357693586935969360693616936269363693646936569366693676936869369693706937169372693736937469375693766937769378693796938069381693826938369384693856938669387693886938969390693916939269393693946939569396693976939869399694006940169402694036940469405694066940769408694096941069411694126941369414694156941669417694186941969420694216942269423694246942569426694276942869429694306943169432694336943469435694366943769438694396944069441694426944369444694456944669447694486944969450694516945269453694546945569456694576945869459694606946169462694636946469465694666946769468694696947069471694726947369474694756947669477694786947969480694816948269483694846948569486694876948869489694906949169492694936949469495694966949769498694996950069501695026950369504695056950669507695086950969510695116951269513695146951569516695176951869519695206952169522695236952469525695266952769528695296953069531695326953369534695356953669537695386953969540695416954269543695446954569546695476954869549695506955169552695536955469555695566955769558695596956069561695626956369564695656956669567695686956969570695716957269573695746957569576695776957869579695806958169582695836958469585695866958769588695896959069591695926959369594695956959669597695986959969600696016960269603696046960569606696076960869609696106961169612696136961469615696166961769618696196962069621696226962369624696256962669627696286962969630696316963269633696346963569636696376963869639696406964169642696436964469645696466964769648696496965069651696526965369654696556965669657696586965969660696616966269663696646966569666696676966869669696706967169672696736967469675696766967769678696796968069681696826968369684696856968669687696886968969690696916969269693696946969569696696976969869699697006970169702697036970469705697066970769708697096971069711697126971369714697156971669717697186971969720697216972269723697246972569726697276972869729697306973169732697336973469735697366973769738697396974069741697426974369744697456974669747697486974969750697516975269753697546975569756697576975869759697606976169762697636976469765697666976769768697696977069771697726977369774697756977669777697786977969780697816978269783697846978569786697876978869789697906979169792697936979469795697966979769798697996980069801698026980369804698056980669807698086980969810698116981269813698146981569816698176981869819698206982169822698236982469825698266982769828698296983069831698326983369834698356983669837698386983969840698416984269843698446984569846698476984869849698506985169852698536985469855698566985769858698596986069861698626986369864698656986669867698686986969870698716987269873698746987569876698776987869879698806988169882698836988469885698866988769888698896989069891698926989369894698956989669897698986989969900699016990269903699046990569906699076990869909699106991169912699136991469915699166991769918699196992069921699226992369924699256992669927699286992969930699316993269933699346993569936699376993869939699406994169942699436994469945699466994769948699496995069951699526995369954699556995669957699586995969960699616996269963699646996569966699676996869969699706997169972699736997469975699766997769978699796998069981699826998369984699856998669987699886998969990699916999269993699946999569996699976999869999700007000170002700037000470005700067000770008700097001070011700127001370014700157001670017700187001970020700217002270023700247002570026700277002870029700307003170032700337003470035700367003770038700397004070041700427004370044700457004670047700487004970050700517005270053700547005570056700577005870059700607006170062700637006470065700667006770068700697007070071700727007370074700757007670077700787007970080700817008270083700847008570086700877008870089700907009170092700937009470095700967009770098700997010070101701027010370104701057010670107701087010970110701117011270113701147011570116701177011870119701207012170122701237012470125701267012770128701297013070131701327013370134701357013670137701387013970140701417014270143701447014570146701477014870149701507015170152701537015470155701567015770158701597016070161701627016370164701657016670167701687016970170701717017270173701747017570176701777017870179701807018170182701837018470185701867018770188701897019070191701927019370194701957019670197701987019970200702017020270203702047020570206702077020870209702107021170212702137021470215702167021770218702197022070221702227022370224702257022670227702287022970230702317023270233702347023570236702377023870239702407024170242702437024470245702467024770248702497025070251702527025370254702557025670257702587025970260702617026270263702647026570266702677026870269702707027170272702737027470275702767027770278702797028070281702827028370284702857028670287702887028970290702917029270293702947029570296702977029870299703007030170302703037030470305703067030770308703097031070311703127031370314703157031670317703187031970320703217032270323703247032570326703277032870329703307033170332703337033470335703367033770338703397034070341703427034370344703457034670347703487034970350703517035270353703547035570356703577035870359703607036170362703637036470365703667036770368703697037070371703727037370374703757037670377703787037970380703817038270383703847038570386703877038870389703907039170392703937039470395703967039770398703997040070401704027040370404704057040670407704087040970410704117041270413704147041570416704177041870419704207042170422704237042470425704267042770428704297043070431704327043370434704357043670437704387043970440704417044270443704447044570446704477044870449704507045170452704537045470455704567045770458704597046070461704627046370464704657046670467704687046970470704717047270473704747047570476704777047870479704807048170482704837048470485704867048770488704897049070491704927049370494704957049670497704987049970500705017050270503705047050570506705077050870509705107051170512705137051470515705167051770518705197052070521705227052370524705257052670527705287052970530705317053270533705347053570536705377053870539705407054170542705437054470545705467054770548705497055070551705527055370554705557055670557705587055970560705617056270563705647056570566705677056870569705707057170572705737057470575705767057770578705797058070581705827058370584705857058670587705887058970590705917059270593705947059570596705977059870599706007060170602706037060470605706067060770608706097061070611706127061370614706157061670617706187061970620706217062270623706247062570626706277062870629706307063170632706337063470635706367063770638706397064070641706427064370644706457064670647706487064970650706517065270653706547065570656706577065870659706607066170662706637066470665706667066770668706697067070671706727067370674706757067670677706787067970680706817068270683706847068570686706877068870689706907069170692706937069470695706967069770698706997070070701707027070370704707057070670707707087070970710707117071270713707147071570716707177071870719707207072170722707237072470725707267072770728707297073070731707327073370734707357073670737707387073970740707417074270743707447074570746707477074870749707507075170752707537075470755707567075770758707597076070761707627076370764707657076670767707687076970770707717077270773707747077570776707777077870779707807078170782707837078470785707867078770788707897079070791707927079370794707957079670797707987079970800708017080270803708047080570806708077080870809708107081170812708137081470815708167081770818708197082070821708227082370824708257082670827708287082970830708317083270833708347083570836708377083870839708407084170842708437084470845708467084770848708497085070851708527085370854708557085670857708587085970860708617086270863708647086570866708677086870869708707087170872708737087470875708767087770878708797088070881708827088370884708857088670887708887088970890708917089270893708947089570896708977089870899709007090170902709037090470905709067090770908709097091070911709127091370914709157091670917709187091970920709217092270923709247092570926709277092870929709307093170932709337093470935709367093770938709397094070941709427094370944709457094670947709487094970950709517095270953709547095570956709577095870959709607096170962709637096470965709667096770968709697097070971709727097370974709757097670977709787097970980709817098270983709847098570986709877098870989709907099170992709937099470995709967099770998709997100071001710027100371004710057100671007710087100971010710117101271013710147101571016710177101871019710207102171022710237102471025710267102771028710297103071031710327103371034710357103671037710387103971040710417104271043710447104571046710477104871049710507105171052710537105471055710567105771058710597106071061710627106371064710657106671067710687106971070710717107271073710747107571076710777107871079710807108171082710837108471085710867108771088710897109071091710927109371094710957109671097710987109971100711017110271103711047110571106711077110871109711107111171112711137111471115711167111771118711197112071121711227112371124711257112671127711287112971130711317113271133711347113571136711377113871139711407114171142711437114471145711467114771148711497115071151711527115371154711557115671157711587115971160711617116271163711647116571166711677116871169711707117171172711737117471175711767117771178711797118071181711827118371184711857118671187711887118971190711917119271193711947119571196711977119871199712007120171202712037120471205712067120771208712097121071211712127121371214712157121671217712187121971220712217122271223712247122571226712277122871229712307123171232712337123471235712367123771238712397124071241712427124371244712457124671247712487124971250712517125271253712547125571256712577125871259712607126171262712637126471265712667126771268712697127071271712727127371274712757127671277712787127971280712817128271283712847128571286712877128871289712907129171292712937129471295712967129771298712997130071301713027130371304713057130671307713087130971310713117131271313713147131571316713177131871319713207132171322713237132471325713267132771328713297133071331713327133371334713357133671337713387133971340713417134271343713447134571346713477134871349713507135171352713537135471355713567135771358713597136071361713627136371364713657136671367713687136971370713717137271373713747137571376713777137871379713807138171382713837138471385713867138771388713897139071391713927139371394713957139671397713987139971400714017140271403714047140571406714077140871409714107141171412714137141471415714167141771418714197142071421714227142371424714257142671427714287142971430714317143271433714347143571436714377143871439714407144171442714437144471445714467144771448714497145071451714527145371454714557145671457714587145971460714617146271463714647146571466714677146871469714707147171472714737147471475714767147771478714797148071481714827148371484714857148671487714887148971490714917149271493714947149571496714977149871499715007150171502715037150471505715067150771508715097151071511715127151371514715157151671517715187151971520715217152271523715247152571526715277152871529715307153171532715337153471535715367153771538715397154071541715427154371544715457154671547715487154971550715517155271553715547155571556715577155871559715607156171562715637156471565715667156771568715697157071571715727157371574715757157671577715787157971580715817158271583715847158571586715877158871589715907159171592715937159471595715967159771598715997160071601716027160371604716057160671607716087160971610716117161271613716147161571616716177161871619716207162171622716237162471625716267162771628716297163071631716327163371634716357163671637716387163971640716417164271643716447164571646716477164871649716507165171652716537165471655716567165771658716597166071661716627166371664716657166671667716687166971670716717167271673716747167571676716777167871679716807168171682716837168471685716867168771688716897169071691716927169371694716957169671697716987169971700717017170271703717047170571706717077170871709717107171171712717137171471715717167171771718717197172071721717227172371724717257172671727717287172971730717317173271733717347173571736717377173871739717407174171742717437174471745717467174771748717497175071751717527175371754717557175671757717587175971760717617176271763717647176571766717677176871769717707177171772717737177471775717767177771778717797178071781717827178371784717857178671787717887178971790717917179271793717947179571796717977179871799718007180171802718037180471805718067180771808718097181071811718127181371814718157181671817718187181971820718217182271823718247182571826718277182871829718307183171832718337183471835718367183771838718397184071841718427184371844718457184671847718487184971850718517185271853718547185571856718577185871859718607186171862718637186471865718667186771868718697187071871718727187371874718757187671877718787187971880718817188271883718847188571886718877188871889718907189171892718937189471895718967189771898718997190071901719027190371904719057190671907719087190971910719117191271913719147191571916719177191871919719207192171922719237192471925719267192771928719297193071931719327193371934719357193671937719387193971940719417194271943719447194571946719477194871949719507195171952719537195471955719567195771958719597196071961719627196371964719657196671967719687196971970719717197271973719747197571976719777197871979719807198171982719837198471985719867198771988719897199071991719927199371994719957199671997719987199972000720017200272003720047200572006720077200872009720107201172012720137201472015720167201772018720197202072021720227202372024720257202672027720287202972030720317203272033720347203572036720377203872039720407204172042720437204472045720467204772048720497205072051720527205372054720557205672057720587205972060720617206272063720647206572066720677206872069720707207172072720737207472075720767207772078720797208072081720827208372084720857208672087720887208972090720917209272093720947209572096720977209872099721007210172102721037210472105721067210772108721097211072111721127211372114721157211672117721187211972120721217212272123721247212572126721277212872129721307213172132721337213472135721367213772138721397214072141721427214372144721457214672147721487214972150721517215272153721547215572156721577215872159721607216172162721637216472165721667216772168721697217072171721727217372174721757217672177721787217972180721817218272183721847218572186721877218872189721907219172192721937219472195721967219772198721997220072201722027220372204722057220672207722087220972210722117221272213722147221572216722177221872219722207222172222722237222472225722267222772228722297223072231722327223372234722357223672237722387223972240722417224272243722447224572246722477224872249722507225172252722537225472255722567225772258722597226072261722627226372264722657226672267722687226972270722717227272273722747227572276722777227872279722807228172282722837228472285722867228772288722897229072291722927229372294722957229672297722987229972300723017230272303723047230572306723077230872309723107231172312723137231472315723167231772318723197232072321723227232372324723257232672327723287232972330723317233272333723347233572336723377233872339723407234172342723437234472345723467234772348723497235072351723527235372354723557235672357723587235972360723617236272363723647236572366723677236872369723707237172372723737237472375723767237772378723797238072381723827238372384723857238672387723887238972390723917239272393723947239572396723977239872399724007240172402724037240472405724067240772408724097241072411724127241372414724157241672417724187241972420724217242272423724247242572426724277242872429724307243172432724337243472435724367243772438724397244072441724427244372444724457244672447724487244972450724517245272453724547245572456724577245872459724607246172462724637246472465724667246772468724697247072471724727247372474724757247672477724787247972480724817248272483724847248572486724877248872489724907249172492724937249472495724967249772498724997250072501725027250372504725057250672507725087250972510725117251272513725147251572516725177251872519725207252172522725237252472525725267252772528725297253072531725327253372534725357253672537725387253972540725417254272543725447254572546725477254872549725507255172552725537255472555725567255772558725597256072561725627256372564725657256672567725687256972570725717257272573725747257572576725777257872579725807258172582725837258472585725867258772588725897259072591725927259372594725957259672597725987259972600726017260272603726047260572606726077260872609726107261172612726137261472615726167261772618726197262072621726227262372624726257262672627726287262972630726317263272633726347263572636726377263872639726407264172642726437264472645726467264772648726497265072651726527265372654726557265672657726587265972660726617266272663726647266572666726677266872669726707267172672726737267472675726767267772678726797268072681726827268372684726857268672687726887268972690726917269272693726947269572696726977269872699727007270172702727037270472705727067270772708727097271072711727127271372714727157271672717727187271972720727217272272723727247272572726727277272872729727307273172732727337273472735727367273772738727397274072741727427274372744727457274672747727487274972750727517275272753727547275572756727577275872759727607276172762727637276472765727667276772768727697277072771727727277372774727757277672777727787277972780727817278272783727847278572786727877278872789727907279172792727937279472795727967279772798727997280072801728027280372804728057280672807728087280972810728117281272813728147281572816728177281872819728207282172822728237282472825728267282772828728297283072831728327283372834728357283672837728387283972840728417284272843728447284572846728477284872849728507285172852728537285472855728567285772858728597286072861728627286372864728657286672867728687286972870728717287272873728747287572876728777287872879728807288172882728837288472885728867288772888728897289072891728927289372894728957289672897728987289972900729017290272903729047290572906729077290872909729107291172912729137291472915729167291772918729197292072921729227292372924729257292672927729287292972930729317293272933729347293572936729377293872939729407294172942729437294472945729467294772948729497295072951729527295372954729557295672957729587295972960729617296272963729647296572966729677296872969729707297172972729737297472975729767297772978729797298072981729827298372984729857298672987729887298972990729917299272993729947299572996729977299872999730007300173002730037300473005730067300773008730097301073011730127301373014730157301673017730187301973020730217302273023730247302573026730277302873029730307303173032730337303473035730367303773038730397304073041730427304373044730457304673047730487304973050730517305273053730547305573056730577305873059730607306173062730637306473065730667306773068730697307073071730727307373074730757307673077730787307973080730817308273083730847308573086730877308873089730907309173092730937309473095730967309773098730997310073101731027310373104731057310673107731087310973110731117311273113731147311573116731177311873119731207312173122731237312473125731267312773128731297313073131731327313373134731357313673137731387313973140731417314273143731447314573146731477314873149731507315173152731537315473155731567315773158731597316073161731627316373164731657316673167731687316973170731717317273173731747317573176731777317873179731807318173182731837318473185731867318773188731897319073191731927319373194731957319673197731987319973200732017320273203732047320573206732077320873209732107321173212732137321473215732167321773218732197322073221732227322373224732257322673227732287322973230732317323273233732347323573236732377323873239732407324173242732437324473245732467324773248732497325073251732527325373254732557325673257732587325973260732617326273263732647326573266732677326873269732707327173272732737327473275732767327773278732797328073281732827328373284732857328673287732887328973290732917329273293732947329573296732977329873299733007330173302733037330473305733067330773308733097331073311733127331373314733157331673317733187331973320733217332273323733247332573326733277332873329733307333173332733337333473335733367333773338733397334073341733427334373344733457334673347733487334973350733517335273353733547335573356733577335873359733607336173362733637336473365733667336773368733697337073371733727337373374733757337673377733787337973380733817338273383733847338573386733877338873389733907339173392733937339473395733967339773398733997340073401734027340373404734057340673407734087340973410734117341273413734147341573416734177341873419734207342173422734237342473425734267342773428734297343073431734327343373434734357343673437734387343973440734417344273443734447344573446734477344873449734507345173452734537345473455734567345773458734597346073461734627346373464734657346673467734687346973470734717347273473734747347573476734777347873479734807348173482734837348473485734867348773488734897349073491734927349373494734957349673497734987349973500735017350273503735047350573506735077350873509735107351173512735137351473515735167351773518735197352073521735227352373524735257352673527735287352973530735317353273533735347353573536735377353873539735407354173542735437354473545735467354773548735497355073551735527355373554735557355673557735587355973560735617356273563735647356573566735677356873569735707357173572735737357473575735767357773578735797358073581735827358373584735857358673587735887358973590735917359273593735947359573596735977359873599736007360173602736037360473605736067360773608736097361073611736127361373614736157361673617736187361973620736217362273623736247362573626736277362873629736307363173632736337363473635736367363773638736397364073641736427364373644736457364673647736487364973650736517365273653736547365573656736577365873659736607366173662736637366473665736667366773668736697367073671736727367373674736757367673677736787367973680736817368273683736847368573686736877368873689736907369173692736937369473695736967369773698736997370073701737027370373704737057370673707737087370973710737117371273713737147371573716737177371873719737207372173722737237372473725737267372773728737297373073731737327373373734737357373673737737387373973740737417374273743737447374573746737477374873749737507375173752737537375473755737567375773758737597376073761737627376373764737657376673767737687376973770737717377273773737747377573776737777377873779737807378173782737837378473785737867378773788737897379073791737927379373794737957379673797737987379973800738017380273803738047380573806738077380873809738107381173812738137381473815738167381773818738197382073821738227382373824738257382673827738287382973830738317383273833738347383573836738377383873839738407384173842738437384473845738467384773848738497385073851738527385373854738557385673857738587385973860738617386273863738647386573866738677386873869738707387173872738737387473875738767387773878738797388073881738827388373884738857388673887738887388973890738917389273893738947389573896738977389873899739007390173902739037390473905739067390773908739097391073911739127391373914739157391673917739187391973920739217392273923739247392573926739277392873929739307393173932739337393473935739367393773938739397394073941739427394373944739457394673947739487394973950739517395273953739547395573956739577395873959739607396173962739637396473965739667396773968739697397073971739727397373974739757397673977739787397973980739817398273983739847398573986739877398873989739907399173992739937399473995739967399773998739997400074001740027400374004740057400674007740087400974010740117401274013740147401574016740177401874019740207402174022740237402474025740267402774028740297403074031740327403374034740357403674037740387403974040740417404274043740447404574046740477404874049740507405174052740537405474055740567405774058740597406074061740627406374064740657406674067740687406974070740717407274073740747407574076740777407874079740807408174082740837408474085740867408774088740897409074091740927409374094740957409674097740987409974100741017410274103741047410574106741077410874109741107411174112741137411474115741167411774118741197412074121741227412374124741257412674127741287412974130741317413274133741347413574136741377413874139741407414174142741437414474145741467414774148741497415074151741527415374154741557415674157741587415974160741617416274163741647416574166741677416874169741707417174172741737417474175741767417774178741797418074181741827418374184741857418674187741887418974190741917419274193741947419574196741977419874199742007420174202742037420474205742067420774208742097421074211742127421374214742157421674217742187421974220742217422274223742247422574226742277422874229742307423174232742337423474235742367423774238742397424074241742427424374244742457424674247742487424974250742517425274253742547425574256742577425874259742607426174262742637426474265742667426774268742697427074271742727427374274742757427674277742787427974280742817428274283742847428574286742877428874289742907429174292742937429474295742967429774298742997430074301743027430374304743057430674307743087430974310743117431274313743147431574316743177431874319743207432174322743237432474325743267432774328743297433074331743327433374334743357433674337743387433974340743417434274343743447434574346743477434874349743507435174352743537435474355743567435774358743597436074361743627436374364743657436674367743687436974370743717437274373743747437574376743777437874379743807438174382743837438474385743867438774388743897439074391743927439374394743957439674397743987439974400744017440274403744047440574406744077440874409744107441174412744137441474415744167441774418744197442074421744227442374424744257442674427744287442974430744317443274433744347443574436744377443874439744407444174442744437444474445744467444774448744497445074451744527445374454744557445674457744587445974460744617446274463744647446574466744677446874469744707447174472744737447474475744767447774478744797448074481744827448374484744857448674487744887448974490744917449274493744947449574496744977449874499745007450174502745037450474505745067450774508745097451074511745127451374514745157451674517745187451974520745217452274523745247452574526745277452874529745307453174532745337453474535745367453774538745397454074541745427454374544745457454674547745487454974550745517455274553745547455574556745577455874559745607456174562745637456474565745667456774568745697457074571745727457374574745757457674577745787457974580745817458274583745847458574586745877458874589745907459174592745937459474595745967459774598745997460074601746027460374604746057460674607746087460974610746117461274613746147461574616746177461874619746207462174622746237462474625746267462774628746297463074631746327463374634746357463674637746387463974640746417464274643746447464574646746477464874649746507465174652746537465474655746567465774658746597466074661746627466374664746657466674667746687466974670746717467274673746747467574676746777467874679746807468174682746837468474685746867468774688746897469074691746927469374694746957469674697746987469974700747017470274703747047470574706747077470874709747107471174712747137471474715747167471774718747197472074721747227472374724747257472674727747287472974730747317473274733747347473574736747377473874739747407474174742747437474474745747467474774748747497475074751747527475374754747557475674757747587475974760747617476274763747647476574766747677476874769747707477174772747737477474775747767477774778747797478074781747827478374784747857478674787747887478974790747917479274793747947479574796747977479874799748007480174802748037480474805748067480774808748097481074811748127481374814748157481674817748187481974820748217482274823748247482574826748277482874829748307483174832748337483474835748367483774838748397484074841748427484374844748457484674847748487484974850748517485274853748547485574856748577485874859748607486174862748637486474865748667486774868748697487074871748727487374874748757487674877748787487974880748817488274883748847488574886748877488874889748907489174892748937489474895748967489774898748997490074901749027490374904749057490674907749087490974910749117491274913749147491574916749177491874919749207492174922749237492474925749267492774928749297493074931749327493374934749357493674937749387493974940749417494274943749447494574946749477494874949749507495174952749537495474955749567495774958749597496074961749627496374964749657496674967749687496974970749717497274973749747497574976749777497874979749807498174982749837498474985749867498774988749897499074991749927499374994749957499674997749987499975000750017500275003750047500575006750077500875009750107501175012750137501475015750167501775018750197502075021750227502375024750257502675027750287502975030750317503275033750347503575036750377503875039750407504175042750437504475045750467504775048750497505075051750527505375054750557505675057750587505975060750617506275063750647506575066750677506875069750707507175072750737507475075750767507775078750797508075081750827508375084750857508675087750887508975090750917509275093750947509575096750977509875099751007510175102751037510475105751067510775108751097511075111751127511375114751157511675117751187511975120751217512275123751247512575126751277512875129751307513175132751337513475135751367513775138751397514075141751427514375144751457514675147751487514975150751517515275153751547515575156751577515875159751607516175162751637516475165751667516775168751697517075171751727517375174751757517675177751787517975180751817518275183751847518575186751877518875189751907519175192751937519475195751967519775198751997520075201752027520375204752057520675207752087520975210752117521275213752147521575216752177521875219752207522175222752237522475225752267522775228752297523075231752327523375234752357523675237752387523975240752417524275243752447524575246752477524875249752507525175252752537525475255752567525775258752597526075261752627526375264752657526675267752687526975270752717527275273752747527575276752777527875279752807528175282752837528475285752867528775288752897529075291752927529375294752957529675297752987529975300753017530275303753047530575306753077530875309753107531175312753137531475315753167531775318753197532075321753227532375324753257532675327753287532975330753317533275333753347533575336753377533875339753407534175342753437534475345753467534775348753497535075351753527535375354753557535675357753587535975360753617536275363753647536575366753677536875369753707537175372753737537475375753767537775378753797538075381753827538375384753857538675387753887538975390753917539275393753947539575396753977539875399754007540175402754037540475405754067540775408754097541075411754127541375414754157541675417754187541975420754217542275423754247542575426754277542875429754307543175432754337543475435754367543775438754397544075441754427544375444754457544675447754487544975450754517545275453754547545575456754577545875459754607546175462754637546475465754667546775468754697547075471754727547375474754757547675477754787547975480754817548275483754847548575486754877548875489754907549175492754937549475495754967549775498754997550075501755027550375504755057550675507755087550975510755117551275513755147551575516755177551875519755207552175522755237552475525755267552775528755297553075531755327553375534755357553675537755387553975540755417554275543755447554575546755477554875549755507555175552755537555475555755567555775558755597556075561755627556375564755657556675567755687556975570755717557275573755747557575576755777557875579755807558175582755837558475585755867558775588755897559075591755927559375594755957559675597755987559975600756017560275603756047560575606756077560875609756107561175612756137561475615756167561775618756197562075621756227562375624756257562675627756287562975630756317563275633756347563575636756377563875639756407564175642756437564475645756467564775648756497565075651756527565375654756557565675657756587565975660756617566275663756647566575666756677566875669756707567175672756737567475675756767567775678756797568075681756827568375684756857568675687756887568975690756917569275693756947569575696756977569875699757007570175702757037570475705757067570775708757097571075711757127571375714757157571675717757187571975720757217572275723757247572575726757277572875729757307573175732757337573475735757367573775738757397574075741757427574375744757457574675747757487574975750757517575275753757547575575756757577575875759757607576175762757637576475765757667576775768757697577075771757727577375774757757577675777757787577975780757817578275783757847578575786757877578875789757907579175792757937579475795757967579775798757997580075801758027580375804758057580675807758087580975810758117581275813758147581575816758177581875819758207582175822758237582475825758267582775828758297583075831758327583375834758357583675837758387583975840758417584275843758447584575846758477584875849758507585175852758537585475855758567585775858758597586075861758627586375864758657586675867758687586975870758717587275873758747587575876758777587875879758807588175882758837588475885758867588775888758897589075891758927589375894758957589675897758987589975900759017590275903759047590575906759077590875909759107591175912759137591475915759167591775918759197592075921759227592375924759257592675927759287592975930759317593275933759347593575936759377593875939759407594175942759437594475945759467594775948759497595075951759527595375954759557595675957759587595975960759617596275963759647596575966759677596875969759707597175972759737597475975759767597775978759797598075981759827598375984759857598675987759887598975990759917599275993759947599575996759977599875999760007600176002760037600476005760067600776008760097601076011760127601376014760157601676017760187601976020760217602276023760247602576026760277602876029760307603176032760337603476035760367603776038760397604076041760427604376044760457604676047760487604976050760517605276053760547605576056760577605876059760607606176062760637606476065760667606776068760697607076071760727607376074760757607676077760787607976080760817608276083760847608576086760877608876089760907609176092760937609476095760967609776098760997610076101761027610376104761057610676107761087610976110761117611276113761147611576116761177611876119761207612176122761237612476125761267612776128761297613076131761327613376134761357613676137761387613976140761417614276143761447614576146761477614876149761507615176152761537615476155761567615776158761597616076161761627616376164761657616676167761687616976170761717617276173761747617576176761777617876179761807618176182761837618476185761867618776188761897619076191761927619376194761957619676197761987619976200762017620276203762047620576206762077620876209762107621176212762137621476215762167621776218762197622076221762227622376224762257622676227762287622976230762317623276233762347623576236762377623876239762407624176242762437624476245762467624776248762497625076251762527625376254762557625676257762587625976260762617626276263762647626576266762677626876269762707627176272762737627476275762767627776278762797628076281762827628376284762857628676287762887628976290762917629276293762947629576296762977629876299763007630176302763037630476305763067630776308763097631076311763127631376314763157631676317763187631976320763217632276323763247632576326763277632876329763307633176332763337633476335763367633776338763397634076341763427634376344763457634676347763487634976350763517635276353763547635576356763577635876359763607636176362763637636476365763667636776368763697637076371763727637376374763757637676377763787637976380763817638276383763847638576386763877638876389763907639176392763937639476395763967639776398763997640076401764027640376404764057640676407764087640976410764117641276413764147641576416764177641876419764207642176422764237642476425764267642776428764297643076431764327643376434764357643676437764387643976440764417644276443764447644576446764477644876449764507645176452764537645476455764567645776458764597646076461764627646376464764657646676467764687646976470764717647276473764747647576476764777647876479764807648176482764837648476485764867648776488764897649076491764927649376494764957649676497764987649976500765017650276503765047650576506765077650876509765107651176512765137651476515765167651776518765197652076521765227652376524765257652676527765287652976530765317653276533765347653576536765377653876539765407654176542765437654476545765467654776548765497655076551765527655376554765557655676557765587655976560765617656276563765647656576566765677656876569765707657176572765737657476575765767657776578765797658076581765827658376584765857658676587765887658976590765917659276593765947659576596765977659876599766007660176602766037660476605766067660776608766097661076611766127661376614766157661676617766187661976620766217662276623766247662576626766277662876629766307663176632766337663476635766367663776638766397664076641766427664376644766457664676647766487664976650766517665276653766547665576656766577665876659766607666176662766637666476665766667666776668766697667076671766727667376674766757667676677766787667976680766817668276683766847668576686766877668876689766907669176692766937669476695766967669776698766997670076701767027670376704767057670676707767087670976710767117671276713767147671576716767177671876719767207672176722767237672476725767267672776728767297673076731767327673376734767357673676737767387673976740767417674276743767447674576746767477674876749767507675176752767537675476755767567675776758767597676076761767627676376764767657676676767767687676976770767717677276773767747677576776767777677876779767807678176782767837678476785767867678776788767897679076791767927679376794767957679676797767987679976800768017680276803768047680576806768077680876809768107681176812768137681476815768167681776818768197682076821768227682376824768257682676827768287682976830768317683276833768347683576836768377683876839768407684176842768437684476845768467684776848768497685076851768527685376854768557685676857768587685976860768617686276863768647686576866768677686876869768707687176872768737687476875768767687776878768797688076881768827688376884768857688676887768887688976890768917689276893768947689576896768977689876899769007690176902769037690476905769067690776908769097691076911769127691376914769157691676917769187691976920769217692276923769247692576926769277692876929769307693176932769337693476935769367693776938769397694076941769427694376944769457694676947769487694976950769517695276953769547695576956769577695876959769607696176962769637696476965769667696776968769697697076971769727697376974769757697676977769787697976980769817698276983769847698576986769877698876989769907699176992769937699476995769967699776998769997700077001770027700377004770057700677007770087700977010770117701277013770147701577016770177701877019770207702177022770237702477025770267702777028770297703077031770327703377034770357703677037770387703977040770417704277043770447704577046770477704877049770507705177052770537705477055770567705777058770597706077061770627706377064770657706677067770687706977070770717707277073770747707577076770777707877079770807708177082770837708477085770867708777088770897709077091770927709377094770957709677097770987709977100771017710277103771047710577106771077710877109771107711177112771137711477115771167711777118771197712077121771227712377124771257712677127771287712977130771317713277133771347713577136771377713877139771407714177142771437714477145771467714777148771497715077151771527715377154771557715677157771587715977160771617716277163771647716577166771677716877169771707717177172771737717477175771767717777178771797718077181771827718377184771857718677187771887718977190771917719277193771947719577196771977719877199772007720177202772037720477205772067720777208772097721077211772127721377214772157721677217772187721977220772217722277223772247722577226772277722877229772307723177232772337723477235772367723777238772397724077241772427724377244772457724677247772487724977250772517725277253772547725577256772577725877259772607726177262772637726477265772667726777268772697727077271772727727377274772757727677277772787727977280772817728277283772847728577286772877728877289772907729177292772937729477295772967729777298772997730077301773027730377304773057730677307773087730977310773117731277313773147731577316773177731877319773207732177322773237732477325773267732777328773297733077331773327733377334773357733677337773387733977340773417734277343773447734577346773477734877349773507735177352773537735477355773567735777358773597736077361773627736377364773657736677367773687736977370773717737277373773747737577376773777737877379773807738177382773837738477385773867738777388773897739077391773927739377394773957739677397773987739977400774017740277403774047740577406774077740877409774107741177412774137741477415774167741777418774197742077421774227742377424774257742677427774287742977430774317743277433774347743577436774377743877439774407744177442774437744477445774467744777448774497745077451774527745377454774557745677457774587745977460774617746277463774647746577466774677746877469774707747177472774737747477475774767747777478774797748077481774827748377484774857748677487774887748977490774917749277493774947749577496774977749877499775007750177502775037750477505775067750777508775097751077511775127751377514775157751677517775187751977520775217752277523775247752577526775277752877529775307753177532775337753477535775367753777538775397754077541775427754377544775457754677547775487754977550775517755277553775547755577556775577755877559775607756177562775637756477565775667756777568775697757077571775727757377574775757757677577775787757977580775817758277583775847758577586775877758877589775907759177592775937759477595775967759777598775997760077601776027760377604776057760677607776087760977610776117761277613776147761577616776177761877619776207762177622776237762477625776267762777628776297763077631776327763377634776357763677637776387763977640776417764277643776447764577646776477764877649776507765177652776537765477655776567765777658776597766077661776627766377664776657766677667776687766977670776717767277673776747767577676776777767877679776807768177682776837768477685776867768777688776897769077691776927769377694776957769677697776987769977700777017770277703777047770577706777077770877709777107771177712777137771477715777167771777718777197772077721777227772377724777257772677727777287772977730777317773277733777347773577736777377773877739777407774177742777437774477745777467774777748777497775077751777527775377754777557775677757777587775977760777617776277763777647776577766777677776877769777707777177772777737777477775777767777777778777797778077781777827778377784777857778677787777887778977790777917779277793777947779577796777977779877799778007780177802778037780477805778067780777808778097781077811778127781377814778157781677817778187781977820778217782277823778247782577826778277782877829778307783177832778337783477835778367783777838778397784077841778427784377844778457784677847778487784977850778517785277853778547785577856778577785877859778607786177862778637786477865778667786777868778697787077871778727787377874778757787677877778787787977880778817788277883778847788577886778877788877889778907789177892778937789477895778967789777898778997790077901779027790377904779057790677907779087790977910779117791277913779147791577916779177791877919779207792177922779237792477925779267792777928779297793077931779327793377934779357793677937779387793977940779417794277943779447794577946779477794877949779507795177952779537795477955779567795777958779597796077961779627796377964779657796677967779687796977970779717797277973779747797577976779777797877979779807798177982779837798477985779867798777988779897799077991779927799377994779957799677997779987799978000780017800278003780047800578006780077800878009780107801178012780137801478015780167801778018780197802078021780227802378024780257802678027780287802978030780317803278033780347803578036780377803878039780407804178042780437804478045780467804778048780497805078051780527805378054780557805678057780587805978060780617806278063780647806578066780677806878069780707807178072780737807478075780767807778078780797808078081780827808378084780857808678087780887808978090780917809278093780947809578096780977809878099781007810178102781037810478105781067810778108781097811078111781127811378114781157811678117781187811978120781217812278123781247812578126781277812878129781307813178132781337813478135781367813778138781397814078141781427814378144781457814678147781487814978150781517815278153781547815578156781577815878159781607816178162781637816478165781667816778168781697817078171781727817378174781757817678177781787817978180781817818278183781847818578186781877818878189781907819178192781937819478195781967819778198781997820078201782027820378204782057820678207782087820978210782117821278213782147821578216782177821878219782207822178222782237822478225782267822778228782297823078231782327823378234782357823678237782387823978240782417824278243782447824578246782477824878249782507825178252782537825478255782567825778258782597826078261782627826378264782657826678267782687826978270782717827278273782747827578276782777827878279782807828178282782837828478285782867828778288782897829078291782927829378294782957829678297782987829978300783017830278303783047830578306783077830878309783107831178312783137831478315783167831778318783197832078321783227832378324783257832678327783287832978330783317833278333783347833578336783377833878339783407834178342783437834478345783467834778348783497835078351783527835378354783557835678357783587835978360783617836278363783647836578366783677836878369783707837178372783737837478375783767837778378783797838078381783827838378384783857838678387783887838978390783917839278393783947839578396783977839878399784007840178402784037840478405784067840778408784097841078411784127841378414784157841678417784187841978420784217842278423784247842578426784277842878429784307843178432784337843478435784367843778438784397844078441784427844378444784457844678447784487844978450784517845278453784547845578456784577845878459784607846178462784637846478465784667846778468784697847078471784727847378474784757847678477784787847978480784817848278483784847848578486784877848878489784907849178492784937849478495784967849778498784997850078501785027850378504785057850678507785087850978510785117851278513785147851578516785177851878519785207852178522785237852478525785267852778528785297853078531785327853378534785357853678537785387853978540785417854278543785447854578546785477854878549785507855178552785537855478555785567855778558785597856078561785627856378564785657856678567785687856978570785717857278573785747857578576785777857878579785807858178582785837858478585785867858778588785897859078591785927859378594785957859678597785987859978600786017860278603786047860578606786077860878609786107861178612786137861478615786167861778618786197862078621786227862378624786257862678627786287862978630786317863278633786347863578636786377863878639786407864178642786437864478645786467864778648786497865078651786527865378654786557865678657786587865978660786617866278663786647866578666786677866878669786707867178672786737867478675786767867778678786797868078681786827868378684786857868678687786887868978690786917869278693786947869578696786977869878699787007870178702787037870478705787067870778708787097871078711787127871378714787157871678717787187871978720787217872278723787247872578726787277872878729787307873178732787337873478735787367873778738787397874078741787427874378744787457874678747787487874978750787517875278753787547875578756787577875878759787607876178762787637876478765787667876778768787697877078771787727877378774787757877678777787787877978780787817878278783787847878578786787877878878789787907879178792787937879478795787967879778798787997880078801788027880378804788057880678807788087880978810788117881278813788147881578816788177881878819788207882178822788237882478825788267882778828788297883078831788327883378834788357883678837788387883978840788417884278843788447884578846788477884878849788507885178852788537885478855788567885778858788597886078861788627886378864788657886678867788687886978870788717887278873788747887578876788777887878879788807888178882788837888478885788867888778888788897889078891788927889378894788957889678897788987889978900789017890278903789047890578906789077890878909789107891178912789137891478915789167891778918789197892078921789227892378924789257892678927789287892978930789317893278933789347893578936789377893878939789407894178942789437894478945789467894778948789497895078951789527895378954789557895678957789587895978960789617896278963789647896578966789677896878969789707897178972789737897478975789767897778978789797898078981789827898378984789857898678987789887898978990789917899278993789947899578996789977899878999790007900179002790037900479005790067900779008790097901079011790127901379014790157901679017790187901979020790217902279023790247902579026790277902879029790307903179032790337903479035790367903779038790397904079041790427904379044790457904679047790487904979050790517905279053790547905579056790577905879059790607906179062790637906479065790667906779068790697907079071790727907379074790757907679077790787907979080790817908279083790847908579086790877908879089790907909179092790937909479095790967909779098790997910079101791027910379104791057910679107791087910979110791117911279113791147911579116791177911879119791207912179122791237912479125791267912779128791297913079131791327913379134791357913679137791387913979140791417914279143791447914579146791477914879149791507915179152791537915479155791567915779158791597916079161791627916379164791657916679167791687916979170791717917279173791747917579176791777917879179791807918179182791837918479185791867918779188791897919079191791927919379194791957919679197791987919979200792017920279203792047920579206792077920879209792107921179212792137921479215792167921779218792197922079221792227922379224792257922679227792287922979230792317923279233792347923579236792377923879239792407924179242792437924479245792467924779248792497925079251792527925379254792557925679257792587925979260792617926279263792647926579266792677926879269792707927179272792737927479275792767927779278792797928079281792827928379284792857928679287792887928979290792917929279293792947929579296792977929879299793007930179302793037930479305793067930779308793097931079311793127931379314793157931679317793187931979320793217932279323793247932579326793277932879329793307933179332793337933479335793367933779338793397934079341793427934379344793457934679347793487934979350793517935279353793547935579356793577935879359793607936179362793637936479365793667936779368793697937079371793727937379374793757937679377793787937979380793817938279383793847938579386793877938879389793907939179392793937939479395793967939779398793997940079401794027940379404794057940679407794087940979410794117941279413794147941579416794177941879419794207942179422794237942479425794267942779428794297943079431794327943379434794357943679437794387943979440794417944279443794447944579446794477944879449794507945179452794537945479455794567945779458794597946079461794627946379464794657946679467794687946979470794717947279473794747947579476794777947879479794807948179482794837948479485794867948779488794897949079491794927949379494794957949679497794987949979500795017950279503795047950579506795077950879509795107951179512795137951479515795167951779518795197952079521795227952379524795257952679527795287952979530795317953279533795347953579536795377953879539795407954179542795437954479545795467954779548795497955079551795527955379554795557955679557795587955979560795617956279563795647956579566795677956879569795707957179572795737957479575795767957779578795797958079581795827958379584795857958679587795887958979590795917959279593795947959579596795977959879599796007960179602796037960479605796067960779608796097961079611796127961379614796157961679617796187961979620796217962279623796247962579626796277962879629796307963179632796337963479635796367963779638796397964079641796427964379644796457964679647796487964979650796517965279653796547965579656796577965879659796607966179662796637966479665796667966779668796697967079671796727967379674796757967679677796787967979680796817968279683796847968579686796877968879689796907969179692796937969479695796967969779698796997970079701797027970379704797057970679707797087970979710797117971279713797147971579716797177971879719797207972179722797237972479725797267972779728797297973079731797327973379734797357973679737797387973979740797417974279743797447974579746797477974879749797507975179752797537975479755797567975779758797597976079761797627976379764797657976679767797687976979770797717977279773797747977579776797777977879779797807978179782797837978479785797867978779788797897979079791797927979379794797957979679797797987979979800798017980279803798047980579806798077980879809798107981179812798137981479815798167981779818798197982079821798227982379824798257982679827798287982979830798317983279833798347983579836798377983879839798407984179842798437984479845798467984779848798497985079851798527985379854798557985679857798587985979860798617986279863798647986579866798677986879869798707987179872798737987479875798767987779878798797988079881798827988379884798857988679887798887988979890798917989279893798947989579896798977989879899799007990179902799037990479905799067990779908799097991079911799127991379914799157991679917799187991979920799217992279923799247992579926799277992879929799307993179932799337993479935799367993779938799397994079941799427994379944799457994679947799487994979950799517995279953799547995579956799577995879959799607996179962799637996479965799667996779968799697997079971799727997379974799757997679977799787997979980799817998279983799847998579986799877998879989799907999179992799937999479995799967999779998799998000080001800028000380004800058000680007800088000980010800118001280013800148001580016800178001880019800208002180022800238002480025800268002780028800298003080031800328003380034800358003680037800388003980040800418004280043800448004580046800478004880049800508005180052800538005480055800568005780058800598006080061800628006380064800658006680067800688006980070800718007280073800748007580076800778007880079800808008180082800838008480085800868008780088800898009080091800928009380094800958009680097800988009980100801018010280103801048010580106801078010880109801108011180112801138011480115801168011780118801198012080121801228012380124801258012680127801288012980130801318013280133801348013580136801378013880139801408014180142801438014480145801468014780148801498015080151801528015380154801558015680157801588015980160801618016280163801648016580166801678016880169801708017180172801738017480175801768017780178801798018080181801828018380184801858018680187801888018980190801918019280193801948019580196801978019880199802008020180202802038020480205802068020780208802098021080211802128021380214802158021680217802188021980220802218022280223802248022580226802278022880229802308023180232802338023480235802368023780238802398024080241802428024380244802458024680247802488024980250802518025280253802548025580256802578025880259802608026180262802638026480265802668026780268802698027080271802728027380274802758027680277802788027980280802818028280283802848028580286802878028880289802908029180292802938029480295802968029780298802998030080301803028030380304803058030680307803088030980310803118031280313803148031580316803178031880319803208032180322803238032480325803268032780328803298033080331803328033380334803358033680337803388033980340803418034280343803448034580346803478034880349803508035180352803538035480355803568035780358803598036080361803628036380364803658036680367803688036980370803718037280373803748037580376803778037880379803808038180382803838038480385803868038780388803898039080391803928039380394803958039680397803988039980400804018040280403804048040580406804078040880409804108041180412804138041480415804168041780418804198042080421804228042380424804258042680427804288042980430804318043280433804348043580436804378043880439804408044180442804438044480445804468044780448804498045080451804528045380454804558045680457804588045980460804618046280463804648046580466804678046880469804708047180472804738047480475804768047780478804798048080481804828048380484804858048680487804888048980490804918049280493804948049580496804978049880499805008050180502805038050480505805068050780508805098051080511805128051380514805158051680517805188051980520805218052280523805248052580526805278052880529805308053180532805338053480535805368053780538805398054080541805428054380544805458054680547805488054980550805518055280553805548055580556805578055880559805608056180562805638056480565805668056780568805698057080571805728057380574805758057680577805788057980580805818058280583805848058580586805878058880589805908059180592805938059480595805968059780598805998060080601806028060380604806058060680607806088060980610806118061280613806148061580616806178061880619806208062180622806238062480625806268062780628806298063080631806328063380634806358063680637806388063980640806418064280643806448064580646806478064880649806508065180652806538065480655806568065780658806598066080661806628066380664806658066680667806688066980670806718067280673806748067580676806778067880679806808068180682806838068480685806868068780688806898069080691806928069380694806958069680697806988069980700807018070280703807048070580706807078070880709807108071180712807138071480715807168071780718807198072080721807228072380724807258072680727807288072980730807318073280733807348073580736807378073880739807408074180742807438074480745807468074780748807498075080751807528075380754807558075680757807588075980760807618076280763807648076580766807678076880769807708077180772807738077480775807768077780778807798078080781807828078380784807858078680787807888078980790807918079280793807948079580796807978079880799808008080180802808038080480805808068080780808808098081080811808128081380814808158081680817808188081980820808218082280823808248082580826808278082880829808308083180832808338083480835808368083780838808398084080841808428084380844808458084680847808488084980850808518085280853808548085580856808578085880859808608086180862808638086480865808668086780868808698087080871808728087380874808758087680877808788087980880808818088280883808848088580886808878088880889808908089180892808938089480895808968089780898808998090080901809028090380904809058090680907809088090980910809118091280913809148091580916809178091880919809208092180922809238092480925809268092780928809298093080931809328093380934809358093680937809388093980940809418094280943809448094580946809478094880949809508095180952809538095480955809568095780958809598096080961809628096380964809658096680967809688096980970809718097280973809748097580976809778097880979809808098180982809838098480985809868098780988809898099080991809928099380994809958099680997809988099981000810018100281003810048100581006810078100881009810108101181012810138101481015810168101781018810198102081021810228102381024810258102681027810288102981030810318103281033810348103581036810378103881039810408104181042810438104481045810468104781048810498105081051810528105381054810558105681057810588105981060810618106281063810648106581066810678106881069810708107181072810738107481075810768107781078810798108081081810828108381084810858108681087810888108981090810918109281093810948109581096810978109881099811008110181102811038110481105811068110781108811098111081111811128111381114811158111681117811188111981120811218112281123811248112581126811278112881129811308113181132811338113481135811368113781138811398114081141811428114381144811458114681147811488114981150811518115281153811548115581156811578115881159811608116181162811638116481165811668116781168811698117081171811728117381174811758117681177811788117981180811818118281183811848118581186811878118881189811908119181192811938119481195811968119781198811998120081201812028120381204812058120681207812088120981210812118121281213812148121581216812178121881219812208122181222812238122481225812268122781228812298123081231812328123381234812358123681237812388123981240812418124281243812448124581246812478124881249812508125181252812538125481255812568125781258812598126081261812628126381264812658126681267812688126981270812718127281273812748127581276812778127881279812808128181282812838128481285812868128781288812898129081291812928129381294812958129681297812988129981300813018130281303813048130581306813078130881309813108131181312813138131481315813168131781318813198132081321813228132381324813258132681327813288132981330813318133281333813348133581336813378133881339813408134181342813438134481345813468134781348813498135081351813528135381354813558135681357813588135981360813618136281363813648136581366813678136881369813708137181372813738137481375813768137781378813798138081381813828138381384813858138681387813888138981390813918139281393813948139581396813978139881399814008140181402814038140481405814068140781408814098141081411814128141381414814158141681417814188141981420814218142281423814248142581426814278142881429814308143181432814338143481435814368143781438814398144081441814428144381444814458144681447814488144981450814518145281453814548145581456814578145881459814608146181462814638146481465814668146781468814698147081471814728147381474814758147681477814788147981480814818148281483814848148581486814878148881489814908149181492814938149481495814968149781498814998150081501815028150381504815058150681507815088150981510815118151281513815148151581516815178151881519815208152181522815238152481525815268152781528815298153081531815328153381534815358153681537815388153981540815418154281543815448154581546815478154881549815508155181552815538155481555815568155781558815598156081561815628156381564815658156681567815688156981570815718157281573815748157581576815778157881579815808158181582815838158481585815868158781588815898159081591815928159381594815958159681597815988159981600816018160281603816048160581606816078160881609816108161181612816138161481615816168161781618816198162081621816228162381624816258162681627816288162981630816318163281633816348163581636816378163881639816408164181642816438164481645816468164781648816498165081651816528165381654816558165681657816588165981660816618166281663816648166581666816678166881669816708167181672816738167481675816768167781678816798168081681816828168381684816858168681687816888168981690816918169281693816948169581696816978169881699817008170181702817038170481705817068170781708817098171081711817128171381714817158171681717817188171981720817218172281723817248172581726817278172881729817308173181732817338173481735817368173781738817398174081741817428174381744817458174681747817488174981750817518175281753817548175581756817578175881759817608176181762817638176481765817668176781768817698177081771817728177381774817758177681777817788177981780817818178281783817848178581786817878178881789817908179181792817938179481795817968179781798817998180081801818028180381804818058180681807818088180981810818118181281813818148181581816818178181881819818208182181822818238182481825818268182781828818298183081831818328183381834818358183681837818388183981840818418184281843818448184581846818478184881849818508185181852818538185481855818568185781858818598186081861818628186381864818658186681867818688186981870818718187281873818748187581876818778187881879818808188181882818838188481885818868188781888818898189081891818928189381894818958189681897818988189981900819018190281903819048190581906819078190881909819108191181912819138191481915819168191781918819198192081921819228192381924819258192681927819288192981930819318193281933819348193581936819378193881939819408194181942819438194481945819468194781948819498195081951819528195381954819558195681957819588195981960819618196281963819648196581966819678196881969819708197181972819738197481975819768197781978819798198081981819828198381984819858198681987819888198981990819918199281993819948199581996819978199881999820008200182002820038200482005820068200782008820098201082011820128201382014820158201682017820188201982020820218202282023820248202582026820278202882029820308203182032820338203482035820368203782038820398204082041820428204382044820458204682047820488204982050820518205282053820548205582056820578205882059820608206182062820638206482065820668206782068820698207082071820728207382074820758207682077820788207982080820818208282083820848208582086820878208882089820908209182092820938209482095820968209782098820998210082101821028210382104821058210682107821088210982110821118211282113821148211582116821178211882119821208212182122821238212482125821268212782128821298213082131821328213382134821358213682137821388213982140821418214282143821448214582146821478214882149821508215182152821538215482155821568215782158821598216082161821628216382164821658216682167821688216982170821718217282173821748217582176821778217882179821808218182182821838218482185821868218782188821898219082191821928219382194821958219682197821988219982200822018220282203822048220582206822078220882209822108221182212822138221482215822168221782218822198222082221822228222382224822258222682227822288222982230822318223282233822348223582236822378223882239822408224182242822438224482245822468224782248822498225082251822528225382254822558225682257822588225982260822618226282263822648226582266822678226882269822708227182272822738227482275822768227782278822798228082281822828228382284822858228682287822888228982290822918229282293822948229582296822978229882299823008230182302823038230482305823068230782308823098231082311823128231382314823158231682317823188231982320823218232282323823248232582326823278232882329823308233182332823338233482335823368233782338823398234082341823428234382344823458234682347823488234982350823518235282353823548235582356823578235882359823608236182362823638236482365823668236782368823698237082371823728237382374823758237682377823788237982380823818238282383823848238582386823878238882389823908239182392823938239482395823968239782398823998240082401824028240382404824058240682407824088240982410824118241282413824148241582416824178241882419824208242182422824238242482425824268242782428824298243082431824328243382434824358243682437824388243982440824418244282443824448244582446824478244882449824508245182452824538245482455824568245782458824598246082461824628246382464824658246682467824688246982470824718247282473824748247582476824778247882479824808248182482824838248482485824868248782488824898249082491824928249382494824958249682497824988249982500825018250282503825048250582506825078250882509825108251182512825138251482515825168251782518825198252082521825228252382524825258252682527825288252982530825318253282533825348253582536825378253882539825408254182542825438254482545825468254782548825498255082551825528255382554825558255682557825588255982560825618256282563825648256582566825678256882569825708257182572825738257482575825768257782578825798258082581825828258382584825858258682587825888258982590825918259282593825948259582596825978259882599826008260182602826038260482605826068260782608826098261082611826128261382614826158261682617826188261982620826218262282623826248262582626826278262882629826308263182632826338263482635826368263782638826398264082641826428264382644826458264682647826488264982650826518265282653826548265582656826578265882659826608266182662826638266482665826668266782668826698267082671826728267382674826758267682677826788267982680826818268282683826848268582686826878268882689826908269182692826938269482695826968269782698826998270082701827028270382704827058270682707827088270982710827118271282713827148271582716827178271882719827208272182722827238272482725827268272782728827298273082731827328273382734827358273682737827388273982740827418274282743827448274582746827478274882749827508275182752827538275482755827568275782758827598276082761827628276382764827658276682767827688276982770827718277282773827748277582776827778277882779827808278182782827838278482785827868278782788827898279082791827928279382794827958279682797827988279982800828018280282803828048280582806828078280882809828108281182812828138281482815828168281782818828198282082821828228282382824828258282682827828288282982830828318283282833828348283582836828378283882839828408284182842828438284482845828468284782848828498285082851828528285382854828558285682857828588285982860828618286282863828648286582866828678286882869828708287182872828738287482875828768287782878828798288082881828828288382884828858288682887828888288982890828918289282893828948289582896828978289882899829008290182902829038290482905829068290782908829098291082911829128291382914829158291682917829188291982920829218292282923829248292582926829278292882929829308293182932829338293482935829368293782938829398294082941829428294382944829458294682947829488294982950829518295282953829548295582956829578295882959829608296182962829638296482965829668296782968829698297082971829728297382974829758297682977829788297982980829818298282983829848298582986829878298882989829908299182992829938299482995829968299782998829998300083001830028300383004830058300683007830088300983010830118301283013830148301583016830178301883019830208302183022830238302483025830268302783028830298303083031830328303383034830358303683037830388303983040830418304283043830448304583046830478304883049830508305183052830538305483055830568305783058830598306083061830628306383064830658306683067830688306983070830718307283073830748307583076830778307883079830808308183082830838308483085830868308783088830898309083091830928309383094830958309683097830988309983100831018310283103831048310583106831078310883109831108311183112831138311483115831168311783118831198312083121831228312383124831258312683127831288312983130831318313283133831348313583136831378313883139831408314183142831438314483145831468314783148831498315083151831528315383154831558315683157831588315983160831618316283163831648316583166831678316883169831708317183172831738317483175831768317783178831798318083181831828318383184831858318683187831888318983190831918319283193831948319583196831978319883199832008320183202832038320483205832068320783208832098321083211832128321383214832158321683217832188321983220832218322283223832248322583226832278322883229832308323183232832338323483235832368323783238832398324083241832428324383244832458324683247832488324983250832518325283253832548325583256832578325883259832608326183262832638326483265832668326783268832698327083271832728327383274832758327683277832788327983280832818328283283832848328583286832878328883289832908329183292832938329483295832968329783298832998330083301833028330383304833058330683307833088330983310833118331283313833148331583316833178331883319833208332183322833238332483325833268332783328833298333083331833328333383334833358333683337833388333983340833418334283343833448334583346833478334883349833508335183352833538335483355833568335783358833598336083361833628336383364833658336683367833688336983370833718337283373833748337583376833778337883379833808338183382833838338483385833868338783388833898339083391833928339383394833958339683397833988339983400834018340283403834048340583406834078340883409834108341183412834138341483415834168341783418834198342083421834228342383424834258342683427834288342983430834318343283433834348343583436834378343883439834408344183442834438344483445834468344783448834498345083451834528345383454834558345683457834588345983460834618346283463834648346583466834678346883469834708347183472834738347483475834768347783478834798348083481834828348383484834858348683487834888348983490834918349283493834948349583496834978349883499835008350183502835038350483505835068350783508835098351083511835128351383514835158351683517835188351983520835218352283523835248352583526835278352883529835308353183532835338353483535835368353783538835398354083541835428354383544835458354683547835488354983550835518355283553835548355583556835578355883559835608356183562835638356483565835668356783568835698357083571835728357383574835758357683577835788357983580835818358283583835848358583586835878358883589835908359183592835938359483595835968359783598835998360083601836028360383604836058360683607836088360983610836118361283613836148361583616836178361883619836208362183622836238362483625836268362783628836298363083631836328363383634836358363683637836388363983640836418364283643836448364583646836478364883649836508365183652836538365483655836568365783658836598366083661836628366383664836658366683667836688366983670836718367283673836748367583676836778367883679836808368183682836838368483685836868368783688836898369083691836928369383694836958369683697836988369983700837018370283703837048370583706837078370883709837108371183712837138371483715837168371783718837198372083721837228372383724837258372683727837288372983730837318373283733837348373583736837378373883739837408374183742837438374483745837468374783748837498375083751837528375383754837558375683757837588375983760837618376283763837648376583766837678376883769837708377183772837738377483775837768377783778837798378083781837828378383784837858378683787837888378983790837918379283793837948379583796837978379883799838008380183802838038380483805838068380783808838098381083811838128381383814838158381683817838188381983820838218382283823838248382583826838278382883829838308383183832838338383483835838368383783838838398384083841838428384383844838458384683847838488384983850838518385283853838548385583856838578385883859838608386183862838638386483865838668386783868838698387083871838728387383874838758387683877838788387983880838818388283883838848388583886838878388883889838908389183892838938389483895838968389783898838998390083901839028390383904839058390683907839088390983910839118391283913839148391583916839178391883919839208392183922839238392483925839268392783928839298393083931839328393383934839358393683937839388393983940839418394283943839448394583946839478394883949839508395183952839538395483955839568395783958839598396083961839628396383964839658396683967839688396983970839718397283973839748397583976839778397883979839808398183982839838398483985839868398783988839898399083991839928399383994839958399683997839988399984000840018400284003840048400584006840078400884009840108401184012840138401484015840168401784018840198402084021840228402384024840258402684027840288402984030840318403284033840348403584036840378403884039840408404184042840438404484045840468404784048840498405084051840528405384054840558405684057840588405984060840618406284063840648406584066840678406884069840708407184072840738407484075840768407784078840798408084081840828408384084840858408684087840888408984090840918409284093840948409584096840978409884099841008410184102841038410484105841068410784108841098411084111841128411384114841158411684117841188411984120841218412284123841248412584126841278412884129841308413184132841338413484135841368413784138841398414084141841428414384144841458414684147841488414984150841518415284153841548415584156841578415884159841608416184162841638416484165841668416784168841698417084171841728417384174841758417684177841788417984180841818418284183841848418584186841878418884189841908419184192841938419484195841968419784198841998420084201842028420384204842058420684207842088420984210842118421284213842148421584216842178421884219842208422184222842238422484225842268422784228842298423084231842328423384234842358423684237842388423984240842418424284243842448424584246842478424884249842508425184252842538425484255842568425784258842598426084261842628426384264842658426684267842688426984270842718427284273842748427584276842778427884279842808428184282842838428484285842868428784288842898429084291842928429384294842958429684297842988429984300843018430284303843048430584306843078430884309843108431184312843138431484315843168431784318843198432084321843228432384324843258432684327843288432984330843318433284333843348433584336843378433884339843408434184342843438434484345843468434784348843498435084351843528435384354843558435684357843588435984360843618436284363843648436584366843678436884369843708437184372843738437484375843768437784378843798438084381843828438384384843858438684387843888438984390843918439284393843948439584396843978439884399844008440184402844038440484405844068440784408844098441084411844128441384414844158441684417844188441984420844218442284423844248442584426844278442884429844308443184432844338443484435844368443784438844398444084441844428444384444844458444684447844488444984450844518445284453844548445584456844578445884459844608446184462844638446484465844668446784468844698447084471844728447384474844758447684477844788447984480844818448284483844848448584486844878448884489844908449184492844938449484495844968449784498844998450084501845028450384504845058450684507845088450984510845118451284513845148451584516845178451884519845208452184522845238452484525845268452784528845298453084531845328453384534845358453684537845388453984540845418454284543845448454584546845478454884549845508455184552845538455484555845568455784558845598456084561845628456384564845658456684567845688456984570845718457284573845748457584576845778457884579845808458184582845838458484585845868458784588845898459084591845928459384594845958459684597845988459984600846018460284603846048460584606846078460884609846108461184612846138461484615846168461784618846198462084621846228462384624846258462684627846288462984630846318463284633846348463584636846378463884639846408464184642846438464484645846468464784648846498465084651846528465384654846558465684657846588465984660846618466284663846648466584666846678466884669846708467184672846738467484675846768467784678846798468084681846828468384684846858468684687846888468984690846918469284693846948469584696846978469884699847008470184702847038470484705847068470784708847098471084711847128471384714847158471684717847188471984720847218472284723847248472584726847278472884729847308473184732847338473484735847368473784738847398474084741847428474384744847458474684747847488474984750847518475284753847548475584756847578475884759847608476184762847638476484765847668476784768847698477084771847728477384774847758477684777847788477984780847818478284783847848478584786847878478884789847908479184792847938479484795847968479784798847998480084801848028480384804848058480684807848088480984810848118481284813848148481584816848178481884819848208482184822848238482484825848268482784828848298483084831848328483384834848358483684837848388483984840848418484284843848448484584846848478484884849848508485184852848538485484855848568485784858848598486084861848628486384864848658486684867848688486984870848718487284873848748487584876848778487884879848808488184882848838488484885848868488784888848898489084891848928489384894848958489684897848988489984900849018490284903849048490584906849078490884909849108491184912849138491484915849168491784918849198492084921849228492384924849258492684927849288492984930849318493284933849348493584936849378493884939849408494184942849438494484945849468494784948849498495084951849528495384954849558495684957849588495984960849618496284963849648496584966849678496884969849708497184972849738497484975849768497784978849798498084981849828498384984849858498684987849888498984990849918499284993849948499584996849978499884999850008500185002850038500485005850068500785008850098501085011850128501385014850158501685017850188501985020850218502285023850248502585026850278502885029850308503185032850338503485035850368503785038850398504085041850428504385044850458504685047850488504985050850518505285053850548505585056850578505885059850608506185062850638506485065850668506785068850698507085071850728507385074850758507685077850788507985080850818508285083850848508585086850878508885089850908509185092850938509485095850968509785098850998510085101851028510385104851058510685107851088510985110851118511285113851148511585116851178511885119851208512185122851238512485125851268512785128851298513085131851328513385134851358513685137851388513985140851418514285143851448514585146851478514885149851508515185152851538515485155851568515785158851598516085161851628516385164851658516685167851688516985170851718517285173851748517585176851778517885179851808518185182851838518485185851868518785188851898519085191851928519385194851958519685197851988519985200852018520285203852048520585206852078520885209852108521185212852138521485215852168521785218852198522085221852228522385224852258522685227852288522985230852318523285233852348523585236852378523885239852408524185242852438524485245852468524785248852498525085251852528525385254852558525685257852588525985260852618526285263852648526585266852678526885269852708527185272852738527485275852768527785278852798528085281852828528385284852858528685287852888528985290852918529285293852948529585296852978529885299853008530185302853038530485305853068530785308853098531085311853128531385314853158531685317853188531985320853218532285323853248532585326853278532885329853308533185332853338533485335853368533785338853398534085341853428534385344853458534685347853488534985350853518535285353853548535585356853578535885359853608536185362853638536485365853668536785368853698537085371853728537385374853758537685377853788537985380853818538285383853848538585386853878538885389853908539185392853938539485395853968539785398853998540085401854028540385404854058540685407854088540985410854118541285413854148541585416854178541885419854208542185422854238542485425854268542785428854298543085431854328543385434854358543685437854388543985440854418544285443854448544585446854478544885449854508545185452854538545485455854568545785458854598546085461854628546385464854658546685467854688546985470854718547285473854748547585476854778547885479854808548185482854838548485485854868548785488854898549085491854928549385494854958549685497854988549985500855018550285503855048550585506855078550885509855108551185512855138551485515855168551785518855198552085521855228552385524855258552685527855288552985530855318553285533855348553585536855378553885539855408554185542855438554485545855468554785548855498555085551855528555385554855558555685557855588555985560855618556285563855648556585566855678556885569855708557185572855738557485575855768557785578855798558085581855828558385584855858558685587855888558985590855918559285593855948559585596855978559885599856008560185602856038560485605856068560785608856098561085611856128561385614856158561685617856188561985620856218562285623856248562585626856278562885629856308563185632856338563485635856368563785638856398564085641856428564385644856458564685647856488564985650856518565285653856548565585656856578565885659856608566185662856638566485665856668566785668856698567085671856728567385674856758567685677856788567985680856818568285683856848568585686856878568885689856908569185692856938569485695856968569785698856998570085701857028570385704857058570685707857088570985710857118571285713857148571585716857178571885719857208572185722857238572485725857268572785728857298573085731857328573385734857358573685737857388573985740857418574285743857448574585746857478574885749857508575185752857538575485755857568575785758857598576085761857628576385764857658576685767857688576985770857718577285773857748577585776857778577885779857808578185782857838578485785857868578785788857898579085791857928579385794857958579685797857988579985800858018580285803858048580585806858078580885809858108581185812858138581485815858168581785818858198582085821858228582385824858258582685827858288582985830858318583285833858348583585836858378583885839858408584185842858438584485845858468584785848858498585085851858528585385854858558585685857858588585985860858618586285863858648586585866858678586885869858708587185872858738587485875858768587785878858798588085881858828588385884858858588685887858888588985890858918589285893858948589585896858978589885899859008590185902859038590485905859068590785908859098591085911859128591385914859158591685917859188591985920859218592285923859248592585926859278592885929859308593185932859338593485935859368593785938859398594085941859428594385944859458594685947859488594985950859518595285953859548595585956859578595885959859608596185962859638596485965859668596785968859698597085971859728597385974859758597685977859788597985980859818598285983859848598585986859878598885989859908599185992859938599485995859968599785998859998600086001860028600386004860058600686007860088600986010860118601286013860148601586016860178601886019860208602186022860238602486025860268602786028860298603086031860328603386034860358603686037860388603986040860418604286043860448604586046860478604886049860508605186052860538605486055860568605786058860598606086061860628606386064860658606686067860688606986070860718607286073860748607586076860778607886079860808608186082860838608486085860868608786088860898609086091860928609386094860958609686097860988609986100861018610286103861048610586106861078610886109861108611186112861138611486115861168611786118861198612086121861228612386124861258612686127861288612986130861318613286133861348613586136861378613886139861408614186142861438614486145861468614786148861498615086151861528615386154861558615686157861588615986160861618616286163861648616586166861678616886169861708617186172861738617486175861768617786178861798618086181861828618386184861858618686187861888618986190861918619286193861948619586196861978619886199862008620186202862038620486205862068620786208862098621086211862128621386214862158621686217862188621986220862218622286223862248622586226862278622886229862308623186232862338623486235862368623786238862398624086241862428624386244862458624686247862488624986250862518625286253862548625586256862578625886259862608626186262862638626486265862668626786268862698627086271862728627386274862758627686277862788627986280862818628286283862848628586286862878628886289862908629186292862938629486295862968629786298862998630086301863028630386304863058630686307863088630986310863118631286313863148631586316863178631886319863208632186322863238632486325863268632786328863298633086331863328633386334863358633686337863388633986340863418634286343863448634586346863478634886349863508635186352863538635486355863568635786358863598636086361863628636386364863658636686367863688636986370863718637286373863748637586376863778637886379863808638186382863838638486385863868638786388863898639086391863928639386394863958639686397863988639986400864018640286403864048640586406864078640886409864108641186412864138641486415864168641786418864198642086421864228642386424864258642686427864288642986430864318643286433864348643586436864378643886439864408644186442864438644486445864468644786448864498645086451864528645386454864558645686457864588645986460864618646286463864648646586466864678646886469864708647186472864738647486475864768647786478864798648086481864828648386484864858648686487864888648986490864918649286493864948649586496864978649886499865008650186502865038650486505865068650786508865098651086511865128651386514865158651686517865188651986520865218652286523865248652586526865278652886529865308653186532865338653486535865368653786538865398654086541865428654386544865458654686547865488654986550865518655286553865548655586556865578655886559865608656186562865638656486565865668656786568865698657086571865728657386574865758657686577865788657986580865818658286583865848658586586865878658886589865908659186592865938659486595865968659786598865998660086601866028660386604866058660686607866088660986610866118661286613866148661586616866178661886619866208662186622866238662486625866268662786628866298663086631866328663386634866358663686637866388663986640866418664286643866448664586646866478664886649866508665186652866538665486655866568665786658866598666086661866628666386664866658666686667866688666986670866718667286673866748667586676866778667886679866808668186682866838668486685866868668786688866898669086691866928669386694866958669686697866988669986700867018670286703867048670586706867078670886709867108671186712867138671486715867168671786718867198672086721867228672386724867258672686727867288672986730867318673286733867348673586736867378673886739867408674186742867438674486745867468674786748867498675086751867528675386754867558675686757867588675986760867618676286763867648676586766867678676886769867708677186772867738677486775867768677786778867798678086781867828678386784867858678686787867888678986790867918679286793867948679586796867978679886799868008680186802868038680486805868068680786808868098681086811868128681386814868158681686817868188681986820868218682286823868248682586826868278682886829868308683186832868338683486835868368683786838868398684086841868428684386844868458684686847868488684986850868518685286853868548685586856868578685886859868608686186862868638686486865868668686786868868698687086871868728687386874868758687686877868788687986880868818688286883868848688586886868878688886889868908689186892868938689486895868968689786898868998690086901869028690386904869058690686907869088690986910869118691286913869148691586916869178691886919869208692186922869238692486925869268692786928869298693086931869328693386934869358693686937869388693986940869418694286943869448694586946869478694886949869508695186952869538695486955869568695786958869598696086961869628696386964869658696686967869688696986970869718697286973869748697586976869778697886979869808698186982869838698486985869868698786988869898699086991869928699386994869958699686997869988699987000870018700287003870048700587006870078700887009870108701187012870138701487015870168701787018870198702087021870228702387024870258702687027870288702987030870318703287033870348703587036870378703887039870408704187042870438704487045870468704787048870498705087051870528705387054870558705687057870588705987060870618706287063870648706587066870678706887069870708707187072870738707487075870768707787078870798708087081870828708387084870858708687087870888708987090870918709287093870948709587096870978709887099871008710187102871038710487105871068710787108871098711087111871128711387114871158711687117871188711987120871218712287123871248712587126871278712887129871308713187132871338713487135871368713787138871398714087141871428714387144871458714687147871488714987150871518715287153871548715587156871578715887159871608716187162871638716487165871668716787168871698717087171871728717387174871758717687177871788717987180871818718287183871848718587186871878718887189871908719187192871938719487195871968719787198871998720087201872028720387204872058720687207872088720987210872118721287213872148721587216872178721887219872208722187222872238722487225872268722787228872298723087231872328723387234872358723687237872388723987240872418724287243872448724587246872478724887249872508725187252872538725487255872568725787258872598726087261872628726387264872658726687267872688726987270872718727287273872748727587276872778727887279872808728187282872838728487285872868728787288872898729087291872928729387294872958729687297872988729987300873018730287303873048730587306873078730887309873108731187312873138731487315873168731787318873198732087321873228732387324873258732687327873288732987330873318733287333873348733587336873378733887339873408734187342873438734487345873468734787348873498735087351873528735387354873558735687357873588735987360873618736287363873648736587366873678736887369873708737187372873738737487375873768737787378873798738087381873828738387384873858738687387873888738987390873918739287393873948739587396873978739887399874008740187402874038740487405874068740787408874098741087411874128741387414874158741687417874188741987420874218742287423874248742587426874278742887429874308743187432874338743487435874368743787438874398744087441874428744387444874458744687447874488744987450874518745287453874548745587456874578745887459874608746187462874638746487465874668746787468874698747087471874728747387474874758747687477874788747987480874818748287483874848748587486874878748887489874908749187492874938749487495874968749787498874998750087501875028750387504875058750687507875088750987510875118751287513875148751587516875178751887519875208752187522875238752487525875268752787528875298753087531875328753387534875358753687537875388753987540875418754287543875448754587546875478754887549875508755187552875538755487555875568755787558875598756087561875628756387564875658756687567875688756987570875718757287573875748757587576875778757887579875808758187582875838758487585875868758787588875898759087591875928759387594875958759687597875988759987600876018760287603876048760587606876078760887609876108761187612876138761487615876168761787618876198762087621876228762387624876258762687627876288762987630876318763287633876348763587636876378763887639876408764187642876438764487645876468764787648876498765087651876528765387654876558765687657876588765987660876618766287663876648766587666876678766887669876708767187672876738767487675876768767787678876798768087681876828768387684876858768687687876888768987690876918769287693876948769587696876978769887699877008770187702877038770487705877068770787708877098771087711877128771387714877158771687717877188771987720877218772287723877248772587726877278772887729877308773187732877338773487735877368773787738877398774087741877428774387744877458774687747877488774987750877518775287753877548775587756877578775887759877608776187762877638776487765877668776787768877698777087771877728777387774877758777687777877788777987780877818778287783877848778587786877878778887789877908779187792877938779487795877968779787798877998780087801878028780387804878058780687807878088780987810878118781287813878148781587816878178781887819878208782187822878238782487825878268782787828878298783087831878328783387834878358783687837878388783987840878418784287843878448784587846878478784887849878508785187852878538785487855878568785787858878598786087861878628786387864878658786687867878688786987870878718787287873878748787587876878778787887879878808788187882878838788487885878868788787888878898789087891878928789387894878958789687897878988789987900879018790287903879048790587906879078790887909879108791187912879138791487915879168791787918879198792087921879228792387924879258792687927879288792987930879318793287933879348793587936879378793887939879408794187942879438794487945879468794787948879498795087951879528795387954879558795687957879588795987960879618796287963879648796587966879678796887969879708797187972879738797487975879768797787978879798798087981879828798387984879858798687987879888798987990879918799287993879948799587996879978799887999880008800188002880038800488005880068800788008880098801088011880128801388014880158801688017880188801988020880218802288023880248802588026880278802888029880308803188032880338803488035880368803788038880398804088041880428804388044880458804688047880488804988050880518805288053880548805588056880578805888059880608806188062880638806488065880668806788068880698807088071880728807388074880758807688077880788807988080880818808288083880848808588086880878808888089880908809188092880938809488095880968809788098880998810088101881028810388104881058810688107881088810988110881118811288113881148811588116881178811888119881208812188122881238812488125881268812788128881298813088131881328813388134881358813688137881388813988140881418814288143881448814588146881478814888149881508815188152881538815488155881568815788158881598816088161881628816388164881658816688167881688816988170881718817288173881748817588176881778817888179881808818188182881838818488185881868818788188881898819088191881928819388194881958819688197881988819988200882018820288203882048820588206882078820888209882108821188212882138821488215882168821788218882198822088221882228822388224882258822688227882288822988230882318823288233882348823588236882378823888239882408824188242882438824488245882468824788248882498825088251882528825388254882558825688257882588825988260882618826288263882648826588266882678826888269882708827188272882738827488275882768827788278882798828088281882828828388284882858828688287882888828988290882918829288293882948829588296882978829888299883008830188302883038830488305883068830788308883098831088311883128831388314883158831688317883188831988320883218832288323883248832588326883278832888329883308833188332883338833488335883368833788338883398834088341883428834388344883458834688347883488834988350883518835288353883548835588356883578835888359883608836188362883638836488365883668836788368883698837088371883728837388374883758837688377883788837988380883818838288383883848838588386883878838888389883908839188392883938839488395883968839788398883998840088401884028840388404884058840688407884088840988410884118841288413884148841588416884178841888419884208842188422884238842488425884268842788428884298843088431884328843388434884358843688437884388843988440884418844288443884448844588446884478844888449884508845188452884538845488455884568845788458884598846088461884628846388464884658846688467884688846988470884718847288473884748847588476884778847888479884808848188482884838848488485884868848788488884898849088491884928849388494884958849688497884988849988500885018850288503885048850588506885078850888509885108851188512885138851488515885168851788518885198852088521885228852388524885258852688527885288852988530885318853288533885348853588536885378853888539885408854188542885438854488545885468854788548885498855088551885528855388554885558855688557885588855988560885618856288563885648856588566885678856888569885708857188572885738857488575885768857788578885798858088581885828858388584885858858688587885888858988590885918859288593885948859588596885978859888599886008860188602886038860488605886068860788608886098861088611886128861388614886158861688617886188861988620886218862288623886248862588626886278862888629886308863188632886338863488635886368863788638886398864088641886428864388644886458864688647886488864988650886518865288653886548865588656886578865888659886608866188662886638866488665886668866788668886698867088671886728867388674886758867688677886788867988680886818868288683886848868588686886878868888689886908869188692886938869488695886968869788698886998870088701887028870388704887058870688707887088870988710887118871288713887148871588716887178871888719887208872188722887238872488725887268872788728887298873088731887328873388734887358873688737887388873988740887418874288743887448874588746887478874888749887508875188752887538875488755887568875788758887598876088761887628876388764887658876688767887688876988770887718877288773887748877588776887778877888779887808878188782887838878488785887868878788788887898879088791887928879388794887958879688797887988879988800888018880288803888048880588806888078880888809888108881188812888138881488815888168881788818888198882088821888228882388824888258882688827888288882988830888318883288833888348883588836888378883888839888408884188842888438884488845888468884788848888498885088851888528885388854888558885688857888588885988860888618886288863888648886588866888678886888869888708887188872888738887488875888768887788878888798888088881888828888388884888858888688887888888888988890888918889288893888948889588896888978889888899889008890188902889038890488905889068890788908889098891088911889128891388914889158891688917889188891988920889218892288923889248892588926889278892888929889308893188932889338893488935889368893788938889398894088941889428894388944889458894688947889488894988950889518895288953889548895588956889578895888959889608896188962889638896488965889668896788968889698897088971889728897388974889758897688977889788897988980889818898288983889848898588986889878898888989889908899188992889938899488995889968899788998889998900089001890028900389004890058900689007890088900989010890118901289013890148901589016890178901889019890208902189022890238902489025890268902789028890298903089031890328903389034890358903689037890388903989040890418904289043890448904589046890478904889049890508905189052890538905489055890568905789058890598906089061890628906389064890658906689067890688906989070890718907289073890748907589076890778907889079890808908189082890838908489085890868908789088890898909089091890928909389094890958909689097890988909989100891018910289103891048910589106891078910889109891108911189112891138911489115891168911789118891198912089121891228912389124891258912689127891288912989130891318913289133891348913589136891378913889139891408914189142891438914489145891468914789148891498915089151891528915389154891558915689157891588915989160891618916289163891648916589166891678916889169891708917189172891738917489175891768917789178891798918089181891828918389184891858918689187891888918989190891918919289193891948919589196891978919889199892008920189202892038920489205892068920789208892098921089211892128921389214892158921689217892188921989220892218922289223892248922589226892278922889229892308923189232892338923489235892368923789238892398924089241892428924389244892458924689247892488924989250892518925289253892548925589256892578925889259892608926189262892638926489265892668926789268892698927089271892728927389274892758927689277892788927989280892818928289283892848928589286892878928889289892908929189292892938929489295892968929789298892998930089301893028930389304893058930689307893088930989310893118931289313893148931589316893178931889319893208932189322893238932489325893268932789328893298933089331893328933389334893358933689337893388933989340893418934289343893448934589346893478934889349893508935189352893538935489355893568935789358893598936089361893628936389364893658936689367893688936989370893718937289373893748937589376893778937889379893808938189382893838938489385893868938789388893898939089391893928939389394893958939689397893988939989400894018940289403894048940589406894078940889409894108941189412894138941489415894168941789418894198942089421894228942389424894258942689427894288942989430894318943289433894348943589436894378943889439894408944189442894438944489445894468944789448894498945089451894528945389454894558945689457894588945989460894618946289463894648946589466894678946889469894708947189472894738947489475894768947789478894798948089481894828948389484894858948689487894888948989490894918949289493894948949589496894978949889499895008950189502895038950489505895068950789508895098951089511895128951389514895158951689517895188951989520895218952289523895248952589526895278952889529895308953189532895338953489535895368953789538895398954089541895428954389544895458954689547895488954989550895518955289553895548955589556895578955889559895608956189562895638956489565895668956789568895698957089571895728957389574895758957689577895788957989580895818958289583895848958589586895878958889589895908959189592895938959489595895968959789598895998960089601896028960389604896058960689607896088960989610896118961289613896148961589616896178961889619896208962189622896238962489625896268962789628896298963089631896328963389634896358963689637896388963989640896418964289643896448964589646896478964889649896508965189652896538965489655896568965789658896598966089661896628966389664896658966689667896688966989670896718967289673896748967589676896778967889679896808968189682896838968489685896868968789688896898969089691896928969389694896958969689697896988969989700897018970289703897048970589706897078970889709897108971189712897138971489715897168971789718897198972089721897228972389724897258972689727897288972989730897318973289733897348973589736897378973889739897408974189742897438974489745897468974789748897498975089751897528975389754897558975689757897588975989760897618976289763897648976589766897678976889769897708977189772897738977489775897768977789778897798978089781897828978389784897858978689787897888978989790897918979289793897948979589796897978979889799898008980189802898038980489805898068980789808898098981089811898128981389814898158981689817898188981989820898218982289823898248982589826898278982889829898308983189832898338983489835898368983789838898398984089841898428984389844898458984689847898488984989850898518985289853898548985589856898578985889859898608986189862898638986489865898668986789868898698987089871898728987389874898758987689877898788987989880898818988289883898848988589886898878988889889898908989189892898938989489895898968989789898898998990089901899028990389904899058990689907899088990989910899118991289913899148991589916899178991889919899208992189922899238992489925899268992789928899298993089931899328993389934899358993689937899388993989940899418994289943899448994589946899478994889949899508995189952899538995489955899568995789958899598996089961899628996389964899658996689967899688996989970899718997289973899748997589976899778997889979899808998189982899838998489985899868998789988899898999089991899928999389994899958999689997899988999990000900019000290003900049000590006900079000890009900109001190012900139001490015900169001790018900199002090021900229002390024900259002690027900289002990030900319003290033900349003590036900379003890039900409004190042900439004490045900469004790048900499005090051900529005390054900559005690057900589005990060900619006290063900649006590066900679006890069900709007190072900739007490075900769007790078900799008090081900829008390084900859008690087900889008990090900919009290093900949009590096900979009890099901009010190102901039010490105901069010790108901099011090111901129011390114901159011690117901189011990120901219012290123901249012590126901279012890129901309013190132901339013490135901369013790138901399014090141901429014390144901459014690147901489014990150901519015290153901549015590156901579015890159901609016190162901639016490165901669016790168901699017090171901729017390174901759017690177901789017990180901819018290183901849018590186901879018890189901909019190192901939019490195901969019790198901999020090201902029020390204902059020690207902089020990210902119021290213902149021590216902179021890219902209022190222902239022490225902269022790228902299023090231902329023390234902359023690237902389023990240902419024290243902449024590246902479024890249902509025190252902539025490255902569025790258902599026090261902629026390264902659026690267902689026990270902719027290273902749027590276902779027890279902809028190282902839028490285902869028790288902899029090291902929029390294902959029690297902989029990300903019030290303903049030590306903079030890309903109031190312903139031490315903169031790318903199032090321903229032390324903259032690327903289032990330903319033290333903349033590336903379033890339903409034190342903439034490345903469034790348903499035090351903529035390354903559035690357903589035990360903619036290363903649036590366903679036890369903709037190372903739037490375903769037790378903799038090381903829038390384903859038690387903889038990390903919039290393903949039590396903979039890399904009040190402904039040490405904069040790408904099041090411904129041390414904159041690417904189041990420904219042290423904249042590426904279042890429904309043190432904339043490435904369043790438904399044090441904429044390444904459044690447904489044990450904519045290453904549045590456904579045890459904609046190462904639046490465904669046790468904699047090471904729047390474904759047690477904789047990480904819048290483904849048590486904879048890489904909049190492904939049490495904969049790498904999050090501905029050390504905059050690507905089050990510905119051290513905149051590516905179051890519905209052190522905239052490525905269052790528905299053090531905329053390534905359053690537905389053990540905419054290543905449054590546905479054890549905509055190552905539055490555905569055790558905599056090561905629056390564905659056690567905689056990570905719057290573905749057590576905779057890579905809058190582905839058490585905869058790588905899059090591905929059390594905959059690597905989059990600906019060290603906049060590606906079060890609906109061190612906139061490615906169061790618906199062090621906229062390624906259062690627906289062990630906319063290633906349063590636906379063890639906409064190642906439064490645906469064790648906499065090651906529065390654906559065690657906589065990660906619066290663906649066590666906679066890669906709067190672906739067490675906769067790678906799068090681906829068390684906859068690687906889068990690906919069290693906949069590696906979069890699907009070190702907039070490705907069070790708907099071090711907129071390714907159071690717907189071990720907219072290723907249072590726907279072890729907309073190732907339073490735907369073790738907399074090741907429074390744907459074690747907489074990750907519075290753907549075590756907579075890759907609076190762907639076490765907669076790768907699077090771907729077390774907759077690777907789077990780907819078290783907849078590786907879078890789907909079190792907939079490795907969079790798907999080090801908029080390804908059080690807908089080990810908119081290813908149081590816908179081890819908209082190822908239082490825908269082790828908299083090831908329083390834908359083690837908389083990840908419084290843908449084590846908479084890849908509085190852908539085490855908569085790858908599086090861908629086390864908659086690867908689086990870908719087290873908749087590876908779087890879908809088190882908839088490885908869088790888908899089090891908929089390894908959089690897908989089990900909019090290903909049090590906909079090890909909109091190912909139091490915909169091790918909199092090921909229092390924909259092690927909289092990930909319093290933909349093590936909379093890939909409094190942909439094490945909469094790948909499095090951909529095390954909559095690957909589095990960909619096290963909649096590966909679096890969909709097190972909739097490975909769097790978909799098090981909829098390984909859098690987909889098990990909919099290993909949099590996909979099890999910009100191002910039100491005910069100791008910099101091011910129101391014910159101691017910189101991020910219102291023910249102591026910279102891029910309103191032910339103491035910369103791038910399104091041910429104391044910459104691047910489104991050910519105291053910549105591056910579105891059910609106191062910639106491065910669106791068910699107091071910729107391074910759107691077910789107991080910819108291083910849108591086910879108891089910909109191092910939109491095910969109791098910999110091101911029110391104911059110691107911089110991110911119111291113911149111591116911179111891119911209112191122911239112491125911269112791128911299113091131911329113391134911359113691137911389113991140911419114291143911449114591146911479114891149911509115191152911539115491155911569115791158911599116091161911629116391164911659116691167911689116991170911719117291173911749117591176911779117891179911809118191182911839118491185911869118791188911899119091191911929119391194911959119691197911989119991200912019120291203912049120591206912079120891209912109121191212912139121491215912169121791218912199122091221912229122391224912259122691227912289122991230912319123291233912349123591236912379123891239912409124191242912439124491245912469124791248912499125091251912529125391254912559125691257912589125991260912619126291263912649126591266912679126891269912709127191272912739127491275912769127791278912799128091281912829128391284912859128691287912889128991290912919129291293912949129591296912979129891299913009130191302913039130491305913069130791308913099131091311913129131391314913159131691317913189131991320913219132291323913249132591326913279132891329913309133191332913339133491335913369133791338913399134091341913429134391344913459134691347913489134991350913519135291353913549135591356913579135891359913609136191362913639136491365913669136791368913699137091371913729137391374913759137691377913789137991380913819138291383913849138591386913879138891389913909139191392913939139491395913969139791398913999140091401914029140391404914059140691407914089140991410914119141291413914149141591416914179141891419914209142191422914239142491425914269142791428914299143091431914329143391434914359143691437914389143991440914419144291443914449144591446914479144891449914509145191452914539145491455914569145791458914599146091461914629146391464914659146691467914689146991470914719147291473914749147591476914779147891479914809148191482914839148491485914869148791488914899149091491914929149391494914959149691497914989149991500915019150291503915049150591506915079150891509915109151191512915139151491515915169151791518915199152091521915229152391524915259152691527915289152991530915319153291533915349153591536915379153891539915409154191542915439154491545915469154791548915499155091551915529155391554915559155691557915589155991560915619156291563915649156591566915679156891569915709157191572915739157491575915769157791578915799158091581915829158391584915859158691587915889158991590915919159291593915949159591596915979159891599916009160191602916039160491605916069160791608916099161091611916129161391614916159161691617916189161991620916219162291623916249162591626916279162891629916309163191632916339163491635916369163791638916399164091641916429164391644916459164691647916489164991650916519165291653916549165591656916579165891659916609166191662916639166491665916669166791668916699167091671916729167391674916759167691677916789167991680916819168291683916849168591686916879168891689916909169191692916939169491695916969169791698916999170091701917029170391704917059170691707917089170991710917119171291713917149171591716917179171891719917209172191722917239172491725917269172791728917299173091731917329173391734917359173691737917389173991740917419174291743917449174591746917479174891749917509175191752917539175491755917569175791758917599176091761917629176391764917659176691767917689176991770917719177291773917749177591776917779177891779917809178191782917839178491785917869178791788917899179091791917929179391794917959179691797917989179991800918019180291803918049180591806918079180891809918109181191812918139181491815918169181791818918199182091821918229182391824918259182691827918289182991830918319183291833918349183591836918379183891839918409184191842918439184491845918469184791848918499185091851918529185391854918559185691857918589185991860918619186291863918649186591866918679186891869918709187191872918739187491875918769187791878918799188091881918829188391884918859188691887918889188991890918919189291893918949189591896918979189891899919009190191902919039190491905919069190791908919099191091911919129191391914919159191691917919189191991920919219192291923919249192591926919279192891929919309193191932919339193491935919369193791938919399194091941919429194391944919459194691947919489194991950919519195291953919549195591956919579195891959919609196191962919639196491965919669196791968919699197091971919729197391974919759197691977919789197991980919819198291983919849198591986919879198891989919909199191992919939199491995919969199791998919999200092001920029200392004920059200692007920089200992010920119201292013920149201592016920179201892019920209202192022920239202492025920269202792028920299203092031920329203392034920359203692037920389203992040920419204292043920449204592046920479204892049920509205192052920539205492055920569205792058920599206092061920629206392064920659206692067920689206992070920719207292073920749207592076920779207892079920809208192082920839208492085920869208792088920899209092091920929209392094920959209692097920989209992100921019210292103921049210592106921079210892109921109211192112921139211492115921169211792118921199212092121921229212392124921259212692127921289212992130921319213292133921349213592136921379213892139921409214192142921439214492145921469214792148921499215092151921529215392154921559215692157921589215992160921619216292163921649216592166921679216892169921709217192172921739217492175921769217792178921799218092181921829218392184921859218692187921889218992190921919219292193921949219592196921979219892199922009220192202922039220492205922069220792208922099221092211922129221392214922159221692217922189221992220922219222292223922249222592226922279222892229922309223192232922339223492235922369223792238922399224092241922429224392244922459224692247922489224992250922519225292253922549225592256922579225892259922609226192262922639226492265922669226792268922699227092271922729227392274922759227692277922789227992280922819228292283922849228592286922879228892289922909229192292922939229492295922969229792298922999230092301923029230392304923059230692307923089230992310923119231292313923149231592316923179231892319923209232192322923239232492325923269232792328923299233092331923329233392334923359233692337923389233992340923419234292343923449234592346923479234892349923509235192352923539235492355923569235792358923599236092361923629236392364923659236692367923689236992370923719237292373923749237592376923779237892379923809238192382923839238492385923869238792388923899239092391923929239392394923959239692397923989239992400924019240292403924049240592406924079240892409924109241192412924139241492415924169241792418924199242092421924229242392424924259242692427924289242992430924319243292433924349243592436924379243892439924409244192442924439244492445924469244792448924499245092451924529245392454924559245692457924589245992460924619246292463924649246592466924679246892469924709247192472924739247492475924769247792478924799248092481924829248392484924859248692487924889248992490924919249292493924949249592496924979249892499925009250192502925039250492505925069250792508925099251092511925129251392514925159251692517925189251992520925219252292523925249252592526925279252892529925309253192532925339253492535925369253792538925399254092541925429254392544925459254692547925489254992550925519255292553925549255592556925579255892559925609256192562925639256492565925669256792568925699257092571925729257392574925759257692577925789257992580925819258292583925849258592586925879258892589925909259192592925939259492595925969259792598925999260092601926029260392604926059260692607926089260992610926119261292613926149261592616926179261892619926209262192622926239262492625926269262792628926299263092631926329263392634926359263692637926389263992640926419264292643926449264592646926479264892649926509265192652926539265492655926569265792658926599266092661926629266392664926659266692667926689266992670926719267292673926749267592676926779267892679926809268192682926839268492685926869268792688926899269092691926929269392694926959269692697926989269992700927019270292703927049270592706927079270892709927109271192712927139271492715927169271792718927199272092721927229272392724927259272692727927289272992730927319273292733927349273592736927379273892739927409274192742927439274492745927469274792748927499275092751927529275392754927559275692757927589275992760927619276292763927649276592766927679276892769927709277192772927739277492775927769277792778927799278092781927829278392784927859278692787927889278992790927919279292793927949279592796927979279892799928009280192802928039280492805928069280792808928099281092811928129281392814928159281692817928189281992820928219282292823928249282592826928279282892829928309283192832928339283492835928369283792838928399284092841928429284392844928459284692847928489284992850928519285292853928549285592856928579285892859928609286192862928639286492865928669286792868928699287092871928729287392874928759287692877928789287992880928819288292883928849288592886928879288892889928909289192892928939289492895928969289792898928999290092901929029290392904929059290692907929089290992910929119291292913929149291592916929179291892919929209292192922929239292492925929269292792928929299293092931929329293392934929359293692937929389293992940929419294292943929449294592946929479294892949929509295192952929539295492955929569295792958929599296092961929629296392964929659296692967929689296992970929719297292973929749297592976929779297892979929809298192982929839298492985929869298792988929899299092991929929299392994929959299692997929989299993000930019300293003930049300593006930079300893009930109301193012930139301493015930169301793018930199302093021930229302393024930259302693027930289302993030930319303293033930349303593036930379303893039930409304193042930439304493045930469304793048930499305093051930529305393054930559305693057930589305993060930619306293063930649306593066930679306893069930709307193072930739307493075930769307793078930799308093081930829308393084930859308693087930889308993090930919309293093930949309593096930979309893099931009310193102931039310493105931069310793108931099311093111931129311393114931159311693117931189311993120931219312293123931249312593126931279312893129931309313193132931339313493135931369313793138931399314093141931429314393144931459314693147931489314993150931519315293153931549315593156931579315893159931609316193162931639316493165931669316793168931699317093171931729317393174931759317693177931789317993180931819318293183931849318593186931879318893189931909319193192931939319493195931969319793198931999320093201932029320393204932059320693207932089320993210932119321293213932149321593216932179321893219932209322193222932239322493225932269322793228932299323093231932329323393234932359323693237932389323993240932419324293243932449324593246932479324893249932509325193252932539325493255932569325793258932599326093261932629326393264932659326693267932689326993270932719327293273932749327593276932779327893279932809328193282932839328493285932869328793288932899329093291932929329393294932959329693297932989329993300933019330293303933049330593306933079330893309933109331193312933139331493315933169331793318933199332093321933229332393324933259332693327933289332993330933319333293333933349333593336933379333893339933409334193342933439334493345933469334793348933499335093351933529335393354933559335693357933589335993360933619336293363933649336593366933679336893369933709337193372933739337493375933769337793378933799338093381933829338393384933859338693387933889338993390933919339293393933949339593396933979339893399934009340193402934039340493405934069340793408934099341093411934129341393414934159341693417934189341993420934219342293423934249342593426934279342893429934309343193432934339343493435934369343793438934399344093441934429344393444934459344693447934489344993450934519345293453934549345593456934579345893459934609346193462934639346493465934669346793468934699347093471934729347393474934759347693477934789347993480934819348293483934849348593486934879348893489934909349193492934939349493495934969349793498934999350093501935029350393504935059350693507935089350993510935119351293513935149351593516935179351893519935209352193522935239352493525935269352793528935299353093531935329353393534935359353693537935389353993540935419354293543935449354593546935479354893549935509355193552935539355493555935569355793558935599356093561935629356393564935659356693567935689356993570935719357293573935749357593576935779357893579935809358193582935839358493585935869358793588935899359093591935929359393594935959359693597935989359993600936019360293603936049360593606936079360893609936109361193612936139361493615936169361793618936199362093621936229362393624936259362693627936289362993630936319363293633936349363593636936379363893639936409364193642936439364493645936469364793648936499365093651936529365393654936559365693657936589365993660936619366293663936649366593666936679366893669936709367193672936739367493675936769367793678936799368093681936829368393684936859368693687936889368993690936919369293693936949369593696936979369893699937009370193702937039370493705937069370793708937099371093711937129371393714937159371693717937189371993720937219372293723937249372593726937279372893729937309373193732937339373493735937369373793738937399374093741937429374393744937459374693747937489374993750937519375293753937549375593756937579375893759937609376193762937639376493765937669376793768937699377093771937729377393774937759377693777937789377993780937819378293783937849378593786937879378893789937909379193792937939379493795937969379793798937999380093801938029380393804938059380693807938089380993810938119381293813938149381593816938179381893819938209382193822938239382493825938269382793828938299383093831938329383393834938359383693837938389383993840938419384293843938449384593846938479384893849938509385193852938539385493855938569385793858938599386093861938629386393864938659386693867938689386993870938719387293873938749387593876938779387893879938809388193882938839388493885938869388793888938899389093891938929389393894938959389693897938989389993900939019390293903939049390593906939079390893909939109391193912939139391493915939169391793918939199392093921939229392393924939259392693927939289392993930939319393293933939349393593936939379393893939939409394193942939439394493945939469394793948939499395093951939529395393954939559395693957939589395993960939619396293963939649396593966939679396893969939709397193972939739397493975939769397793978939799398093981939829398393984939859398693987939889398993990939919399293993939949399593996939979399893999940009400194002940039400494005940069400794008940099401094011940129401394014940159401694017940189401994020940219402294023940249402594026940279402894029940309403194032940339403494035940369403794038940399404094041940429404394044940459404694047940489404994050940519405294053940549405594056940579405894059940609406194062940639406494065940669406794068940699407094071940729407394074940759407694077940789407994080940819408294083940849408594086940879408894089940909409194092940939409494095940969409794098940999410094101941029410394104941059410694107941089410994110941119411294113941149411594116941179411894119941209412194122941239412494125941269412794128941299413094131941329413394134941359413694137941389413994140941419414294143941449414594146941479414894149941509415194152941539415494155941569415794158941599416094161941629416394164941659416694167941689416994170941719417294173941749417594176941779417894179941809418194182941839418494185941869418794188941899419094191941929419394194941959419694197941989419994200942019420294203942049420594206942079420894209942109421194212942139421494215942169421794218942199422094221942229422394224942259422694227942289422994230942319423294233942349423594236942379423894239942409424194242942439424494245942469424794248942499425094251942529425394254942559425694257942589425994260942619426294263942649426594266942679426894269942709427194272942739427494275942769427794278942799428094281942829428394284942859428694287942889428994290942919429294293942949429594296942979429894299943009430194302943039430494305943069430794308943099431094311943129431394314943159431694317943189431994320943219432294323943249432594326943279432894329943309433194332943339433494335943369433794338943399434094341943429434394344943459434694347943489434994350943519435294353943549435594356943579435894359943609436194362943639436494365943669436794368943699437094371943729437394374943759437694377943789437994380943819438294383943849438594386943879438894389943909439194392943939439494395943969439794398943999440094401944029440394404944059440694407944089440994410944119441294413944149441594416944179441894419944209442194422944239442494425944269442794428944299443094431944329443394434944359443694437944389443994440944419444294443944449444594446944479444894449944509445194452944539445494455944569445794458944599446094461944629446394464944659446694467944689446994470944719447294473944749447594476944779447894479944809448194482944839448494485944869448794488944899449094491944929449394494944959449694497944989449994500945019450294503945049450594506945079450894509945109451194512945139451494515945169451794518945199452094521945229452394524945259452694527945289452994530945319453294533945349453594536945379453894539945409454194542945439454494545945469454794548945499455094551945529455394554945559455694557945589455994560945619456294563945649456594566945679456894569945709457194572945739457494575945769457794578945799458094581945829458394584945859458694587945889458994590945919459294593945949459594596945979459894599946009460194602946039460494605946069460794608946099461094611946129461394614946159461694617946189461994620946219462294623946249462594626946279462894629946309463194632946339463494635946369463794638946399464094641946429464394644946459464694647946489464994650946519465294653946549465594656946579465894659946609466194662946639466494665946669466794668946699467094671946729467394674946759467694677946789467994680946819468294683946849468594686946879468894689946909469194692946939469494695946969469794698946999470094701947029470394704947059470694707947089470994710947119471294713947149471594716947179471894719947209472194722947239472494725947269472794728947299473094731947329473394734947359473694737947389473994740947419474294743947449474594746947479474894749947509475194752947539475494755947569475794758947599476094761947629476394764947659476694767947689476994770947719477294773947749477594776947779477894779947809478194782947839478494785947869478794788947899479094791947929479394794947959479694797947989479994800948019480294803948049480594806948079480894809948109481194812948139481494815948169481794818948199482094821948229482394824948259482694827948289482994830948319483294833948349483594836948379483894839948409484194842948439484494845948469484794848948499485094851948529485394854948559485694857948589485994860948619486294863948649486594866948679486894869948709487194872948739487494875948769487794878948799488094881948829488394884948859488694887948889488994890948919489294893948949489594896948979489894899949009490194902949039490494905949069490794908949099491094911949129491394914949159491694917949189491994920949219492294923949249492594926949279492894929949309493194932949339493494935949369493794938949399494094941949429494394944949459494694947949489494994950949519495294953949549495594956949579495894959949609496194962949639496494965949669496794968949699497094971949729497394974949759497694977949789497994980949819498294983949849498594986949879498894989949909499194992949939499494995949969499794998949999500095001950029500395004950059500695007950089500995010950119501295013950149501595016950179501895019950209502195022950239502495025950269502795028950299503095031950329503395034950359503695037950389503995040950419504295043950449504595046950479504895049950509505195052950539505495055950569505795058950599506095061950629506395064950659506695067950689506995070950719507295073950749507595076950779507895079950809508195082950839508495085950869508795088950899509095091950929509395094950959509695097950989509995100951019510295103951049510595106951079510895109951109511195112951139511495115951169511795118951199512095121951229512395124951259512695127951289512995130951319513295133951349513595136951379513895139951409514195142951439514495145951469514795148951499515095151951529515395154951559515695157951589515995160951619516295163951649516595166951679516895169951709517195172951739517495175951769517795178951799518095181951829518395184951859518695187951889518995190951919519295193951949519595196951979519895199952009520195202952039520495205952069520795208952099521095211952129521395214952159521695217952189521995220952219522295223952249522595226952279522895229952309523195232952339523495235952369523795238952399524095241952429524395244952459524695247952489524995250952519525295253952549525595256952579525895259952609526195262952639526495265952669526795268952699527095271952729527395274952759527695277952789527995280952819528295283952849528595286952879528895289952909529195292952939529495295952969529795298952999530095301953029530395304953059530695307953089530995310953119531295313953149531595316953179531895319953209532195322953239532495325953269532795328953299533095331953329533395334953359533695337953389533995340953419534295343953449534595346953479534895349953509535195352953539535495355953569535795358953599536095361953629536395364953659536695367953689536995370953719537295373953749537595376953779537895379953809538195382953839538495385953869538795388953899539095391953929539395394953959539695397953989539995400954019540295403954049540595406954079540895409954109541195412954139541495415954169541795418954199542095421954229542395424954259542695427954289542995430954319543295433954349543595436954379543895439954409544195442954439544495445954469544795448954499545095451954529545395454954559545695457954589545995460954619546295463954649546595466954679546895469954709547195472954739547495475954769547795478954799548095481954829548395484954859548695487954889548995490954919549295493954949549595496954979549895499955009550195502955039550495505955069550795508955099551095511955129551395514955159551695517955189551995520955219552295523955249552595526955279552895529955309553195532955339553495535955369553795538955399554095541955429554395544955459554695547955489554995550955519555295553955549555595556955579555895559955609556195562955639556495565955669556795568955699557095571955729557395574955759557695577955789557995580955819558295583955849558595586955879558895589955909559195592955939559495595955969559795598955999560095601956029560395604956059560695607956089560995610956119561295613956149561595616956179561895619956209562195622956239562495625956269562795628956299563095631956329563395634956359563695637956389563995640956419564295643956449564595646956479564895649956509565195652956539565495655956569565795658956599566095661956629566395664956659566695667956689566995670956719567295673956749567595676956779567895679956809568195682956839568495685956869568795688956899569095691956929569395694956959569695697956989569995700957019570295703957049570595706957079570895709957109571195712957139571495715957169571795718957199572095721957229572395724957259572695727957289572995730957319573295733957349573595736957379573895739957409574195742957439574495745957469574795748957499575095751957529575395754957559575695757957589575995760957619576295763957649576595766957679576895769957709577195772957739577495775957769577795778957799578095781957829578395784957859578695787957889578995790957919579295793957949579595796957979579895799958009580195802958039580495805958069580795808958099581095811958129581395814958159581695817958189581995820958219582295823958249582595826958279582895829958309583195832958339583495835958369583795838958399584095841958429584395844958459584695847958489584995850958519585295853958549585595856958579585895859958609586195862958639586495865958669586795868958699587095871958729587395874958759587695877958789587995880958819588295883958849588595886958879588895889958909589195892958939589495895958969589795898958999590095901959029590395904959059590695907959089590995910959119591295913959149591595916959179591895919959209592195922959239592495925959269592795928959299593095931959329593395934959359593695937959389593995940959419594295943959449594595946959479594895949959509595195952959539595495955959569595795958959599596095961959629596395964959659596695967959689596995970959719597295973959749597595976959779597895979959809598195982959839598495985959869598795988959899599095991959929599395994959959599695997959989599996000960019600296003960049600596006960079600896009960109601196012960139601496015960169601796018960199602096021960229602396024960259602696027960289602996030960319603296033960349603596036960379603896039960409604196042960439604496045960469604796048960499605096051960529605396054960559605696057960589605996060960619606296063960649606596066960679606896069960709607196072960739607496075960769607796078960799608096081960829608396084960859608696087960889608996090960919609296093960949609596096960979609896099961009610196102961039610496105961069610796108961099611096111961129611396114961159611696117961189611996120961219612296123961249612596126961279612896129961309613196132961339613496135961369613796138961399614096141961429614396144961459614696147961489614996150961519615296153961549615596156961579615896159961609616196162961639616496165961669616796168961699617096171961729617396174961759617696177961789617996180961819618296183961849618596186961879618896189961909619196192961939619496195961969619796198961999620096201962029620396204962059620696207962089620996210962119621296213962149621596216962179621896219962209622196222962239622496225962269622796228962299623096231962329623396234962359623696237962389623996240962419624296243962449624596246962479624896249962509625196252962539625496255962569625796258962599626096261962629626396264962659626696267962689626996270962719627296273962749627596276962779627896279962809628196282962839628496285962869628796288962899629096291962929629396294962959629696297962989629996300963019630296303963049630596306963079630896309963109631196312963139631496315963169631796318963199632096321963229632396324963259632696327963289632996330963319633296333963349633596336963379633896339963409634196342963439634496345963469634796348963499635096351963529635396354963559635696357963589635996360963619636296363963649636596366963679636896369963709637196372963739637496375963769637796378963799638096381963829638396384963859638696387963889638996390963919639296393963949639596396963979639896399964009640196402964039640496405964069640796408964099641096411964129641396414964159641696417964189641996420964219642296423964249642596426964279642896429964309643196432964339643496435964369643796438964399644096441964429644396444964459644696447964489644996450964519645296453964549645596456964579645896459964609646196462964639646496465964669646796468964699647096471964729647396474964759647696477964789647996480964819648296483964849648596486964879648896489964909649196492964939649496495964969649796498964999650096501965029650396504965059650696507965089650996510965119651296513965149651596516965179651896519965209652196522965239652496525965269652796528965299653096531965329653396534965359653696537965389653996540965419654296543965449654596546965479654896549965509655196552965539655496555965569655796558965599656096561965629656396564965659656696567965689656996570965719657296573965749657596576965779657896579965809658196582965839658496585965869658796588965899659096591965929659396594965959659696597965989659996600966019660296603966049660596606966079660896609966109661196612966139661496615966169661796618966199662096621966229662396624966259662696627966289662996630966319663296633966349663596636966379663896639966409664196642966439664496645966469664796648966499665096651966529665396654966559665696657966589665996660966619666296663966649666596666966679666896669966709667196672966739667496675966769667796678966799668096681966829668396684966859668696687966889668996690966919669296693966949669596696966979669896699967009670196702967039670496705967069670796708967099671096711967129671396714967159671696717967189671996720967219672296723967249672596726967279672896729967309673196732967339673496735967369673796738967399674096741967429674396744967459674696747967489674996750967519675296753967549675596756967579675896759967609676196762967639676496765967669676796768967699677096771967729677396774967759677696777967789677996780967819678296783967849678596786967879678896789967909679196792967939679496795967969679796798967999680096801968029680396804968059680696807968089680996810968119681296813968149681596816968179681896819968209682196822968239682496825968269682796828968299683096831968329683396834968359683696837968389683996840968419684296843968449684596846968479684896849968509685196852968539685496855968569685796858968599686096861968629686396864968659686696867968689686996870968719687296873968749687596876968779687896879968809688196882968839688496885968869688796888968899689096891968929689396894968959689696897968989689996900969019690296903969049690596906969079690896909969109691196912969139691496915969169691796918969199692096921969229692396924969259692696927969289692996930969319693296933969349693596936969379693896939969409694196942969439694496945969469694796948969499695096951969529695396954969559695696957969589695996960969619696296963969649696596966969679696896969969709697196972969739697496975969769697796978969799698096981969829698396984969859698696987969889698996990969919699296993969949699596996969979699896999970009700197002970039700497005970069700797008970099701097011970129701397014970159701697017970189701997020970219702297023970249702597026970279702897029970309703197032970339703497035970369703797038970399704097041970429704397044970459704697047970489704997050970519705297053970549705597056970579705897059970609706197062970639706497065970669706797068970699707097071970729707397074970759707697077970789707997080970819708297083970849708597086970879708897089970909709197092970939709497095970969709797098970999710097101971029710397104971059710697107971089710997110971119711297113971149711597116971179711897119971209712197122971239712497125971269712797128971299713097131971329713397134971359713697137971389713997140971419714297143971449714597146971479714897149971509715197152971539715497155971569715797158971599716097161971629716397164971659716697167971689716997170971719717297173971749717597176971779717897179971809718197182971839718497185971869718797188971899719097191971929719397194971959719697197971989719997200972019720297203972049720597206972079720897209972109721197212972139721497215972169721797218972199722097221972229722397224972259722697227972289722997230972319723297233972349723597236972379723897239972409724197242972439724497245972469724797248972499725097251972529725397254972559725697257972589725997260972619726297263972649726597266972679726897269972709727197272972739727497275972769727797278972799728097281972829728397284972859728697287972889728997290972919729297293972949729597296972979729897299973009730197302973039730497305973069730797308973099731097311973129731397314973159731697317973189731997320973219732297323973249732597326973279732897329973309733197332973339733497335973369733797338973399734097341973429734397344973459734697347973489734997350973519735297353973549735597356973579735897359973609736197362973639736497365973669736797368973699737097371973729737397374973759737697377973789737997380973819738297383973849738597386973879738897389973909739197392973939739497395973969739797398973999740097401974029740397404974059740697407974089740997410974119741297413974149741597416974179741897419974209742197422974239742497425974269742797428974299743097431974329743397434974359743697437974389743997440974419744297443974449744597446974479744897449974509745197452974539745497455974569745797458974599746097461974629746397464974659746697467974689746997470974719747297473974749747597476974779747897479974809748197482974839748497485974869748797488974899749097491974929749397494974959749697497974989749997500975019750297503975049750597506975079750897509975109751197512975139751497515975169751797518975199752097521975229752397524975259752697527975289752997530975319753297533975349753597536975379753897539975409754197542975439754497545975469754797548975499755097551975529755397554975559755697557975589755997560975619756297563975649756597566975679756897569975709757197572975739757497575975769757797578975799758097581975829758397584975859758697587975889758997590975919759297593975949759597596975979759897599976009760197602976039760497605976069760797608976099761097611976129761397614976159761697617976189761997620976219762297623976249762597626976279762897629976309763197632976339763497635976369763797638976399764097641976429764397644976459764697647976489764997650976519765297653976549765597656976579765897659976609766197662976639766497665976669766797668976699767097671976729767397674976759767697677976789767997680976819768297683976849768597686976879768897689976909769197692976939769497695976969769797698976999770097701977029770397704977059770697707977089770997710977119771297713977149771597716977179771897719977209772197722977239772497725977269772797728977299773097731977329773397734977359773697737977389773997740977419774297743977449774597746977479774897749977509775197752977539775497755977569775797758977599776097761977629776397764977659776697767977689776997770977719777297773977749777597776977779777897779977809778197782977839778497785977869778797788977899779097791977929779397794977959779697797977989779997800978019780297803978049780597806978079780897809978109781197812978139781497815978169781797818978199782097821978229782397824978259782697827978289782997830978319783297833978349783597836978379783897839978409784197842978439784497845978469784797848978499785097851978529785397854978559785697857978589785997860978619786297863978649786597866978679786897869978709787197872978739787497875978769787797878978799788097881978829788397884978859788697887978889788997890978919789297893978949789597896978979789897899979009790197902979039790497905979069790797908979099791097911979129791397914979159791697917979189791997920979219792297923979249792597926979279792897929979309793197932979339793497935979369793797938979399794097941979429794397944979459794697947979489794997950979519795297953979549795597956979579795897959979609796197962979639796497965979669796797968979699797097971979729797397974979759797697977979789797997980979819798297983979849798597986979879798897989979909799197992979939799497995979969799797998979999800098001980029800398004980059800698007980089800998010980119801298013980149801598016980179801898019980209802198022980239802498025980269802798028980299803098031980329803398034980359803698037980389803998040980419804298043980449804598046980479804898049980509805198052980539805498055980569805798058980599806098061980629806398064980659806698067980689806998070980719807298073980749807598076980779807898079980809808198082980839808498085980869808798088980899809098091980929809398094980959809698097980989809998100981019810298103981049810598106981079810898109981109811198112981139811498115981169811798118981199812098121981229812398124981259812698127981289812998130981319813298133981349813598136981379813898139981409814198142981439814498145981469814798148981499815098151981529815398154981559815698157981589815998160981619816298163981649816598166981679816898169981709817198172981739817498175981769817798178981799818098181981829818398184981859818698187981889818998190981919819298193981949819598196981979819898199982009820198202982039820498205982069820798208982099821098211982129821398214982159821698217982189821998220982219822298223982249822598226982279822898229982309823198232982339823498235982369823798238982399824098241982429824398244982459824698247982489824998250982519825298253982549825598256982579825898259982609826198262982639826498265982669826798268982699827098271982729827398274982759827698277982789827998280982819828298283982849828598286982879828898289982909829198292982939829498295982969829798298982999830098301983029830398304983059830698307983089830998310983119831298313983149831598316983179831898319983209832198322983239832498325983269832798328983299833098331983329833398334983359833698337983389833998340983419834298343983449834598346983479834898349983509835198352983539835498355983569835798358983599836098361983629836398364983659836698367983689836998370983719837298373983749837598376983779837898379983809838198382983839838498385983869838798388983899839098391983929839398394983959839698397983989839998400984019840298403984049840598406984079840898409984109841198412984139841498415984169841798418984199842098421984229842398424984259842698427984289842998430984319843298433984349843598436984379843898439984409844198442984439844498445984469844798448984499845098451984529845398454984559845698457984589845998460984619846298463984649846598466984679846898469984709847198472984739847498475984769847798478984799848098481984829848398484984859848698487984889848998490984919849298493984949849598496984979849898499985009850198502985039850498505985069850798508985099851098511985129851398514985159851698517985189851998520985219852298523985249852598526985279852898529985309853198532985339853498535985369853798538985399854098541985429854398544985459854698547985489854998550985519855298553985549855598556985579855898559985609856198562985639856498565985669856798568985699857098571985729857398574985759857698577985789857998580985819858298583985849858598586985879858898589985909859198592985939859498595985969859798598985999860098601986029860398604986059860698607986089860998610986119861298613986149861598616986179861898619986209862198622986239862498625986269862798628986299863098631986329863398634986359863698637986389863998640986419864298643986449864598646986479864898649986509865198652986539865498655986569865798658986599866098661986629866398664986659866698667986689866998670986719867298673986749867598676986779867898679986809868198682986839868498685986869868798688986899869098691986929869398694986959869698697986989869998700987019870298703987049870598706987079870898709987109871198712987139871498715987169871798718987199872098721987229872398724987259872698727987289872998730987319873298733987349873598736987379873898739987409874198742987439874498745987469874798748987499875098751987529875398754987559875698757987589875998760987619876298763987649876598766987679876898769987709877198772987739877498775987769877798778987799878098781987829878398784987859878698787987889878998790987919879298793987949879598796987979879898799988009880198802988039880498805988069880798808988099881098811988129881398814988159881698817988189881998820988219882298823988249882598826988279882898829988309883198832988339883498835988369883798838988399884098841988429884398844988459884698847988489884998850988519885298853988549885598856988579885898859988609886198862988639886498865988669886798868988699887098871988729887398874988759887698877988789887998880988819888298883988849888598886988879888898889988909889198892988939889498895988969889798898988999890098901989029890398904989059890698907989089890998910989119891298913989149891598916989179891898919989209892198922989239892498925989269892798928989299893098931989329893398934989359893698937989389893998940989419894298943989449894598946989479894898949989509895198952989539895498955989569895798958989599896098961989629896398964989659896698967989689896998970989719897298973989749897598976989779897898979989809898198982989839898498985989869898798988989899899098991989929899398994989959899698997989989899999000990019900299003990049900599006990079900899009990109901199012990139901499015990169901799018990199902099021990229902399024990259902699027990289902999030990319903299033990349903599036990379903899039990409904199042990439904499045990469904799048990499905099051990529905399054990559905699057990589905999060990619906299063990649906599066990679906899069990709907199072990739907499075990769907799078990799908099081990829908399084990859908699087990889908999090990919909299093990949909599096990979909899099991009910199102991039910499105991069910799108991099911099111991129911399114991159911699117991189911999120991219912299123991249912599126991279912899129991309913199132991339913499135991369913799138991399914099141991429914399144991459914699147991489914999150991519915299153991549915599156991579915899159991609916199162991639916499165991669916799168991699917099171991729917399174991759917699177991789917999180991819918299183991849918599186991879918899189991909919199192991939919499195991969919799198991999920099201992029920399204992059920699207992089920999210992119921299213992149921599216992179921899219992209922199222992239922499225992269922799228992299923099231992329923399234992359923699237992389923999240992419924299243992449924599246992479924899249992509925199252992539925499255992569925799258992599926099261992629926399264992659926699267992689926999270992719927299273992749927599276992779927899279992809928199282992839928499285992869928799288992899929099291992929929399294992959929699297992989929999300993019930299303993049930599306993079930899309993109931199312993139931499315993169931799318993199932099321993229932399324993259932699327993289932999330993319933299333993349933599336993379933899339993409934199342993439934499345993469934799348993499935099351993529935399354993559935699357993589935999360993619936299363993649936599366993679936899369993709937199372993739937499375993769937799378993799938099381993829938399384993859938699387993889938999390993919939299393993949939599396993979939899399994009940199402994039940499405994069940799408994099941099411994129941399414994159941699417994189941999420994219942299423994249942599426994279942899429994309943199432994339943499435994369943799438994399944099441994429944399444994459944699447994489944999450994519945299453994549945599456994579945899459994609946199462994639946499465994669946799468994699947099471994729947399474994759947699477994789947999480994819948299483994849948599486994879948899489994909949199492994939949499495994969949799498994999950099501995029950399504995059950699507995089950999510995119951299513995149951599516995179951899519995209952199522995239952499525995269952799528995299953099531995329953399534995359953699537995389953999540995419954299543995449954599546995479954899549995509955199552995539955499555995569955799558995599956099561995629956399564995659956699567995689956999570995719957299573995749957599576995779957899579995809958199582995839958499585995869958799588995899959099591995929959399594995959959699597995989959999600996019960299603996049960599606996079960899609996109961199612996139961499615996169961799618996199962099621996229962399624996259962699627996289962999630996319963299633996349963599636996379963899639996409964199642996439964499645996469964799648996499965099651996529965399654996559965699657996589965999660996619966299663996649966599666996679966899669996709967199672996739967499675996769967799678996799968099681996829968399684996859968699687996889968999690996919969299693996949969599696996979969899699997009970199702997039970499705997069970799708997099971099711997129971399714997159971699717997189971999720997219972299723997249972599726997279972899729997309973199732997339973499735997369973799738997399974099741997429974399744997459974699747997489974999750997519975299753997549975599756997579975899759997609976199762997639976499765997669976799768997699977099771997729977399774997759977699777997789977999780997819978299783997849978599786997879978899789997909979199792997939979499795997969979799798997999980099801998029980399804998059980699807998089980999810998119981299813998149981599816998179981899819998209982199822998239982499825998269982799828998299983099831998329983399834998359983699837998389983999840998419984299843998449984599846998479984899849998509985199852998539985499855998569985799858998599986099861998629986399864998659986699867998689986999870998719987299873998749987599876998779987899879998809988199882998839988499885998869988799888998899989099891998929989399894998959989699897998989989999900999019990299903999049990599906999079990899909999109991199912999139991499915999169991799918999199992099921999229992399924999259992699927999289992999930999319993299933999349993599936999379993899939999409994199942999439994499945999469994799948999499995099951999529995399954999559995699957999589995999960999619996299963999649996599966999679996899969999709997199972999739997499975999769997799978999799998099981999829998399984999859998699987999889998999990999919999299993999949999599996999979999899999100000100001100002100003100004100005100006100007100008100009100010100011100012100013100014100015100016100017100018100019100020100021100022100023100024100025100026100027100028100029100030100031100032100033100034100035100036100037100038100039100040100041100042100043100044100045100046100047100048100049100050100051100052100053100054100055100056100057100058100059100060100061100062100063100064100065100066100067100068100069100070100071100072100073100074100075100076100077100078100079100080100081100082100083100084100085100086100087100088100089100090100091100092100093100094100095100096100097100098100099100100100101100102100103100104100105100106100107100108100109100110100111100112100113100114100115100116100117100118100119100120100121100122100123100124100125100126100127100128100129100130100131100132100133100134100135100136100137100138100139100140100141100142100143100144100145100146100147100148100149100150100151100152100153100154100155100156100157100158100159100160100161100162100163100164100165100166100167100168100169100170100171100172100173100174100175100176100177100178100179100180100181100182100183100184100185100186100187100188100189100190100191100192100193100194100195100196100197100198100199100200100201100202100203100204100205100206100207100208100209100210100211100212100213100214100215100216100217100218100219100220100221100222100223100224100225100226100227100228100229100230100231100232100233100234100235100236100237100238100239100240100241100242100243100244100245100246100247100248100249100250100251100252100253100254100255100256100257100258100259100260100261100262100263100264100265100266100267100268100269100270100271100272100273100274100275100276100277100278100279100280100281100282100283100284100285100286100287100288100289100290100291100292100293100294100295100296100297100298100299100300100301100302100303100304100305100306100307100308100309100310100311100312100313100314100315100316100317100318100319100320100321100322100323100324100325100326100327100328100329100330100331100332100333100334100335100336100337100338100339100340100341100342100343100344100345100346100347100348100349100350100351100352100353100354100355100356100357100358100359100360100361100362100363100364100365100366100367100368100369100370100371100372100373100374100375100376100377100378100379100380100381100382100383100384100385100386100387100388100389100390100391100392100393100394100395100396100397100398100399100400100401100402100403100404100405100406100407100408100409100410100411100412100413100414100415100416100417100418100419100420100421100422100423100424100425100426100427100428100429100430100431100432100433100434100435100436100437100438100439100440100441100442100443100444100445100446100447100448100449100450100451100452100453100454100455100456100457100458100459100460100461100462100463100464100465100466100467100468100469100470100471100472100473100474100475100476100477100478100479100480100481100482100483100484100485100486100487100488100489100490100491100492100493100494100495100496100497100498100499100500100501100502100503100504100505100506100507100508100509100510100511100512100513100514100515100516100517100518100519100520100521100522100523100524100525100526100527100528100529100530100531100532100533100534100535100536100537100538100539100540100541100542100543100544100545100546100547100548100549100550100551100552100553100554100555100556100557100558100559100560100561100562100563100564100565100566100567100568100569100570100571100572100573100574100575100576100577100578100579100580100581100582100583100584100585100586100587100588100589100590100591100592100593100594100595100596100597100598100599100600100601100602100603100604100605100606100607100608100609100610100611100612100613100614100615100616100617100618100619100620100621100622100623100624100625100626100627100628100629100630100631100632100633100634100635100636100637100638100639100640100641100642100643100644100645100646100647100648100649100650100651100652100653100654100655100656100657100658100659100660100661100662100663100664100665100666100667100668100669100670100671100672100673100674100675100676100677100678100679100680100681100682100683100684100685100686100687100688100689100690100691100692100693100694100695100696100697100698100699100700100701100702100703100704100705100706100707100708100709100710100711100712100713100714100715100716100717100718100719100720100721100722100723100724100725100726100727100728100729100730100731100732100733100734100735100736100737100738100739100740100741100742100743100744100745100746100747100748100749100750100751100752100753100754100755100756100757100758100759100760100761100762100763100764100765100766100767100768100769100770100771100772100773100774100775100776100777100778100779100780100781100782100783100784100785100786100787100788100789100790100791100792100793100794100795100796100797100798100799100800100801100802100803100804100805100806100807100808100809100810100811100812100813100814100815100816100817100818100819100820100821100822100823100824100825100826100827100828100829100830100831100832100833100834100835100836100837100838100839100840100841100842100843100844100845100846100847100848100849100850100851100852100853100854100855100856100857100858100859100860100861100862100863100864100865100866100867100868100869100870100871100872100873100874100875100876100877100878100879100880100881100882100883100884100885100886100887100888100889100890100891100892100893100894100895100896100897100898100899100900100901100902100903100904100905100906100907100908100909100910100911100912100913100914100915100916100917100918100919100920100921100922100923100924100925100926100927100928100929100930100931100932100933100934100935100936100937100938100939100940100941100942100943100944100945100946100947100948100949100950100951100952100953100954100955100956100957100958100959100960100961100962100963100964100965100966100967100968100969100970100971100972100973100974100975100976100977100978100979100980100981100982100983100984100985100986100987100988100989100990100991100992100993100994100995100996100997100998100999101000101001101002101003101004101005101006101007101008101009101010101011101012101013101014101015101016101017101018101019101020101021101022101023101024101025101026101027101028101029101030101031101032101033101034101035101036101037101038101039101040101041101042101043101044101045101046101047101048101049101050101051101052101053101054101055101056101057101058101059101060101061101062101063101064101065101066101067101068101069101070101071101072101073101074101075101076101077101078101079101080101081101082101083101084101085101086101087101088101089101090101091101092101093101094101095101096101097101098101099101100101101101102101103101104101105101106101107101108101109101110101111101112101113101114101115101116101117101118101119101120101121101122101123101124101125101126101127101128101129101130101131101132101133101134101135101136101137101138101139101140101141101142101143101144101145101146101147101148101149101150101151101152101153101154101155101156101157101158101159101160101161101162101163101164101165101166101167101168101169101170101171101172101173101174101175101176101177101178101179101180101181101182101183101184101185101186101187101188101189101190101191101192101193101194101195101196101197101198101199101200101201101202101203101204101205101206101207101208101209101210101211101212101213101214101215101216101217101218101219101220101221101222101223101224101225101226101227101228101229101230101231101232101233101234101235101236101237101238101239101240101241101242101243101244101245101246101247101248101249101250101251101252101253101254101255101256101257101258101259101260101261101262101263101264101265101266101267101268101269101270101271101272101273101274101275101276101277101278101279101280101281101282101283101284101285101286101287101288101289101290101291101292101293101294101295101296101297101298101299101300101301101302101303101304101305101306101307101308101309101310101311101312101313101314101315101316101317101318101319101320101321101322101323101324101325101326101327101328101329101330101331101332101333101334101335101336101337101338101339101340101341101342101343101344101345101346101347101348101349101350101351101352101353101354101355101356101357101358101359101360101361101362101363101364101365101366101367101368101369101370101371101372101373101374101375101376101377101378101379101380101381101382101383101384101385101386101387101388101389101390101391101392101393101394101395101396101397101398101399101400101401101402101403101404101405101406101407101408101409101410101411101412101413101414101415101416101417101418101419101420101421101422101423101424101425101426101427101428101429101430101431101432101433101434101435101436101437101438101439101440101441101442101443101444101445101446101447101448101449101450101451101452101453101454101455101456101457101458101459101460101461101462101463101464101465101466101467101468101469101470101471101472101473101474101475101476101477101478101479101480101481101482101483101484101485101486101487101488101489101490101491101492101493101494101495101496101497101498101499101500101501101502101503101504101505101506101507101508101509101510101511101512101513101514101515101516101517101518101519101520101521101522101523101524101525101526101527101528101529101530101531101532101533101534101535101536101537101538101539101540101541101542101543101544101545101546101547101548101549101550101551101552101553101554101555101556101557101558101559101560101561101562101563101564101565101566101567101568101569101570101571101572101573101574101575101576101577101578101579101580101581101582101583101584101585101586101587101588101589101590101591101592101593101594101595101596101597101598101599101600101601101602101603101604101605101606101607101608101609101610101611101612101613101614101615101616101617101618101619101620101621101622101623101624101625101626101627101628101629101630101631101632101633101634101635101636101637101638101639101640101641101642101643101644101645101646101647101648101649101650101651101652101653101654101655101656101657101658101659101660101661101662101663101664101665101666101667101668101669101670101671101672101673101674101675101676101677101678101679101680101681101682101683101684101685101686101687101688101689101690101691101692101693101694101695101696101697101698101699101700101701101702101703101704101705101706101707101708101709101710101711101712101713101714101715101716101717101718101719101720101721101722101723101724101725101726101727101728101729101730101731101732101733101734101735101736101737101738101739101740101741101742101743101744101745101746101747101748101749101750101751101752101753101754101755101756101757101758101759101760101761101762101763101764101765101766101767101768101769101770101771101772101773101774101775101776101777101778101779101780101781101782101783101784101785101786101787101788101789101790101791101792101793101794101795101796101797101798101799101800101801101802101803101804101805101806101807101808101809101810101811101812101813101814101815101816101817101818101819101820101821101822101823101824101825101826101827101828101829101830101831101832101833101834101835101836101837101838101839101840101841101842101843101844101845101846101847101848101849101850101851101852101853101854101855101856101857101858101859101860101861101862101863101864101865101866101867101868101869101870101871101872101873101874101875101876101877101878101879101880101881101882101883101884101885101886101887101888101889101890101891101892101893101894101895101896101897101898101899101900101901101902101903101904101905101906101907101908101909101910101911101912101913101914101915101916101917101918101919101920101921101922101923101924101925101926101927101928101929101930101931101932101933101934101935101936101937101938101939101940101941101942101943101944101945101946101947101948101949101950101951101952101953101954101955101956101957101958101959101960101961101962101963101964101965101966101967101968101969101970101971101972101973101974101975101976101977101978101979101980101981101982101983101984101985101986101987101988101989101990101991101992101993101994101995101996101997101998101999102000102001102002102003102004102005102006102007102008102009102010102011102012102013102014102015102016102017102018102019102020102021102022102023102024102025102026102027102028102029102030102031102032102033102034102035102036102037102038102039102040102041102042102043102044102045102046102047102048102049102050102051102052102053102054102055102056102057102058102059102060102061102062102063102064102065102066102067102068102069102070102071102072102073102074102075102076102077102078102079102080102081102082102083102084102085102086102087102088102089102090102091102092102093102094102095102096102097102098102099102100102101102102102103102104102105102106102107102108102109102110102111102112102113102114102115102116102117102118102119102120102121102122102123102124102125102126102127102128102129102130102131102132102133102134102135102136102137102138102139102140102141102142102143102144102145102146102147102148102149102150102151102152102153102154102155102156102157102158102159102160102161102162102163102164102165102166102167102168102169102170102171102172102173102174102175102176102177102178102179102180102181102182102183102184102185102186102187102188102189102190102191102192102193102194102195102196102197102198102199102200102201102202102203102204102205102206102207102208102209102210102211102212102213102214102215102216102217102218102219102220102221102222102223102224102225102226102227102228102229102230102231102232102233102234102235102236102237102238102239102240102241102242102243102244102245102246102247102248102249102250102251102252102253102254102255102256102257102258102259102260102261102262102263102264102265102266102267102268102269102270102271102272102273102274102275102276102277102278102279102280102281102282102283102284102285102286102287102288102289102290102291102292102293102294102295102296102297102298102299102300102301102302102303102304102305102306102307102308102309102310102311102312102313102314102315102316102317102318102319102320102321102322102323102324102325102326102327102328102329102330102331102332102333102334102335102336102337102338102339102340102341102342102343102344102345102346102347102348102349102350102351102352102353102354102355102356102357102358102359102360102361102362102363102364102365102366102367102368102369102370102371102372102373102374102375102376102377102378102379102380102381102382102383102384102385102386102387102388102389102390102391102392102393102394102395102396102397102398102399102400102401102402102403102404102405102406102407102408102409102410102411102412102413102414102415102416102417102418102419102420102421102422102423102424102425102426102427102428102429102430102431102432102433102434102435102436102437102438102439102440102441102442102443102444102445102446102447102448102449102450102451102452102453102454102455102456102457102458102459102460102461102462102463102464102465102466102467102468102469102470102471102472102473102474102475102476102477102478102479102480102481102482102483102484102485102486102487102488102489102490102491102492102493102494102495102496102497102498102499102500102501102502102503102504102505102506102507102508102509102510102511102512102513102514102515102516102517102518102519102520102521102522102523102524102525102526102527102528102529102530102531102532102533102534102535102536102537102538102539102540102541102542102543102544102545102546102547102548102549102550102551102552102553102554102555102556102557102558102559102560102561102562102563102564102565102566102567102568102569102570102571102572102573102574102575102576102577102578102579102580102581102582102583102584102585102586102587102588102589102590102591102592102593102594102595102596102597102598102599102600102601102602102603102604102605102606102607102608102609102610102611102612102613102614102615102616102617102618102619102620102621102622102623102624102625102626102627102628102629102630102631102632102633102634102635102636102637102638102639102640102641102642102643102644102645102646102647102648102649102650102651102652102653102654102655102656102657102658102659102660102661102662102663102664102665102666102667102668102669102670102671102672102673102674102675102676102677102678102679102680102681102682102683102684102685102686102687102688102689102690102691102692102693102694102695102696102697102698102699102700102701102702102703102704102705102706102707102708102709102710102711102712102713102714102715102716102717102718102719102720102721102722102723102724102725102726102727102728102729102730102731102732102733102734102735102736102737102738102739102740102741102742102743102744102745102746102747102748102749102750102751102752102753102754102755102756102757102758102759102760102761102762102763102764102765102766102767102768102769102770102771102772102773102774102775102776102777102778102779102780102781102782102783102784102785102786102787102788102789102790102791102792102793102794102795102796102797102798102799102800102801102802102803102804102805102806102807102808102809102810102811102812102813102814102815102816102817102818102819102820102821102822102823102824102825102826102827102828102829102830102831102832102833102834102835102836102837102838102839102840102841102842102843102844102845102846102847102848102849102850102851102852102853102854102855102856102857102858102859102860102861102862102863102864102865102866102867102868102869102870102871102872102873102874102875102876102877102878102879102880102881102882102883102884102885102886102887102888102889102890102891102892102893102894102895102896102897102898102899102900102901102902102903102904102905102906102907102908102909102910102911102912102913102914102915102916102917102918102919102920102921102922102923102924102925102926102927102928102929102930102931102932102933102934102935102936102937102938102939102940102941102942102943102944102945102946102947102948102949102950102951102952102953102954102955102956102957102958102959102960102961102962102963102964102965102966102967102968102969102970102971102972102973102974102975102976102977102978102979102980102981102982102983102984102985102986102987102988102989102990102991102992102993102994102995102996102997102998102999103000103001103002103003103004103005103006103007103008103009103010103011103012103013103014103015103016103017103018103019103020103021103022103023103024103025103026103027103028103029103030103031103032103033103034103035103036103037103038103039103040103041103042103043103044103045103046103047103048103049103050103051103052103053103054103055103056103057103058103059103060103061103062103063103064103065103066103067103068103069103070103071103072103073103074103075103076103077103078103079103080103081103082103083103084103085103086103087103088103089103090103091103092103093103094103095103096103097103098103099103100103101103102103103103104103105103106103107103108103109103110103111103112103113103114103115103116103117103118103119103120103121103122103123103124103125103126103127103128103129103130103131103132103133103134103135103136103137103138103139103140103141103142103143103144103145103146103147103148103149103150103151103152103153103154103155103156103157103158103159103160103161103162103163103164103165103166103167103168103169103170103171103172103173103174103175103176103177103178103179103180103181103182103183103184103185103186103187103188103189103190103191103192103193103194103195103196103197103198103199103200103201103202103203103204103205103206103207103208103209103210103211103212103213103214103215103216103217103218103219103220103221103222103223103224103225103226103227103228103229103230103231103232103233103234103235103236103237103238103239103240103241103242103243103244103245103246103247103248103249103250103251103252103253103254103255103256103257103258103259103260103261103262103263103264103265103266103267103268103269103270103271103272103273103274103275103276103277103278103279103280103281103282103283103284103285103286103287103288103289103290103291103292103293103294103295103296103297103298103299103300103301103302103303103304103305103306103307103308103309103310103311103312103313103314103315103316103317103318103319103320103321103322103323103324103325103326103327103328103329103330103331103332103333103334103335103336103337103338103339103340103341103342103343103344103345103346103347103348103349103350103351103352103353103354103355103356103357103358103359103360103361103362103363103364103365103366103367103368103369103370103371103372103373103374103375103376103377103378103379103380103381103382103383103384103385103386103387103388103389103390103391103392103393103394103395103396103397103398103399103400103401103402103403103404103405103406103407103408103409103410103411103412103413103414103415103416103417103418103419103420103421103422103423103424103425103426103427103428103429103430103431103432103433103434103435103436103437103438103439103440103441103442103443103444103445103446103447103448103449103450103451103452103453103454103455103456103457103458103459103460103461103462103463103464103465103466103467103468103469103470103471103472103473103474103475103476103477103478103479103480103481103482103483103484103485103486103487103488103489103490103491103492103493103494103495103496103497103498103499103500103501103502103503103504103505103506103507103508103509103510103511103512103513103514103515103516103517103518103519103520103521103522103523103524103525103526103527103528103529103530103531103532103533103534103535103536103537103538103539103540103541103542103543103544103545103546103547103548103549103550103551103552103553103554103555103556103557103558103559103560103561103562103563103564103565103566103567103568103569103570103571103572103573103574103575103576103577103578103579103580103581103582103583103584103585103586103587103588103589103590103591103592103593103594103595103596103597103598103599103600103601103602103603103604103605103606103607103608103609103610103611103612103613103614103615103616103617103618103619103620103621103622103623103624103625103626103627103628103629103630103631103632103633103634103635103636103637103638103639103640103641103642103643103644103645103646103647103648103649103650103651103652103653103654103655103656103657103658103659103660103661103662103663103664103665103666103667103668103669103670103671103672103673103674103675103676103677103678103679103680103681103682103683103684103685103686103687103688103689103690103691103692103693103694103695103696103697103698103699103700103701103702103703103704103705103706103707103708103709103710103711103712103713103714103715103716103717103718103719103720103721103722103723103724103725103726103727103728103729103730103731103732103733103734103735103736103737103738103739103740103741103742103743103744103745103746103747103748103749103750103751103752103753103754103755103756103757103758103759103760103761103762103763103764103765103766103767103768103769103770103771103772103773103774103775103776103777103778103779103780103781103782103783103784103785103786103787103788103789103790103791103792103793103794103795103796103797103798103799103800103801103802103803103804103805103806103807103808103809103810103811103812103813103814103815103816103817103818103819103820103821103822103823103824103825103826103827103828103829103830103831103832103833103834103835103836103837103838103839103840103841103842103843103844103845103846103847103848103849103850103851103852103853103854103855103856103857103858103859103860103861103862103863103864103865103866103867103868103869103870103871103872103873103874103875103876103877103878103879103880103881103882103883103884103885103886103887103888103889103890103891103892103893103894103895103896103897103898103899103900103901103902103903103904103905103906103907103908103909103910103911103912103913103914103915103916103917103918103919103920103921103922103923103924103925103926103927103928103929103930103931103932103933103934103935103936103937103938103939103940103941103942103943103944103945103946103947103948103949103950103951103952103953103954103955103956103957103958103959103960103961103962103963103964103965103966103967103968103969103970103971103972103973103974103975103976103977103978103979103980103981103982103983103984103985103986103987103988103989103990103991103992103993103994103995103996103997103998103999104000104001104002104003104004104005104006104007104008104009104010104011104012104013104014104015104016104017104018104019104020104021104022104023104024104025104026104027104028104029104030104031104032104033104034104035104036104037104038104039104040104041104042104043104044104045104046104047104048104049104050104051104052104053104054104055104056104057104058104059104060104061104062104063104064104065104066104067104068104069104070104071104072104073104074104075104076104077104078104079104080104081104082104083104084104085104086104087104088104089104090104091104092104093104094104095104096104097104098104099104100104101104102104103104104104105104106104107104108104109104110104111104112104113104114104115104116104117104118104119104120104121104122104123104124104125104126104127104128104129104130104131104132104133104134104135104136104137104138104139104140104141104142104143104144104145104146104147104148104149104150104151104152104153104154104155104156104157104158104159104160104161104162104163104164104165104166104167104168104169104170104171104172104173104174104175104176104177104178104179104180104181104182104183104184104185104186104187104188104189104190104191104192104193104194104195104196104197104198104199104200104201104202104203104204104205104206104207104208104209104210104211104212104213104214104215104216104217104218104219104220104221104222104223104224104225104226104227104228104229104230104231104232104233104234104235104236104237104238104239104240104241104242104243104244104245104246104247104248104249104250104251104252104253104254104255104256104257104258104259104260104261104262104263104264104265104266104267104268104269104270104271104272104273104274104275104276104277104278104279104280104281104282104283104284104285104286104287104288104289104290104291104292104293104294104295104296104297104298104299104300104301104302104303104304104305104306104307104308104309104310104311104312104313104314104315104316104317104318104319104320104321104322104323104324104325104326104327104328104329104330104331104332104333104334104335104336104337104338104339104340104341104342104343104344104345104346104347104348104349104350104351104352104353104354104355104356104357104358104359104360104361104362104363104364104365104366104367104368104369104370104371104372104373104374104375104376104377104378104379104380104381104382104383104384104385104386104387104388104389104390104391104392104393104394104395104396104397104398104399104400104401104402104403104404104405104406104407104408104409104410104411104412104413104414104415104416104417104418104419104420104421104422104423104424104425104426104427104428104429104430104431104432104433104434104435104436104437104438104439104440104441104442104443104444104445104446104447104448104449104450104451104452104453104454104455104456104457104458104459104460104461104462104463104464104465104466104467104468104469104470104471104472104473104474104475104476104477104478104479104480104481104482104483104484104485104486104487104488104489104490104491104492104493104494104495104496104497104498104499104500104501104502104503104504104505104506104507104508104509104510104511104512104513104514104515104516104517104518104519104520104521104522104523104524104525104526104527104528104529104530104531104532104533104534104535104536104537104538104539104540104541104542104543104544104545104546104547104548104549104550104551104552104553104554104555104556104557104558104559104560104561104562104563104564104565104566104567104568104569104570104571104572104573104574104575104576104577104578104579104580104581104582104583104584104585104586104587104588104589104590104591104592104593104594104595104596104597104598104599104600104601104602104603104604104605104606104607104608104609104610104611104612104613104614104615104616104617104618104619104620104621104622104623104624104625104626104627104628104629104630104631104632104633104634104635104636104637104638104639104640104641104642104643104644104645104646104647104648104649104650104651104652104653104654104655104656104657104658104659104660104661104662104663104664104665104666104667104668104669104670104671104672104673104674104675104676104677104678104679104680104681104682104683104684104685104686104687104688104689104690104691104692104693104694104695104696104697104698104699104700104701104702104703104704104705104706104707104708104709104710104711104712104713104714104715104716104717104718104719104720104721104722104723104724104725104726104727104728104729104730104731104732104733104734104735104736104737104738104739104740104741104742104743104744104745104746104747104748104749104750104751104752104753104754104755104756104757104758104759104760104761104762104763104764104765104766104767104768104769104770104771104772104773104774104775104776104777104778104779104780104781104782104783104784104785104786104787104788104789104790104791104792104793104794104795104796104797104798104799104800104801104802104803104804104805104806104807104808104809104810104811104812104813104814104815104816104817104818104819104820104821104822104823104824104825104826104827104828104829104830104831104832104833104834104835104836104837104838104839104840104841104842104843104844104845104846104847104848104849104850104851104852104853104854104855104856104857104858104859104860104861104862104863104864104865104866104867104868104869104870104871104872104873104874104875104876104877104878104879104880104881104882104883104884104885104886104887104888104889104890104891104892104893104894104895104896104897104898104899104900104901104902104903104904104905104906104907104908104909104910104911104912104913104914104915104916104917104918104919104920104921104922104923104924104925104926104927104928104929104930104931104932104933104934104935104936104937104938104939104940104941104942104943104944104945104946104947104948104949104950104951104952104953104954104955104956104957104958104959104960104961104962104963104964104965104966104967104968104969104970104971104972104973104974104975104976104977104978104979104980104981104982104983104984104985104986104987104988104989104990104991104992104993104994104995104996104997104998104999105000105001105002105003105004105005105006105007105008105009105010105011105012105013105014105015105016105017105018105019105020105021105022105023105024105025105026105027105028105029105030105031105032105033105034105035105036105037105038105039105040105041105042105043105044105045105046105047105048105049105050105051105052105053105054105055105056105057105058105059105060105061105062105063105064105065105066105067105068105069105070105071105072105073105074105075105076105077105078105079105080105081105082105083105084105085105086105087105088105089105090105091105092105093105094105095105096105097105098105099105100105101105102105103105104105105105106105107105108105109105110105111105112105113105114105115105116105117105118105119105120105121105122105123105124105125105126105127105128105129105130105131105132105133105134105135105136105137105138105139105140105141105142105143105144105145105146105147105148105149105150105151105152105153105154105155105156105157105158105159105160105161105162105163105164105165105166105167105168105169105170105171105172105173105174105175105176105177105178105179105180105181105182105183105184105185105186105187105188105189105190105191105192105193105194105195105196105197105198105199105200105201105202105203105204105205105206105207105208105209105210105211105212105213105214105215105216105217105218105219105220105221105222105223105224105225105226105227105228105229105230105231105232105233105234105235105236105237105238105239105240105241105242105243105244105245105246105247105248105249105250105251105252105253105254105255105256105257105258105259105260105261105262105263105264105265105266105267105268105269105270105271105272105273105274105275105276105277105278105279105280105281105282105283105284105285105286105287105288105289105290105291105292105293105294105295105296105297105298105299105300105301105302105303105304105305105306105307105308105309105310105311105312105313105314105315105316105317105318105319105320105321105322105323105324105325105326105327105328105329105330105331105332105333105334105335105336105337105338105339105340105341105342105343105344105345105346105347105348105349105350105351105352105353105354105355105356105357105358105359105360105361105362105363105364105365105366105367105368105369105370105371105372105373105374105375105376105377105378105379105380105381105382105383105384105385105386105387105388105389105390105391105392105393105394105395105396105397105398105399105400105401105402105403105404105405105406105407105408105409105410105411105412105413105414105415105416105417105418105419105420105421105422105423105424105425105426105427105428105429105430105431105432105433105434105435105436105437105438105439105440105441105442105443105444105445105446105447105448105449105450105451105452105453105454105455105456105457105458105459105460105461105462105463105464105465105466105467105468105469105470105471105472105473105474105475105476105477105478105479105480105481105482105483105484105485105486105487105488105489105490105491105492105493105494105495105496105497105498105499105500105501105502105503105504105505105506105507105508105509105510105511105512105513105514105515105516105517105518105519105520105521105522105523105524105525105526105527105528105529105530105531105532105533105534105535105536105537105538105539105540105541105542105543105544105545105546105547105548105549105550105551105552105553105554105555105556105557105558105559105560105561105562105563105564105565105566105567105568105569105570105571105572105573105574105575105576105577105578105579105580105581105582105583105584105585105586105587105588105589105590105591105592105593105594105595105596105597105598105599105600105601105602105603105604105605105606105607105608105609105610105611105612105613105614105615105616105617105618105619105620105621105622105623105624105625105626105627105628105629105630105631105632105633105634105635105636105637105638105639105640105641105642105643105644105645105646105647105648105649105650105651105652105653105654105655105656105657105658105659105660105661105662105663105664105665105666105667105668105669105670105671105672105673105674105675105676105677105678105679105680105681105682105683105684105685105686105687105688105689105690105691105692105693105694105695105696105697105698105699105700105701105702105703105704105705105706105707105708105709105710105711105712105713105714105715105716105717105718105719105720105721105722105723105724105725105726105727105728105729105730105731105732105733105734105735105736105737105738105739105740105741105742105743105744105745105746105747105748105749105750105751105752105753105754105755105756105757105758105759105760105761105762105763105764105765105766105767105768105769105770105771105772105773105774105775105776105777105778105779105780105781105782105783105784105785105786105787105788105789105790105791105792105793105794105795105796105797105798105799105800105801105802105803105804105805105806105807105808105809105810105811105812105813105814105815105816105817105818105819105820105821105822105823105824105825105826105827105828105829105830105831105832105833105834105835105836105837105838105839105840105841105842105843105844105845105846105847105848105849105850105851105852105853105854105855105856105857105858105859105860105861105862105863105864105865105866105867105868105869105870105871105872105873105874105875105876105877105878105879105880105881105882105883105884105885105886105887105888105889105890105891105892105893105894105895105896105897105898105899105900105901105902105903105904105905105906105907105908105909105910105911105912105913105914105915105916105917105918105919105920105921105922105923105924105925105926105927105928105929105930105931105932105933105934105935105936105937105938105939105940105941105942105943105944105945105946105947105948105949105950105951105952105953105954105955105956105957105958105959105960105961105962105963105964105965105966105967105968105969105970105971105972105973105974105975105976105977105978105979105980105981105982105983105984105985105986105987105988105989105990105991105992105993105994105995105996105997105998105999106000106001106002106003106004106005106006106007106008106009106010106011106012106013106014106015106016106017106018106019106020106021106022106023106024106025106026106027106028106029106030106031106032106033106034106035106036106037106038106039106040106041106042106043106044106045106046106047106048106049106050106051106052106053106054106055106056106057106058106059106060106061106062106063106064106065106066106067106068106069106070106071106072106073106074106075106076106077106078106079106080106081106082106083106084106085106086106087106088106089106090106091106092106093106094106095106096106097106098106099106100106101106102106103106104106105106106106107106108106109106110106111106112106113106114106115106116106117106118106119106120106121106122106123106124106125106126106127106128106129106130106131106132106133106134106135106136106137106138106139106140106141106142106143106144106145106146106147106148106149106150106151106152106153106154106155106156106157106158106159106160106161106162106163106164106165106166106167106168106169106170106171106172106173106174106175106176106177106178106179106180106181106182106183106184106185106186106187106188106189106190106191106192106193106194106195106196106197106198106199106200106201106202106203106204106205106206106207106208106209106210106211106212106213106214106215106216106217106218106219106220106221106222106223106224106225106226106227106228106229106230106231106232106233106234106235106236106237106238106239106240106241106242106243106244106245106246106247106248106249106250106251106252106253106254106255106256106257106258106259106260106261106262106263106264106265106266106267106268106269106270106271106272106273106274106275106276106277106278106279106280106281106282106283106284106285106286106287106288106289106290106291106292106293106294106295106296106297106298106299106300106301106302106303106304106305106306106307106308106309106310106311106312106313106314106315106316106317106318106319106320106321106322106323106324106325106326106327106328106329106330106331106332106333106334106335106336106337106338106339106340106341106342106343106344106345106346106347106348106349106350106351106352106353106354106355106356106357106358106359106360106361106362106363106364106365106366106367106368106369106370106371106372106373106374106375106376106377106378106379106380106381106382106383106384106385106386106387106388106389106390106391106392106393106394106395106396106397106398106399106400106401106402106403106404106405106406106407106408106409106410106411106412106413106414106415106416106417106418106419106420106421106422106423106424106425106426106427106428106429106430106431106432106433106434106435106436106437106438106439106440106441106442106443106444106445106446106447106448106449106450106451106452106453106454106455106456106457106458106459106460106461106462106463106464106465106466106467106468106469106470106471106472106473106474106475106476106477106478106479106480106481106482106483106484106485106486106487106488106489106490106491106492106493106494106495106496106497106498106499106500106501106502106503106504106505106506106507106508106509106510106511106512106513106514106515106516106517106518106519106520106521106522106523106524106525106526106527106528106529106530106531106532106533106534106535106536106537106538106539106540106541106542106543106544106545106546106547106548106549106550106551106552106553106554106555106556106557106558106559106560106561106562106563106564106565106566106567106568106569106570106571106572106573106574106575106576106577106578106579106580106581106582106583106584106585106586106587106588106589106590106591106592106593106594106595106596106597106598106599106600106601106602106603106604106605106606106607106608106609106610106611106612106613106614106615106616106617106618106619106620106621106622106623106624106625106626106627106628106629106630106631106632106633106634106635106636106637106638106639106640106641106642106643106644106645106646106647106648106649106650106651106652106653106654106655106656106657106658106659106660106661106662106663106664106665106666106667106668106669106670106671106672106673106674106675106676106677106678106679106680106681106682106683106684106685106686106687106688106689106690106691106692106693106694106695106696106697106698106699106700106701106702106703106704106705106706106707106708106709106710106711106712106713106714106715106716106717106718106719106720106721106722106723106724106725106726106727106728106729106730106731106732106733106734106735106736106737106738106739106740106741106742106743106744106745106746106747106748106749106750106751106752106753106754106755106756106757106758106759106760106761106762106763106764106765106766106767106768106769106770106771106772106773106774106775106776106777106778106779106780106781106782106783106784106785106786106787106788106789106790106791106792106793106794106795106796106797106798106799106800106801106802106803106804106805106806106807106808106809106810106811106812106813106814106815106816106817106818106819106820106821106822106823106824106825106826106827106828106829106830106831106832106833106834106835106836106837106838106839106840106841106842106843106844106845106846106847106848106849106850106851106852106853106854106855106856106857106858106859106860106861106862106863106864106865106866106867106868106869106870106871106872106873106874106875106876106877106878106879106880106881106882106883106884106885106886106887106888106889106890106891106892106893106894106895106896106897106898106899106900106901106902106903106904106905106906106907106908106909106910106911106912106913106914106915106916106917106918106919106920106921106922106923106924106925106926106927106928106929106930106931106932106933106934106935106936106937106938106939106940106941106942106943106944106945106946106947106948106949106950106951106952106953106954106955106956106957106958106959106960106961106962106963106964106965106966106967106968106969106970106971106972106973106974106975106976106977106978106979106980106981106982106983106984106985106986106987106988106989106990106991106992106993106994106995106996106997106998106999107000107001107002107003107004107005107006107007107008107009107010107011107012107013107014107015107016107017107018107019107020107021107022107023107024107025107026107027107028107029107030107031107032107033107034107035107036107037107038107039107040107041107042107043107044107045107046107047107048107049107050107051107052107053107054107055107056107057107058107059107060107061107062107063107064107065107066107067107068107069107070107071107072107073107074107075107076107077107078107079107080107081107082107083107084107085107086107087107088107089107090107091107092107093107094107095107096107097107098107099107100107101107102107103107104107105107106107107107108107109107110107111107112107113107114107115107116107117107118107119107120107121107122107123107124107125107126107127107128107129107130107131107132107133107134107135107136107137107138107139107140107141107142107143107144107145107146107147107148107149107150107151107152107153107154107155107156107157107158107159107160107161107162107163107164107165107166107167107168107169107170107171107172107173107174107175107176107177107178107179107180107181107182107183107184107185107186107187107188107189107190107191107192107193107194107195107196107197107198107199107200107201107202107203107204107205107206107207107208107209107210107211107212107213107214107215107216107217107218107219107220107221107222107223107224107225107226107227107228107229107230107231107232107233107234107235107236107237107238107239107240107241107242107243107244107245107246107247107248107249107250107251107252107253107254107255107256107257107258107259107260107261107262107263107264107265107266107267107268107269107270107271107272107273107274107275107276107277107278107279107280107281107282107283107284107285107286107287107288107289107290107291107292107293107294107295107296107297107298107299107300107301107302107303107304107305107306107307107308107309107310107311107312107313107314107315107316107317107318107319107320107321107322107323107324107325107326107327107328107329107330107331107332107333107334107335107336107337107338107339107340107341107342107343107344107345107346107347107348107349107350107351107352107353107354107355107356107357107358107359107360107361107362107363107364107365107366107367107368107369107370107371107372107373107374107375107376107377107378107379107380107381107382107383107384107385107386107387107388107389107390107391107392107393107394107395107396107397107398107399107400107401107402107403107404107405107406107407107408107409107410107411107412107413107414107415107416107417107418107419107420107421107422107423107424107425107426107427107428107429107430107431107432107433107434107435107436107437107438107439107440107441107442107443107444107445107446107447107448107449107450107451107452107453107454107455107456107457107458107459107460107461107462107463107464107465107466107467107468107469107470107471107472107473107474107475107476107477107478107479107480107481107482107483107484107485107486107487107488107489107490107491107492107493107494107495107496107497107498107499107500107501107502107503107504107505107506107507107508107509107510107511107512107513107514107515107516107517107518107519107520107521107522107523107524107525107526107527107528107529107530107531107532107533107534107535107536107537107538107539107540107541107542107543107544107545107546107547107548107549107550107551107552107553107554107555107556107557107558107559107560107561107562107563107564107565107566107567107568107569107570107571107572107573107574107575107576107577107578107579107580107581107582107583107584107585107586107587107588107589107590107591107592107593107594107595107596107597107598107599107600107601107602107603107604107605107606107607107608107609107610107611107612107613107614107615107616107617107618107619107620107621107622107623107624107625107626107627107628107629107630107631107632107633107634107635107636107637107638107639107640107641107642107643107644107645107646107647107648107649107650107651107652107653107654107655107656107657107658107659107660107661107662107663107664107665107666107667107668107669107670107671107672107673107674107675107676107677107678107679107680107681107682107683107684107685107686107687107688107689107690107691107692107693107694107695107696107697107698107699107700107701107702107703107704107705107706107707107708107709107710107711107712107713107714107715107716107717107718107719107720107721107722107723107724107725107726107727107728107729107730107731107732107733107734107735107736107737107738107739107740107741107742107743107744107745107746107747107748107749107750107751107752107753107754107755107756107757107758107759107760107761107762107763107764107765107766107767107768107769107770107771107772107773107774107775107776107777107778107779107780107781107782107783107784107785107786107787107788107789107790107791107792107793107794107795107796107797107798107799107800107801107802107803107804107805107806107807107808107809107810107811107812107813107814107815107816107817107818107819107820107821107822107823107824107825107826107827107828107829107830107831107832107833107834107835107836107837107838107839107840107841107842107843107844107845107846107847107848107849107850107851107852107853107854107855107856107857107858107859107860107861107862107863107864107865107866107867107868107869107870107871107872107873107874107875107876107877107878107879107880107881107882107883107884107885107886107887107888107889107890107891107892107893107894107895107896107897107898107899107900107901107902107903107904107905107906107907107908107909107910107911107912107913107914107915107916107917107918107919107920107921107922107923107924107925107926107927107928107929107930107931107932107933107934107935107936107937107938107939107940107941107942107943107944107945107946107947107948107949107950107951107952107953107954107955107956107957107958107959107960107961107962107963107964107965107966107967107968107969107970107971107972107973107974107975107976107977107978107979107980107981107982107983107984107985107986107987107988107989107990107991107992107993107994107995107996107997107998107999108000108001108002108003108004108005108006108007108008108009108010108011108012108013108014108015108016108017108018108019108020108021108022108023108024108025108026108027108028108029108030108031108032108033108034108035108036108037108038108039108040108041108042108043108044108045108046108047108048108049108050108051108052108053108054108055108056108057108058108059108060108061108062108063108064108065108066108067108068108069108070108071108072108073108074108075108076108077108078108079108080108081108082108083108084108085108086108087108088108089108090108091108092108093108094108095108096108097108098108099108100108101108102108103108104108105108106108107108108108109108110108111108112108113108114108115108116108117108118108119108120108121108122108123108124108125108126108127108128108129108130108131108132108133108134108135108136108137108138108139108140108141108142108143108144108145108146108147108148108149108150108151108152108153108154108155108156108157108158108159108160108161108162108163108164108165108166108167108168108169108170108171108172108173108174108175108176108177108178108179108180108181108182108183108184108185108186108187108188108189108190108191108192108193108194108195108196108197108198108199108200108201108202108203108204108205108206108207108208108209108210108211108212108213108214108215108216108217108218108219108220108221108222108223108224108225108226108227108228108229108230108231108232108233108234108235108236108237108238108239108240108241108242108243108244108245108246108247108248108249108250108251108252108253108254108255108256108257108258108259108260108261108262108263108264108265108266108267108268108269108270108271108272108273108274108275108276108277108278108279108280108281108282108283108284108285108286108287108288108289108290108291108292108293108294108295108296108297108298108299108300108301108302108303108304108305108306108307108308108309108310108311108312108313108314108315108316108317108318108319108320108321108322108323108324108325108326108327108328108329108330108331108332108333108334108335108336108337108338108339108340108341108342108343108344108345108346108347108348108349108350108351108352108353108354108355108356108357108358108359108360108361108362108363108364108365108366108367108368108369108370108371108372108373108374108375108376108377108378108379108380108381108382108383108384108385108386108387108388108389108390108391108392108393108394108395108396108397108398108399108400108401108402108403108404108405108406108407108408108409108410108411108412108413108414108415108416108417108418108419108420108421108422108423108424108425108426108427108428108429108430108431108432108433108434108435108436108437108438108439108440108441108442108443108444108445108446108447108448108449108450108451108452108453108454108455108456108457108458108459108460108461108462108463108464108465108466108467108468108469108470108471108472108473108474108475108476108477108478108479108480108481108482108483108484108485108486108487108488108489108490108491108492108493108494108495108496108497108498108499108500108501108502108503108504108505108506108507108508108509108510108511108512108513108514108515108516108517108518108519108520108521108522108523108524108525108526108527108528108529108530108531108532108533108534108535108536108537108538108539108540108541108542108543108544108545108546108547108548108549108550108551108552108553108554108555108556108557108558108559108560108561108562108563108564108565108566108567108568108569108570108571108572108573108574108575108576108577108578108579108580108581108582108583108584108585108586108587108588108589108590108591108592108593108594108595108596108597108598108599108600108601108602108603108604108605108606108607108608108609108610108611108612108613108614108615108616108617108618108619108620108621108622108623108624108625108626108627108628108629108630108631108632108633108634108635108636108637108638108639108640108641108642108643108644108645108646108647108648108649108650108651108652108653108654108655108656108657108658108659108660108661108662108663108664108665108666108667108668108669108670108671108672108673108674108675108676108677108678108679108680108681108682108683108684108685108686108687108688108689108690108691108692108693108694108695108696108697108698108699108700108701108702108703108704108705108706108707108708108709108710108711108712108713108714108715108716108717108718108719108720108721108722108723108724108725108726108727108728108729108730108731108732108733108734108735108736108737108738108739108740108741108742108743108744108745108746108747108748108749108750108751108752108753108754108755108756108757108758108759108760108761108762108763108764108765108766108767108768108769108770108771108772108773108774108775108776108777108778108779108780108781108782108783108784108785108786108787108788108789108790108791108792108793108794108795108796108797108798108799108800108801108802108803108804108805108806108807108808108809108810108811108812108813108814108815108816108817108818108819108820108821108822108823108824108825108826108827108828108829108830108831108832108833108834108835108836108837108838108839108840108841108842108843108844108845108846108847108848108849108850108851108852108853108854108855108856108857108858108859108860108861108862108863108864108865108866108867108868108869108870108871108872108873108874108875108876108877108878108879108880108881108882108883108884108885108886108887108888108889108890108891108892108893108894108895108896108897108898108899108900108901108902108903108904108905108906108907108908108909108910108911108912108913108914108915108916108917108918108919108920108921108922108923108924108925108926108927108928108929108930108931108932108933108934108935108936108937108938108939108940108941108942108943108944108945108946108947108948108949108950108951108952108953108954108955108956108957108958108959108960108961108962108963108964108965108966108967108968108969108970108971108972108973108974108975108976108977108978108979108980108981108982108983108984108985108986108987108988108989108990108991108992108993108994108995108996108997108998108999109000109001109002109003109004109005109006109007109008109009109010109011109012109013109014109015109016109017109018109019109020109021109022109023109024109025109026109027109028109029109030109031109032109033109034109035109036109037109038109039109040109041109042109043109044109045109046109047109048109049109050109051109052109053109054109055109056109057109058109059109060109061109062109063109064109065109066109067109068109069109070109071109072109073109074109075109076109077109078109079109080109081109082109083109084109085109086109087109088109089109090109091109092109093109094109095109096109097109098109099109100109101109102109103109104109105109106109107109108109109109110109111109112109113109114109115109116109117109118109119109120109121109122109123109124109125109126109127109128109129109130109131109132109133109134109135109136109137109138109139109140109141109142109143109144109145109146109147109148109149109150109151109152109153109154109155109156109157109158109159109160109161109162109163109164109165109166109167109168109169109170109171109172109173109174109175109176109177109178109179109180109181109182109183109184109185109186109187109188109189109190109191109192109193109194109195109196109197109198109199109200109201109202109203109204109205109206109207109208109209109210109211109212109213109214109215109216109217109218109219109220109221109222109223109224109225109226109227109228109229109230109231109232109233109234109235109236109237109238109239109240109241109242109243109244109245109246109247109248109249109250109251109252109253109254109255109256109257109258109259109260109261109262109263109264109265109266109267109268109269109270109271109272109273109274109275109276109277109278109279109280109281109282109283109284109285109286109287109288109289109290109291109292109293109294109295109296109297109298109299109300109301109302109303109304109305109306109307109308109309109310109311109312109313109314109315109316109317109318109319109320109321109322109323109324109325109326109327109328109329109330109331109332109333109334109335109336109337109338109339109340109341109342109343109344109345109346109347109348109349109350109351109352109353109354109355109356109357109358109359109360109361109362109363109364109365109366109367109368109369109370109371109372109373109374109375109376109377109378109379109380109381109382109383109384109385109386109387109388109389109390109391109392109393109394109395109396109397109398109399109400109401109402109403109404109405109406109407109408109409109410109411109412109413109414109415109416109417109418109419109420109421109422109423109424109425109426109427109428109429109430109431109432109433109434109435109436109437109438109439109440109441109442109443109444109445109446109447109448109449109450109451109452109453109454109455109456109457109458109459109460109461109462109463109464109465109466109467109468109469109470109471109472109473109474109475109476109477109478109479109480109481109482109483109484109485109486109487109488109489109490109491109492109493109494109495109496109497109498109499109500109501109502109503109504109505109506109507109508109509109510109511109512109513109514109515109516109517109518109519109520109521109522109523109524109525109526109527109528109529109530109531109532109533109534109535109536109537109538109539109540109541109542109543109544109545109546109547109548109549109550109551109552109553109554109555109556109557109558109559109560109561109562109563109564109565109566109567109568109569109570109571109572109573109574109575109576109577109578109579109580109581109582109583109584109585109586109587109588109589109590109591109592109593109594109595109596109597109598109599109600109601109602109603109604109605109606109607109608109609109610109611109612109613109614109615109616109617109618109619109620109621109622109623109624109625109626109627109628109629109630109631109632109633109634109635109636109637109638109639109640109641109642109643109644109645109646109647109648109649109650109651109652109653109654109655109656109657109658109659109660109661109662109663109664109665109666109667109668109669109670109671109672109673109674109675109676109677109678109679109680109681109682109683109684109685109686109687109688109689109690109691109692109693109694109695109696109697109698109699109700109701109702109703109704109705109706109707109708109709109710109711109712109713109714109715109716109717109718109719109720109721109722109723109724109725109726109727109728109729109730109731109732109733109734109735109736109737109738109739109740109741109742109743109744109745109746109747109748109749109750109751109752109753109754109755109756109757109758109759109760109761109762109763109764109765109766109767109768109769109770109771109772109773109774109775109776109777109778109779109780109781109782109783109784109785109786109787109788109789109790109791109792109793109794109795109796109797109798109799109800109801109802109803109804109805109806109807109808109809109810109811109812109813109814109815109816109817109818109819109820109821109822109823109824109825109826109827109828109829109830109831109832109833109834109835109836109837109838109839109840109841109842109843109844109845109846109847109848109849109850109851109852109853109854109855109856109857109858109859109860109861109862109863109864109865109866109867109868109869109870109871109872109873109874109875109876109877109878109879109880109881109882109883109884109885109886109887109888109889109890109891109892109893109894109895109896109897109898109899109900109901109902109903109904109905109906109907109908109909109910109911109912109913109914109915109916109917109918109919109920109921109922109923109924109925109926109927109928109929109930109931109932109933109934109935109936109937109938109939109940109941109942109943109944109945109946109947109948109949109950109951109952109953109954109955109956109957109958109959109960109961109962109963109964109965109966109967109968109969109970109971109972109973109974109975109976109977109978109979109980109981109982109983109984109985109986109987109988109989109990109991109992109993109994109995109996109997109998109999110000110001110002110003110004110005110006110007110008110009110010110011110012110013110014110015110016110017110018110019110020110021110022110023110024110025110026110027110028110029110030110031110032110033110034110035110036110037110038110039110040110041110042110043110044110045110046110047110048110049110050110051110052110053110054110055110056110057110058110059110060110061110062110063110064110065110066110067110068110069110070110071110072110073110074110075110076110077110078110079110080110081110082110083110084110085110086110087110088110089110090110091110092110093110094110095110096110097110098110099110100110101110102110103110104110105110106110107110108110109110110110111110112110113110114110115110116110117110118110119110120110121110122110123110124110125110126110127110128110129110130110131110132110133110134110135110136110137110138110139110140110141110142110143110144110145110146110147110148110149110150110151110152110153110154110155110156110157110158110159110160110161110162110163110164110165110166110167110168110169110170110171110172110173110174110175110176110177110178110179110180110181110182110183110184110185110186110187110188110189110190110191110192110193110194110195110196110197110198110199110200110201110202110203110204110205110206110207110208110209110210110211110212110213110214110215110216110217110218110219110220110221110222110223110224110225110226110227110228110229110230110231110232110233110234110235110236110237110238110239110240110241110242110243110244110245110246110247110248110249110250110251110252110253110254110255110256110257110258110259110260110261110262110263110264110265110266110267110268110269110270110271110272110273110274110275110276110277110278110279110280110281110282110283110284110285110286110287110288110289110290110291110292110293110294110295110296110297110298110299110300110301110302110303110304110305110306110307110308110309110310110311110312110313110314110315110316110317110318110319110320110321110322110323110324110325110326110327110328110329110330110331110332110333110334110335110336110337110338110339110340110341110342110343110344110345110346110347110348110349110350110351110352110353110354110355110356110357110358110359110360110361110362110363110364110365110366110367110368110369110370110371110372110373110374110375110376110377110378110379110380110381110382110383110384110385110386110387110388110389110390110391110392110393110394110395110396110397110398110399110400110401110402110403110404110405110406110407110408110409110410110411110412110413110414110415110416110417110418110419110420110421110422110423110424110425110426110427110428110429110430110431110432110433110434110435110436110437110438110439110440110441110442110443110444110445110446110447110448110449110450110451110452110453110454110455110456110457110458110459110460110461110462110463110464110465110466110467110468110469110470110471110472110473110474110475110476110477110478110479110480110481110482110483110484110485110486110487110488110489110490110491110492110493110494110495110496110497110498110499110500110501110502110503110504110505110506110507110508110509110510110511110512110513110514110515110516110517110518110519110520110521110522110523110524110525110526110527110528110529110530110531110532110533110534110535110536110537110538110539110540110541110542110543110544110545110546110547110548110549110550110551110552110553110554110555110556110557110558110559110560110561110562110563110564110565110566110567110568110569110570110571110572110573110574110575110576110577110578110579110580110581110582110583110584110585110586110587110588110589110590110591110592110593110594110595110596110597110598110599110600110601110602110603110604110605110606110607110608110609110610110611110612110613110614110615110616110617110618110619110620110621110622110623110624110625110626110627110628110629110630110631110632110633110634110635110636110637110638110639110640110641110642110643110644110645110646110647110648110649110650110651110652110653110654110655110656110657110658110659110660110661110662110663110664110665110666110667110668110669110670110671110672110673110674110675110676110677110678110679110680110681110682110683110684110685110686110687110688110689110690110691110692110693110694110695110696110697110698110699110700110701110702110703110704110705110706110707110708110709110710110711110712110713110714110715110716110717110718110719110720110721110722110723110724110725110726110727110728110729110730110731110732110733110734110735110736110737110738110739110740110741110742110743110744110745110746110747110748110749110750110751110752110753110754110755110756110757110758110759110760110761110762110763110764110765110766110767110768110769110770110771110772110773110774110775110776110777110778110779110780110781110782110783110784110785110786110787110788110789110790110791110792110793110794110795110796110797110798110799110800110801110802110803110804110805110806110807110808110809110810110811110812110813110814110815110816110817110818110819110820110821110822110823110824110825110826110827110828110829110830110831110832110833110834110835110836110837110838110839110840110841110842110843110844110845110846110847110848110849110850110851110852110853110854110855110856110857110858110859110860110861110862110863110864110865110866110867110868110869110870110871110872110873110874110875110876110877110878110879110880110881110882110883110884110885110886110887110888110889110890110891110892110893110894110895110896110897110898110899110900110901110902110903110904110905110906110907110908110909110910110911110912110913110914110915110916110917110918110919110920110921110922110923110924110925110926110927110928110929110930110931110932110933110934110935110936110937110938110939110940110941110942110943110944110945110946110947110948110949110950110951110952110953110954110955110956110957110958110959110960110961110962110963110964110965110966110967110968110969110970110971110972110973110974110975110976110977110978110979110980110981110982110983110984110985110986110987110988110989110990110991110992110993110994110995110996110997110998110999111000111001111002111003111004111005111006111007111008111009111010111011111012111013111014111015111016111017111018111019111020111021111022111023111024111025111026111027111028111029111030111031111032111033111034111035111036111037111038111039111040111041111042111043111044111045111046111047111048111049111050111051111052111053111054111055111056111057111058111059111060111061111062111063111064111065111066111067111068111069111070111071111072111073111074111075111076111077111078111079111080111081111082111083111084111085111086111087111088111089111090111091111092111093111094111095111096111097111098111099111100111101111102111103111104111105111106111107111108111109111110111111111112111113111114111115111116111117111118111119111120111121111122111123111124111125111126111127111128111129111130111131111132111133111134111135111136111137111138111139111140111141111142111143111144111145111146111147111148111149111150111151111152111153111154111155111156111157111158111159111160111161111162111163111164111165111166111167111168111169111170111171111172111173111174111175111176111177111178111179111180111181111182111183111184111185111186111187111188111189111190111191111192111193111194111195111196111197111198111199111200111201111202111203111204111205111206111207111208111209111210111211111212111213111214111215111216111217111218111219111220111221111222111223111224111225111226111227111228111229111230111231111232111233111234111235111236111237111238111239111240111241111242111243111244111245111246111247111248111249111250111251111252111253111254111255111256111257111258111259111260111261111262111263111264111265111266111267111268111269111270111271111272111273111274111275111276111277111278111279111280111281111282111283111284111285111286111287111288111289111290111291111292111293111294111295111296111297111298111299111300111301111302111303111304111305111306111307111308111309111310111311111312111313111314111315111316111317111318111319111320111321111322111323111324111325111326111327111328111329111330111331111332111333111334111335111336111337111338111339111340111341111342111343111344111345111346111347111348111349111350111351111352111353111354111355111356111357111358111359111360111361111362111363111364111365111366111367111368111369111370111371111372111373111374111375111376111377111378111379111380111381111382111383111384111385111386111387111388111389111390111391111392111393111394111395111396111397111398111399111400111401111402111403111404111405111406111407111408111409111410111411111412111413111414111415111416111417111418111419111420111421111422111423111424111425111426111427111428111429111430111431111432111433111434111435111436111437111438111439111440111441111442111443111444111445111446111447111448111449111450111451111452111453111454111455111456111457111458111459111460111461111462111463111464111465111466111467111468111469111470111471111472111473111474111475111476111477111478111479111480111481111482111483111484111485111486111487111488111489111490111491111492111493111494111495111496111497111498111499111500111501111502111503111504111505111506111507111508111509111510111511111512111513111514111515111516111517111518111519111520111521111522111523111524111525111526111527111528111529111530111531111532111533111534111535111536111537111538111539111540111541111542111543111544111545111546111547111548111549111550111551111552111553111554111555111556111557111558111559111560111561111562111563111564111565111566111567111568111569111570111571111572111573111574111575111576111577111578111579111580111581111582111583111584111585111586111587111588111589111590111591111592111593111594111595111596111597111598111599111600111601111602111603111604111605111606111607111608111609111610111611111612111613111614111615111616111617111618111619111620111621111622111623111624111625111626111627111628111629111630111631111632111633111634111635111636111637111638111639111640111641111642111643111644111645111646111647111648111649111650111651111652111653111654111655111656111657111658111659111660111661111662111663111664111665111666111667111668111669111670111671111672111673111674111675111676111677111678111679111680111681111682111683111684111685111686111687111688111689111690111691111692111693111694111695111696111697111698111699111700111701111702111703111704111705111706111707111708111709111710111711111712111713111714111715111716111717111718111719111720111721111722111723111724111725111726111727111728111729111730111731111732111733111734111735111736111737111738111739111740111741111742111743111744111745111746111747111748111749111750111751111752111753111754111755111756111757111758111759111760111761111762111763111764111765111766111767111768111769111770111771111772111773111774111775111776111777111778111779111780111781111782111783111784111785111786111787111788111789111790111791111792111793111794111795111796111797111798111799111800111801111802111803111804111805111806111807111808111809111810111811111812111813111814111815111816111817111818111819111820111821111822111823111824111825111826111827111828111829111830111831111832111833111834111835111836111837111838111839111840111841111842111843111844111845111846111847111848111849111850111851111852111853111854111855111856111857111858111859111860111861111862111863111864111865111866111867111868111869111870111871111872111873111874111875111876111877111878111879111880111881111882111883111884111885111886111887111888111889111890111891111892111893111894111895111896111897111898111899111900111901111902111903111904111905111906111907111908111909111910111911111912111913111914111915111916111917111918111919111920111921111922111923111924111925111926111927111928111929111930111931111932111933111934111935111936111937111938111939111940111941111942111943111944111945111946111947111948111949111950111951111952111953111954111955111956111957111958111959111960111961111962111963111964111965111966111967111968111969111970111971111972111973111974111975111976111977111978111979111980111981111982111983111984111985111986111987111988111989111990111991111992111993111994111995111996111997111998111999112000112001112002112003112004112005112006112007112008112009112010112011112012112013112014112015112016112017112018112019112020112021112022112023112024112025112026112027112028112029112030112031112032112033112034112035112036112037112038112039112040112041112042112043112044112045112046112047112048112049112050112051112052112053112054112055112056112057112058112059112060112061112062112063112064112065112066112067112068112069112070112071112072112073112074112075112076112077112078112079112080112081112082112083112084112085112086112087112088112089112090112091112092112093112094112095112096112097112098112099112100112101112102112103112104112105112106112107112108112109112110112111112112112113112114112115112116112117112118112119112120112121112122112123112124112125112126112127112128112129112130112131112132112133112134112135112136112137112138112139112140112141112142112143112144112145112146112147112148112149112150112151112152112153112154112155112156112157112158112159112160112161112162112163112164112165112166112167112168112169112170112171112172112173112174112175112176112177112178112179112180112181112182112183112184112185112186112187112188112189112190112191112192112193112194112195112196112197112198112199112200112201112202112203112204112205112206112207112208112209112210112211112212112213112214112215112216112217112218112219112220112221112222112223112224112225112226112227112228112229112230112231112232112233112234112235112236112237112238112239112240112241112242112243112244112245112246112247112248112249112250112251112252112253112254112255112256112257112258112259112260112261112262112263112264112265112266112267112268112269112270112271112272112273112274112275112276112277112278112279112280112281112282112283112284112285112286112287112288112289112290112291112292112293112294112295112296112297112298112299112300112301112302112303112304112305112306112307112308112309112310112311112312112313112314112315112316112317112318112319112320112321112322112323112324112325112326112327112328112329112330112331112332112333112334112335112336112337112338112339112340112341112342112343112344112345112346112347112348112349112350112351112352112353112354112355112356112357112358112359112360112361112362112363112364112365112366112367112368112369112370112371112372112373112374112375112376112377112378112379112380112381112382112383112384112385112386112387112388112389112390112391112392112393112394112395112396112397112398112399112400112401112402112403112404112405112406112407112408112409112410112411112412112413112414112415112416112417112418112419112420112421112422112423112424112425112426112427112428112429112430112431112432112433112434112435112436112437112438112439112440112441112442112443112444112445112446112447112448112449112450112451112452112453112454112455112456112457112458112459112460112461112462112463112464112465112466112467112468112469112470112471112472112473112474112475112476112477112478112479112480112481112482112483112484112485112486112487112488112489112490112491112492112493112494112495112496112497112498112499112500112501112502112503112504112505112506112507112508112509112510112511112512112513112514112515112516112517112518112519112520112521112522112523112524112525112526112527112528112529112530112531112532112533112534112535112536112537112538112539112540112541112542112543112544112545112546112547112548112549112550112551112552112553112554112555112556112557112558112559112560112561112562112563112564112565112566112567112568112569112570112571112572112573112574112575112576112577112578112579112580112581112582112583112584112585112586112587112588112589112590112591112592112593112594112595112596112597112598112599112600112601112602112603112604112605112606112607112608112609112610112611112612112613112614112615112616112617112618112619112620112621112622112623112624112625112626112627112628112629112630112631112632112633112634112635112636112637112638112639112640112641112642112643112644112645112646112647112648112649112650112651112652112653112654112655112656112657112658112659112660112661112662112663112664112665112666112667112668112669112670112671112672112673112674112675112676112677112678112679112680112681112682112683112684112685112686112687112688112689112690112691112692112693112694112695112696112697112698112699112700112701112702112703112704112705112706112707112708112709112710112711112712112713112714112715112716112717112718112719112720112721112722112723112724112725112726112727112728112729112730112731112732112733112734112735112736112737112738112739112740112741112742112743112744112745112746112747112748112749112750112751112752112753112754112755112756112757112758112759112760112761112762112763112764112765112766112767112768112769112770112771112772112773112774112775112776112777112778112779112780112781112782112783112784112785112786112787112788112789112790112791112792112793112794112795112796112797112798112799112800112801112802112803112804112805112806112807112808112809112810112811112812112813112814112815112816112817112818112819112820112821112822112823112824112825112826112827112828112829112830112831112832112833112834112835112836112837112838112839112840112841112842112843112844112845112846112847112848112849112850112851112852112853112854112855112856112857112858112859112860112861112862112863112864112865112866112867112868112869112870112871112872112873112874112875112876112877112878112879112880112881112882112883112884112885112886112887112888112889112890112891112892112893112894112895112896112897112898112899112900112901112902112903112904112905112906112907112908112909112910112911112912112913112914112915112916112917112918112919112920112921112922112923112924112925112926112927112928112929112930112931112932112933112934112935112936112937112938112939112940112941112942112943112944112945112946112947112948112949112950112951112952112953112954112955112956112957112958112959112960112961112962112963112964112965112966112967112968112969112970112971112972112973112974112975112976112977112978112979112980112981112982112983112984112985112986112987112988112989112990112991112992112993112994112995112996112997112998112999113000113001113002113003113004113005113006113007113008113009113010113011113012113013113014113015113016113017113018113019113020113021113022113023113024113025113026113027113028113029113030113031113032113033113034113035113036113037113038113039113040113041113042113043113044113045113046113047113048113049113050113051113052113053113054113055113056113057113058113059113060113061113062113063113064113065113066113067113068113069113070113071113072113073113074113075113076113077113078113079113080113081113082113083113084113085113086113087113088113089113090113091113092113093113094113095113096113097113098113099113100113101113102113103113104113105113106113107113108113109113110113111113112113113113114113115113116113117113118113119113120113121113122113123113124113125113126113127113128113129113130113131113132113133113134113135113136113137113138113139113140113141113142113143113144113145113146113147113148113149113150113151113152113153113154113155113156113157113158113159113160113161113162113163113164113165113166113167113168113169113170113171113172113173113174113175113176113177113178113179113180113181113182113183113184113185113186113187113188113189113190113191113192113193113194113195113196113197113198113199113200113201113202113203113204113205113206113207113208113209113210113211113212113213113214113215113216113217113218113219113220113221113222113223113224113225113226113227113228113229113230113231113232113233113234113235113236113237113238113239113240113241113242113243113244113245113246113247113248113249113250113251113252113253113254113255113256113257113258113259113260113261113262113263113264113265113266113267113268113269113270113271113272113273113274113275113276113277113278113279113280113281113282113283113284113285113286113287113288113289113290113291113292113293113294113295113296113297113298113299113300113301113302113303113304113305113306113307113308113309113310113311113312113313113314113315113316113317113318113319113320113321113322113323113324113325113326113327113328113329113330113331113332113333113334113335113336113337113338113339113340113341113342113343113344113345113346113347113348113349113350113351113352113353113354113355113356113357113358113359113360113361113362113363113364113365113366113367113368113369113370113371113372113373113374113375113376113377113378113379113380113381113382113383113384113385113386113387113388113389113390113391113392113393113394113395113396113397113398113399113400113401113402113403113404113405113406113407113408113409113410113411113412113413113414113415113416113417113418113419113420113421113422113423113424113425113426113427113428113429113430113431113432113433113434113435113436113437113438113439113440113441113442113443113444113445113446113447113448113449113450113451113452113453113454113455113456113457113458113459113460113461113462113463113464113465113466113467113468113469113470113471113472113473113474113475113476113477113478113479113480113481113482113483113484113485113486113487113488113489113490113491113492113493113494113495113496113497113498113499113500113501113502113503113504113505113506113507113508113509113510113511113512113513113514113515113516113517113518113519113520113521113522113523113524113525113526113527113528113529113530113531113532113533113534113535113536113537113538113539113540113541113542113543113544113545113546113547113548113549113550113551113552113553113554113555113556113557113558113559113560113561113562113563113564113565113566113567113568113569113570113571113572113573113574113575113576113577113578113579113580113581113582113583113584113585113586113587113588113589113590113591113592113593113594113595113596113597113598113599113600113601113602113603113604113605113606113607113608113609113610113611113612113613113614113615113616113617113618113619113620113621113622113623113624113625113626113627113628113629113630113631113632113633113634113635113636113637113638113639113640113641113642113643113644113645113646113647113648113649113650113651113652113653113654113655113656113657113658113659113660113661113662113663113664113665113666113667113668113669113670113671113672113673113674113675113676113677113678113679113680113681113682113683113684113685113686113687113688113689113690113691113692113693113694113695113696113697113698113699113700113701113702113703113704113705113706113707113708113709113710113711113712113713113714113715113716113717113718113719113720113721113722113723113724113725113726113727113728113729113730113731113732113733113734113735113736113737113738113739113740113741113742113743113744113745113746113747113748113749113750113751113752113753113754113755113756113757113758113759113760113761113762113763113764113765113766113767113768113769113770113771113772113773113774113775113776113777113778113779113780113781113782113783113784113785113786113787113788113789113790113791113792113793113794113795113796113797113798113799113800113801113802113803113804113805113806113807113808113809113810113811113812113813113814113815113816113817113818113819113820113821113822113823113824113825113826113827113828113829113830113831113832113833113834113835113836113837113838113839113840113841113842113843113844113845113846113847113848113849113850113851113852113853113854113855113856113857113858113859113860113861113862113863113864113865113866113867113868113869113870113871113872113873113874113875113876113877113878113879113880113881113882113883113884113885113886113887113888113889113890113891113892113893113894113895113896113897113898113899113900113901113902113903113904113905113906113907113908113909113910113911113912113913113914113915113916113917113918113919113920113921113922113923113924113925113926113927113928113929113930113931113932113933113934113935113936113937113938113939113940113941113942113943113944113945113946113947113948113949113950113951113952113953113954113955113956113957113958113959113960113961113962113963113964113965113966113967113968113969113970113971113972113973113974113975113976113977113978113979113980113981113982113983113984113985113986113987113988113989113990113991113992113993113994113995113996113997113998113999114000114001114002114003114004114005114006114007114008114009114010114011114012114013114014114015114016114017114018114019114020114021114022114023114024114025114026114027114028114029114030114031114032114033114034114035114036114037114038114039114040114041114042114043114044114045114046114047114048114049114050114051114052114053114054114055114056114057114058114059114060114061114062114063114064114065114066114067114068114069114070114071114072114073114074114075114076114077114078114079114080114081114082114083114084114085114086114087114088114089114090114091114092114093114094114095114096114097114098114099114100114101114102114103114104114105114106114107114108114109114110114111114112114113114114114115114116114117114118114119114120114121114122114123114124114125114126114127114128114129114130114131114132114133114134114135114136114137114138114139114140114141114142114143114144114145114146114147114148114149114150114151114152114153114154114155114156114157114158114159114160114161114162114163114164114165114166114167114168114169114170114171114172114173114174114175114176114177114178114179114180114181114182114183114184114185114186114187114188114189114190114191114192114193114194114195114196114197114198114199114200114201114202114203114204114205114206114207114208114209114210114211114212114213114214114215114216114217114218114219114220114221114222114223114224114225114226114227114228114229114230114231114232114233114234114235114236114237114238114239114240114241114242114243114244114245114246114247114248114249114250114251114252114253114254114255114256114257114258114259114260114261114262114263114264114265114266114267114268114269114270114271114272114273114274114275114276114277114278114279114280114281114282114283114284114285114286114287114288114289114290114291114292114293114294114295114296114297114298114299114300114301114302114303114304114305114306114307114308114309114310114311114312114313114314114315114316114317114318114319114320114321114322114323114324114325114326114327114328114329114330114331114332114333114334114335114336114337114338114339114340114341114342114343114344114345114346114347114348114349114350114351114352114353114354114355114356114357114358114359114360114361114362114363114364114365114366114367114368114369114370114371114372114373114374114375114376114377114378114379114380114381114382114383114384114385114386114387114388114389114390114391114392114393114394114395114396114397114398114399114400114401114402114403114404114405114406114407114408114409114410114411114412114413114414114415114416114417114418114419114420114421114422114423114424114425114426114427114428114429114430114431114432114433114434114435114436114437114438114439114440114441114442114443114444114445114446114447114448114449114450114451114452114453114454114455114456114457114458114459114460114461114462114463114464114465114466114467114468114469114470114471114472114473114474114475114476114477114478114479114480114481114482114483114484114485114486114487114488114489114490114491114492114493114494114495114496114497114498114499114500114501114502114503114504114505114506114507114508114509114510114511114512114513114514114515114516114517114518114519114520114521114522114523114524114525114526114527114528114529114530114531114532114533114534114535114536114537114538114539114540114541114542114543114544114545114546114547114548114549114550114551114552114553114554114555114556114557114558114559114560114561114562114563114564114565114566114567114568114569114570114571114572114573114574114575114576114577114578114579114580114581114582114583114584114585114586114587114588114589114590114591114592114593114594114595114596114597114598114599114600114601114602114603114604114605114606114607114608114609114610114611114612114613114614114615114616114617114618114619114620114621114622114623114624114625114626114627114628114629114630114631114632114633114634114635114636114637114638114639114640114641114642114643114644114645114646114647114648114649114650114651114652114653114654114655114656114657114658114659114660114661114662114663114664114665114666114667114668114669114670114671114672114673114674114675114676114677114678114679114680114681114682114683114684114685114686114687114688114689114690114691114692114693114694114695114696114697114698114699114700114701114702114703114704114705114706114707114708114709114710114711114712114713114714114715114716114717114718114719114720114721114722114723114724114725114726114727114728114729114730114731114732114733114734114735114736114737114738114739114740114741114742114743114744114745114746114747114748114749114750114751114752114753114754114755114756114757114758114759114760114761114762114763114764114765114766114767114768114769114770114771114772114773114774114775114776114777114778114779114780114781114782114783114784114785114786114787114788114789114790114791114792114793114794114795114796114797114798114799114800114801114802114803114804114805114806114807114808114809114810114811114812114813114814114815114816114817114818114819114820114821114822114823114824114825114826114827114828114829114830114831114832114833114834114835114836114837114838114839114840114841114842114843114844114845114846114847114848114849114850114851114852114853114854114855114856114857114858114859114860114861114862114863114864114865114866114867114868114869114870114871114872114873114874114875114876114877114878114879114880114881114882114883114884114885114886114887114888114889114890114891114892114893114894114895114896114897114898114899114900114901114902114903114904114905114906114907114908114909114910114911114912114913114914114915114916114917114918114919114920114921114922114923114924114925114926114927114928114929114930114931114932114933114934114935114936114937114938114939114940114941114942114943114944114945114946114947114948114949114950114951114952114953114954114955114956114957114958114959114960114961114962114963114964114965114966114967114968114969114970114971114972114973114974114975114976114977114978114979114980114981114982114983114984114985114986114987114988114989114990114991114992114993114994114995114996114997114998114999115000115001115002115003115004115005115006115007115008115009115010115011115012115013115014115015115016115017115018115019115020115021115022115023115024115025115026115027115028115029115030115031115032115033115034115035115036115037115038115039115040115041115042115043115044115045115046115047115048115049115050115051115052115053115054115055115056115057115058115059115060115061115062115063115064115065115066115067115068115069115070115071115072115073115074115075115076115077115078115079115080115081115082115083115084115085115086115087115088115089115090115091115092115093115094115095115096115097115098115099115100115101115102115103115104115105115106115107115108115109115110115111115112115113115114115115115116115117115118115119115120115121115122115123115124115125115126115127115128115129115130115131115132115133115134115135115136115137115138115139115140115141115142115143115144115145115146115147115148115149115150115151115152115153115154115155115156115157115158115159115160115161115162115163115164115165115166115167115168115169115170115171115172115173115174115175115176115177115178115179115180115181115182115183115184115185115186115187115188115189115190115191115192115193115194115195115196115197115198115199115200115201115202115203115204115205115206115207115208115209115210115211115212115213115214115215115216115217115218115219115220115221115222115223115224115225115226115227115228115229115230115231115232115233115234115235115236115237115238115239115240115241115242115243115244115245115246115247115248115249115250115251115252115253115254115255115256115257115258115259115260115261115262115263115264115265115266115267115268115269115270115271115272115273115274115275115276115277115278115279115280115281115282115283115284115285115286115287115288115289115290115291115292115293115294115295115296115297115298115299115300115301115302115303115304115305115306115307115308115309115310115311115312115313115314115315115316115317115318115319115320115321115322115323115324115325115326115327115328115329115330115331115332115333115334115335115336115337115338115339115340115341115342115343115344115345115346115347115348115349115350115351115352115353115354115355115356115357115358115359115360115361115362115363115364115365115366115367115368115369115370115371115372115373115374115375115376115377115378115379115380115381115382115383115384115385115386115387115388115389115390115391115392115393115394115395115396115397115398115399115400115401115402115403115404115405115406115407115408115409115410115411115412115413115414115415115416115417115418115419115420115421115422115423115424115425115426115427115428115429115430115431115432115433115434115435115436115437115438115439115440115441115442115443115444115445115446115447115448115449115450115451115452115453115454115455115456115457115458115459115460115461115462115463115464115465115466115467115468115469115470115471115472115473115474115475115476115477115478115479115480115481115482115483115484115485115486115487115488115489115490115491115492115493115494115495115496115497115498115499115500115501115502115503115504115505115506115507115508115509115510115511115512115513115514115515115516115517115518115519115520115521115522115523115524115525115526115527115528115529115530115531115532115533115534115535115536115537115538115539115540115541115542115543115544115545115546115547115548115549115550115551115552115553115554115555115556115557115558115559115560115561115562115563115564115565115566115567115568115569115570115571115572115573115574115575115576115577115578115579115580115581115582115583115584115585115586115587115588115589115590115591115592115593115594115595115596115597115598115599115600115601115602115603115604115605115606115607115608115609115610115611115612115613115614115615115616115617115618115619115620115621115622115623115624115625115626115627115628115629115630115631115632115633115634115635115636115637115638115639115640115641115642115643115644115645115646115647115648115649115650115651115652115653115654115655115656115657115658115659115660115661115662115663115664115665115666115667115668115669115670115671115672115673115674115675115676115677115678115679115680115681115682115683115684115685115686115687115688115689115690115691115692115693115694115695115696115697115698115699115700115701115702115703115704115705115706115707115708115709115710115711115712115713115714115715115716115717115718115719115720115721115722115723115724115725115726115727115728115729115730115731115732115733115734115735115736115737115738115739115740115741115742115743115744115745115746115747115748115749115750115751115752115753115754115755115756115757115758115759115760115761115762115763115764115765115766115767115768115769115770115771115772115773115774115775115776115777115778115779115780115781115782115783115784115785115786115787115788115789115790115791115792115793115794115795115796115797115798115799115800115801115802115803115804115805115806115807115808115809115810115811115812115813115814115815115816115817115818115819115820115821115822115823115824115825115826115827115828115829115830115831115832115833115834115835115836115837115838115839115840115841115842115843115844115845115846115847115848115849115850115851115852115853115854115855115856115857115858115859115860115861115862115863115864115865115866115867115868115869115870115871115872115873115874115875115876115877115878115879115880115881115882115883115884115885115886115887115888115889115890115891115892115893115894115895115896115897115898115899115900115901115902115903115904115905115906115907115908115909115910115911115912115913115914115915115916115917115918115919115920115921115922115923115924115925115926115927115928115929115930115931115932115933115934115935115936115937115938115939115940115941115942115943115944115945115946115947115948115949115950115951115952115953115954115955115956115957115958115959115960115961115962115963115964115965115966115967115968115969115970115971115972115973115974115975115976115977115978115979115980115981115982115983115984115985115986115987115988115989115990115991115992115993115994115995115996115997115998115999116000116001116002116003116004116005116006116007116008116009116010116011116012116013116014116015116016116017116018116019116020116021116022116023116024116025116026116027116028116029116030116031116032116033116034116035116036116037116038116039116040116041116042116043116044116045116046116047116048116049116050116051116052116053116054116055116056116057116058116059116060116061116062116063116064116065116066116067116068116069116070116071116072116073116074116075116076116077116078116079116080116081116082116083116084116085116086116087116088116089116090116091116092116093116094116095116096116097116098116099116100116101116102116103116104116105116106116107116108116109116110116111116112116113116114116115116116116117116118116119116120116121116122116123116124116125116126116127116128116129116130116131116132116133116134116135116136116137116138116139116140116141116142116143116144116145116146116147116148116149116150116151116152116153116154116155116156116157116158116159116160116161116162116163116164116165116166116167116168116169116170116171116172116173116174116175116176116177116178116179116180116181116182116183116184116185116186116187116188116189116190116191116192116193116194116195116196116197116198116199116200116201116202116203116204116205116206116207116208116209116210116211116212116213116214116215116216116217116218116219116220116221116222116223116224116225116226116227116228116229116230116231116232116233116234116235116236116237116238116239116240116241116242116243116244116245116246116247116248116249116250116251116252116253116254116255116256116257116258116259116260116261116262116263116264116265116266116267116268116269116270116271116272116273116274116275116276116277116278116279116280116281116282116283116284116285116286116287116288116289116290116291116292116293116294116295116296116297116298116299116300116301116302116303116304116305116306116307116308116309116310116311116312116313116314116315116316116317116318116319116320116321116322116323116324116325116326116327116328116329116330116331116332116333116334116335116336116337116338116339116340116341116342116343116344116345116346116347116348116349116350116351116352116353116354116355116356116357116358116359116360116361116362116363116364116365116366116367116368116369116370116371116372116373116374116375116376116377116378116379116380116381116382116383116384116385116386116387116388116389116390116391116392116393116394116395116396116397116398116399116400116401116402116403116404116405116406116407116408116409116410116411116412116413116414116415116416116417116418116419116420116421116422116423116424116425116426116427116428116429116430116431116432116433116434116435116436116437116438116439116440116441116442116443116444116445116446116447116448116449116450116451116452116453116454116455116456116457116458116459116460116461116462116463116464116465116466116467116468116469116470116471116472116473116474116475116476116477116478116479116480116481116482116483116484116485116486116487116488116489116490116491116492116493116494116495116496116497116498116499116500116501116502116503116504116505116506116507116508116509116510116511116512116513116514116515116516116517116518116519116520116521116522116523116524116525116526116527116528116529116530116531116532116533116534116535116536116537116538116539116540116541116542116543116544116545116546116547116548116549116550116551116552116553116554116555116556116557116558116559116560116561116562116563116564116565116566116567116568116569116570116571116572116573116574116575116576116577116578116579116580116581116582116583116584116585116586116587116588116589116590116591116592116593116594116595116596116597116598116599116600116601116602116603116604116605116606116607116608116609116610116611116612116613116614116615116616116617116618116619116620116621116622116623116624116625116626116627116628116629116630116631116632116633116634116635116636116637116638116639116640116641116642116643116644116645116646116647116648116649116650116651116652116653116654116655116656116657116658116659116660116661116662116663116664116665116666116667116668116669116670116671116672116673116674116675116676116677116678116679116680116681116682116683116684116685116686116687116688116689116690116691116692116693116694116695116696116697116698116699116700116701116702116703116704116705116706116707116708116709116710116711116712116713116714116715116716116717116718116719116720116721116722116723116724116725116726116727116728116729116730116731116732116733116734116735116736116737116738116739116740116741116742116743116744116745116746116747116748116749116750116751116752116753116754116755116756116757116758116759116760116761116762116763116764116765116766116767116768116769116770116771116772116773116774116775116776116777116778116779116780116781116782116783116784116785116786116787116788116789116790116791116792116793116794116795116796116797116798116799116800116801116802116803116804116805116806116807116808116809116810116811116812116813116814116815116816116817116818116819116820116821116822116823116824116825116826116827116828116829116830116831116832116833116834116835116836116837116838116839116840116841116842116843116844116845116846116847116848116849116850116851116852116853116854116855116856116857116858116859116860116861116862116863116864116865116866116867116868116869116870116871116872116873116874116875116876116877116878116879116880116881116882116883116884116885116886116887116888116889116890116891116892116893116894116895116896116897116898116899116900116901116902116903116904116905116906116907116908116909116910116911116912116913116914116915116916116917116918116919116920116921116922116923116924116925116926116927116928116929116930116931116932116933116934116935116936116937116938116939116940116941116942116943116944116945116946116947116948116949116950116951116952116953116954116955116956116957116958116959116960116961116962116963116964116965116966116967116968116969116970116971116972116973116974116975116976116977116978116979116980116981116982116983116984116985116986116987116988116989116990116991116992116993116994116995116996116997116998116999117000117001117002117003117004117005117006117007117008117009117010117011117012117013117014117015117016117017117018117019117020117021117022117023117024117025117026117027117028117029117030117031117032117033117034117035117036117037117038117039117040117041117042117043117044117045117046117047117048117049117050117051117052117053117054117055117056117057117058117059117060117061117062117063117064117065117066117067117068117069117070117071117072117073117074117075117076117077117078117079117080117081117082117083117084117085117086117087117088117089117090117091117092117093117094117095117096117097117098117099117100117101117102117103117104117105117106117107117108117109117110117111117112117113117114117115117116117117117118117119117120117121117122117123117124117125117126117127117128117129117130117131117132117133117134117135117136117137117138117139117140117141117142117143117144117145117146117147117148117149117150117151117152117153117154117155117156117157117158117159117160117161117162117163117164117165117166117167117168117169117170117171117172117173117174117175117176117177117178117179117180117181117182117183117184117185117186117187117188117189117190117191117192117193117194117195117196117197117198117199117200117201117202117203117204117205117206117207117208117209117210117211117212117213117214117215117216117217117218117219117220117221117222117223117224117225117226117227117228117229117230117231117232117233117234117235117236117237117238117239117240117241117242117243117244117245117246117247117248117249117250117251117252117253117254117255117256117257117258117259117260117261117262117263117264117265117266117267117268117269117270117271117272117273117274117275117276117277117278117279117280117281117282117283117284117285117286117287117288117289117290117291117292117293117294117295117296117297117298117299117300117301117302117303117304117305117306117307117308117309117310117311117312117313117314117315117316117317117318117319117320117321117322117323117324117325117326117327117328117329117330117331117332117333117334117335117336117337117338117339117340117341117342117343117344117345117346117347117348117349117350117351117352117353117354117355117356117357117358117359117360117361117362117363117364117365117366117367117368117369117370117371117372117373117374117375117376117377117378117379117380117381117382117383117384117385117386117387117388117389117390117391117392117393117394117395117396117397117398117399117400117401117402117403117404117405117406117407117408117409117410117411117412117413117414117415117416117417117418117419117420117421117422117423117424117425117426117427117428117429117430117431117432117433117434117435117436117437117438117439117440117441117442117443117444117445117446117447117448117449117450117451117452117453117454117455117456117457117458117459117460117461117462117463117464117465117466117467117468117469117470117471117472117473117474117475117476117477117478117479117480117481117482117483117484117485117486117487117488117489117490117491117492117493117494117495117496117497117498117499117500117501117502117503117504117505117506117507117508117509117510117511117512117513117514117515117516117517117518117519117520117521117522117523117524117525117526117527117528117529117530117531117532117533117534117535117536117537117538117539117540117541117542117543117544117545117546117547117548117549117550117551117552117553117554117555117556117557117558117559117560117561117562117563117564117565117566117567117568117569117570117571117572117573117574117575117576117577117578117579117580117581117582117583117584117585117586117587117588117589117590117591117592117593117594117595117596117597117598117599117600117601117602117603117604117605117606117607117608117609117610117611117612117613117614117615117616117617117618117619117620117621117622117623117624117625117626117627117628117629117630117631117632117633117634117635117636117637117638117639117640117641117642117643117644117645117646117647117648117649117650117651117652117653117654117655117656117657117658117659117660117661117662117663117664117665117666117667117668117669117670117671117672117673117674117675117676117677117678117679117680117681117682117683117684117685117686117687117688117689117690117691117692117693117694117695117696117697117698117699117700117701117702117703117704117705117706117707117708117709117710117711117712117713117714117715117716117717117718117719117720117721117722117723117724117725117726117727117728117729117730117731117732117733117734117735117736117737117738117739117740117741117742117743117744117745117746117747117748117749117750117751117752117753117754117755117756117757117758117759117760117761117762117763117764117765117766117767117768117769117770117771117772117773117774117775117776117777117778117779117780117781117782117783117784117785117786117787117788117789117790117791117792117793117794117795117796117797117798117799117800117801117802117803117804117805117806117807117808117809117810117811117812117813117814117815117816117817117818117819117820117821117822117823117824117825117826117827117828117829117830117831117832117833117834117835117836117837117838117839117840117841117842117843117844117845117846117847117848117849117850117851117852117853117854117855117856117857117858117859117860117861117862117863117864117865117866117867117868117869117870117871117872117873117874117875117876117877117878117879117880117881117882117883117884117885117886117887117888117889117890117891117892117893117894117895117896117897117898117899117900117901117902117903117904117905117906117907117908117909117910117911117912117913117914117915117916117917117918117919117920117921117922117923117924117925117926117927117928117929117930117931117932117933117934117935117936117937117938117939117940117941117942117943117944117945117946117947117948117949117950117951117952117953117954117955117956117957117958117959117960117961117962117963117964117965117966117967117968117969117970117971117972117973117974117975117976117977117978117979117980117981117982117983117984117985117986117987117988117989117990117991117992117993117994117995117996117997117998117999118000118001118002118003118004118005118006118007118008118009118010118011118012118013118014118015118016118017118018118019118020118021118022118023118024118025118026118027118028118029118030118031118032118033118034118035118036118037118038118039118040118041118042118043118044118045118046118047118048118049118050118051118052118053118054118055118056118057118058118059118060118061118062118063118064118065118066118067118068118069118070118071118072118073118074118075118076118077118078118079118080118081118082118083118084118085118086118087118088118089118090118091118092118093118094118095118096118097118098118099118100118101118102118103118104118105118106118107118108118109118110118111118112118113118114118115118116118117118118118119118120118121118122118123118124118125118126118127118128118129118130118131118132118133118134118135118136118137118138118139118140118141118142118143118144118145118146118147118148118149118150118151118152118153118154118155118156118157118158118159118160118161118162118163118164118165118166118167118168118169118170118171118172118173118174118175118176118177118178118179118180118181118182118183118184118185118186118187118188118189118190118191118192118193118194118195118196118197118198118199118200118201118202118203118204118205118206118207118208118209118210118211118212118213118214118215118216118217118218118219118220118221118222118223118224118225118226118227118228118229118230118231118232118233118234118235118236118237118238118239118240118241118242118243118244118245118246118247118248118249118250118251118252118253118254118255118256118257118258118259118260118261118262118263118264118265118266118267118268118269118270118271118272118273118274118275118276118277118278118279118280118281118282118283118284118285118286118287118288118289118290118291118292118293118294118295118296118297118298118299118300118301118302118303118304118305118306118307118308118309118310118311118312118313118314118315118316118317118318118319118320118321118322118323118324118325118326118327118328118329118330118331118332118333118334118335118336118337118338118339118340118341118342118343118344118345118346118347118348118349118350118351118352118353118354118355118356118357118358118359118360118361118362118363118364118365118366118367118368118369118370118371118372118373118374118375118376118377118378118379118380118381118382118383118384118385118386118387118388118389118390118391118392118393118394118395118396118397118398118399118400118401118402118403118404118405118406118407118408118409118410118411118412118413118414118415118416118417118418118419118420118421118422118423118424118425118426118427118428118429118430118431118432118433118434118435118436118437118438118439118440118441118442118443118444118445118446118447118448118449118450118451118452118453118454118455118456118457118458118459118460118461118462118463118464118465118466118467118468118469118470118471118472118473118474118475118476118477118478118479118480118481118482118483118484118485118486118487118488118489118490118491118492118493118494118495118496118497118498118499118500118501118502118503118504118505118506118507118508118509118510118511118512118513118514118515118516118517118518118519118520118521118522118523118524118525118526118527118528118529118530118531118532118533118534118535118536118537118538118539118540118541118542118543118544118545118546118547118548118549118550118551118552118553118554118555118556118557118558118559118560118561118562118563118564118565118566118567118568118569118570118571118572118573118574118575118576118577118578118579118580118581118582118583118584118585118586118587118588118589118590118591118592118593118594118595118596118597118598118599118600118601118602118603118604118605118606118607118608118609118610118611118612118613118614118615118616118617118618118619118620118621118622118623118624118625118626118627118628118629118630118631118632118633118634118635118636118637118638118639118640118641118642118643118644118645118646118647118648118649118650118651118652118653118654118655118656118657118658118659118660118661118662118663118664118665118666118667118668118669118670118671118672118673118674118675118676118677118678118679118680118681118682118683118684118685118686118687118688118689118690118691118692118693118694118695118696118697118698118699118700118701118702118703118704118705118706118707118708118709118710118711118712118713118714118715118716118717118718118719118720118721118722118723118724118725118726118727118728118729118730118731118732118733118734118735118736118737118738118739118740118741118742118743118744118745118746118747118748118749118750118751118752118753118754118755118756118757118758118759118760118761118762118763118764118765118766118767118768118769118770118771118772118773118774118775118776118777118778118779118780118781118782118783118784118785118786118787118788118789118790118791118792118793118794118795118796118797118798118799118800118801118802118803118804118805118806118807118808118809118810118811118812118813118814118815118816118817118818118819118820118821118822118823118824118825118826118827118828118829118830118831118832118833118834118835118836118837118838118839118840118841118842118843118844118845118846118847118848118849118850118851118852118853118854118855118856118857118858118859118860118861118862118863118864118865118866118867118868118869118870118871118872118873118874118875118876118877118878118879118880118881118882118883118884118885118886118887118888118889118890118891118892118893118894118895118896118897118898118899118900118901118902118903118904118905118906118907118908118909118910118911118912118913118914118915118916118917118918118919118920118921118922118923118924118925118926118927118928118929118930118931118932118933118934118935118936118937118938118939118940118941118942118943118944118945118946118947118948118949118950118951118952118953118954118955118956118957118958118959118960118961118962118963118964118965118966118967118968118969118970118971118972118973118974118975118976118977118978118979118980118981118982118983118984118985118986118987118988118989118990118991118992118993118994118995118996118997118998118999119000119001119002119003119004119005119006119007119008119009119010119011119012119013119014119015119016119017119018119019119020119021119022119023119024119025119026119027119028119029119030119031119032119033119034119035119036119037119038119039119040119041119042119043119044119045119046119047119048119049119050119051119052119053119054119055119056119057119058119059119060119061119062119063119064119065119066119067119068119069119070119071119072119073119074119075119076119077119078119079119080119081119082119083119084119085119086119087119088119089119090119091119092119093119094119095119096119097119098119099119100119101119102119103119104119105119106119107119108119109119110119111119112119113119114119115119116119117119118119119119120119121119122119123119124119125119126119127119128119129119130119131119132119133119134119135119136119137119138119139119140119141119142119143119144119145119146119147119148119149119150119151119152119153119154119155119156119157119158119159119160119161119162119163119164119165119166119167119168119169119170119171119172119173119174119175119176119177119178119179119180119181119182119183119184119185119186119187119188119189119190119191119192119193119194119195119196119197119198119199119200119201119202119203119204119205119206119207119208119209119210119211119212119213119214119215119216119217119218119219119220119221119222119223119224119225119226119227119228119229119230119231119232119233119234119235119236119237119238119239119240119241119242119243119244119245119246119247119248119249119250119251119252119253119254119255119256119257119258119259119260119261119262119263119264119265119266119267119268119269119270119271119272119273119274119275119276119277119278119279119280119281119282119283119284119285119286119287119288119289119290119291119292119293119294119295119296119297119298119299119300119301119302119303119304119305119306119307119308119309119310119311119312119313119314119315119316119317119318119319119320119321119322119323119324119325119326119327119328119329119330119331119332119333119334119335119336119337119338119339119340119341119342119343119344119345119346119347119348119349119350119351119352119353119354119355119356119357119358119359119360119361119362119363119364119365119366119367119368119369119370119371119372119373119374119375119376119377119378119379119380119381119382119383119384119385119386119387119388119389119390119391119392119393119394119395119396119397119398119399119400119401119402119403119404119405119406119407119408119409119410119411119412119413119414119415119416119417119418119419119420119421119422119423119424119425119426119427119428119429119430119431119432119433119434119435119436119437119438119439119440119441119442119443119444119445119446119447119448119449119450119451119452119453119454119455119456119457119458119459119460119461119462119463119464119465119466119467119468119469119470119471119472119473119474119475119476119477119478119479119480119481119482119483119484119485119486119487119488119489119490119491119492119493119494119495119496119497119498119499119500119501119502119503119504119505119506119507119508119509119510119511119512119513119514119515119516119517119518119519119520119521119522119523119524119525119526119527119528119529119530119531119532119533119534119535119536119537119538119539119540119541119542119543119544119545119546119547119548119549119550119551119552119553119554119555119556119557119558119559119560119561119562119563119564119565119566119567119568119569119570119571119572119573119574119575119576119577119578119579119580119581119582119583119584119585119586119587119588119589119590119591119592119593119594119595119596119597119598119599119600119601119602119603119604119605119606119607119608119609119610119611119612119613119614119615119616119617119618119619119620119621119622119623119624119625119626119627119628119629119630119631119632119633119634119635119636119637119638119639119640119641119642119643119644119645119646119647119648119649119650119651119652119653119654119655119656119657119658119659119660119661119662119663119664119665119666119667119668119669119670119671119672119673119674119675119676119677119678119679119680119681119682119683119684119685119686119687119688119689119690119691119692119693119694119695119696119697119698119699119700119701119702119703119704119705119706119707119708119709119710119711119712119713119714119715119716119717119718119719119720119721119722119723119724119725119726119727119728119729119730119731119732119733119734119735119736119737119738119739119740119741119742119743119744119745119746119747119748119749119750119751119752119753119754119755119756119757119758119759119760119761119762119763119764119765119766119767119768119769119770119771119772119773119774119775119776119777119778119779119780119781119782119783119784119785119786119787119788119789119790119791119792119793119794119795119796119797119798119799119800119801119802119803119804119805119806119807119808119809119810119811119812119813119814119815119816119817119818119819119820119821119822119823119824119825119826119827119828119829119830119831119832119833119834119835119836119837119838119839119840119841119842119843119844119845119846119847119848119849119850119851119852119853119854119855119856119857119858119859119860119861119862119863119864119865119866119867119868119869119870119871119872119873119874119875119876119877119878119879119880119881119882119883119884119885119886119887119888119889119890119891119892119893119894119895119896119897119898119899119900119901119902119903119904119905119906119907119908119909119910119911119912119913119914119915119916119917119918119919119920119921119922119923119924119925119926119927119928119929119930119931119932119933119934119935119936119937119938119939119940119941119942119943119944119945119946119947119948119949119950119951119952119953119954119955119956119957119958119959119960119961119962119963119964119965119966119967119968119969119970119971119972119973119974119975119976119977119978119979119980119981119982119983119984119985119986119987119988119989119990119991119992119993119994119995119996119997119998119999120000120001120002120003120004120005120006120007120008120009120010120011120012120013120014120015120016120017120018120019120020120021120022120023120024120025120026120027120028120029120030120031120032120033120034120035120036120037120038120039120040120041120042120043120044120045120046120047120048120049120050120051120052120053120054120055120056120057120058120059120060120061120062120063120064120065120066120067120068120069120070120071120072120073120074120075120076120077120078120079120080120081120082120083120084120085120086120087120088120089120090120091120092120093120094120095120096120097120098120099120100120101120102120103120104120105120106120107120108120109120110120111120112120113120114120115120116120117120118120119120120120121120122120123120124120125120126120127120128120129120130120131120132120133120134120135120136120137120138120139120140120141120142120143120144120145120146120147120148120149120150120151120152120153120154120155120156120157120158120159120160120161120162120163120164120165120166120167120168120169120170120171120172120173120174120175120176120177120178120179120180120181120182120183120184120185120186120187120188120189120190120191120192120193120194120195120196120197120198120199120200120201120202120203120204120205120206120207120208120209120210120211120212120213120214120215120216120217120218120219120220120221120222120223120224120225120226120227120228120229120230120231120232120233120234120235120236120237120238120239120240120241120242120243120244120245120246120247120248120249120250120251120252120253120254120255120256120257120258120259120260120261120262120263120264120265120266120267120268120269120270120271120272120273120274120275120276120277120278120279120280120281120282120283120284120285120286120287120288120289120290120291120292120293120294120295120296120297120298120299120300120301120302120303120304120305120306120307120308120309120310120311120312120313120314120315120316120317120318120319120320120321120322120323120324120325120326120327120328120329120330120331120332120333120334120335120336120337120338120339120340120341120342120343120344120345120346120347120348120349120350120351120352120353120354120355120356120357120358120359120360120361120362120363120364120365120366120367120368120369120370120371120372120373120374120375120376120377120378120379120380120381120382120383120384120385120386120387120388120389120390120391120392120393120394120395120396120397120398120399120400120401120402120403120404120405120406120407120408120409120410120411120412120413120414120415120416120417120418120419120420120421120422120423120424120425120426120427120428120429120430120431120432120433120434120435120436120437120438120439120440120441120442120443120444120445120446120447120448120449120450120451120452120453120454120455120456120457120458120459120460120461120462120463120464120465120466120467120468120469120470120471120472120473120474120475120476120477120478120479120480120481120482120483120484120485120486120487120488120489120490120491120492120493120494120495120496120497120498120499120500120501120502120503120504120505120506120507120508120509120510120511120512120513120514120515120516120517120518120519120520120521120522120523120524120525120526120527120528120529120530120531120532120533120534120535120536120537120538120539120540120541120542120543120544120545120546120547120548120549120550120551120552120553120554120555120556120557120558120559120560120561120562120563120564120565120566120567120568120569120570120571120572120573120574120575120576120577120578120579120580120581120582120583120584120585120586120587120588120589120590120591120592120593120594120595120596120597120598120599120600120601120602120603120604120605120606120607120608120609120610120611120612120613120614120615120616120617120618120619120620120621120622120623120624120625120626120627120628120629120630120631120632120633120634120635120636120637120638120639120640120641120642120643120644120645120646120647120648120649120650120651120652120653120654120655120656120657120658120659120660120661120662120663120664120665120666120667120668120669120670120671120672120673120674120675120676120677120678120679120680120681120682120683120684120685120686120687120688120689120690120691120692120693120694120695120696120697120698120699120700120701120702120703120704120705120706120707120708120709120710120711120712120713120714120715120716120717120718120719120720120721120722120723120724120725120726120727120728120729120730120731120732120733120734120735120736120737120738120739120740120741120742120743120744120745120746120747120748120749120750120751120752120753120754120755120756120757120758120759120760120761120762120763120764120765120766120767120768120769120770120771120772120773120774120775120776120777120778120779120780120781120782120783120784120785120786120787120788120789120790120791120792120793120794120795120796120797120798120799120800120801120802120803120804120805120806120807120808120809120810120811120812120813120814120815120816120817120818120819120820120821120822120823120824120825120826120827120828120829120830120831120832120833120834120835120836120837120838120839120840120841120842120843120844120845120846120847120848120849120850120851120852120853120854120855120856120857120858120859120860120861120862120863120864120865120866120867120868120869120870120871120872120873120874120875120876120877120878120879120880120881120882120883120884120885120886120887120888120889120890120891120892120893120894120895120896120897120898120899120900120901120902120903120904120905120906120907120908120909120910120911120912120913120914120915120916120917120918120919120920120921120922120923120924120925120926120927120928120929120930120931120932120933120934120935120936120937120938120939120940120941120942120943120944120945120946120947120948120949120950120951120952120953120954120955120956120957120958120959120960120961120962120963120964120965120966120967120968120969120970120971120972120973120974120975120976120977120978120979120980120981120982120983120984120985120986120987120988120989120990120991120992120993120994120995120996120997120998120999121000121001121002121003121004121005121006121007121008121009121010121011121012121013121014121015121016121017121018121019121020121021121022121023121024121025121026121027121028121029121030121031121032121033121034121035121036121037121038121039121040121041121042121043121044121045121046121047121048121049121050121051121052121053121054121055121056121057121058121059121060121061121062121063121064121065121066121067121068121069121070121071121072121073121074121075121076121077121078121079121080121081121082121083121084121085121086121087121088121089121090121091121092121093121094121095121096121097121098121099121100121101121102121103121104121105121106121107121108121109121110121111121112121113121114121115121116121117121118121119121120121121121122121123121124121125121126121127121128121129121130121131121132121133121134121135121136121137121138121139121140121141121142121143121144121145121146121147121148121149121150121151121152121153121154121155121156121157121158121159121160121161121162121163121164121165121166121167121168121169121170121171121172121173121174121175121176121177121178121179121180121181121182121183121184121185121186121187121188121189121190121191121192121193121194121195121196121197121198121199121200121201121202121203121204121205121206121207121208121209121210121211121212121213121214121215121216121217121218121219121220121221121222121223121224121225121226121227121228121229121230121231121232121233121234121235121236121237121238121239121240121241121242121243121244121245121246121247121248121249121250121251121252121253121254121255121256121257121258121259121260121261121262121263121264121265121266121267121268121269121270121271121272121273121274121275121276121277121278121279121280121281121282121283121284121285121286121287121288121289121290121291121292121293121294121295121296121297121298121299121300121301121302121303121304121305121306121307121308121309121310121311121312121313121314121315121316121317121318121319121320121321121322121323121324121325121326121327121328121329121330121331121332121333121334121335121336121337121338121339121340121341121342121343121344121345121346121347121348121349121350121351121352121353121354121355121356121357121358121359121360121361121362121363121364121365121366121367121368121369121370121371121372121373121374121375121376121377121378121379121380121381121382121383121384121385121386121387121388121389121390121391121392121393121394121395121396121397121398121399121400121401121402121403121404121405121406121407121408121409121410121411121412121413121414121415121416121417121418121419121420121421121422121423121424121425121426121427121428121429121430121431121432121433121434121435121436121437121438121439121440121441121442121443121444121445121446121447121448121449121450121451121452121453121454121455121456121457121458121459121460121461121462121463121464121465121466121467121468121469121470121471121472121473121474121475121476121477121478121479121480121481121482121483121484121485121486121487121488121489121490121491121492121493121494121495121496121497121498121499121500121501121502121503121504121505121506121507121508121509121510121511121512121513121514121515121516121517121518121519121520121521121522121523121524121525121526121527121528121529121530121531121532121533121534121535121536121537121538121539121540121541121542121543121544121545121546121547121548121549121550121551121552121553121554121555121556121557121558121559121560121561121562121563121564121565121566121567121568121569121570121571121572121573121574121575121576121577121578121579121580121581121582121583121584121585121586121587121588121589121590121591121592121593121594121595121596121597121598121599121600121601121602121603121604121605121606121607121608121609121610121611121612121613121614121615121616121617121618121619121620121621121622121623121624121625121626121627121628121629121630121631121632121633121634121635121636121637121638121639121640121641121642121643121644121645121646121647121648121649121650121651121652121653121654121655121656121657121658121659121660121661121662121663121664121665121666121667121668121669121670121671121672121673121674121675121676121677121678121679121680121681121682121683121684121685121686121687121688121689121690121691121692121693121694121695121696121697121698121699121700121701121702121703121704121705121706121707121708121709121710121711121712121713121714121715121716121717121718121719121720121721121722121723121724121725121726121727121728121729121730121731121732121733121734121735121736121737121738121739121740121741121742121743121744121745121746121747121748121749121750121751121752121753121754121755121756121757121758121759121760121761121762121763121764121765121766121767121768121769121770121771121772121773121774121775121776121777121778121779121780121781121782121783121784121785121786121787121788121789121790121791121792121793121794121795121796121797121798121799121800121801121802121803121804121805121806121807121808121809121810121811121812121813121814121815121816121817121818121819121820121821121822121823121824121825121826121827121828121829121830121831121832121833121834121835121836121837121838121839121840121841121842121843121844121845121846121847121848121849121850121851121852121853121854121855121856121857121858121859121860121861121862121863121864121865121866121867121868121869121870121871121872121873121874121875121876121877121878121879121880121881121882121883121884121885121886121887121888121889121890121891121892121893121894121895121896121897121898121899121900121901121902121903121904121905121906121907121908121909121910121911121912121913121914121915121916121917121918121919121920121921121922121923121924121925121926121927121928121929121930121931121932121933121934121935121936121937121938121939121940121941121942121943121944121945121946121947121948121949121950121951121952121953121954121955121956121957121958121959121960121961121962121963121964121965121966121967121968121969121970121971121972121973121974121975121976121977121978121979121980121981121982121983121984121985121986121987121988121989121990121991121992121993121994121995121996121997121998121999122000122001122002122003122004122005122006122007122008122009122010122011122012122013122014122015122016122017122018122019122020122021122022122023122024122025122026122027122028122029122030122031122032122033122034122035122036122037122038122039122040122041122042122043122044122045122046122047122048122049122050122051122052122053122054122055122056122057122058122059122060122061122062122063122064122065122066122067122068122069122070122071122072122073122074122075122076122077122078122079122080122081122082122083122084122085122086122087122088122089122090122091122092122093122094122095122096122097122098122099122100122101122102122103122104122105122106122107122108122109122110122111122112122113122114122115122116122117122118122119122120122121122122122123122124122125122126122127122128122129122130122131122132122133122134122135122136122137122138122139122140122141122142122143122144122145122146122147122148122149122150122151122152122153122154122155122156122157122158122159122160122161122162122163122164122165122166122167122168122169122170122171122172122173122174122175122176122177122178122179122180122181122182122183122184122185122186122187122188122189122190122191122192122193122194122195122196122197122198122199122200122201122202122203122204122205122206122207122208122209122210122211122212122213122214122215122216122217122218122219122220122221122222122223122224122225122226122227122228122229122230122231122232122233122234122235122236122237122238122239122240122241122242122243122244122245122246122247122248122249122250122251122252122253122254122255122256122257122258122259122260122261122262122263122264122265122266122267122268122269122270122271122272122273122274122275122276122277122278122279122280122281122282122283122284122285122286122287122288122289122290122291122292122293122294122295122296122297122298122299122300122301122302122303122304122305122306122307122308122309122310122311122312122313122314122315122316122317122318122319122320122321122322122323122324122325122326122327122328122329122330122331122332122333122334122335122336122337122338122339122340122341122342122343122344122345122346122347122348122349122350122351122352122353122354122355122356122357122358122359122360122361122362122363122364122365122366122367122368122369122370122371122372122373122374122375122376122377122378122379122380122381122382122383122384122385122386122387122388122389122390122391122392122393122394122395122396122397122398122399122400122401122402122403122404122405122406122407122408122409122410122411122412122413122414122415122416122417122418122419122420122421122422122423122424122425122426122427122428122429122430122431122432122433122434122435122436122437122438122439122440122441122442122443122444122445122446122447122448122449122450122451122452122453122454122455122456122457122458122459122460122461122462122463122464122465122466122467122468122469122470122471122472122473122474122475122476122477122478122479122480122481122482122483122484122485122486122487122488122489122490122491122492122493122494122495122496122497122498122499122500122501122502122503122504122505122506122507122508122509122510122511122512122513122514122515122516122517122518122519122520122521122522122523122524122525122526122527122528122529122530122531122532122533122534122535122536122537122538122539122540122541122542122543122544122545122546122547122548122549122550122551122552122553122554122555122556122557122558122559122560122561122562122563122564122565122566122567122568122569122570122571122572122573122574122575122576122577122578122579122580122581122582122583122584122585122586122587122588122589122590122591122592122593122594122595122596122597122598122599122600122601122602122603122604122605122606122607122608122609122610122611122612122613122614122615122616122617122618122619122620122621122622122623122624122625122626122627122628122629122630122631122632122633122634122635122636122637122638122639122640122641122642122643122644122645122646122647122648122649122650122651122652122653122654122655122656122657122658122659122660122661122662122663122664122665122666122667122668122669122670122671122672122673122674122675122676122677122678122679122680122681122682122683122684122685122686122687122688122689122690122691122692122693122694122695122696122697122698122699122700122701122702122703122704122705122706122707122708122709122710122711122712122713122714122715122716122717122718122719122720122721122722122723122724122725122726122727122728122729122730122731122732122733122734122735122736122737122738122739122740122741122742122743122744122745122746122747122748122749122750122751122752122753122754122755122756122757122758122759122760122761122762122763122764122765122766122767122768122769122770122771122772122773122774122775122776122777122778122779122780122781122782122783122784122785122786122787122788122789122790122791122792122793122794122795122796122797122798122799122800122801122802122803122804122805122806122807122808122809122810122811122812122813122814122815122816122817122818122819122820122821122822122823122824122825122826122827122828122829122830122831122832122833122834122835122836122837122838122839122840122841122842122843122844122845122846122847122848122849122850122851122852122853122854122855122856122857122858122859122860122861122862122863122864122865122866122867122868122869122870122871122872122873122874122875122876122877122878122879122880122881122882122883122884122885122886122887122888122889122890122891122892122893122894122895122896122897122898122899122900122901122902122903122904122905122906122907122908122909122910122911122912122913122914122915122916122917122918122919122920122921122922122923122924122925122926122927122928122929122930122931122932122933122934122935122936122937122938122939122940122941122942122943122944122945122946122947122948122949122950122951122952122953122954122955122956122957122958122959122960122961122962122963122964122965122966122967122968122969122970122971122972122973122974122975122976122977122978122979122980122981122982122983122984122985122986122987122988122989122990122991122992122993122994122995122996122997122998122999123000123001123002123003123004123005123006123007123008123009123010123011123012123013123014123015123016123017123018123019123020123021123022123023123024123025123026123027123028123029123030123031123032123033123034123035123036123037123038123039123040123041123042123043123044123045123046123047123048123049123050123051123052123053123054123055123056123057123058123059123060123061123062123063123064123065123066123067123068123069123070123071123072123073123074123075123076123077123078123079123080123081123082123083123084123085123086123087123088123089123090123091123092123093123094123095123096123097123098123099123100123101123102123103123104123105123106123107123108123109123110123111123112123113123114123115123116123117123118123119123120123121123122123123123124123125123126123127123128123129123130123131123132123133123134123135123136123137123138123139123140123141123142123143123144123145123146123147123148123149123150123151123152123153123154123155123156123157123158123159123160123161123162123163123164123165123166123167123168123169123170123171123172123173123174123175123176123177123178123179123180123181123182123183123184123185123186123187123188123189123190123191123192123193123194123195123196123197123198123199123200123201123202123203123204123205123206123207123208123209123210123211123212123213123214123215123216123217123218123219123220123221123222123223123224123225123226123227123228123229123230123231123232123233123234123235123236123237123238123239123240123241123242123243123244123245123246123247123248123249123250123251123252123253123254123255123256123257123258123259123260123261123262123263123264123265123266123267123268123269123270123271123272123273123274123275123276123277123278123279123280123281123282123283123284123285123286123287123288123289123290123291123292123293123294123295123296123297123298123299123300123301123302123303123304123305123306123307123308123309123310123311123312123313123314123315123316123317123318123319123320123321123322123323123324123325123326123327123328123329123330123331123332123333123334123335123336123337123338123339123340123341123342123343123344123345123346123347123348123349123350123351123352123353123354123355123356123357123358123359123360123361123362123363123364123365123366123367123368123369123370123371123372123373123374123375123376123377123378123379123380123381123382123383123384123385123386123387123388123389123390123391123392123393123394123395123396123397123398123399123400123401123402123403123404123405123406123407123408123409123410123411123412123413123414123415123416123417123418123419123420123421123422123423123424123425123426123427123428123429123430123431123432123433123434123435123436123437123438123439123440123441123442123443123444123445123446123447123448123449123450123451123452123453123454123455123456123457123458123459123460123461123462123463123464123465123466123467123468123469123470123471123472123473123474123475123476123477123478123479123480123481123482123483123484123485123486123487123488123489123490123491123492123493123494123495123496123497123498123499123500123501123502123503123504123505123506123507123508123509123510123511123512123513123514123515123516123517123518123519123520123521123522123523123524123525123526123527123528123529123530123531123532123533123534123535123536123537123538123539123540123541123542123543123544123545123546123547123548123549123550123551123552123553123554123555123556123557123558123559123560123561123562123563123564123565123566123567123568123569123570123571123572123573123574123575123576123577123578123579123580123581123582123583123584123585123586123587123588123589123590123591123592123593123594123595123596123597123598123599123600123601123602123603123604123605123606123607123608123609123610123611123612123613123614123615123616123617123618123619123620123621123622123623123624123625123626123627123628123629123630123631123632123633123634123635123636123637123638123639123640123641123642123643123644123645123646123647123648123649123650123651123652123653123654123655123656123657123658123659123660123661123662123663123664123665123666123667123668123669123670123671123672123673123674123675123676123677123678123679123680123681123682123683123684123685123686123687123688123689123690123691123692123693123694123695123696123697123698123699123700123701123702123703123704123705123706123707123708123709123710123711123712123713123714123715123716123717123718123719123720123721123722123723123724123725123726123727123728123729123730123731123732123733123734123735123736123737123738123739123740123741123742123743123744123745123746123747123748123749123750123751123752123753123754123755123756123757123758123759123760123761123762123763123764123765123766123767123768123769123770123771123772123773123774123775123776123777123778123779123780123781123782123783123784123785123786123787123788123789123790123791123792123793123794123795123796123797123798123799123800123801123802123803123804123805123806123807123808123809123810123811123812123813123814123815123816123817123818123819123820123821123822123823123824123825123826123827123828123829123830123831123832123833123834123835123836123837123838123839123840123841123842123843123844123845123846123847123848123849123850123851123852123853123854123855123856123857123858123859123860123861123862123863123864123865123866123867123868123869123870123871123872123873123874123875123876123877123878123879123880123881123882123883123884123885123886123887123888123889123890123891123892123893123894123895123896123897123898123899123900123901123902123903123904123905123906123907123908123909123910123911123912123913123914123915123916123917123918123919123920123921123922123923123924123925123926123927123928123929123930123931123932123933123934123935123936123937123938123939123940123941123942123943123944123945123946123947123948123949123950123951123952123953123954123955123956123957123958123959123960123961123962123963123964123965123966123967123968123969123970123971123972123973123974123975123976123977123978123979123980123981123982123983123984123985123986123987123988123989123990123991123992123993123994123995123996123997123998123999124000124001124002124003124004124005124006124007124008124009124010124011124012124013124014124015124016124017124018124019124020124021124022124023124024124025124026124027124028124029124030124031124032124033124034124035124036124037124038124039124040124041124042124043124044124045124046124047124048124049124050124051124052124053124054124055124056124057124058124059124060124061124062124063124064124065124066124067124068124069124070124071124072124073124074124075124076124077124078124079124080124081124082124083124084124085124086124087124088124089124090124091124092124093124094124095124096124097124098124099124100124101124102124103124104124105124106124107124108124109124110124111124112124113124114124115124116124117124118124119124120124121124122124123124124124125124126124127124128124129124130124131124132124133124134124135124136124137124138124139124140124141124142124143124144124145124146124147124148124149124150124151124152124153124154124155124156124157124158124159124160124161124162124163124164124165124166124167124168124169124170124171124172124173124174124175124176124177124178124179124180124181124182124183124184124185124186124187124188124189124190124191124192124193124194124195124196124197124198124199124200124201124202124203124204124205124206124207124208124209124210124211124212124213124214124215124216124217124218124219124220124221124222124223124224124225124226124227124228124229124230124231124232124233124234124235124236124237124238124239124240124241124242124243124244124245124246124247124248124249124250124251124252124253124254124255124256124257124258124259124260124261124262124263124264124265124266124267124268124269124270124271124272124273124274124275124276124277124278124279124280124281124282124283124284124285124286124287124288124289124290124291124292124293124294124295124296124297124298124299124300124301124302124303124304124305124306124307124308124309124310124311124312124313124314124315124316124317124318124319124320124321124322124323124324124325124326124327124328124329124330124331124332124333124334124335124336124337124338124339124340124341124342124343124344124345124346124347124348124349124350124351124352124353124354124355124356124357124358124359124360124361124362124363124364124365124366124367124368124369124370124371124372124373124374124375124376124377124378124379124380124381124382124383124384124385124386124387124388124389124390124391124392124393124394124395124396124397124398124399124400124401124402124403124404124405124406124407124408124409124410124411124412124413124414124415124416124417124418124419124420124421124422124423124424124425124426124427124428124429124430124431124432124433124434124435124436124437124438124439124440124441124442124443124444124445124446124447124448124449124450124451124452124453124454124455124456124457124458124459124460124461124462124463124464124465124466124467124468124469124470124471124472124473124474124475124476124477124478124479124480124481124482124483124484124485124486124487124488124489124490124491124492124493124494124495124496124497124498124499124500124501124502124503124504124505124506124507124508124509124510124511124512124513124514124515124516124517124518124519124520124521124522124523124524124525124526124527124528124529124530124531124532124533124534124535124536124537124538124539124540124541124542124543124544124545124546124547124548124549124550124551124552124553124554124555124556124557124558124559124560124561124562124563124564124565124566124567124568124569124570124571124572124573124574124575124576124577124578124579124580124581124582124583124584124585124586124587124588124589124590124591124592124593124594124595124596124597124598124599124600124601124602124603124604124605124606124607124608124609124610124611124612124613124614124615124616124617124618124619124620124621124622124623124624124625124626124627124628124629124630124631124632124633124634124635124636124637124638124639124640124641124642124643124644124645124646124647124648124649124650124651124652124653124654124655124656124657124658124659124660124661124662124663124664124665124666124667124668124669124670124671124672124673124674124675124676124677124678124679124680124681124682124683124684124685124686124687124688124689124690124691124692124693124694124695124696124697124698124699124700124701124702124703124704124705124706124707124708124709124710124711124712124713124714124715124716124717124718124719124720124721124722124723124724124725124726124727124728124729124730124731124732124733124734124735124736124737124738124739124740124741124742124743124744124745124746124747124748124749124750124751124752124753124754124755124756124757124758124759124760124761124762124763124764124765124766124767124768124769124770124771124772124773124774124775124776124777124778124779124780124781124782124783124784124785124786124787124788124789124790124791124792124793124794124795124796124797124798124799124800124801124802124803124804124805124806124807124808124809124810124811124812124813124814124815124816124817124818124819124820124821124822124823124824124825124826124827124828124829124830124831124832124833124834124835124836124837124838124839124840124841124842124843124844124845124846124847124848124849124850124851124852124853124854124855124856124857124858124859124860124861124862124863124864124865124866124867124868124869124870124871124872124873124874124875124876124877124878124879124880124881124882124883124884124885124886124887124888124889124890124891124892124893124894124895124896124897124898124899124900124901124902124903124904124905124906124907124908124909124910124911124912124913124914124915124916124917124918124919124920124921124922124923124924124925124926124927124928124929124930124931124932124933124934124935124936124937124938124939124940124941124942124943124944124945124946124947124948124949124950124951124952124953124954124955124956124957124958124959124960124961124962124963124964124965124966124967124968124969124970124971124972124973124974124975124976124977124978124979124980124981124982124983124984124985124986124987124988124989124990124991124992124993124994124995124996124997124998124999125000125001125002125003125004125005125006125007125008125009125010125011125012125013125014125015125016125017125018125019125020125021125022125023125024125025125026125027125028125029125030125031125032125033125034125035125036125037125038125039125040125041125042125043125044125045125046125047125048125049125050125051125052125053125054125055125056125057125058125059125060125061125062125063125064125065125066125067125068125069125070125071125072125073125074125075125076125077125078125079125080125081125082125083125084125085125086125087125088125089125090125091125092125093125094125095125096125097125098125099125100125101125102125103125104125105125106125107125108125109125110125111125112125113125114125115125116125117125118125119125120125121125122125123125124125125125126125127125128125129125130125131125132125133125134125135125136125137125138125139125140125141125142125143125144125145125146125147125148125149125150125151125152125153125154125155125156125157125158125159125160125161125162125163125164125165125166125167125168125169125170125171125172125173125174125175125176125177125178125179125180125181125182125183125184125185125186125187125188125189125190125191125192125193125194125195125196125197125198125199125200125201125202125203125204125205125206125207125208125209125210125211125212125213125214125215125216125217125218125219125220125221125222125223125224125225125226125227125228125229125230125231125232125233125234125235125236125237125238125239125240125241125242125243125244125245125246125247125248125249125250125251125252125253125254125255125256125257125258125259125260125261125262125263125264125265125266125267125268125269125270125271125272125273125274125275125276125277125278125279125280125281125282125283125284125285125286125287125288125289125290125291125292125293125294125295125296125297125298125299125300125301125302125303125304125305125306125307125308125309125310125311125312125313125314125315125316125317125318125319125320125321125322125323125324125325125326125327125328125329125330125331125332125333125334125335125336125337125338125339125340125341125342125343125344125345125346125347125348125349125350125351125352125353125354125355125356125357125358125359125360125361125362125363125364125365125366125367125368125369125370125371125372125373125374125375125376125377125378125379125380125381125382125383125384125385125386125387125388125389125390125391125392125393125394125395125396125397125398125399125400125401125402125403125404125405125406125407125408125409125410125411125412125413125414125415125416125417125418125419125420125421125422125423125424125425125426125427125428125429125430125431125432125433125434125435125436125437125438125439125440125441125442125443125444125445125446125447125448125449125450125451125452125453125454125455125456125457125458125459125460125461125462125463125464125465125466125467125468125469125470125471125472125473125474125475125476125477125478125479125480125481125482125483125484125485125486125487125488125489125490125491125492125493125494125495125496125497125498125499125500125501125502125503125504125505125506125507125508125509125510125511125512125513125514125515125516125517125518125519125520125521125522125523125524125525125526125527125528125529125530125531125532125533125534125535125536125537125538125539125540125541125542125543125544125545125546125547125548125549125550125551125552125553125554125555125556125557125558125559125560125561125562125563125564125565125566125567125568125569125570125571125572125573125574125575125576125577125578125579125580125581125582125583125584125585125586125587125588125589125590125591125592125593125594125595125596125597125598125599125600125601125602125603125604125605125606125607125608125609125610125611125612125613125614125615125616125617125618125619125620125621125622125623125624125625125626125627125628125629125630125631125632125633125634125635125636125637125638125639125640125641125642125643125644125645125646125647125648125649125650125651125652125653125654125655125656125657125658125659125660125661125662125663125664125665125666125667125668125669125670125671125672125673125674125675125676125677125678125679125680125681125682125683125684125685125686125687125688125689125690125691125692125693125694125695125696125697125698125699125700125701125702125703125704125705125706125707125708125709125710125711125712125713125714125715125716125717125718125719125720125721125722125723125724125725125726125727125728125729125730125731125732125733125734125735125736125737125738125739125740125741125742125743125744125745125746125747125748125749125750125751125752125753125754125755125756125757125758125759125760125761125762125763125764125765125766125767125768125769125770125771125772125773125774125775125776125777125778125779125780125781125782125783125784125785125786125787125788125789125790125791125792125793125794125795125796125797125798125799125800125801125802125803125804125805125806125807125808125809125810125811125812125813125814125815125816125817125818125819125820125821125822125823125824125825125826125827125828125829125830125831125832125833125834125835125836125837125838125839125840125841125842125843125844125845125846125847125848125849125850125851125852125853125854125855125856125857125858125859125860125861125862125863125864125865125866125867125868125869125870125871125872125873125874125875125876125877125878125879125880125881125882125883125884125885125886125887125888125889125890125891125892125893125894125895125896125897125898125899125900125901125902125903125904125905125906125907125908125909125910125911125912125913125914125915125916125917125918125919125920125921125922125923125924125925125926125927125928125929125930125931125932125933125934125935125936125937125938125939125940125941125942125943125944125945125946125947125948125949125950125951125952125953125954125955125956125957125958125959125960125961125962125963125964125965125966125967125968125969125970125971125972125973125974125975125976125977125978125979125980125981125982125983125984125985125986125987125988125989125990125991125992125993125994125995125996125997125998125999126000126001126002126003126004126005126006126007126008126009126010126011126012126013126014126015126016126017126018126019126020126021126022126023126024126025126026126027126028126029126030126031126032126033126034126035126036126037126038126039126040126041126042126043126044126045126046126047126048126049126050126051126052126053126054126055126056126057126058126059126060126061126062126063126064126065126066126067126068126069126070126071126072126073126074126075126076126077126078126079126080126081126082126083126084126085126086126087126088126089126090126091126092126093126094126095126096126097126098126099126100126101126102126103126104126105126106126107126108126109126110126111126112126113126114126115126116126117126118126119126120126121126122126123126124126125126126126127126128126129126130126131126132126133126134126135126136126137126138126139126140126141126142126143126144126145126146126147126148126149126150126151126152126153126154126155126156126157126158126159126160126161126162126163126164126165126166126167126168126169126170126171126172126173126174126175126176126177126178126179126180126181126182126183126184126185126186126187126188126189126190126191126192126193126194126195126196126197126198126199126200126201126202126203126204126205126206126207126208126209126210126211126212126213126214126215126216126217126218126219126220126221126222126223126224126225126226126227126228126229126230126231126232126233126234126235126236126237126238126239126240126241126242126243126244126245126246126247126248126249126250126251126252126253126254126255126256126257126258126259126260126261126262126263126264126265126266126267126268126269126270126271126272126273126274126275126276126277126278126279126280126281126282126283126284126285126286126287126288126289126290126291126292126293126294126295126296126297126298126299126300126301126302126303126304126305126306126307126308126309126310126311126312126313126314126315126316126317126318126319126320126321126322126323126324126325126326126327126328126329126330126331126332126333126334126335126336126337126338126339126340126341126342126343126344126345126346126347126348126349126350126351126352126353126354126355126356126357126358126359126360126361126362126363126364126365126366126367126368126369126370126371126372126373126374126375126376126377126378126379126380126381126382126383126384126385126386126387126388126389126390126391126392126393126394126395126396126397126398126399126400126401126402126403126404126405126406126407126408126409126410126411126412126413126414126415126416126417126418126419126420126421126422126423126424126425126426126427126428126429126430126431126432126433126434126435126436126437126438126439126440126441126442126443126444126445126446126447126448126449126450126451126452126453126454126455126456126457126458126459126460126461126462126463126464126465126466126467126468126469126470126471126472126473126474126475126476126477126478126479126480126481126482126483126484126485126486126487126488126489126490126491126492126493126494126495126496126497126498126499126500126501126502126503126504126505126506126507126508126509126510126511126512126513126514126515126516126517126518126519126520126521126522126523126524126525126526126527126528126529126530126531126532126533126534126535126536126537126538126539126540126541126542126543126544126545126546126547126548126549126550126551126552126553126554126555126556126557126558126559126560126561126562126563126564126565126566126567126568126569126570126571126572126573126574126575126576126577126578126579126580126581126582126583126584126585126586126587126588126589126590126591126592126593126594126595126596126597126598126599126600126601126602126603126604126605126606126607126608126609126610126611126612126613126614126615126616126617126618126619126620126621126622126623126624126625126626126627126628126629126630126631126632126633126634126635126636126637126638126639126640126641126642126643126644126645126646126647126648126649126650126651126652126653126654126655126656126657126658126659126660126661126662126663126664126665126666126667126668126669126670126671126672126673126674126675126676126677126678126679126680126681126682126683126684126685126686126687126688126689126690126691126692126693126694126695126696126697126698126699126700126701126702126703126704126705126706126707126708126709126710126711126712126713126714126715126716126717126718126719126720126721126722126723126724126725126726126727126728126729126730126731126732126733126734126735126736126737126738126739126740126741126742126743126744126745126746126747126748126749126750126751126752126753126754126755126756126757126758126759126760126761126762126763126764126765126766126767126768126769126770126771126772126773126774126775126776126777126778126779126780126781126782126783126784126785126786126787126788126789126790126791126792126793126794126795126796126797126798126799126800126801126802126803126804126805126806126807126808126809126810126811126812126813126814126815126816126817126818126819126820126821126822126823126824126825126826126827126828126829126830126831126832126833126834126835126836126837126838126839126840126841126842126843126844126845126846126847126848126849126850126851126852126853126854126855126856126857126858126859126860126861126862126863126864126865126866126867126868126869126870126871126872126873126874126875126876126877126878126879126880126881126882126883126884126885126886126887126888126889126890126891126892126893126894126895126896126897126898126899126900126901126902126903126904126905126906126907126908126909126910126911126912126913126914126915126916126917126918126919126920126921126922126923126924126925126926126927126928126929126930126931126932126933126934126935126936126937126938126939126940126941126942126943126944126945126946126947126948126949126950126951126952126953126954126955126956126957126958126959126960126961126962126963126964126965126966126967126968126969126970126971126972126973126974126975126976126977126978126979126980126981126982126983126984126985126986126987126988126989126990126991126992126993126994126995126996126997126998126999127000127001127002127003127004127005127006127007127008127009127010127011127012127013127014127015127016127017127018127019127020127021127022127023127024127025127026127027127028127029127030127031127032127033127034127035127036127037127038127039127040127041127042127043127044127045127046127047127048127049127050127051127052127053127054127055127056127057127058127059127060127061127062127063127064127065127066127067127068127069127070127071127072127073127074127075127076127077127078127079127080127081127082127083127084127085127086127087127088127089127090127091127092127093127094127095127096127097127098127099127100127101127102127103127104127105127106127107127108127109127110127111127112127113127114127115127116127117127118127119127120127121127122127123127124127125127126127127127128127129127130127131127132127133127134127135127136127137127138127139127140127141127142127143127144127145127146127147127148127149127150127151127152127153127154127155127156127157127158127159127160127161127162127163127164127165127166127167127168127169127170127171127172127173127174127175127176127177127178127179127180127181127182127183127184127185127186127187127188127189127190127191127192127193127194127195127196127197127198127199127200127201127202127203127204127205127206127207127208127209127210127211127212127213127214127215127216127217127218127219127220127221127222127223127224127225127226127227127228127229127230127231127232127233127234127235127236127237127238127239127240127241127242127243127244127245127246127247127248127249127250127251127252127253127254127255127256127257127258127259127260127261127262127263127264127265127266127267127268127269127270127271127272127273127274127275127276127277127278127279127280127281127282127283127284127285127286127287127288127289127290127291127292127293127294127295127296127297127298127299127300127301127302127303127304127305127306127307127308127309127310127311127312127313127314127315127316127317127318127319127320127321127322127323127324127325127326127327127328127329127330127331127332127333127334127335127336127337127338127339127340127341127342127343127344127345127346127347127348127349127350127351127352127353127354127355127356127357127358127359127360127361127362127363127364127365127366127367127368127369127370127371127372127373127374127375127376127377127378127379127380127381127382127383127384127385127386127387127388127389127390127391127392127393127394127395127396127397127398127399127400127401127402127403127404127405127406127407127408127409127410127411127412127413127414127415127416127417127418127419127420127421127422127423127424127425127426127427127428127429127430127431127432127433127434127435127436127437127438127439127440127441127442127443127444127445127446127447127448127449127450127451127452127453127454127455127456127457127458127459127460127461127462127463127464127465127466127467127468127469127470127471127472127473127474127475127476127477127478127479127480127481127482127483127484127485127486127487127488127489127490127491127492127493127494127495127496127497127498127499127500127501127502127503127504127505127506127507127508127509127510127511127512127513127514127515127516127517127518127519127520127521127522127523127524127525127526127527127528127529127530127531127532127533127534127535127536127537127538127539127540127541127542127543127544127545127546127547127548127549127550127551127552127553127554127555127556127557127558127559127560127561127562127563127564127565127566127567127568127569127570127571127572127573127574127575127576127577127578127579127580127581127582127583127584127585127586127587127588127589127590127591127592127593127594127595127596127597127598127599127600127601127602127603127604127605127606127607127608127609127610127611127612127613127614127615127616127617127618127619127620127621127622127623127624127625127626127627127628127629127630127631127632127633127634127635127636127637127638127639127640127641127642127643127644127645127646127647127648127649127650127651127652127653127654127655127656127657127658127659127660127661127662127663127664127665127666127667127668127669127670127671127672127673127674127675127676127677127678127679127680127681127682127683127684127685127686127687127688127689127690127691127692127693127694127695127696127697127698127699127700127701127702127703127704127705127706127707127708127709127710127711127712127713127714127715127716127717127718127719127720127721127722127723127724127725127726127727127728127729127730127731127732127733127734127735127736127737127738127739127740127741127742127743127744127745127746127747127748127749127750127751127752127753127754127755127756127757127758127759127760127761127762127763127764127765127766127767127768127769127770127771127772127773127774127775127776127777127778127779127780127781127782127783127784127785127786127787127788127789127790127791127792127793127794127795127796127797127798127799127800127801127802127803127804127805127806127807127808127809127810127811127812127813127814127815127816127817127818127819127820127821127822127823127824127825127826127827127828127829127830127831127832127833127834127835127836127837127838127839127840127841127842127843127844127845127846127847127848127849127850127851127852127853127854127855127856127857127858127859127860127861127862127863127864127865127866127867127868127869127870127871127872127873127874127875127876127877127878127879127880127881127882127883127884127885127886127887127888127889127890127891127892127893127894127895127896127897127898127899127900127901127902127903127904127905127906127907127908127909127910127911127912127913127914127915127916127917127918127919127920127921127922127923127924127925127926127927127928127929127930127931127932127933127934127935127936127937127938127939127940127941127942127943127944127945127946127947127948127949127950127951127952127953127954127955127956127957127958127959127960127961127962127963127964127965127966127967127968127969127970127971127972127973127974127975127976127977127978127979127980127981127982127983127984127985127986127987127988127989127990127991127992127993127994127995127996127997127998127999128000128001128002128003128004128005128006128007128008128009128010128011128012128013128014128015128016128017128018128019128020128021128022128023128024128025128026128027128028128029128030128031128032128033128034128035128036128037128038128039128040128041128042128043128044128045128046128047128048128049128050128051128052128053128054128055128056128057128058128059128060128061128062128063128064128065128066128067128068128069128070128071128072128073128074128075128076128077128078128079128080128081128082128083128084128085128086128087128088128089128090128091128092128093128094128095128096128097128098128099128100128101128102128103128104128105128106128107128108128109128110128111128112128113128114128115128116128117128118128119128120128121128122128123128124128125128126128127128128128129128130128131128132128133128134128135128136128137128138128139128140128141128142128143128144128145128146128147128148128149128150128151128152128153128154128155128156128157128158128159128160128161128162128163128164
  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. /** @hidden */
  41. interface DeepImmutableArray<T> extends ReadonlyArray<DeepImmutable<T>> {
  42. }
  43. /** @hidden */
  44. /** @hidden */
  45. type DeepImmutableObject<T> = {
  46. readonly [K in keyof T]: DeepImmutable<T[K]>;
  47. };
  48. }
  49. declare module "babylonjs/Misc/observable" {
  50. import { Nullable } from "babylonjs/types";
  51. /**
  52. * A class serves as a medium between the observable and its observers
  53. */
  54. export class EventState {
  55. /**
  56. * Create a new EventState
  57. * @param mask defines the mask associated with this state
  58. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  59. * @param target defines the original target of the state
  60. * @param currentTarget defines the current target of the state
  61. */
  62. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  63. /**
  64. * Initialize the current event state
  65. * @param mask defines the mask associated with this state
  66. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  67. * @param target defines the original target of the state
  68. * @param currentTarget defines the current target of the state
  69. * @returns the current event state
  70. */
  71. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  72. /**
  73. * An Observer can set this property to true to prevent subsequent observers of being notified
  74. */
  75. skipNextObservers: boolean;
  76. /**
  77. * Get the mask value that were used to trigger the event corresponding to this EventState object
  78. */
  79. mask: number;
  80. /**
  81. * The object that originally notified the event
  82. */
  83. target?: any;
  84. /**
  85. * The current object in the bubbling phase
  86. */
  87. currentTarget?: any;
  88. /**
  89. * This will be populated with the return value of the last function that was executed.
  90. * If it is the first function in the callback chain it will be the event data.
  91. */
  92. lastReturnValue?: any;
  93. }
  94. /**
  95. * Represent an Observer registered to a given Observable object.
  96. */
  97. export class Observer<T> {
  98. /**
  99. * Defines the callback to call when the observer is notified
  100. */
  101. callback: (eventData: T, eventState: EventState) => void;
  102. /**
  103. * Defines the mask of the observer (used to filter notifications)
  104. */
  105. mask: number;
  106. /**
  107. * Defines the current scope used to restore the JS context
  108. */
  109. scope: any;
  110. /** @hidden */
  111. _willBeUnregistered: boolean;
  112. /**
  113. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  114. */
  115. unregisterOnNextCall: boolean;
  116. /**
  117. * Creates a new observer
  118. * @param callback defines the callback to call when the observer is notified
  119. * @param mask defines the mask of the observer (used to filter notifications)
  120. * @param scope defines the current scope used to restore the JS context
  121. */
  122. constructor(
  123. /**
  124. * Defines the callback to call when the observer is notified
  125. */
  126. callback: (eventData: T, eventState: EventState) => void,
  127. /**
  128. * Defines the mask of the observer (used to filter notifications)
  129. */
  130. mask: number,
  131. /**
  132. * Defines the current scope used to restore the JS context
  133. */
  134. scope?: any);
  135. }
  136. /**
  137. * Represent a list of observers registered to multiple Observables object.
  138. */
  139. export class MultiObserver<T> {
  140. private _observers;
  141. private _observables;
  142. /**
  143. * Release associated resources
  144. */
  145. dispose(): void;
  146. /**
  147. * Raise a callback when one of the observable will notify
  148. * @param observables defines a list of observables to watch
  149. * @param callback defines the callback to call on notification
  150. * @param mask defines the mask used to filter notifications
  151. * @param scope defines the current scope used to restore the JS context
  152. * @returns the new MultiObserver
  153. */
  154. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  155. }
  156. /**
  157. * The Observable class is a simple implementation of the Observable pattern.
  158. *
  159. * 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.
  160. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  161. * 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).
  162. * 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.
  163. */
  164. export class Observable<T> {
  165. private _observers;
  166. private _eventState;
  167. private _onObserverAdded;
  168. /**
  169. * Gets the list of observers
  170. */
  171. readonly observers: Array<Observer<T>>;
  172. /**
  173. * Creates a new observable
  174. * @param onObserverAdded defines a callback to call when a new observer is added
  175. */
  176. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  177. /**
  178. * Create a new Observer with the specified callback
  179. * @param callback the callback that will be executed for that Observer
  180. * @param mask the mask used to filter observers
  181. * @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.
  182. * @param scope optional scope for the callback to be called from
  183. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  184. * @returns the new observer created for the callback
  185. */
  186. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  187. /**
  188. * Create a new Observer with the specified callback and unregisters after the next notification
  189. * @param callback the callback that will be executed for that Observer
  190. * @returns the new observer created for the callback
  191. */
  192. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  193. /**
  194. * Remove an Observer from the Observable object
  195. * @param observer the instance of the Observer to remove
  196. * @returns false if it doesn't belong to this Observable
  197. */
  198. remove(observer: Nullable<Observer<T>>): boolean;
  199. /**
  200. * Remove a callback from the Observable object
  201. * @param callback the callback to remove
  202. * @param scope optional scope. If used only the callbacks with this scope will be removed
  203. * @returns false if it doesn't belong to this Observable
  204. */
  205. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  206. private _deferUnregister;
  207. private _remove;
  208. /**
  209. * Moves the observable to the top of the observer list making it get called first when notified
  210. * @param observer the observer to move
  211. */
  212. makeObserverTopPriority(observer: Observer<T>): void;
  213. /**
  214. * Moves the observable to the bottom of the observer list making it get called last when notified
  215. * @param observer the observer to move
  216. */
  217. makeObserverBottomPriority(observer: Observer<T>): void;
  218. /**
  219. * Notify all Observers by calling their respective callback with the given data
  220. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  221. * @param eventData defines the data to send to all observers
  222. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  223. * @param target defines the original target of the state
  224. * @param currentTarget defines the current target of the state
  225. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  226. */
  227. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  228. /**
  229. * Calling this will execute each callback, expecting it to be a promise or return a value.
  230. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  231. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  232. * and it is crucial that all callbacks will be executed.
  233. * The order of the callbacks is kept, callbacks are not executed parallel.
  234. *
  235. * @param eventData The data to be sent to each callback
  236. * @param mask is used to filter observers defaults to -1
  237. * @param target defines the callback target (see EventState)
  238. * @param currentTarget defines he current object in the bubbling phase
  239. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  240. */
  241. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  242. /**
  243. * Notify a specific observer
  244. * @param observer defines the observer to notify
  245. * @param eventData defines the data to be sent to each callback
  246. * @param mask is used to filter observers defaults to -1
  247. */
  248. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  249. /**
  250. * Gets a boolean indicating if the observable has at least one observer
  251. * @returns true is the Observable has at least one Observer registered
  252. */
  253. hasObservers(): boolean;
  254. /**
  255. * Clear the list of observers
  256. */
  257. clear(): void;
  258. /**
  259. * Clone the current observable
  260. * @returns a new observable
  261. */
  262. clone(): Observable<T>;
  263. /**
  264. * Does this observable handles observer registered with a given mask
  265. * @param mask defines the mask to be tested
  266. * @return whether or not one observer registered with the given mask is handeled
  267. **/
  268. hasSpecificMask(mask?: number): boolean;
  269. }
  270. }
  271. declare module "babylonjs/Misc/domManagement" {
  272. /**
  273. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  274. * Babylon.js
  275. */
  276. export class DomManagement {
  277. /**
  278. * Checks if the window object exists
  279. * @returns true if the window object exists
  280. */
  281. static IsWindowObjectExist(): boolean;
  282. /**
  283. * Checks if the navigator object exists
  284. * @returns true if the navigator object exists
  285. */
  286. static IsNavigatorAvailable(): boolean;
  287. /**
  288. * Extracts text content from a DOM element hierarchy
  289. * @param element defines the root element
  290. * @returns a string
  291. */
  292. static GetDOMTextContent(element: HTMLElement): string;
  293. }
  294. }
  295. declare module "babylonjs/Misc/logger" {
  296. /**
  297. * Logger used througouht the application to allow configuration of
  298. * the log level required for the messages.
  299. */
  300. export class Logger {
  301. /**
  302. * No log
  303. */
  304. static readonly NoneLogLevel: number;
  305. /**
  306. * Only message logs
  307. */
  308. static readonly MessageLogLevel: number;
  309. /**
  310. * Only warning logs
  311. */
  312. static readonly WarningLogLevel: number;
  313. /**
  314. * Only error logs
  315. */
  316. static readonly ErrorLogLevel: number;
  317. /**
  318. * All logs
  319. */
  320. static readonly AllLogLevel: number;
  321. private static _LogCache;
  322. /**
  323. * Gets a value indicating the number of loading errors
  324. * @ignorenaming
  325. */
  326. static errorsCount: number;
  327. /**
  328. * Callback called when a new log is added
  329. */
  330. static OnNewCacheEntry: (entry: string) => void;
  331. private static _AddLogEntry;
  332. private static _FormatMessage;
  333. private static _LogDisabled;
  334. private static _LogEnabled;
  335. private static _WarnDisabled;
  336. private static _WarnEnabled;
  337. private static _ErrorDisabled;
  338. private static _ErrorEnabled;
  339. /**
  340. * Log a message to the console
  341. */
  342. static Log: (message: string) => void;
  343. /**
  344. * Write a warning message to the console
  345. */
  346. static Warn: (message: string) => void;
  347. /**
  348. * Write an error message to the console
  349. */
  350. static Error: (message: string) => void;
  351. /**
  352. * Gets current log cache (list of logs)
  353. */
  354. static readonly LogCache: string;
  355. /**
  356. * Clears the log cache
  357. */
  358. static ClearLogCache(): void;
  359. /**
  360. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  361. */
  362. static LogLevels: number;
  363. }
  364. }
  365. declare module "babylonjs/Misc/typeStore" {
  366. /** @hidden */
  367. export class _TypeStore {
  368. /** @hidden */
  369. static RegisteredTypes: {
  370. [key: string]: Object;
  371. };
  372. /** @hidden */
  373. static GetClass(fqdn: string): any;
  374. }
  375. }
  376. declare module "babylonjs/Misc/deepCopier" {
  377. /**
  378. * Class containing a set of static utilities functions for deep copy.
  379. */
  380. export class DeepCopier {
  381. /**
  382. * Tries to copy an object by duplicating every property
  383. * @param source defines the source object
  384. * @param destination defines the target object
  385. * @param doNotCopyList defines a list of properties to avoid
  386. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  387. */
  388. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  389. }
  390. }
  391. declare module "babylonjs/Misc/precisionDate" {
  392. /**
  393. * Class containing a set of static utilities functions for precision date
  394. */
  395. export class PrecisionDate {
  396. /**
  397. * Gets either window.performance.now() if supported or Date.now() else
  398. */
  399. static readonly Now: number;
  400. }
  401. }
  402. declare module "babylonjs/Misc/devTools" {
  403. /** @hidden */
  404. export class _DevTools {
  405. static WarnImport(name: string): string;
  406. }
  407. }
  408. declare module "babylonjs/Misc/webRequest" {
  409. /**
  410. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  411. */
  412. export class WebRequest {
  413. private _xhr;
  414. /**
  415. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  416. * i.e. when loading files, where the server/service expects an Authorization header
  417. */
  418. static CustomRequestHeaders: {
  419. [key: string]: string;
  420. };
  421. /**
  422. * Add callback functions in this array to update all the requests before they get sent to the network
  423. */
  424. static CustomRequestModifiers: ((request: XMLHttpRequest, url: string) => void)[];
  425. private _injectCustomRequestHeaders;
  426. /**
  427. * Gets or sets a function to be called when loading progress changes
  428. */
  429. onprogress: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  430. /**
  431. * Returns client's state
  432. */
  433. readonly readyState: number;
  434. /**
  435. * Returns client's status
  436. */
  437. readonly status: number;
  438. /**
  439. * Returns client's status as a text
  440. */
  441. readonly statusText: string;
  442. /**
  443. * Returns client's response
  444. */
  445. readonly response: any;
  446. /**
  447. * Returns client's response url
  448. */
  449. readonly responseURL: string;
  450. /**
  451. * Returns client's response as text
  452. */
  453. readonly responseText: string;
  454. /**
  455. * Gets or sets the expected response type
  456. */
  457. responseType: XMLHttpRequestResponseType;
  458. /** @hidden */
  459. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  460. /** @hidden */
  461. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  462. /**
  463. * Cancels any network activity
  464. */
  465. abort(): void;
  466. /**
  467. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  468. * @param body defines an optional request body
  469. */
  470. send(body?: Document | BodyInit | null): void;
  471. /**
  472. * Sets the request method, request URL
  473. * @param method defines the method to use (GET, POST, etc..)
  474. * @param url defines the url to connect with
  475. */
  476. open(method: string, url: string): void;
  477. }
  478. }
  479. declare module "babylonjs/Misc/fileRequest" {
  480. import { Observable } from "babylonjs/Misc/observable";
  481. /**
  482. * File request interface
  483. */
  484. export interface IFileRequest {
  485. /**
  486. * Raised when the request is complete (success or error).
  487. */
  488. onCompleteObservable: Observable<IFileRequest>;
  489. /**
  490. * Aborts the request for a file.
  491. */
  492. abort: () => void;
  493. }
  494. }
  495. declare module "babylonjs/Misc/performanceMonitor" {
  496. /**
  497. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  498. */
  499. export class PerformanceMonitor {
  500. private _enabled;
  501. private _rollingFrameTime;
  502. private _lastFrameTimeMs;
  503. /**
  504. * constructor
  505. * @param frameSampleSize The number of samples required to saturate the sliding window
  506. */
  507. constructor(frameSampleSize?: number);
  508. /**
  509. * Samples current frame
  510. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  511. */
  512. sampleFrame(timeMs?: number): void;
  513. /**
  514. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  515. */
  516. readonly averageFrameTime: number;
  517. /**
  518. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  519. */
  520. readonly averageFrameTimeVariance: number;
  521. /**
  522. * Returns the frame time of the most recent frame
  523. */
  524. readonly instantaneousFrameTime: number;
  525. /**
  526. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  527. */
  528. readonly averageFPS: number;
  529. /**
  530. * Returns the average framerate in frames per second using the most recent frame time
  531. */
  532. readonly instantaneousFPS: number;
  533. /**
  534. * Returns true if enough samples have been taken to completely fill the sliding window
  535. */
  536. readonly isSaturated: boolean;
  537. /**
  538. * Enables contributions to the sliding window sample set
  539. */
  540. enable(): void;
  541. /**
  542. * Disables contributions to the sliding window sample set
  543. * Samples will not be interpolated over the disabled period
  544. */
  545. disable(): void;
  546. /**
  547. * Returns true if sampling is enabled
  548. */
  549. readonly isEnabled: boolean;
  550. /**
  551. * Resets performance monitor
  552. */
  553. reset(): void;
  554. }
  555. /**
  556. * RollingAverage
  557. *
  558. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  559. */
  560. export class RollingAverage {
  561. /**
  562. * Current average
  563. */
  564. average: number;
  565. /**
  566. * Current variance
  567. */
  568. variance: number;
  569. protected _samples: Array<number>;
  570. protected _sampleCount: number;
  571. protected _pos: number;
  572. protected _m2: number;
  573. /**
  574. * constructor
  575. * @param length The number of samples required to saturate the sliding window
  576. */
  577. constructor(length: number);
  578. /**
  579. * Adds a sample to the sample set
  580. * @param v The sample value
  581. */
  582. add(v: number): void;
  583. /**
  584. * Returns previously added values or null if outside of history or outside the sliding window domain
  585. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  586. * @return Value previously recorded with add() or null if outside of range
  587. */
  588. history(i: number): number;
  589. /**
  590. * Returns true if enough samples have been taken to completely fill the sliding window
  591. * @return true if sample-set saturated
  592. */
  593. isSaturated(): boolean;
  594. /**
  595. * Resets the rolling average (equivalent to 0 samples taken so far)
  596. */
  597. reset(): void;
  598. /**
  599. * Wraps a value around the sample range boundaries
  600. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  601. * @return Wrapped position in sample range
  602. */
  603. protected _wrapPosition(i: number): number;
  604. }
  605. }
  606. declare module "babylonjs/Misc/stringDictionary" {
  607. import { Nullable } from "babylonjs/types";
  608. /**
  609. * This class implement a typical dictionary using a string as key and the generic type T as value.
  610. * The underlying implementation relies on an associative array to ensure the best performances.
  611. * The value can be anything including 'null' but except 'undefined'
  612. */
  613. export class StringDictionary<T> {
  614. /**
  615. * This will clear this dictionary and copy the content from the 'source' one.
  616. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  617. * @param source the dictionary to take the content from and copy to this dictionary
  618. */
  619. copyFrom(source: StringDictionary<T>): void;
  620. /**
  621. * Get a value based from its key
  622. * @param key the given key to get the matching value from
  623. * @return the value if found, otherwise undefined is returned
  624. */
  625. get(key: string): T | undefined;
  626. /**
  627. * Get a value from its key or add it if it doesn't exist.
  628. * This method will ensure you that a given key/data will be present in the dictionary.
  629. * @param key the given key to get the matching value from
  630. * @param factory the factory that will create the value if the key is not present in the dictionary.
  631. * The factory will only be invoked if there's no data for the given key.
  632. * @return the value corresponding to the key.
  633. */
  634. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  635. /**
  636. * Get a value from its key if present in the dictionary otherwise add it
  637. * @param key the key to get the value from
  638. * @param val if there's no such key/value pair in the dictionary add it with this value
  639. * @return the value corresponding to the key
  640. */
  641. getOrAdd(key: string, val: T): T;
  642. /**
  643. * Check if there's a given key in the dictionary
  644. * @param key the key to check for
  645. * @return true if the key is present, false otherwise
  646. */
  647. contains(key: string): boolean;
  648. /**
  649. * Add a new key and its corresponding value
  650. * @param key the key to add
  651. * @param value the value corresponding to the key
  652. * @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
  653. */
  654. add(key: string, value: T): boolean;
  655. /**
  656. * Update a specific value associated to a key
  657. * @param key defines the key to use
  658. * @param value defines the value to store
  659. * @returns true if the value was updated (or false if the key was not found)
  660. */
  661. set(key: string, value: T): boolean;
  662. /**
  663. * Get the element of the given key and remove it from the dictionary
  664. * @param key defines the key to search
  665. * @returns the value associated with the key or null if not found
  666. */
  667. getAndRemove(key: string): Nullable<T>;
  668. /**
  669. * Remove a key/value from the dictionary.
  670. * @param key the key to remove
  671. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  672. */
  673. remove(key: string): boolean;
  674. /**
  675. * Clear the whole content of the dictionary
  676. */
  677. clear(): void;
  678. /**
  679. * Gets the current count
  680. */
  681. readonly count: number;
  682. /**
  683. * Execute a callback on each key/val of the dictionary.
  684. * Note that you can remove any element in this dictionary in the callback implementation
  685. * @param callback the callback to execute on a given key/value pair
  686. */
  687. forEach(callback: (key: string, val: T) => void): void;
  688. /**
  689. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  690. * If the callback returns null or undefined the method will iterate to the next key/value pair
  691. * Note that you can remove any element in this dictionary in the callback implementation
  692. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  693. * @returns the first item
  694. */
  695. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  696. private _count;
  697. private _data;
  698. }
  699. }
  700. declare module "babylonjs/Meshes/dataBuffer" {
  701. /**
  702. * Class used to store gfx data (like WebGLBuffer)
  703. */
  704. export class DataBuffer {
  705. /**
  706. * Gets or sets the number of objects referencing this buffer
  707. */
  708. references: number;
  709. /** Gets or sets the size of the underlying buffer */
  710. capacity: number;
  711. /**
  712. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  713. */
  714. is32Bits: boolean;
  715. /**
  716. * Gets the underlying buffer
  717. */
  718. readonly underlyingResource: any;
  719. }
  720. }
  721. declare module "babylonjs/Meshes/buffer" {
  722. import { Nullable, DataArray } from "babylonjs/types";
  723. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  724. /**
  725. * Class used to store data that will be store in GPU memory
  726. */
  727. export class Buffer {
  728. private _engine;
  729. private _buffer;
  730. /** @hidden */
  731. _data: Nullable<DataArray>;
  732. private _updatable;
  733. private _instanced;
  734. /**
  735. * Gets the byte stride.
  736. */
  737. readonly byteStride: number;
  738. /**
  739. * Constructor
  740. * @param engine the engine
  741. * @param data the data to use for this buffer
  742. * @param updatable whether the data is updatable
  743. * @param stride the stride (optional)
  744. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  745. * @param instanced whether the buffer is instanced (optional)
  746. * @param useBytes set to true if the stride in in bytes (optional)
  747. */
  748. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean);
  749. /**
  750. * Create a new VertexBuffer based on the current buffer
  751. * @param kind defines the vertex buffer kind (position, normal, etc.)
  752. * @param offset defines offset in the buffer (0 by default)
  753. * @param size defines the size in floats of attributes (position is 3 for instance)
  754. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  755. * @param instanced defines if the vertex buffer contains indexed data
  756. * @param useBytes defines if the offset and stride are in bytes
  757. * @returns the new vertex buffer
  758. */
  759. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean): VertexBuffer;
  760. /**
  761. * Gets a boolean indicating if the Buffer is updatable?
  762. * @returns true if the buffer is updatable
  763. */
  764. isUpdatable(): boolean;
  765. /**
  766. * Gets current buffer's data
  767. * @returns a DataArray or null
  768. */
  769. getData(): Nullable<DataArray>;
  770. /**
  771. * Gets underlying native buffer
  772. * @returns underlying native buffer
  773. */
  774. getBuffer(): Nullable<DataBuffer>;
  775. /**
  776. * Gets the stride in float32 units (i.e. byte stride / 4).
  777. * May not be an integer if the byte stride is not divisible by 4.
  778. * DEPRECATED. Use byteStride instead.
  779. * @returns the stride in float32 units
  780. */
  781. getStrideSize(): number;
  782. /**
  783. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  784. * @param data defines the data to store
  785. */
  786. create(data?: Nullable<DataArray>): void;
  787. /** @hidden */
  788. _rebuild(): void;
  789. /**
  790. * Update current buffer data
  791. * @param data defines the data to store
  792. */
  793. update(data: DataArray): void;
  794. /**
  795. * Updates the data directly.
  796. * @param data the new data
  797. * @param offset the new offset
  798. * @param vertexCount the vertex count (optional)
  799. * @param useBytes set to true if the offset is in bytes
  800. */
  801. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  802. /**
  803. * Release all resources
  804. */
  805. dispose(): void;
  806. }
  807. /**
  808. * Specialized buffer used to store vertex data
  809. */
  810. export class VertexBuffer {
  811. /** @hidden */
  812. _buffer: Buffer;
  813. private _kind;
  814. private _size;
  815. private _ownsBuffer;
  816. private _instanced;
  817. private _instanceDivisor;
  818. /**
  819. * The byte type.
  820. */
  821. static readonly BYTE: number;
  822. /**
  823. * The unsigned byte type.
  824. */
  825. static readonly UNSIGNED_BYTE: number;
  826. /**
  827. * The short type.
  828. */
  829. static readonly SHORT: number;
  830. /**
  831. * The unsigned short type.
  832. */
  833. static readonly UNSIGNED_SHORT: number;
  834. /**
  835. * The integer type.
  836. */
  837. static readonly INT: number;
  838. /**
  839. * The unsigned integer type.
  840. */
  841. static readonly UNSIGNED_INT: number;
  842. /**
  843. * The float type.
  844. */
  845. static readonly FLOAT: number;
  846. /**
  847. * Gets or sets the instance divisor when in instanced mode
  848. */
  849. instanceDivisor: number;
  850. /**
  851. * Gets the byte stride.
  852. */
  853. readonly byteStride: number;
  854. /**
  855. * Gets the byte offset.
  856. */
  857. readonly byteOffset: number;
  858. /**
  859. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  860. */
  861. readonly normalized: boolean;
  862. /**
  863. * Gets the data type of each component in the array.
  864. */
  865. readonly type: number;
  866. /**
  867. * Constructor
  868. * @param engine the engine
  869. * @param data the data to use for this vertex buffer
  870. * @param kind the vertex buffer kind
  871. * @param updatable whether the data is updatable
  872. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  873. * @param stride the stride (optional)
  874. * @param instanced whether the buffer is instanced (optional)
  875. * @param offset the offset of the data (optional)
  876. * @param size the number of components (optional)
  877. * @param type the type of the component (optional)
  878. * @param normalized whether the data contains normalized data (optional)
  879. * @param useBytes set to true if stride and offset are in bytes (optional)
  880. */
  881. 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);
  882. /** @hidden */
  883. _rebuild(): void;
  884. /**
  885. * Returns the kind of the VertexBuffer (string)
  886. * @returns a string
  887. */
  888. getKind(): string;
  889. /**
  890. * Gets a boolean indicating if the VertexBuffer is updatable?
  891. * @returns true if the buffer is updatable
  892. */
  893. isUpdatable(): boolean;
  894. /**
  895. * Gets current buffer's data
  896. * @returns a DataArray or null
  897. */
  898. getData(): Nullable<DataArray>;
  899. /**
  900. * Gets underlying native buffer
  901. * @returns underlying native buffer
  902. */
  903. getBuffer(): Nullable<DataBuffer>;
  904. /**
  905. * Gets the stride in float32 units (i.e. byte stride / 4).
  906. * May not be an integer if the byte stride is not divisible by 4.
  907. * DEPRECATED. Use byteStride instead.
  908. * @returns the stride in float32 units
  909. */
  910. getStrideSize(): number;
  911. /**
  912. * Returns the offset as a multiple of the type byte length.
  913. * DEPRECATED. Use byteOffset instead.
  914. * @returns the offset in bytes
  915. */
  916. getOffset(): number;
  917. /**
  918. * Returns the number of components per vertex attribute (integer)
  919. * @returns the size in float
  920. */
  921. getSize(): number;
  922. /**
  923. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  924. * @returns true if this buffer is instanced
  925. */
  926. getIsInstanced(): boolean;
  927. /**
  928. * Returns the instancing divisor, zero for non-instanced (integer).
  929. * @returns a number
  930. */
  931. getInstanceDivisor(): number;
  932. /**
  933. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  934. * @param data defines the data to store
  935. */
  936. create(data?: DataArray): void;
  937. /**
  938. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  939. * This function will create a new buffer if the current one is not updatable
  940. * @param data defines the data to store
  941. */
  942. update(data: DataArray): void;
  943. /**
  944. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  945. * Returns the directly updated WebGLBuffer.
  946. * @param data the new data
  947. * @param offset the new offset
  948. * @param useBytes set to true if the offset is in bytes
  949. */
  950. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  951. /**
  952. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  953. */
  954. dispose(): void;
  955. /**
  956. * Enumerates each value of this vertex buffer as numbers.
  957. * @param count the number of values to enumerate
  958. * @param callback the callback function called for each value
  959. */
  960. forEach(count: number, callback: (value: number, index: number) => void): void;
  961. /**
  962. * Positions
  963. */
  964. static readonly PositionKind: string;
  965. /**
  966. * Normals
  967. */
  968. static readonly NormalKind: string;
  969. /**
  970. * Tangents
  971. */
  972. static readonly TangentKind: string;
  973. /**
  974. * Texture coordinates
  975. */
  976. static readonly UVKind: string;
  977. /**
  978. * Texture coordinates 2
  979. */
  980. static readonly UV2Kind: string;
  981. /**
  982. * Texture coordinates 3
  983. */
  984. static readonly UV3Kind: string;
  985. /**
  986. * Texture coordinates 4
  987. */
  988. static readonly UV4Kind: string;
  989. /**
  990. * Texture coordinates 5
  991. */
  992. static readonly UV5Kind: string;
  993. /**
  994. * Texture coordinates 6
  995. */
  996. static readonly UV6Kind: string;
  997. /**
  998. * Colors
  999. */
  1000. static readonly ColorKind: string;
  1001. /**
  1002. * Matrix indices (for bones)
  1003. */
  1004. static readonly MatricesIndicesKind: string;
  1005. /**
  1006. * Matrix weights (for bones)
  1007. */
  1008. static readonly MatricesWeightsKind: string;
  1009. /**
  1010. * Additional matrix indices (for bones)
  1011. */
  1012. static readonly MatricesIndicesExtraKind: string;
  1013. /**
  1014. * Additional matrix weights (for bones)
  1015. */
  1016. static readonly MatricesWeightsExtraKind: string;
  1017. /**
  1018. * Deduces the stride given a kind.
  1019. * @param kind The kind string to deduce
  1020. * @returns The deduced stride
  1021. */
  1022. static DeduceStride(kind: string): number;
  1023. /**
  1024. * Gets the byte length of the given type.
  1025. * @param type the type
  1026. * @returns the number of bytes
  1027. */
  1028. static GetTypeByteLength(type: number): number;
  1029. /**
  1030. * Enumerates each value of the given parameters as numbers.
  1031. * @param data the data to enumerate
  1032. * @param byteOffset the byte offset of the data
  1033. * @param byteStride the byte stride of the data
  1034. * @param componentCount the number of components per element
  1035. * @param componentType the type of the component
  1036. * @param count the number of values to enumerate
  1037. * @param normalized whether the data is normalized
  1038. * @param callback the callback function called for each value
  1039. */
  1040. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  1041. private static _GetFloatValue;
  1042. }
  1043. }
  1044. declare module "babylonjs/Maths/math.scalar" {
  1045. /**
  1046. * Scalar computation library
  1047. */
  1048. export class Scalar {
  1049. /**
  1050. * Two pi constants convenient for computation.
  1051. */
  1052. static TwoPi: number;
  1053. /**
  1054. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  1055. * @param a number
  1056. * @param b number
  1057. * @param epsilon (default = 1.401298E-45)
  1058. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  1059. */
  1060. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  1061. /**
  1062. * Returns a string : the upper case translation of the number i to hexadecimal.
  1063. * @param i number
  1064. * @returns the upper case translation of the number i to hexadecimal.
  1065. */
  1066. static ToHex(i: number): string;
  1067. /**
  1068. * Returns -1 if value is negative and +1 is value is positive.
  1069. * @param value the value
  1070. * @returns the value itself if it's equal to zero.
  1071. */
  1072. static Sign(value: number): number;
  1073. /**
  1074. * Returns the value itself if it's between min and max.
  1075. * Returns min if the value is lower than min.
  1076. * Returns max if the value is greater than max.
  1077. * @param value the value to clmap
  1078. * @param min the min value to clamp to (default: 0)
  1079. * @param max the max value to clamp to (default: 1)
  1080. * @returns the clamped value
  1081. */
  1082. static Clamp(value: number, min?: number, max?: number): number;
  1083. /**
  1084. * the log2 of value.
  1085. * @param value the value to compute log2 of
  1086. * @returns the log2 of value.
  1087. */
  1088. static Log2(value: number): number;
  1089. /**
  1090. * Loops the value, so that it is never larger than length and never smaller than 0.
  1091. *
  1092. * This is similar to the modulo operator but it works with floating point numbers.
  1093. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  1094. * With t = 5 and length = 2.5, the result would be 0.0.
  1095. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  1096. * @param value the value
  1097. * @param length the length
  1098. * @returns the looped value
  1099. */
  1100. static Repeat(value: number, length: number): number;
  1101. /**
  1102. * Normalize the value between 0.0 and 1.0 using min and max values
  1103. * @param value value to normalize
  1104. * @param min max to normalize between
  1105. * @param max min to normalize between
  1106. * @returns the normalized value
  1107. */
  1108. static Normalize(value: number, min: number, max: number): number;
  1109. /**
  1110. * Denormalize the value from 0.0 and 1.0 using min and max values
  1111. * @param normalized value to denormalize
  1112. * @param min max to denormalize between
  1113. * @param max min to denormalize between
  1114. * @returns the denormalized value
  1115. */
  1116. static Denormalize(normalized: number, min: number, max: number): number;
  1117. /**
  1118. * Calculates the shortest difference between two given angles given in degrees.
  1119. * @param current current angle in degrees
  1120. * @param target target angle in degrees
  1121. * @returns the delta
  1122. */
  1123. static DeltaAngle(current: number, target: number): number;
  1124. /**
  1125. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  1126. * @param tx value
  1127. * @param length length
  1128. * @returns The returned value will move back and forth between 0 and length
  1129. */
  1130. static PingPong(tx: number, length: number): number;
  1131. /**
  1132. * Interpolates between min and max with smoothing at the limits.
  1133. *
  1134. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  1135. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  1136. * @param from from
  1137. * @param to to
  1138. * @param tx value
  1139. * @returns the smooth stepped value
  1140. */
  1141. static SmoothStep(from: number, to: number, tx: number): number;
  1142. /**
  1143. * Moves a value current towards target.
  1144. *
  1145. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  1146. * Negative values of maxDelta pushes the value away from target.
  1147. * @param current current value
  1148. * @param target target value
  1149. * @param maxDelta max distance to move
  1150. * @returns resulting value
  1151. */
  1152. static MoveTowards(current: number, target: number, maxDelta: number): number;
  1153. /**
  1154. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  1155. *
  1156. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  1157. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  1158. * @param current current value
  1159. * @param target target value
  1160. * @param maxDelta max distance to move
  1161. * @returns resulting angle
  1162. */
  1163. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  1164. /**
  1165. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  1166. * @param start start value
  1167. * @param end target value
  1168. * @param amount amount to lerp between
  1169. * @returns the lerped value
  1170. */
  1171. static Lerp(start: number, end: number, amount: number): number;
  1172. /**
  1173. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  1174. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  1175. * @param start start value
  1176. * @param end target value
  1177. * @param amount amount to lerp between
  1178. * @returns the lerped value
  1179. */
  1180. static LerpAngle(start: number, end: number, amount: number): number;
  1181. /**
  1182. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  1183. * @param a start value
  1184. * @param b target value
  1185. * @param value value between a and b
  1186. * @returns the inverseLerp value
  1187. */
  1188. static InverseLerp(a: number, b: number, value: number): number;
  1189. /**
  1190. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  1191. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  1192. * @param value1 spline value
  1193. * @param tangent1 spline value
  1194. * @param value2 spline value
  1195. * @param tangent2 spline value
  1196. * @param amount input value
  1197. * @returns hermite result
  1198. */
  1199. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  1200. /**
  1201. * Returns a random float number between and min and max values
  1202. * @param min min value of random
  1203. * @param max max value of random
  1204. * @returns random value
  1205. */
  1206. static RandomRange(min: number, max: number): number;
  1207. /**
  1208. * This function returns percentage of a number in a given range.
  1209. *
  1210. * RangeToPercent(40,20,60) will return 0.5 (50%)
  1211. * RangeToPercent(34,0,100) will return 0.34 (34%)
  1212. * @param number to convert to percentage
  1213. * @param min min range
  1214. * @param max max range
  1215. * @returns the percentage
  1216. */
  1217. static RangeToPercent(number: number, min: number, max: number): number;
  1218. /**
  1219. * This function returns number that corresponds to the percentage in a given range.
  1220. *
  1221. * PercentToRange(0.34,0,100) will return 34.
  1222. * @param percent to convert to number
  1223. * @param min min range
  1224. * @param max max range
  1225. * @returns the number
  1226. */
  1227. static PercentToRange(percent: number, min: number, max: number): number;
  1228. /**
  1229. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  1230. * @param angle The angle to normalize in radian.
  1231. * @return The converted angle.
  1232. */
  1233. static NormalizeRadians(angle: number): number;
  1234. }
  1235. }
  1236. declare module "babylonjs/Maths/math.constants" {
  1237. /**
  1238. * Constant used to convert a value to gamma space
  1239. * @ignorenaming
  1240. */
  1241. export const ToGammaSpace: number;
  1242. /**
  1243. * Constant used to convert a value to linear space
  1244. * @ignorenaming
  1245. */
  1246. export const ToLinearSpace = 2.2;
  1247. /**
  1248. * Constant used to define the minimal number value in Babylon.js
  1249. * @ignorenaming
  1250. */
  1251. let Epsilon: number;
  1252. export { Epsilon };
  1253. }
  1254. declare module "babylonjs/Maths/math.viewport" {
  1255. /**
  1256. * Class used to represent a viewport on screen
  1257. */
  1258. export class Viewport {
  1259. /** viewport left coordinate */
  1260. x: number;
  1261. /** viewport top coordinate */
  1262. y: number;
  1263. /**viewport width */
  1264. width: number;
  1265. /** viewport height */
  1266. height: number;
  1267. /**
  1268. * Creates a Viewport object located at (x, y) and sized (width, height)
  1269. * @param x defines viewport left coordinate
  1270. * @param y defines viewport top coordinate
  1271. * @param width defines the viewport width
  1272. * @param height defines the viewport height
  1273. */
  1274. constructor(
  1275. /** viewport left coordinate */
  1276. x: number,
  1277. /** viewport top coordinate */
  1278. y: number,
  1279. /**viewport width */
  1280. width: number,
  1281. /** viewport height */
  1282. height: number);
  1283. /**
  1284. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  1285. * @param renderWidth defines the rendering width
  1286. * @param renderHeight defines the rendering height
  1287. * @returns a new Viewport
  1288. */
  1289. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  1290. /**
  1291. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  1292. * @param renderWidth defines the rendering width
  1293. * @param renderHeight defines the rendering height
  1294. * @param ref defines the target viewport
  1295. * @returns the current viewport
  1296. */
  1297. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  1298. /**
  1299. * Returns a new Viewport copied from the current one
  1300. * @returns a new Viewport
  1301. */
  1302. clone(): Viewport;
  1303. }
  1304. }
  1305. declare module "babylonjs/Misc/arrayTools" {
  1306. /**
  1307. * Class containing a set of static utilities functions for arrays.
  1308. */
  1309. export class ArrayTools {
  1310. /**
  1311. * Returns an array of the given size filled with element built from the given constructor and the paramters
  1312. * @param size the number of element to construct and put in the array
  1313. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  1314. * @returns a new array filled with new objects
  1315. */
  1316. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  1317. }
  1318. }
  1319. declare module "babylonjs/Maths/math.like" {
  1320. import { float, int, DeepImmutable } from "babylonjs/types";
  1321. /**
  1322. * @hidden
  1323. */
  1324. export interface IColor4Like {
  1325. r: float;
  1326. g: float;
  1327. b: float;
  1328. a: float;
  1329. }
  1330. /**
  1331. * @hidden
  1332. */
  1333. export interface IColor3Like {
  1334. r: float;
  1335. g: float;
  1336. b: float;
  1337. }
  1338. /**
  1339. * @hidden
  1340. */
  1341. export interface IVector4Like {
  1342. x: float;
  1343. y: float;
  1344. z: float;
  1345. w: float;
  1346. }
  1347. /**
  1348. * @hidden
  1349. */
  1350. export interface IVector3Like {
  1351. x: float;
  1352. y: float;
  1353. z: float;
  1354. }
  1355. /**
  1356. * @hidden
  1357. */
  1358. export interface IVector2Like {
  1359. x: float;
  1360. y: float;
  1361. }
  1362. /**
  1363. * @hidden
  1364. */
  1365. export interface IMatrixLike {
  1366. toArray(): DeepImmutable<Float32Array>;
  1367. updateFlag: int;
  1368. }
  1369. /**
  1370. * @hidden
  1371. */
  1372. export interface IViewportLike {
  1373. x: float;
  1374. y: float;
  1375. width: float;
  1376. height: float;
  1377. }
  1378. /**
  1379. * @hidden
  1380. */
  1381. export interface IPlaneLike {
  1382. normal: IVector3Like;
  1383. d: float;
  1384. normalize(): void;
  1385. }
  1386. }
  1387. declare module "babylonjs/Maths/math.vector" {
  1388. import { Viewport } from "babylonjs/Maths/math.viewport";
  1389. import { DeepImmutable, Nullable, FloatArray, float } from "babylonjs/types";
  1390. import { IPlaneLike } from "babylonjs/Maths/math.like";
  1391. /**
  1392. * Class representing a vector containing 2 coordinates
  1393. */
  1394. export class Vector2 {
  1395. /** defines the first coordinate */
  1396. x: number;
  1397. /** defines the second coordinate */
  1398. y: number;
  1399. /**
  1400. * Creates a new Vector2 from the given x and y coordinates
  1401. * @param x defines the first coordinate
  1402. * @param y defines the second coordinate
  1403. */
  1404. constructor(
  1405. /** defines the first coordinate */
  1406. x?: number,
  1407. /** defines the second coordinate */
  1408. y?: number);
  1409. /**
  1410. * Gets a string with the Vector2 coordinates
  1411. * @returns a string with the Vector2 coordinates
  1412. */
  1413. toString(): string;
  1414. /**
  1415. * Gets class name
  1416. * @returns the string "Vector2"
  1417. */
  1418. getClassName(): string;
  1419. /**
  1420. * Gets current vector hash code
  1421. * @returns the Vector2 hash code as a number
  1422. */
  1423. getHashCode(): number;
  1424. /**
  1425. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  1426. * @param array defines the source array
  1427. * @param index defines the offset in source array
  1428. * @returns the current Vector2
  1429. */
  1430. toArray(array: FloatArray, index?: number): Vector2;
  1431. /**
  1432. * Copy the current vector to an array
  1433. * @returns a new array with 2 elements: the Vector2 coordinates.
  1434. */
  1435. asArray(): number[];
  1436. /**
  1437. * Sets the Vector2 coordinates with the given Vector2 coordinates
  1438. * @param source defines the source Vector2
  1439. * @returns the current updated Vector2
  1440. */
  1441. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  1442. /**
  1443. * Sets the Vector2 coordinates with the given floats
  1444. * @param x defines the first coordinate
  1445. * @param y defines the second coordinate
  1446. * @returns the current updated Vector2
  1447. */
  1448. copyFromFloats(x: number, y: number): Vector2;
  1449. /**
  1450. * Sets the Vector2 coordinates with the given floats
  1451. * @param x defines the first coordinate
  1452. * @param y defines the second coordinate
  1453. * @returns the current updated Vector2
  1454. */
  1455. set(x: number, y: number): Vector2;
  1456. /**
  1457. * Add another vector with the current one
  1458. * @param otherVector defines the other vector
  1459. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  1460. */
  1461. add(otherVector: DeepImmutable<Vector2>): Vector2;
  1462. /**
  1463. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  1464. * @param otherVector defines the other vector
  1465. * @param result defines the target vector
  1466. * @returns the unmodified current Vector2
  1467. */
  1468. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  1469. /**
  1470. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  1471. * @param otherVector defines the other vector
  1472. * @returns the current updated Vector2
  1473. */
  1474. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  1475. /**
  1476. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  1477. * @param otherVector defines the other vector
  1478. * @returns a new Vector2
  1479. */
  1480. addVector3(otherVector: Vector3): Vector2;
  1481. /**
  1482. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  1483. * @param otherVector defines the other vector
  1484. * @returns a new Vector2
  1485. */
  1486. subtract(otherVector: Vector2): Vector2;
  1487. /**
  1488. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  1489. * @param otherVector defines the other vector
  1490. * @param result defines the target vector
  1491. * @returns the unmodified current Vector2
  1492. */
  1493. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  1494. /**
  1495. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  1496. * @param otherVector defines the other vector
  1497. * @returns the current updated Vector2
  1498. */
  1499. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  1500. /**
  1501. * Multiplies in place the current Vector2 coordinates by the given ones
  1502. * @param otherVector defines the other vector
  1503. * @returns the current updated Vector2
  1504. */
  1505. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  1506. /**
  1507. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  1508. * @param otherVector defines the other vector
  1509. * @returns a new Vector2
  1510. */
  1511. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  1512. /**
  1513. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  1514. * @param otherVector defines the other vector
  1515. * @param result defines the target vector
  1516. * @returns the unmodified current Vector2
  1517. */
  1518. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  1519. /**
  1520. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  1521. * @param x defines the first coordinate
  1522. * @param y defines the second coordinate
  1523. * @returns a new Vector2
  1524. */
  1525. multiplyByFloats(x: number, y: number): Vector2;
  1526. /**
  1527. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  1528. * @param otherVector defines the other vector
  1529. * @returns a new Vector2
  1530. */
  1531. divide(otherVector: Vector2): Vector2;
  1532. /**
  1533. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  1534. * @param otherVector defines the other vector
  1535. * @param result defines the target vector
  1536. * @returns the unmodified current Vector2
  1537. */
  1538. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  1539. /**
  1540. * Divides the current Vector2 coordinates by the given ones
  1541. * @param otherVector defines the other vector
  1542. * @returns the current updated Vector2
  1543. */
  1544. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  1545. /**
  1546. * Gets a new Vector2 with current Vector2 negated coordinates
  1547. * @returns a new Vector2
  1548. */
  1549. negate(): Vector2;
  1550. /**
  1551. * Multiply the Vector2 coordinates by scale
  1552. * @param scale defines the scaling factor
  1553. * @returns the current updated Vector2
  1554. */
  1555. scaleInPlace(scale: number): Vector2;
  1556. /**
  1557. * Returns a new Vector2 scaled by "scale" from the current Vector2
  1558. * @param scale defines the scaling factor
  1559. * @returns a new Vector2
  1560. */
  1561. scale(scale: number): Vector2;
  1562. /**
  1563. * Scale the current Vector2 values by a factor to a given Vector2
  1564. * @param scale defines the scale factor
  1565. * @param result defines the Vector2 object where to store the result
  1566. * @returns the unmodified current Vector2
  1567. */
  1568. scaleToRef(scale: number, result: Vector2): Vector2;
  1569. /**
  1570. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  1571. * @param scale defines the scale factor
  1572. * @param result defines the Vector2 object where to store the result
  1573. * @returns the unmodified current Vector2
  1574. */
  1575. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  1576. /**
  1577. * Gets a boolean if two vectors are equals
  1578. * @param otherVector defines the other vector
  1579. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  1580. */
  1581. equals(otherVector: DeepImmutable<Vector2>): boolean;
  1582. /**
  1583. * Gets a boolean if two vectors are equals (using an epsilon value)
  1584. * @param otherVector defines the other vector
  1585. * @param epsilon defines the minimal distance to consider equality
  1586. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  1587. */
  1588. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  1589. /**
  1590. * Gets a new Vector2 from current Vector2 floored values
  1591. * @returns a new Vector2
  1592. */
  1593. floor(): Vector2;
  1594. /**
  1595. * Gets a new Vector2 from current Vector2 floored values
  1596. * @returns a new Vector2
  1597. */
  1598. fract(): Vector2;
  1599. /**
  1600. * Gets the length of the vector
  1601. * @returns the vector length (float)
  1602. */
  1603. length(): number;
  1604. /**
  1605. * Gets the vector squared length
  1606. * @returns the vector squared length (float)
  1607. */
  1608. lengthSquared(): number;
  1609. /**
  1610. * Normalize the vector
  1611. * @returns the current updated Vector2
  1612. */
  1613. normalize(): Vector2;
  1614. /**
  1615. * Gets a new Vector2 copied from the Vector2
  1616. * @returns a new Vector2
  1617. */
  1618. clone(): Vector2;
  1619. /**
  1620. * Gets a new Vector2(0, 0)
  1621. * @returns a new Vector2
  1622. */
  1623. static Zero(): Vector2;
  1624. /**
  1625. * Gets a new Vector2(1, 1)
  1626. * @returns a new Vector2
  1627. */
  1628. static One(): Vector2;
  1629. /**
  1630. * Gets a new Vector2 set from the given index element of the given array
  1631. * @param array defines the data source
  1632. * @param offset defines the offset in the data source
  1633. * @returns a new Vector2
  1634. */
  1635. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  1636. /**
  1637. * Sets "result" from the given index element of the given array
  1638. * @param array defines the data source
  1639. * @param offset defines the offset in the data source
  1640. * @param result defines the target vector
  1641. */
  1642. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  1643. /**
  1644. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  1645. * @param value1 defines 1st point of control
  1646. * @param value2 defines 2nd point of control
  1647. * @param value3 defines 3rd point of control
  1648. * @param value4 defines 4th point of control
  1649. * @param amount defines the interpolation factor
  1650. * @returns a new Vector2
  1651. */
  1652. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  1653. /**
  1654. * 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".
  1655. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  1656. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  1657. * @param value defines the value to clamp
  1658. * @param min defines the lower limit
  1659. * @param max defines the upper limit
  1660. * @returns a new Vector2
  1661. */
  1662. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  1663. /**
  1664. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  1665. * @param value1 defines the 1st control point
  1666. * @param tangent1 defines the outgoing tangent
  1667. * @param value2 defines the 2nd control point
  1668. * @param tangent2 defines the incoming tangent
  1669. * @param amount defines the interpolation factor
  1670. * @returns a new Vector2
  1671. */
  1672. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  1673. /**
  1674. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  1675. * @param start defines the start vector
  1676. * @param end defines the end vector
  1677. * @param amount defines the interpolation factor
  1678. * @returns a new Vector2
  1679. */
  1680. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  1681. /**
  1682. * Gets the dot product of the vector "left" and the vector "right"
  1683. * @param left defines first vector
  1684. * @param right defines second vector
  1685. * @returns the dot product (float)
  1686. */
  1687. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  1688. /**
  1689. * Returns a new Vector2 equal to the normalized given vector
  1690. * @param vector defines the vector to normalize
  1691. * @returns a new Vector2
  1692. */
  1693. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  1694. /**
  1695. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  1696. * @param left defines 1st vector
  1697. * @param right defines 2nd vector
  1698. * @returns a new Vector2
  1699. */
  1700. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  1701. /**
  1702. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  1703. * @param left defines 1st vector
  1704. * @param right defines 2nd vector
  1705. * @returns a new Vector2
  1706. */
  1707. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  1708. /**
  1709. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  1710. * @param vector defines the vector to transform
  1711. * @param transformation defines the matrix to apply
  1712. * @returns a new Vector2
  1713. */
  1714. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  1715. /**
  1716. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  1717. * @param vector defines the vector to transform
  1718. * @param transformation defines the matrix to apply
  1719. * @param result defines the target vector
  1720. */
  1721. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  1722. /**
  1723. * Determines if a given vector is included in a triangle
  1724. * @param p defines the vector to test
  1725. * @param p0 defines 1st triangle point
  1726. * @param p1 defines 2nd triangle point
  1727. * @param p2 defines 3rd triangle point
  1728. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  1729. */
  1730. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  1731. /**
  1732. * Gets the distance between the vectors "value1" and "value2"
  1733. * @param value1 defines first vector
  1734. * @param value2 defines second vector
  1735. * @returns the distance between vectors
  1736. */
  1737. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  1738. /**
  1739. * Returns the squared distance between the vectors "value1" and "value2"
  1740. * @param value1 defines first vector
  1741. * @param value2 defines second vector
  1742. * @returns the squared distance between vectors
  1743. */
  1744. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  1745. /**
  1746. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  1747. * @param value1 defines first vector
  1748. * @param value2 defines second vector
  1749. * @returns a new Vector2
  1750. */
  1751. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  1752. /**
  1753. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  1754. * @param p defines the middle point
  1755. * @param segA defines one point of the segment
  1756. * @param segB defines the other point of the segment
  1757. * @returns the shortest distance
  1758. */
  1759. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  1760. }
  1761. /**
  1762. * Classed used to store (x,y,z) vector representation
  1763. * A Vector3 is the main object used in 3D geometry
  1764. * It can represent etiher the coordinates of a point the space, either a direction
  1765. * Reminder: js uses a left handed forward facing system
  1766. */
  1767. export class Vector3 {
  1768. /**
  1769. * Defines the first coordinates (on X axis)
  1770. */
  1771. x: number;
  1772. /**
  1773. * Defines the second coordinates (on Y axis)
  1774. */
  1775. y: number;
  1776. /**
  1777. * Defines the third coordinates (on Z axis)
  1778. */
  1779. z: number;
  1780. private static _UpReadOnly;
  1781. private static _ZeroReadOnly;
  1782. /**
  1783. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  1784. * @param x defines the first coordinates (on X axis)
  1785. * @param y defines the second coordinates (on Y axis)
  1786. * @param z defines the third coordinates (on Z axis)
  1787. */
  1788. constructor(
  1789. /**
  1790. * Defines the first coordinates (on X axis)
  1791. */
  1792. x?: number,
  1793. /**
  1794. * Defines the second coordinates (on Y axis)
  1795. */
  1796. y?: number,
  1797. /**
  1798. * Defines the third coordinates (on Z axis)
  1799. */
  1800. z?: number);
  1801. /**
  1802. * Creates a string representation of the Vector3
  1803. * @returns a string with the Vector3 coordinates.
  1804. */
  1805. toString(): string;
  1806. /**
  1807. * Gets the class name
  1808. * @returns the string "Vector3"
  1809. */
  1810. getClassName(): string;
  1811. /**
  1812. * Creates the Vector3 hash code
  1813. * @returns a number which tends to be unique between Vector3 instances
  1814. */
  1815. getHashCode(): number;
  1816. /**
  1817. * Creates an array containing three elements : the coordinates of the Vector3
  1818. * @returns a new array of numbers
  1819. */
  1820. asArray(): number[];
  1821. /**
  1822. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  1823. * @param array defines the destination array
  1824. * @param index defines the offset in the destination array
  1825. * @returns the current Vector3
  1826. */
  1827. toArray(array: FloatArray, index?: number): Vector3;
  1828. /**
  1829. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  1830. * @returns a new Quaternion object, computed from the Vector3 coordinates
  1831. */
  1832. toQuaternion(): Quaternion;
  1833. /**
  1834. * Adds the given vector to the current Vector3
  1835. * @param otherVector defines the second operand
  1836. * @returns the current updated Vector3
  1837. */
  1838. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  1839. /**
  1840. * Adds the given coordinates to the current Vector3
  1841. * @param x defines the x coordinate of the operand
  1842. * @param y defines the y coordinate of the operand
  1843. * @param z defines the z coordinate of the operand
  1844. * @returns the current updated Vector3
  1845. */
  1846. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  1847. /**
  1848. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  1849. * @param otherVector defines the second operand
  1850. * @returns the resulting Vector3
  1851. */
  1852. add(otherVector: DeepImmutable<Vector3>): Vector3;
  1853. /**
  1854. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  1855. * @param otherVector defines the second operand
  1856. * @param result defines the Vector3 object where to store the result
  1857. * @returns the current Vector3
  1858. */
  1859. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1860. /**
  1861. * Subtract the given vector from the current Vector3
  1862. * @param otherVector defines the second operand
  1863. * @returns the current updated Vector3
  1864. */
  1865. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  1866. /**
  1867. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  1868. * @param otherVector defines the second operand
  1869. * @returns the resulting Vector3
  1870. */
  1871. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  1872. /**
  1873. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  1874. * @param otherVector defines the second operand
  1875. * @param result defines the Vector3 object where to store the result
  1876. * @returns the current Vector3
  1877. */
  1878. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1879. /**
  1880. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  1881. * @param x defines the x coordinate of the operand
  1882. * @param y defines the y coordinate of the operand
  1883. * @param z defines the z coordinate of the operand
  1884. * @returns the resulting Vector3
  1885. */
  1886. subtractFromFloats(x: number, y: number, z: number): Vector3;
  1887. /**
  1888. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  1889. * @param x defines the x coordinate of the operand
  1890. * @param y defines the y coordinate of the operand
  1891. * @param z defines the z coordinate of the operand
  1892. * @param result defines the Vector3 object where to store the result
  1893. * @returns the current Vector3
  1894. */
  1895. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  1896. /**
  1897. * Gets a new Vector3 set with the current Vector3 negated coordinates
  1898. * @returns a new Vector3
  1899. */
  1900. negate(): Vector3;
  1901. /**
  1902. * Multiplies the Vector3 coordinates by the float "scale"
  1903. * @param scale defines the multiplier factor
  1904. * @returns the current updated Vector3
  1905. */
  1906. scaleInPlace(scale: number): Vector3;
  1907. /**
  1908. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  1909. * @param scale defines the multiplier factor
  1910. * @returns a new Vector3
  1911. */
  1912. scale(scale: number): Vector3;
  1913. /**
  1914. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  1915. * @param scale defines the multiplier factor
  1916. * @param result defines the Vector3 object where to store the result
  1917. * @returns the current Vector3
  1918. */
  1919. scaleToRef(scale: number, result: Vector3): Vector3;
  1920. /**
  1921. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  1922. * @param scale defines the scale factor
  1923. * @param result defines the Vector3 object where to store the result
  1924. * @returns the unmodified current Vector3
  1925. */
  1926. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  1927. /**
  1928. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  1929. * @param otherVector defines the second operand
  1930. * @returns true if both vectors are equals
  1931. */
  1932. equals(otherVector: DeepImmutable<Vector3>): boolean;
  1933. /**
  1934. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  1935. * @param otherVector defines the second operand
  1936. * @param epsilon defines the minimal distance to define values as equals
  1937. * @returns true if both vectors are distant less than epsilon
  1938. */
  1939. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  1940. /**
  1941. * Returns true if the current Vector3 coordinates equals the given floats
  1942. * @param x defines the x coordinate of the operand
  1943. * @param y defines the y coordinate of the operand
  1944. * @param z defines the z coordinate of the operand
  1945. * @returns true if both vectors are equals
  1946. */
  1947. equalsToFloats(x: number, y: number, z: number): boolean;
  1948. /**
  1949. * Multiplies the current Vector3 coordinates by the given ones
  1950. * @param otherVector defines the second operand
  1951. * @returns the current updated Vector3
  1952. */
  1953. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  1954. /**
  1955. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  1956. * @param otherVector defines the second operand
  1957. * @returns the new Vector3
  1958. */
  1959. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  1960. /**
  1961. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  1962. * @param otherVector defines the second operand
  1963. * @param result defines the Vector3 object where to store the result
  1964. * @returns the current Vector3
  1965. */
  1966. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1967. /**
  1968. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  1969. * @param x defines the x coordinate of the operand
  1970. * @param y defines the y coordinate of the operand
  1971. * @param z defines the z coordinate of the operand
  1972. * @returns the new Vector3
  1973. */
  1974. multiplyByFloats(x: number, y: number, z: number): Vector3;
  1975. /**
  1976. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  1977. * @param otherVector defines the second operand
  1978. * @returns the new Vector3
  1979. */
  1980. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  1981. /**
  1982. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  1983. * @param otherVector defines the second operand
  1984. * @param result defines the Vector3 object where to store the result
  1985. * @returns the current Vector3
  1986. */
  1987. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1988. /**
  1989. * Divides the current Vector3 coordinates by the given ones.
  1990. * @param otherVector defines the second operand
  1991. * @returns the current updated Vector3
  1992. */
  1993. divideInPlace(otherVector: Vector3): Vector3;
  1994. /**
  1995. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  1996. * @param other defines the second operand
  1997. * @returns the current updated Vector3
  1998. */
  1999. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  2000. /**
  2001. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  2002. * @param other defines the second operand
  2003. * @returns the current updated Vector3
  2004. */
  2005. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  2006. /**
  2007. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  2008. * @param x defines the x coordinate of the operand
  2009. * @param y defines the y coordinate of the operand
  2010. * @param z defines the z coordinate of the operand
  2011. * @returns the current updated Vector3
  2012. */
  2013. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2014. /**
  2015. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  2016. * @param x defines the x coordinate of the operand
  2017. * @param y defines the y coordinate of the operand
  2018. * @param z defines the z coordinate of the operand
  2019. * @returns the current updated Vector3
  2020. */
  2021. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2022. /**
  2023. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  2024. * Check if is non uniform within a certain amount of decimal places to account for this
  2025. * @param epsilon the amount the values can differ
  2026. * @returns if the the vector is non uniform to a certain number of decimal places
  2027. */
  2028. isNonUniformWithinEpsilon(epsilon: number): boolean;
  2029. /**
  2030. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  2031. */
  2032. readonly isNonUniform: boolean;
  2033. /**
  2034. * Gets a new Vector3 from current Vector3 floored values
  2035. * @returns a new Vector3
  2036. */
  2037. floor(): Vector3;
  2038. /**
  2039. * Gets a new Vector3 from current Vector3 floored values
  2040. * @returns a new Vector3
  2041. */
  2042. fract(): Vector3;
  2043. /**
  2044. * Gets the length of the Vector3
  2045. * @returns the length of the Vector3
  2046. */
  2047. length(): number;
  2048. /**
  2049. * Gets the squared length of the Vector3
  2050. * @returns squared length of the Vector3
  2051. */
  2052. lengthSquared(): number;
  2053. /**
  2054. * Normalize the current Vector3.
  2055. * Please note that this is an in place operation.
  2056. * @returns the current updated Vector3
  2057. */
  2058. normalize(): Vector3;
  2059. /**
  2060. * Reorders the x y z properties of the vector in place
  2061. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  2062. * @returns the current updated vector
  2063. */
  2064. reorderInPlace(order: string): this;
  2065. /**
  2066. * Rotates the vector around 0,0,0 by a quaternion
  2067. * @param quaternion the rotation quaternion
  2068. * @param result vector to store the result
  2069. * @returns the resulting vector
  2070. */
  2071. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  2072. /**
  2073. * Rotates a vector around a given point
  2074. * @param quaternion the rotation quaternion
  2075. * @param point the point to rotate around
  2076. * @param result vector to store the result
  2077. * @returns the resulting vector
  2078. */
  2079. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  2080. /**
  2081. * Normalize the current Vector3 with the given input length.
  2082. * Please note that this is an in place operation.
  2083. * @param len the length of the vector
  2084. * @returns the current updated Vector3
  2085. */
  2086. normalizeFromLength(len: number): Vector3;
  2087. /**
  2088. * Normalize the current Vector3 to a new vector
  2089. * @returns the new Vector3
  2090. */
  2091. normalizeToNew(): Vector3;
  2092. /**
  2093. * Normalize the current Vector3 to the reference
  2094. * @param reference define the Vector3 to update
  2095. * @returns the updated Vector3
  2096. */
  2097. normalizeToRef(reference: DeepImmutable<Vector3>): Vector3;
  2098. /**
  2099. * Creates a new Vector3 copied from the current Vector3
  2100. * @returns the new Vector3
  2101. */
  2102. clone(): Vector3;
  2103. /**
  2104. * Copies the given vector coordinates to the current Vector3 ones
  2105. * @param source defines the source Vector3
  2106. * @returns the current updated Vector3
  2107. */
  2108. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  2109. /**
  2110. * Copies the given floats to the current Vector3 coordinates
  2111. * @param x defines the x coordinate of the operand
  2112. * @param y defines the y coordinate of the operand
  2113. * @param z defines the z coordinate of the operand
  2114. * @returns the current updated Vector3
  2115. */
  2116. copyFromFloats(x: number, y: number, z: number): Vector3;
  2117. /**
  2118. * Copies the given floats to the current Vector3 coordinates
  2119. * @param x defines the x coordinate of the operand
  2120. * @param y defines the y coordinate of the operand
  2121. * @param z defines the z coordinate of the operand
  2122. * @returns the current updated Vector3
  2123. */
  2124. set(x: number, y: number, z: number): Vector3;
  2125. /**
  2126. * Copies the given float to the current Vector3 coordinates
  2127. * @param v defines the x, y and z coordinates of the operand
  2128. * @returns the current updated Vector3
  2129. */
  2130. setAll(v: number): Vector3;
  2131. /**
  2132. * Get the clip factor between two vectors
  2133. * @param vector0 defines the first operand
  2134. * @param vector1 defines the second operand
  2135. * @param axis defines the axis to use
  2136. * @param size defines the size along the axis
  2137. * @returns the clip factor
  2138. */
  2139. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  2140. /**
  2141. * Get angle between two vectors
  2142. * @param vector0 angle between vector0 and vector1
  2143. * @param vector1 angle between vector0 and vector1
  2144. * @param normal direction of the normal
  2145. * @return the angle between vector0 and vector1
  2146. */
  2147. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  2148. /**
  2149. * Returns a new Vector3 set from the index "offset" of the given array
  2150. * @param array defines the source array
  2151. * @param offset defines the offset in the source array
  2152. * @returns the new Vector3
  2153. */
  2154. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  2155. /**
  2156. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  2157. * This function is deprecated. Use FromArray instead
  2158. * @param array defines the source array
  2159. * @param offset defines the offset in the source array
  2160. * @returns the new Vector3
  2161. */
  2162. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  2163. /**
  2164. * Sets the given vector "result" with the element values from the index "offset" of the given array
  2165. * @param array defines the source array
  2166. * @param offset defines the offset in the source array
  2167. * @param result defines the Vector3 where to store the result
  2168. */
  2169. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  2170. /**
  2171. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  2172. * This function is deprecated. Use FromArrayToRef instead.
  2173. * @param array defines the source array
  2174. * @param offset defines the offset in the source array
  2175. * @param result defines the Vector3 where to store the result
  2176. */
  2177. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  2178. /**
  2179. * Sets the given vector "result" with the given floats.
  2180. * @param x defines the x coordinate of the source
  2181. * @param y defines the y coordinate of the source
  2182. * @param z defines the z coordinate of the source
  2183. * @param result defines the Vector3 where to store the result
  2184. */
  2185. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  2186. /**
  2187. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  2188. * @returns a new empty Vector3
  2189. */
  2190. static Zero(): Vector3;
  2191. /**
  2192. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  2193. * @returns a new unit Vector3
  2194. */
  2195. static One(): Vector3;
  2196. /**
  2197. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  2198. * @returns a new up Vector3
  2199. */
  2200. static Up(): Vector3;
  2201. /**
  2202. * Gets a up Vector3 that must not be updated
  2203. */
  2204. static readonly UpReadOnly: DeepImmutable<Vector3>;
  2205. /**
  2206. * Gets a zero Vector3 that must not be updated
  2207. */
  2208. static readonly ZeroReadOnly: DeepImmutable<Vector3>;
  2209. /**
  2210. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  2211. * @returns a new down Vector3
  2212. */
  2213. static Down(): Vector3;
  2214. /**
  2215. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  2216. * @returns a new forward Vector3
  2217. */
  2218. static Forward(): Vector3;
  2219. /**
  2220. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  2221. * @returns a new forward Vector3
  2222. */
  2223. static Backward(): Vector3;
  2224. /**
  2225. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  2226. * @returns a new right Vector3
  2227. */
  2228. static Right(): Vector3;
  2229. /**
  2230. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  2231. * @returns a new left Vector3
  2232. */
  2233. static Left(): Vector3;
  2234. /**
  2235. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  2236. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  2237. * @param vector defines the Vector3 to transform
  2238. * @param transformation defines the transformation matrix
  2239. * @returns the transformed Vector3
  2240. */
  2241. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  2242. /**
  2243. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  2244. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  2245. * @param vector defines the Vector3 to transform
  2246. * @param transformation defines the transformation matrix
  2247. * @param result defines the Vector3 where to store the result
  2248. */
  2249. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2250. /**
  2251. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  2252. * This method computes tranformed coordinates only, not transformed direction vectors
  2253. * @param x define the x coordinate of the source vector
  2254. * @param y define the y coordinate of the source vector
  2255. * @param z define the z coordinate of the source vector
  2256. * @param transformation defines the transformation matrix
  2257. * @param result defines the Vector3 where to store the result
  2258. */
  2259. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2260. /**
  2261. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  2262. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2263. * @param vector defines the Vector3 to transform
  2264. * @param transformation defines the transformation matrix
  2265. * @returns the new Vector3
  2266. */
  2267. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  2268. /**
  2269. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  2270. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2271. * @param vector defines the Vector3 to transform
  2272. * @param transformation defines the transformation matrix
  2273. * @param result defines the Vector3 where to store the result
  2274. */
  2275. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2276. /**
  2277. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  2278. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2279. * @param x define the x coordinate of the source vector
  2280. * @param y define the y coordinate of the source vector
  2281. * @param z define the z coordinate of the source vector
  2282. * @param transformation defines the transformation matrix
  2283. * @param result defines the Vector3 where to store the result
  2284. */
  2285. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2286. /**
  2287. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  2288. * @param value1 defines the first control point
  2289. * @param value2 defines the second control point
  2290. * @param value3 defines the third control point
  2291. * @param value4 defines the fourth control point
  2292. * @param amount defines the amount on the spline to use
  2293. * @returns the new Vector3
  2294. */
  2295. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  2296. /**
  2297. * 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"
  2298. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  2299. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  2300. * @param value defines the current value
  2301. * @param min defines the lower range value
  2302. * @param max defines the upper range value
  2303. * @returns the new Vector3
  2304. */
  2305. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  2306. /**
  2307. * 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"
  2308. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  2309. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  2310. * @param value defines the current value
  2311. * @param min defines the lower range value
  2312. * @param max defines the upper range value
  2313. * @param result defines the Vector3 where to store the result
  2314. */
  2315. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  2316. /**
  2317. * Checks if a given vector is inside a specific range
  2318. * @param v defines the vector to test
  2319. * @param min defines the minimum range
  2320. * @param max defines the maximum range
  2321. */
  2322. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  2323. /**
  2324. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  2325. * @param value1 defines the first control point
  2326. * @param tangent1 defines the first tangent vector
  2327. * @param value2 defines the second control point
  2328. * @param tangent2 defines the second tangent vector
  2329. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  2330. * @returns the new Vector3
  2331. */
  2332. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  2333. /**
  2334. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  2335. * @param start defines the start value
  2336. * @param end defines the end value
  2337. * @param amount max defines amount between both (between 0 and 1)
  2338. * @returns the new Vector3
  2339. */
  2340. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  2341. /**
  2342. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  2343. * @param start defines the start value
  2344. * @param end defines the end value
  2345. * @param amount max defines amount between both (between 0 and 1)
  2346. * @param result defines the Vector3 where to store the result
  2347. */
  2348. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  2349. /**
  2350. * Returns the dot product (float) between the vectors "left" and "right"
  2351. * @param left defines the left operand
  2352. * @param right defines the right operand
  2353. * @returns the dot product
  2354. */
  2355. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  2356. /**
  2357. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  2358. * The cross product is then orthogonal to both "left" and "right"
  2359. * @param left defines the left operand
  2360. * @param right defines the right operand
  2361. * @returns the cross product
  2362. */
  2363. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  2364. /**
  2365. * Sets the given vector "result" with the cross product of "left" and "right"
  2366. * The cross product is then orthogonal to both "left" and "right"
  2367. * @param left defines the left operand
  2368. * @param right defines the right operand
  2369. * @param result defines the Vector3 where to store the result
  2370. */
  2371. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  2372. /**
  2373. * Returns a new Vector3 as the normalization of the given vector
  2374. * @param vector defines the Vector3 to normalize
  2375. * @returns the new Vector3
  2376. */
  2377. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  2378. /**
  2379. * Sets the given vector "result" with the normalization of the given first vector
  2380. * @param vector defines the Vector3 to normalize
  2381. * @param result defines the Vector3 where to store the result
  2382. */
  2383. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  2384. /**
  2385. * Project a Vector3 onto screen space
  2386. * @param vector defines the Vector3 to project
  2387. * @param world defines the world matrix to use
  2388. * @param transform defines the transform (view x projection) matrix to use
  2389. * @param viewport defines the screen viewport to use
  2390. * @returns the new Vector3
  2391. */
  2392. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  2393. /** @hidden */
  2394. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  2395. /**
  2396. * Unproject from screen space to object space
  2397. * @param source defines the screen space Vector3 to use
  2398. * @param viewportWidth defines the current width of the viewport
  2399. * @param viewportHeight defines the current height of the viewport
  2400. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2401. * @param transform defines the transform (view x projection) matrix to use
  2402. * @returns the new Vector3
  2403. */
  2404. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  2405. /**
  2406. * Unproject from screen space to object space
  2407. * @param source defines the screen space Vector3 to use
  2408. * @param viewportWidth defines the current width of the viewport
  2409. * @param viewportHeight defines the current height of the viewport
  2410. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2411. * @param view defines the view matrix to use
  2412. * @param projection defines the projection matrix to use
  2413. * @returns the new Vector3
  2414. */
  2415. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  2416. /**
  2417. * Unproject from screen space to object space
  2418. * @param source defines the screen space Vector3 to use
  2419. * @param viewportWidth defines the current width of the viewport
  2420. * @param viewportHeight defines the current height of the viewport
  2421. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2422. * @param view defines the view matrix to use
  2423. * @param projection defines the projection matrix to use
  2424. * @param result defines the Vector3 where to store the result
  2425. */
  2426. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  2427. /**
  2428. * Unproject from screen space to object space
  2429. * @param sourceX defines the screen space x coordinate to use
  2430. * @param sourceY defines the screen space y coordinate to use
  2431. * @param sourceZ defines the screen space z coordinate to use
  2432. * @param viewportWidth defines the current width of the viewport
  2433. * @param viewportHeight defines the current height of the viewport
  2434. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2435. * @param view defines the view matrix to use
  2436. * @param projection defines the projection matrix to use
  2437. * @param result defines the Vector3 where to store the result
  2438. */
  2439. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  2440. /**
  2441. * Gets the minimal coordinate values between two Vector3
  2442. * @param left defines the first operand
  2443. * @param right defines the second operand
  2444. * @returns the new Vector3
  2445. */
  2446. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  2447. /**
  2448. * Gets the maximal coordinate values between two Vector3
  2449. * @param left defines the first operand
  2450. * @param right defines the second operand
  2451. * @returns the new Vector3
  2452. */
  2453. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  2454. /**
  2455. * Returns the distance between the vectors "value1" and "value2"
  2456. * @param value1 defines the first operand
  2457. * @param value2 defines the second operand
  2458. * @returns the distance
  2459. */
  2460. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  2461. /**
  2462. * Returns the squared distance between the vectors "value1" and "value2"
  2463. * @param value1 defines the first operand
  2464. * @param value2 defines the second operand
  2465. * @returns the squared distance
  2466. */
  2467. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  2468. /**
  2469. * Returns a new Vector3 located at the center between "value1" and "value2"
  2470. * @param value1 defines the first operand
  2471. * @param value2 defines the second operand
  2472. * @returns the new Vector3
  2473. */
  2474. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  2475. /**
  2476. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  2477. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  2478. * to something in order to rotate it from its local system to the given target system
  2479. * Note: axis1, axis2 and axis3 are normalized during this operation
  2480. * @param axis1 defines the first axis
  2481. * @param axis2 defines the second axis
  2482. * @param axis3 defines the third axis
  2483. * @returns a new Vector3
  2484. */
  2485. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  2486. /**
  2487. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  2488. * @param axis1 defines the first axis
  2489. * @param axis2 defines the second axis
  2490. * @param axis3 defines the third axis
  2491. * @param ref defines the Vector3 where to store the result
  2492. */
  2493. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  2494. }
  2495. /**
  2496. * Vector4 class created for EulerAngle class conversion to Quaternion
  2497. */
  2498. export class Vector4 {
  2499. /** x value of the vector */
  2500. x: number;
  2501. /** y value of the vector */
  2502. y: number;
  2503. /** z value of the vector */
  2504. z: number;
  2505. /** w value of the vector */
  2506. w: number;
  2507. /**
  2508. * Creates a Vector4 object from the given floats.
  2509. * @param x x value of the vector
  2510. * @param y y value of the vector
  2511. * @param z z value of the vector
  2512. * @param w w value of the vector
  2513. */
  2514. constructor(
  2515. /** x value of the vector */
  2516. x: number,
  2517. /** y value of the vector */
  2518. y: number,
  2519. /** z value of the vector */
  2520. z: number,
  2521. /** w value of the vector */
  2522. w: number);
  2523. /**
  2524. * Returns the string with the Vector4 coordinates.
  2525. * @returns a string containing all the vector values
  2526. */
  2527. toString(): string;
  2528. /**
  2529. * Returns the string "Vector4".
  2530. * @returns "Vector4"
  2531. */
  2532. getClassName(): string;
  2533. /**
  2534. * Returns the Vector4 hash code.
  2535. * @returns a unique hash code
  2536. */
  2537. getHashCode(): number;
  2538. /**
  2539. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  2540. * @returns the resulting array
  2541. */
  2542. asArray(): number[];
  2543. /**
  2544. * Populates the given array from the given index with the Vector4 coordinates.
  2545. * @param array array to populate
  2546. * @param index index of the array to start at (default: 0)
  2547. * @returns the Vector4.
  2548. */
  2549. toArray(array: FloatArray, index?: number): Vector4;
  2550. /**
  2551. * Adds the given vector to the current Vector4.
  2552. * @param otherVector the vector to add
  2553. * @returns the updated Vector4.
  2554. */
  2555. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  2556. /**
  2557. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  2558. * @param otherVector the vector to add
  2559. * @returns the resulting vector
  2560. */
  2561. add(otherVector: DeepImmutable<Vector4>): Vector4;
  2562. /**
  2563. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  2564. * @param otherVector the vector to add
  2565. * @param result the vector to store the result
  2566. * @returns the current Vector4.
  2567. */
  2568. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  2569. /**
  2570. * Subtract in place the given vector from the current Vector4.
  2571. * @param otherVector the vector to subtract
  2572. * @returns the updated Vector4.
  2573. */
  2574. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  2575. /**
  2576. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  2577. * @param otherVector the vector to add
  2578. * @returns the new vector with the result
  2579. */
  2580. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  2581. /**
  2582. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  2583. * @param otherVector the vector to subtract
  2584. * @param result the vector to store the result
  2585. * @returns the current Vector4.
  2586. */
  2587. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  2588. /**
  2589. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  2590. */
  2591. /**
  2592. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  2593. * @param x value to subtract
  2594. * @param y value to subtract
  2595. * @param z value to subtract
  2596. * @param w value to subtract
  2597. * @returns new vector containing the result
  2598. */
  2599. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  2600. /**
  2601. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  2602. * @param x value to subtract
  2603. * @param y value to subtract
  2604. * @param z value to subtract
  2605. * @param w value to subtract
  2606. * @param result the vector to store the result in
  2607. * @returns the current Vector4.
  2608. */
  2609. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  2610. /**
  2611. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  2612. * @returns a new vector with the negated values
  2613. */
  2614. negate(): Vector4;
  2615. /**
  2616. * Multiplies the current Vector4 coordinates by scale (float).
  2617. * @param scale the number to scale with
  2618. * @returns the updated Vector4.
  2619. */
  2620. scaleInPlace(scale: number): Vector4;
  2621. /**
  2622. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  2623. * @param scale the number to scale with
  2624. * @returns a new vector with the result
  2625. */
  2626. scale(scale: number): Vector4;
  2627. /**
  2628. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  2629. * @param scale the number to scale with
  2630. * @param result a vector to store the result in
  2631. * @returns the current Vector4.
  2632. */
  2633. scaleToRef(scale: number, result: Vector4): Vector4;
  2634. /**
  2635. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  2636. * @param scale defines the scale factor
  2637. * @param result defines the Vector4 object where to store the result
  2638. * @returns the unmodified current Vector4
  2639. */
  2640. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  2641. /**
  2642. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  2643. * @param otherVector the vector to compare against
  2644. * @returns true if they are equal
  2645. */
  2646. equals(otherVector: DeepImmutable<Vector4>): boolean;
  2647. /**
  2648. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  2649. * @param otherVector vector to compare against
  2650. * @param epsilon (Default: very small number)
  2651. * @returns true if they are equal
  2652. */
  2653. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  2654. /**
  2655. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  2656. * @param x x value to compare against
  2657. * @param y y value to compare against
  2658. * @param z z value to compare against
  2659. * @param w w value to compare against
  2660. * @returns true if equal
  2661. */
  2662. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  2663. /**
  2664. * Multiplies in place the current Vector4 by the given one.
  2665. * @param otherVector vector to multiple with
  2666. * @returns the updated Vector4.
  2667. */
  2668. multiplyInPlace(otherVector: Vector4): Vector4;
  2669. /**
  2670. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  2671. * @param otherVector vector to multiple with
  2672. * @returns resulting new vector
  2673. */
  2674. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  2675. /**
  2676. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  2677. * @param otherVector vector to multiple with
  2678. * @param result vector to store the result
  2679. * @returns the current Vector4.
  2680. */
  2681. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  2682. /**
  2683. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  2684. * @param x x value multiply with
  2685. * @param y y value multiply with
  2686. * @param z z value multiply with
  2687. * @param w w value multiply with
  2688. * @returns resulting new vector
  2689. */
  2690. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  2691. /**
  2692. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  2693. * @param otherVector vector to devide with
  2694. * @returns resulting new vector
  2695. */
  2696. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  2697. /**
  2698. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  2699. * @param otherVector vector to devide with
  2700. * @param result vector to store the result
  2701. * @returns the current Vector4.
  2702. */
  2703. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  2704. /**
  2705. * Divides the current Vector3 coordinates by the given ones.
  2706. * @param otherVector vector to devide with
  2707. * @returns the updated Vector3.
  2708. */
  2709. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  2710. /**
  2711. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  2712. * @param other defines the second operand
  2713. * @returns the current updated Vector4
  2714. */
  2715. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  2716. /**
  2717. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  2718. * @param other defines the second operand
  2719. * @returns the current updated Vector4
  2720. */
  2721. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  2722. /**
  2723. * Gets a new Vector4 from current Vector4 floored values
  2724. * @returns a new Vector4
  2725. */
  2726. floor(): Vector4;
  2727. /**
  2728. * Gets a new Vector4 from current Vector3 floored values
  2729. * @returns a new Vector4
  2730. */
  2731. fract(): Vector4;
  2732. /**
  2733. * Returns the Vector4 length (float).
  2734. * @returns the length
  2735. */
  2736. length(): number;
  2737. /**
  2738. * Returns the Vector4 squared length (float).
  2739. * @returns the length squared
  2740. */
  2741. lengthSquared(): number;
  2742. /**
  2743. * Normalizes in place the Vector4.
  2744. * @returns the updated Vector4.
  2745. */
  2746. normalize(): Vector4;
  2747. /**
  2748. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  2749. * @returns this converted to a new vector3
  2750. */
  2751. toVector3(): Vector3;
  2752. /**
  2753. * Returns a new Vector4 copied from the current one.
  2754. * @returns the new cloned vector
  2755. */
  2756. clone(): Vector4;
  2757. /**
  2758. * Updates the current Vector4 with the given one coordinates.
  2759. * @param source the source vector to copy from
  2760. * @returns the updated Vector4.
  2761. */
  2762. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  2763. /**
  2764. * Updates the current Vector4 coordinates with the given floats.
  2765. * @param x float to copy from
  2766. * @param y float to copy from
  2767. * @param z float to copy from
  2768. * @param w float to copy from
  2769. * @returns the updated Vector4.
  2770. */
  2771. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  2772. /**
  2773. * Updates the current Vector4 coordinates with the given floats.
  2774. * @param x float to set from
  2775. * @param y float to set from
  2776. * @param z float to set from
  2777. * @param w float to set from
  2778. * @returns the updated Vector4.
  2779. */
  2780. set(x: number, y: number, z: number, w: number): Vector4;
  2781. /**
  2782. * Copies the given float to the current Vector3 coordinates
  2783. * @param v defines the x, y, z and w coordinates of the operand
  2784. * @returns the current updated Vector3
  2785. */
  2786. setAll(v: number): Vector4;
  2787. /**
  2788. * Returns a new Vector4 set from the starting index of the given array.
  2789. * @param array the array to pull values from
  2790. * @param offset the offset into the array to start at
  2791. * @returns the new vector
  2792. */
  2793. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  2794. /**
  2795. * Updates the given vector "result" from the starting index of the given array.
  2796. * @param array the array to pull values from
  2797. * @param offset the offset into the array to start at
  2798. * @param result the vector to store the result in
  2799. */
  2800. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  2801. /**
  2802. * Updates the given vector "result" from the starting index of the given Float32Array.
  2803. * @param array the array to pull values from
  2804. * @param offset the offset into the array to start at
  2805. * @param result the vector to store the result in
  2806. */
  2807. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  2808. /**
  2809. * Updates the given vector "result" coordinates from the given floats.
  2810. * @param x float to set from
  2811. * @param y float to set from
  2812. * @param z float to set from
  2813. * @param w float to set from
  2814. * @param result the vector to the floats in
  2815. */
  2816. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  2817. /**
  2818. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  2819. * @returns the new vector
  2820. */
  2821. static Zero(): Vector4;
  2822. /**
  2823. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  2824. * @returns the new vector
  2825. */
  2826. static One(): Vector4;
  2827. /**
  2828. * Returns a new normalized Vector4 from the given one.
  2829. * @param vector the vector to normalize
  2830. * @returns the vector
  2831. */
  2832. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  2833. /**
  2834. * Updates the given vector "result" from the normalization of the given one.
  2835. * @param vector the vector to normalize
  2836. * @param result the vector to store the result in
  2837. */
  2838. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  2839. /**
  2840. * Returns a vector with the minimum values from the left and right vectors
  2841. * @param left left vector to minimize
  2842. * @param right right vector to minimize
  2843. * @returns a new vector with the minimum of the left and right vector values
  2844. */
  2845. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  2846. /**
  2847. * Returns a vector with the maximum values from the left and right vectors
  2848. * @param left left vector to maximize
  2849. * @param right right vector to maximize
  2850. * @returns a new vector with the maximum of the left and right vector values
  2851. */
  2852. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  2853. /**
  2854. * Returns the distance (float) between the vectors "value1" and "value2".
  2855. * @param value1 value to calulate the distance between
  2856. * @param value2 value to calulate the distance between
  2857. * @return the distance between the two vectors
  2858. */
  2859. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  2860. /**
  2861. * Returns the squared distance (float) between the vectors "value1" and "value2".
  2862. * @param value1 value to calulate the distance between
  2863. * @param value2 value to calulate the distance between
  2864. * @return the distance between the two vectors squared
  2865. */
  2866. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  2867. /**
  2868. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  2869. * @param value1 value to calulate the center between
  2870. * @param value2 value to calulate the center between
  2871. * @return the center between the two vectors
  2872. */
  2873. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  2874. /**
  2875. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  2876. * This methods computes transformed normalized direction vectors only.
  2877. * @param vector the vector to transform
  2878. * @param transformation the transformation matrix to apply
  2879. * @returns the new vector
  2880. */
  2881. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  2882. /**
  2883. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  2884. * This methods computes transformed normalized direction vectors only.
  2885. * @param vector the vector to transform
  2886. * @param transformation the transformation matrix to apply
  2887. * @param result the vector to store the result in
  2888. */
  2889. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  2890. /**
  2891. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  2892. * This methods computes transformed normalized direction vectors only.
  2893. * @param x value to transform
  2894. * @param y value to transform
  2895. * @param z value to transform
  2896. * @param w value to transform
  2897. * @param transformation the transformation matrix to apply
  2898. * @param result the vector to store the results in
  2899. */
  2900. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  2901. /**
  2902. * Creates a new Vector4 from a Vector3
  2903. * @param source defines the source data
  2904. * @param w defines the 4th component (default is 0)
  2905. * @returns a new Vector4
  2906. */
  2907. static FromVector3(source: Vector3, w?: number): Vector4;
  2908. }
  2909. /**
  2910. * Class used to store quaternion data
  2911. * @see https://en.wikipedia.org/wiki/Quaternion
  2912. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  2913. */
  2914. export class Quaternion {
  2915. /** defines the first component (0 by default) */
  2916. x: number;
  2917. /** defines the second component (0 by default) */
  2918. y: number;
  2919. /** defines the third component (0 by default) */
  2920. z: number;
  2921. /** defines the fourth component (1.0 by default) */
  2922. w: number;
  2923. /**
  2924. * Creates a new Quaternion from the given floats
  2925. * @param x defines the first component (0 by default)
  2926. * @param y defines the second component (0 by default)
  2927. * @param z defines the third component (0 by default)
  2928. * @param w defines the fourth component (1.0 by default)
  2929. */
  2930. constructor(
  2931. /** defines the first component (0 by default) */
  2932. x?: number,
  2933. /** defines the second component (0 by default) */
  2934. y?: number,
  2935. /** defines the third component (0 by default) */
  2936. z?: number,
  2937. /** defines the fourth component (1.0 by default) */
  2938. w?: number);
  2939. /**
  2940. * Gets a string representation for the current quaternion
  2941. * @returns a string with the Quaternion coordinates
  2942. */
  2943. toString(): string;
  2944. /**
  2945. * Gets the class name of the quaternion
  2946. * @returns the string "Quaternion"
  2947. */
  2948. getClassName(): string;
  2949. /**
  2950. * Gets a hash code for this quaternion
  2951. * @returns the quaternion hash code
  2952. */
  2953. getHashCode(): number;
  2954. /**
  2955. * Copy the quaternion to an array
  2956. * @returns a new array populated with 4 elements from the quaternion coordinates
  2957. */
  2958. asArray(): number[];
  2959. /**
  2960. * Check if two quaternions are equals
  2961. * @param otherQuaternion defines the second operand
  2962. * @return true if the current quaternion and the given one coordinates are strictly equals
  2963. */
  2964. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  2965. /**
  2966. * Clone the current quaternion
  2967. * @returns a new quaternion copied from the current one
  2968. */
  2969. clone(): Quaternion;
  2970. /**
  2971. * Copy a quaternion to the current one
  2972. * @param other defines the other quaternion
  2973. * @returns the updated current quaternion
  2974. */
  2975. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  2976. /**
  2977. * Updates the current quaternion with the given float coordinates
  2978. * @param x defines the x coordinate
  2979. * @param y defines the y coordinate
  2980. * @param z defines the z coordinate
  2981. * @param w defines the w coordinate
  2982. * @returns the updated current quaternion
  2983. */
  2984. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  2985. /**
  2986. * Updates the current quaternion from the given float coordinates
  2987. * @param x defines the x coordinate
  2988. * @param y defines the y coordinate
  2989. * @param z defines the z coordinate
  2990. * @param w defines the w coordinate
  2991. * @returns the updated current quaternion
  2992. */
  2993. set(x: number, y: number, z: number, w: number): Quaternion;
  2994. /**
  2995. * Adds two quaternions
  2996. * @param other defines the second operand
  2997. * @returns a new quaternion as the addition result of the given one and the current quaternion
  2998. */
  2999. add(other: DeepImmutable<Quaternion>): Quaternion;
  3000. /**
  3001. * Add a quaternion to the current one
  3002. * @param other defines the quaternion to add
  3003. * @returns the current quaternion
  3004. */
  3005. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  3006. /**
  3007. * Subtract two quaternions
  3008. * @param other defines the second operand
  3009. * @returns a new quaternion as the subtraction result of the given one from the current one
  3010. */
  3011. subtract(other: Quaternion): Quaternion;
  3012. /**
  3013. * Multiplies the current quaternion by a scale factor
  3014. * @param value defines the scale factor
  3015. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  3016. */
  3017. scale(value: number): Quaternion;
  3018. /**
  3019. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  3020. * @param scale defines the scale factor
  3021. * @param result defines the Quaternion object where to store the result
  3022. * @returns the unmodified current quaternion
  3023. */
  3024. scaleToRef(scale: number, result: Quaternion): Quaternion;
  3025. /**
  3026. * Multiplies in place the current quaternion by a scale factor
  3027. * @param value defines the scale factor
  3028. * @returns the current modified quaternion
  3029. */
  3030. scaleInPlace(value: number): Quaternion;
  3031. /**
  3032. * Scale the current quaternion values by a factor and add the result to a given quaternion
  3033. * @param scale defines the scale factor
  3034. * @param result defines the Quaternion object where to store the result
  3035. * @returns the unmodified current quaternion
  3036. */
  3037. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  3038. /**
  3039. * Multiplies two quaternions
  3040. * @param q1 defines the second operand
  3041. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  3042. */
  3043. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  3044. /**
  3045. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  3046. * @param q1 defines the second operand
  3047. * @param result defines the target quaternion
  3048. * @returns the current quaternion
  3049. */
  3050. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  3051. /**
  3052. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  3053. * @param q1 defines the second operand
  3054. * @returns the currentupdated quaternion
  3055. */
  3056. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  3057. /**
  3058. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  3059. * @param ref defines the target quaternion
  3060. * @returns the current quaternion
  3061. */
  3062. conjugateToRef(ref: Quaternion): Quaternion;
  3063. /**
  3064. * Conjugates in place (1-q) the current quaternion
  3065. * @returns the current updated quaternion
  3066. */
  3067. conjugateInPlace(): Quaternion;
  3068. /**
  3069. * Conjugates in place (1-q) the current quaternion
  3070. * @returns a new quaternion
  3071. */
  3072. conjugate(): Quaternion;
  3073. /**
  3074. * Gets length of current quaternion
  3075. * @returns the quaternion length (float)
  3076. */
  3077. length(): number;
  3078. /**
  3079. * Normalize in place the current quaternion
  3080. * @returns the current updated quaternion
  3081. */
  3082. normalize(): Quaternion;
  3083. /**
  3084. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  3085. * @param order is a reserved parameter and is ignore for now
  3086. * @returns a new Vector3 containing the Euler angles
  3087. */
  3088. toEulerAngles(order?: string): Vector3;
  3089. /**
  3090. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  3091. * @param result defines the vector which will be filled with the Euler angles
  3092. * @param order is a reserved parameter and is ignore for now
  3093. * @returns the current unchanged quaternion
  3094. */
  3095. toEulerAnglesToRef(result: Vector3): Quaternion;
  3096. /**
  3097. * Updates the given rotation matrix with the current quaternion values
  3098. * @param result defines the target matrix
  3099. * @returns the current unchanged quaternion
  3100. */
  3101. toRotationMatrix(result: Matrix): Quaternion;
  3102. /**
  3103. * Updates the current quaternion from the given rotation matrix values
  3104. * @param matrix defines the source matrix
  3105. * @returns the current updated quaternion
  3106. */
  3107. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  3108. /**
  3109. * Creates a new quaternion from a rotation matrix
  3110. * @param matrix defines the source matrix
  3111. * @returns a new quaternion created from the given rotation matrix values
  3112. */
  3113. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  3114. /**
  3115. * Updates the given quaternion with the given rotation matrix values
  3116. * @param matrix defines the source matrix
  3117. * @param result defines the target quaternion
  3118. */
  3119. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  3120. /**
  3121. * Returns the dot product (float) between the quaternions "left" and "right"
  3122. * @param left defines the left operand
  3123. * @param right defines the right operand
  3124. * @returns the dot product
  3125. */
  3126. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  3127. /**
  3128. * Checks if the two quaternions are close to each other
  3129. * @param quat0 defines the first quaternion to check
  3130. * @param quat1 defines the second quaternion to check
  3131. * @returns true if the two quaternions are close to each other
  3132. */
  3133. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  3134. /**
  3135. * Creates an empty quaternion
  3136. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  3137. */
  3138. static Zero(): Quaternion;
  3139. /**
  3140. * Inverse a given quaternion
  3141. * @param q defines the source quaternion
  3142. * @returns a new quaternion as the inverted current quaternion
  3143. */
  3144. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  3145. /**
  3146. * Inverse a given quaternion
  3147. * @param q defines the source quaternion
  3148. * @param result the quaternion the result will be stored in
  3149. * @returns the result quaternion
  3150. */
  3151. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  3152. /**
  3153. * Creates an identity quaternion
  3154. * @returns the identity quaternion
  3155. */
  3156. static Identity(): Quaternion;
  3157. /**
  3158. * Gets a boolean indicating if the given quaternion is identity
  3159. * @param quaternion defines the quaternion to check
  3160. * @returns true if the quaternion is identity
  3161. */
  3162. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  3163. /**
  3164. * Creates a quaternion from a rotation around an axis
  3165. * @param axis defines the axis to use
  3166. * @param angle defines the angle to use
  3167. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  3168. */
  3169. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  3170. /**
  3171. * Creates a rotation around an axis and stores it into the given quaternion
  3172. * @param axis defines the axis to use
  3173. * @param angle defines the angle to use
  3174. * @param result defines the target quaternion
  3175. * @returns the target quaternion
  3176. */
  3177. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  3178. /**
  3179. * Creates a new quaternion from data stored into an array
  3180. * @param array defines the data source
  3181. * @param offset defines the offset in the source array where the data starts
  3182. * @returns a new quaternion
  3183. */
  3184. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  3185. /**
  3186. * Create a quaternion from Euler rotation angles
  3187. * @param x Pitch
  3188. * @param y Yaw
  3189. * @param z Roll
  3190. * @returns the new Quaternion
  3191. */
  3192. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  3193. /**
  3194. * Updates a quaternion from Euler rotation angles
  3195. * @param x Pitch
  3196. * @param y Yaw
  3197. * @param z Roll
  3198. * @param result the quaternion to store the result
  3199. * @returns the updated quaternion
  3200. */
  3201. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  3202. /**
  3203. * Create a quaternion from Euler rotation vector
  3204. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  3205. * @returns the new Quaternion
  3206. */
  3207. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  3208. /**
  3209. * Updates a quaternion from Euler rotation vector
  3210. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  3211. * @param result the quaternion to store the result
  3212. * @returns the updated quaternion
  3213. */
  3214. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  3215. /**
  3216. * Creates a new quaternion from the given Euler float angles (y, x, z)
  3217. * @param yaw defines the rotation around Y axis
  3218. * @param pitch defines the rotation around X axis
  3219. * @param roll defines the rotation around Z axis
  3220. * @returns the new quaternion
  3221. */
  3222. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  3223. /**
  3224. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  3225. * @param yaw defines the rotation around Y axis
  3226. * @param pitch defines the rotation around X axis
  3227. * @param roll defines the rotation around Z axis
  3228. * @param result defines the target quaternion
  3229. */
  3230. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  3231. /**
  3232. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  3233. * @param alpha defines the rotation around first axis
  3234. * @param beta defines the rotation around second axis
  3235. * @param gamma defines the rotation around third axis
  3236. * @returns the new quaternion
  3237. */
  3238. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  3239. /**
  3240. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  3241. * @param alpha defines the rotation around first axis
  3242. * @param beta defines the rotation around second axis
  3243. * @param gamma defines the rotation around third axis
  3244. * @param result defines the target quaternion
  3245. */
  3246. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  3247. /**
  3248. * 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)
  3249. * @param axis1 defines the first axis
  3250. * @param axis2 defines the second axis
  3251. * @param axis3 defines the third axis
  3252. * @returns the new quaternion
  3253. */
  3254. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  3255. /**
  3256. * 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
  3257. * @param axis1 defines the first axis
  3258. * @param axis2 defines the second axis
  3259. * @param axis3 defines the third axis
  3260. * @param ref defines the target quaternion
  3261. */
  3262. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  3263. /**
  3264. * Interpolates between two quaternions
  3265. * @param left defines first quaternion
  3266. * @param right defines second quaternion
  3267. * @param amount defines the gradient to use
  3268. * @returns the new interpolated quaternion
  3269. */
  3270. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  3271. /**
  3272. * Interpolates between two quaternions and stores it into a target quaternion
  3273. * @param left defines first quaternion
  3274. * @param right defines second quaternion
  3275. * @param amount defines the gradient to use
  3276. * @param result defines the target quaternion
  3277. */
  3278. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  3279. /**
  3280. * Interpolate between two quaternions using Hermite interpolation
  3281. * @param value1 defines first quaternion
  3282. * @param tangent1 defines the incoming tangent
  3283. * @param value2 defines second quaternion
  3284. * @param tangent2 defines the outgoing tangent
  3285. * @param amount defines the target quaternion
  3286. * @returns the new interpolated quaternion
  3287. */
  3288. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  3289. }
  3290. /**
  3291. * Class used to store matrix data (4x4)
  3292. */
  3293. export class Matrix {
  3294. private static _updateFlagSeed;
  3295. private static _identityReadOnly;
  3296. private _isIdentity;
  3297. private _isIdentityDirty;
  3298. private _isIdentity3x2;
  3299. private _isIdentity3x2Dirty;
  3300. /**
  3301. * Gets the update flag of the matrix which is an unique number for the matrix.
  3302. * It will be incremented every time the matrix data change.
  3303. * You can use it to speed the comparison between two versions of the same matrix.
  3304. */
  3305. updateFlag: number;
  3306. private readonly _m;
  3307. /**
  3308. * Gets the internal data of the matrix
  3309. */
  3310. readonly m: DeepImmutable<Float32Array>;
  3311. /** @hidden */
  3312. _markAsUpdated(): void;
  3313. /** @hidden */
  3314. private _updateIdentityStatus;
  3315. /**
  3316. * Creates an empty matrix (filled with zeros)
  3317. */
  3318. constructor();
  3319. /**
  3320. * Check if the current matrix is identity
  3321. * @returns true is the matrix is the identity matrix
  3322. */
  3323. isIdentity(): boolean;
  3324. /**
  3325. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  3326. * @returns true is the matrix is the identity matrix
  3327. */
  3328. isIdentityAs3x2(): boolean;
  3329. /**
  3330. * Gets the determinant of the matrix
  3331. * @returns the matrix determinant
  3332. */
  3333. determinant(): number;
  3334. /**
  3335. * Returns the matrix as a Float32Array
  3336. * @returns the matrix underlying array
  3337. */
  3338. toArray(): DeepImmutable<Float32Array>;
  3339. /**
  3340. * Returns the matrix as a Float32Array
  3341. * @returns the matrix underlying array.
  3342. */
  3343. asArray(): DeepImmutable<Float32Array>;
  3344. /**
  3345. * Inverts the current matrix in place
  3346. * @returns the current inverted matrix
  3347. */
  3348. invert(): Matrix;
  3349. /**
  3350. * Sets all the matrix elements to zero
  3351. * @returns the current matrix
  3352. */
  3353. reset(): Matrix;
  3354. /**
  3355. * Adds the current matrix with a second one
  3356. * @param other defines the matrix to add
  3357. * @returns a new matrix as the addition of the current matrix and the given one
  3358. */
  3359. add(other: DeepImmutable<Matrix>): Matrix;
  3360. /**
  3361. * Sets the given matrix "result" to the addition of the current matrix and the given one
  3362. * @param other defines the matrix to add
  3363. * @param result defines the target matrix
  3364. * @returns the current matrix
  3365. */
  3366. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  3367. /**
  3368. * Adds in place the given matrix to the current matrix
  3369. * @param other defines the second operand
  3370. * @returns the current updated matrix
  3371. */
  3372. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  3373. /**
  3374. * Sets the given matrix to the current inverted Matrix
  3375. * @param other defines the target matrix
  3376. * @returns the unmodified current matrix
  3377. */
  3378. invertToRef(other: Matrix): Matrix;
  3379. /**
  3380. * add a value at the specified position in the current Matrix
  3381. * @param index the index of the value within the matrix. between 0 and 15.
  3382. * @param value the value to be added
  3383. * @returns the current updated matrix
  3384. */
  3385. addAtIndex(index: number, value: number): Matrix;
  3386. /**
  3387. * mutiply the specified position in the current Matrix by a value
  3388. * @param index the index of the value within the matrix. between 0 and 15.
  3389. * @param value the value to be added
  3390. * @returns the current updated matrix
  3391. */
  3392. multiplyAtIndex(index: number, value: number): Matrix;
  3393. /**
  3394. * Inserts the translation vector (using 3 floats) in the current matrix
  3395. * @param x defines the 1st component of the translation
  3396. * @param y defines the 2nd component of the translation
  3397. * @param z defines the 3rd component of the translation
  3398. * @returns the current updated matrix
  3399. */
  3400. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  3401. /**
  3402. * Adds the translation vector (using 3 floats) in the current matrix
  3403. * @param x defines the 1st component of the translation
  3404. * @param y defines the 2nd component of the translation
  3405. * @param z defines the 3rd component of the translation
  3406. * @returns the current updated matrix
  3407. */
  3408. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  3409. /**
  3410. * Inserts the translation vector in the current matrix
  3411. * @param vector3 defines the translation to insert
  3412. * @returns the current updated matrix
  3413. */
  3414. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  3415. /**
  3416. * Gets the translation value of the current matrix
  3417. * @returns a new Vector3 as the extracted translation from the matrix
  3418. */
  3419. getTranslation(): Vector3;
  3420. /**
  3421. * Fill a Vector3 with the extracted translation from the matrix
  3422. * @param result defines the Vector3 where to store the translation
  3423. * @returns the current matrix
  3424. */
  3425. getTranslationToRef(result: Vector3): Matrix;
  3426. /**
  3427. * Remove rotation and scaling part from the matrix
  3428. * @returns the updated matrix
  3429. */
  3430. removeRotationAndScaling(): Matrix;
  3431. /**
  3432. * Multiply two matrices
  3433. * @param other defines the second operand
  3434. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  3435. */
  3436. multiply(other: DeepImmutable<Matrix>): Matrix;
  3437. /**
  3438. * Copy the current matrix from the given one
  3439. * @param other defines the source matrix
  3440. * @returns the current updated matrix
  3441. */
  3442. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  3443. /**
  3444. * Populates the given array from the starting index with the current matrix values
  3445. * @param array defines the target array
  3446. * @param offset defines the offset in the target array where to start storing values
  3447. * @returns the current matrix
  3448. */
  3449. copyToArray(array: Float32Array, offset?: number): Matrix;
  3450. /**
  3451. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  3452. * @param other defines the second operand
  3453. * @param result defines the matrix where to store the multiplication
  3454. * @returns the current matrix
  3455. */
  3456. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  3457. /**
  3458. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  3459. * @param other defines the second operand
  3460. * @param result defines the array where to store the multiplication
  3461. * @param offset defines the offset in the target array where to start storing values
  3462. * @returns the current matrix
  3463. */
  3464. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  3465. /**
  3466. * Check equality between this matrix and a second one
  3467. * @param value defines the second matrix to compare
  3468. * @returns true is the current matrix and the given one values are strictly equal
  3469. */
  3470. equals(value: DeepImmutable<Matrix>): boolean;
  3471. /**
  3472. * Clone the current matrix
  3473. * @returns a new matrix from the current matrix
  3474. */
  3475. clone(): Matrix;
  3476. /**
  3477. * Returns the name of the current matrix class
  3478. * @returns the string "Matrix"
  3479. */
  3480. getClassName(): string;
  3481. /**
  3482. * Gets the hash code of the current matrix
  3483. * @returns the hash code
  3484. */
  3485. getHashCode(): number;
  3486. /**
  3487. * Decomposes the current Matrix into a translation, rotation and scaling components
  3488. * @param scale defines the scale vector3 given as a reference to update
  3489. * @param rotation defines the rotation quaternion given as a reference to update
  3490. * @param translation defines the translation vector3 given as a reference to update
  3491. * @returns true if operation was successful
  3492. */
  3493. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  3494. /**
  3495. * Gets specific row of the matrix
  3496. * @param index defines the number of the row to get
  3497. * @returns the index-th row of the current matrix as a new Vector4
  3498. */
  3499. getRow(index: number): Nullable<Vector4>;
  3500. /**
  3501. * Sets the index-th row of the current matrix to the vector4 values
  3502. * @param index defines the number of the row to set
  3503. * @param row defines the target vector4
  3504. * @returns the updated current matrix
  3505. */
  3506. setRow(index: number, row: Vector4): Matrix;
  3507. /**
  3508. * Compute the transpose of the matrix
  3509. * @returns the new transposed matrix
  3510. */
  3511. transpose(): Matrix;
  3512. /**
  3513. * Compute the transpose of the matrix and store it in a given matrix
  3514. * @param result defines the target matrix
  3515. * @returns the current matrix
  3516. */
  3517. transposeToRef(result: Matrix): Matrix;
  3518. /**
  3519. * Sets the index-th row of the current matrix with the given 4 x float values
  3520. * @param index defines the row index
  3521. * @param x defines the x component to set
  3522. * @param y defines the y component to set
  3523. * @param z defines the z component to set
  3524. * @param w defines the w component to set
  3525. * @returns the updated current matrix
  3526. */
  3527. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  3528. /**
  3529. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  3530. * @param scale defines the scale factor
  3531. * @returns a new matrix
  3532. */
  3533. scale(scale: number): Matrix;
  3534. /**
  3535. * Scale the current matrix values by a factor to a given result matrix
  3536. * @param scale defines the scale factor
  3537. * @param result defines the matrix to store the result
  3538. * @returns the current matrix
  3539. */
  3540. scaleToRef(scale: number, result: Matrix): Matrix;
  3541. /**
  3542. * Scale the current matrix values by a factor and add the result to a given matrix
  3543. * @param scale defines the scale factor
  3544. * @param result defines the Matrix to store the result
  3545. * @returns the current matrix
  3546. */
  3547. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  3548. /**
  3549. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  3550. * @param ref matrix to store the result
  3551. */
  3552. toNormalMatrix(ref: Matrix): void;
  3553. /**
  3554. * Gets only rotation part of the current matrix
  3555. * @returns a new matrix sets to the extracted rotation matrix from the current one
  3556. */
  3557. getRotationMatrix(): Matrix;
  3558. /**
  3559. * Extracts the rotation matrix from the current one and sets it as the given "result"
  3560. * @param result defines the target matrix to store data to
  3561. * @returns the current matrix
  3562. */
  3563. getRotationMatrixToRef(result: Matrix): Matrix;
  3564. /**
  3565. * Toggles model matrix from being right handed to left handed in place and vice versa
  3566. */
  3567. toggleModelMatrixHandInPlace(): void;
  3568. /**
  3569. * Toggles projection matrix from being right handed to left handed in place and vice versa
  3570. */
  3571. toggleProjectionMatrixHandInPlace(): void;
  3572. /**
  3573. * Creates a matrix from an array
  3574. * @param array defines the source array
  3575. * @param offset defines an offset in the source array
  3576. * @returns a new Matrix set from the starting index of the given array
  3577. */
  3578. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  3579. /**
  3580. * Copy the content of an array into a given matrix
  3581. * @param array defines the source array
  3582. * @param offset defines an offset in the source array
  3583. * @param result defines the target matrix
  3584. */
  3585. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  3586. /**
  3587. * Stores an array into a matrix after having multiplied each component by a given factor
  3588. * @param array defines the source array
  3589. * @param offset defines the offset in the source array
  3590. * @param scale defines the scaling factor
  3591. * @param result defines the target matrix
  3592. */
  3593. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  3594. /**
  3595. * Gets an identity matrix that must not be updated
  3596. */
  3597. static readonly IdentityReadOnly: DeepImmutable<Matrix>;
  3598. /**
  3599. * Stores a list of values (16) inside a given matrix
  3600. * @param initialM11 defines 1st value of 1st row
  3601. * @param initialM12 defines 2nd value of 1st row
  3602. * @param initialM13 defines 3rd value of 1st row
  3603. * @param initialM14 defines 4th value of 1st row
  3604. * @param initialM21 defines 1st value of 2nd row
  3605. * @param initialM22 defines 2nd value of 2nd row
  3606. * @param initialM23 defines 3rd value of 2nd row
  3607. * @param initialM24 defines 4th value of 2nd row
  3608. * @param initialM31 defines 1st value of 3rd row
  3609. * @param initialM32 defines 2nd value of 3rd row
  3610. * @param initialM33 defines 3rd value of 3rd row
  3611. * @param initialM34 defines 4th value of 3rd row
  3612. * @param initialM41 defines 1st value of 4th row
  3613. * @param initialM42 defines 2nd value of 4th row
  3614. * @param initialM43 defines 3rd value of 4th row
  3615. * @param initialM44 defines 4th value of 4th row
  3616. * @param result defines the target matrix
  3617. */
  3618. 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;
  3619. /**
  3620. * Creates new matrix from a list of values (16)
  3621. * @param initialM11 defines 1st value of 1st row
  3622. * @param initialM12 defines 2nd value of 1st row
  3623. * @param initialM13 defines 3rd value of 1st row
  3624. * @param initialM14 defines 4th value of 1st row
  3625. * @param initialM21 defines 1st value of 2nd row
  3626. * @param initialM22 defines 2nd value of 2nd row
  3627. * @param initialM23 defines 3rd value of 2nd row
  3628. * @param initialM24 defines 4th value of 2nd row
  3629. * @param initialM31 defines 1st value of 3rd row
  3630. * @param initialM32 defines 2nd value of 3rd row
  3631. * @param initialM33 defines 3rd value of 3rd row
  3632. * @param initialM34 defines 4th value of 3rd row
  3633. * @param initialM41 defines 1st value of 4th row
  3634. * @param initialM42 defines 2nd value of 4th row
  3635. * @param initialM43 defines 3rd value of 4th row
  3636. * @param initialM44 defines 4th value of 4th row
  3637. * @returns the new matrix
  3638. */
  3639. 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;
  3640. /**
  3641. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  3642. * @param scale defines the scale vector3
  3643. * @param rotation defines the rotation quaternion
  3644. * @param translation defines the translation vector3
  3645. * @returns a new matrix
  3646. */
  3647. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  3648. /**
  3649. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  3650. * @param scale defines the scale vector3
  3651. * @param rotation defines the rotation quaternion
  3652. * @param translation defines the translation vector3
  3653. * @param result defines the target matrix
  3654. */
  3655. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  3656. /**
  3657. * Creates a new identity matrix
  3658. * @returns a new identity matrix
  3659. */
  3660. static Identity(): Matrix;
  3661. /**
  3662. * Creates a new identity matrix and stores the result in a given matrix
  3663. * @param result defines the target matrix
  3664. */
  3665. static IdentityToRef(result: Matrix): void;
  3666. /**
  3667. * Creates a new zero matrix
  3668. * @returns a new zero matrix
  3669. */
  3670. static Zero(): Matrix;
  3671. /**
  3672. * Creates a new rotation matrix for "angle" radians around the X axis
  3673. * @param angle defines the angle (in radians) to use
  3674. * @return the new matrix
  3675. */
  3676. static RotationX(angle: number): Matrix;
  3677. /**
  3678. * Creates a new matrix as the invert of a given matrix
  3679. * @param source defines the source matrix
  3680. * @returns the new matrix
  3681. */
  3682. static Invert(source: DeepImmutable<Matrix>): Matrix;
  3683. /**
  3684. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  3685. * @param angle defines the angle (in radians) to use
  3686. * @param result defines the target matrix
  3687. */
  3688. static RotationXToRef(angle: number, result: Matrix): void;
  3689. /**
  3690. * Creates a new rotation matrix for "angle" radians around the Y axis
  3691. * @param angle defines the angle (in radians) to use
  3692. * @return the new matrix
  3693. */
  3694. static RotationY(angle: number): Matrix;
  3695. /**
  3696. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  3697. * @param angle defines the angle (in radians) to use
  3698. * @param result defines the target matrix
  3699. */
  3700. static RotationYToRef(angle: number, result: Matrix): void;
  3701. /**
  3702. * Creates a new rotation matrix for "angle" radians around the Z axis
  3703. * @param angle defines the angle (in radians) to use
  3704. * @return the new matrix
  3705. */
  3706. static RotationZ(angle: number): Matrix;
  3707. /**
  3708. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  3709. * @param angle defines the angle (in radians) to use
  3710. * @param result defines the target matrix
  3711. */
  3712. static RotationZToRef(angle: number, result: Matrix): void;
  3713. /**
  3714. * Creates a new rotation matrix for "angle" radians around the given axis
  3715. * @param axis defines the axis to use
  3716. * @param angle defines the angle (in radians) to use
  3717. * @return the new matrix
  3718. */
  3719. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  3720. /**
  3721. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  3722. * @param axis defines the axis to use
  3723. * @param angle defines the angle (in radians) to use
  3724. * @param result defines the target matrix
  3725. */
  3726. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  3727. /**
  3728. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  3729. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  3730. * @param from defines the vector to align
  3731. * @param to defines the vector to align to
  3732. * @param result defines the target matrix
  3733. */
  3734. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  3735. /**
  3736. * Creates a rotation matrix
  3737. * @param yaw defines the yaw angle in radians (Y axis)
  3738. * @param pitch defines the pitch angle in radians (X axis)
  3739. * @param roll defines the roll angle in radians (X axis)
  3740. * @returns the new rotation matrix
  3741. */
  3742. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  3743. /**
  3744. * Creates a rotation matrix and stores it in a given matrix
  3745. * @param yaw defines the yaw angle in radians (Y axis)
  3746. * @param pitch defines the pitch angle in radians (X axis)
  3747. * @param roll defines the roll angle in radians (X axis)
  3748. * @param result defines the target matrix
  3749. */
  3750. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  3751. /**
  3752. * Creates a scaling matrix
  3753. * @param x defines the scale factor on X axis
  3754. * @param y defines the scale factor on Y axis
  3755. * @param z defines the scale factor on Z axis
  3756. * @returns the new matrix
  3757. */
  3758. static Scaling(x: number, y: number, z: number): Matrix;
  3759. /**
  3760. * Creates a scaling matrix and stores it in a given matrix
  3761. * @param x defines the scale factor on X axis
  3762. * @param y defines the scale factor on Y axis
  3763. * @param z defines the scale factor on Z axis
  3764. * @param result defines the target matrix
  3765. */
  3766. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  3767. /**
  3768. * Creates a translation matrix
  3769. * @param x defines the translation on X axis
  3770. * @param y defines the translation on Y axis
  3771. * @param z defines the translationon Z axis
  3772. * @returns the new matrix
  3773. */
  3774. static Translation(x: number, y: number, z: number): Matrix;
  3775. /**
  3776. * Creates a translation matrix and stores it in a given matrix
  3777. * @param x defines the translation on X axis
  3778. * @param y defines the translation on Y axis
  3779. * @param z defines the translationon Z axis
  3780. * @param result defines the target matrix
  3781. */
  3782. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  3783. /**
  3784. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  3785. * @param startValue defines the start value
  3786. * @param endValue defines the end value
  3787. * @param gradient defines the gradient factor
  3788. * @returns the new matrix
  3789. */
  3790. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  3791. /**
  3792. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  3793. * @param startValue defines the start value
  3794. * @param endValue defines the end value
  3795. * @param gradient defines the gradient factor
  3796. * @param result defines the Matrix object where to store data
  3797. */
  3798. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  3799. /**
  3800. * Builds a new matrix whose values are computed by:
  3801. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  3802. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  3803. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  3804. * @param startValue defines the first matrix
  3805. * @param endValue defines the second matrix
  3806. * @param gradient defines the gradient between the two matrices
  3807. * @returns the new matrix
  3808. */
  3809. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  3810. /**
  3811. * Update a matrix to values which are computed by:
  3812. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  3813. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  3814. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  3815. * @param startValue defines the first matrix
  3816. * @param endValue defines the second matrix
  3817. * @param gradient defines the gradient between the two matrices
  3818. * @param result defines the target matrix
  3819. */
  3820. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  3821. /**
  3822. * 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"
  3823. * This function works in left handed mode
  3824. * @param eye defines the final position of the entity
  3825. * @param target defines where the entity should look at
  3826. * @param up defines the up vector for the entity
  3827. * @returns the new matrix
  3828. */
  3829. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  3830. /**
  3831. * 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".
  3832. * This function works in left handed mode
  3833. * @param eye defines the final position of the entity
  3834. * @param target defines where the entity should look at
  3835. * @param up defines the up vector for the entity
  3836. * @param result defines the target matrix
  3837. */
  3838. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  3839. /**
  3840. * 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"
  3841. * This function works in right handed mode
  3842. * @param eye defines the final position of the entity
  3843. * @param target defines where the entity should look at
  3844. * @param up defines the up vector for the entity
  3845. * @returns the new matrix
  3846. */
  3847. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  3848. /**
  3849. * 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".
  3850. * This function works in right handed mode
  3851. * @param eye defines the final position of the entity
  3852. * @param target defines where the entity should look at
  3853. * @param up defines the up vector for the entity
  3854. * @param result defines the target matrix
  3855. */
  3856. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  3857. /**
  3858. * Create a left-handed orthographic projection matrix
  3859. * @param width defines the viewport width
  3860. * @param height defines the viewport height
  3861. * @param znear defines the near clip plane
  3862. * @param zfar defines the far clip plane
  3863. * @returns a new matrix as a left-handed orthographic projection matrix
  3864. */
  3865. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  3866. /**
  3867. * Store a left-handed orthographic projection to a given matrix
  3868. * @param width defines the viewport width
  3869. * @param height defines the viewport height
  3870. * @param znear defines the near clip plane
  3871. * @param zfar defines the far clip plane
  3872. * @param result defines the target matrix
  3873. */
  3874. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  3875. /**
  3876. * Create a left-handed orthographic projection matrix
  3877. * @param left defines the viewport left coordinate
  3878. * @param right defines the viewport right coordinate
  3879. * @param bottom defines the viewport bottom coordinate
  3880. * @param top defines the viewport top coordinate
  3881. * @param znear defines the near clip plane
  3882. * @param zfar defines the far clip plane
  3883. * @returns a new matrix as a left-handed orthographic projection matrix
  3884. */
  3885. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  3886. /**
  3887. * Stores a left-handed orthographic projection into a given matrix
  3888. * @param left defines the viewport left coordinate
  3889. * @param right defines the viewport right coordinate
  3890. * @param bottom defines the viewport bottom coordinate
  3891. * @param top defines the viewport top coordinate
  3892. * @param znear defines the near clip plane
  3893. * @param zfar defines the far clip plane
  3894. * @param result defines the target matrix
  3895. */
  3896. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  3897. /**
  3898. * Creates a right-handed orthographic projection matrix
  3899. * @param left defines the viewport left coordinate
  3900. * @param right defines the viewport right coordinate
  3901. * @param bottom defines the viewport bottom coordinate
  3902. * @param top defines the viewport top coordinate
  3903. * @param znear defines the near clip plane
  3904. * @param zfar defines the far clip plane
  3905. * @returns a new matrix as a right-handed orthographic projection matrix
  3906. */
  3907. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  3908. /**
  3909. * Stores a right-handed orthographic projection into a given matrix
  3910. * @param left defines the viewport left coordinate
  3911. * @param right defines the viewport right coordinate
  3912. * @param bottom defines the viewport bottom coordinate
  3913. * @param top defines the viewport top coordinate
  3914. * @param znear defines the near clip plane
  3915. * @param zfar defines the far clip plane
  3916. * @param result defines the target matrix
  3917. */
  3918. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  3919. /**
  3920. * Creates a left-handed perspective projection matrix
  3921. * @param width defines the viewport width
  3922. * @param height defines the viewport height
  3923. * @param znear defines the near clip plane
  3924. * @param zfar defines the far clip plane
  3925. * @returns a new matrix as a left-handed perspective projection matrix
  3926. */
  3927. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  3928. /**
  3929. * Creates a left-handed perspective projection matrix
  3930. * @param fov defines the horizontal field of view
  3931. * @param aspect defines the aspect ratio
  3932. * @param znear defines the near clip plane
  3933. * @param zfar defines the far clip plane
  3934. * @returns a new matrix as a left-handed perspective projection matrix
  3935. */
  3936. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  3937. /**
  3938. * Stores a left-handed perspective projection into a given matrix
  3939. * @param fov defines the horizontal field of view
  3940. * @param aspect defines the aspect ratio
  3941. * @param znear defines the near clip plane
  3942. * @param zfar defines the far clip plane
  3943. * @param result defines the target matrix
  3944. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  3945. */
  3946. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  3947. /**
  3948. * Creates a right-handed perspective projection matrix
  3949. * @param fov defines the horizontal field of view
  3950. * @param aspect defines the aspect ratio
  3951. * @param znear defines the near clip plane
  3952. * @param zfar defines the far clip plane
  3953. * @returns a new matrix as a right-handed perspective projection matrix
  3954. */
  3955. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  3956. /**
  3957. * Stores a right-handed perspective projection into a given matrix
  3958. * @param fov defines the horizontal field of view
  3959. * @param aspect defines the aspect ratio
  3960. * @param znear defines the near clip plane
  3961. * @param zfar defines the far clip plane
  3962. * @param result defines the target matrix
  3963. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  3964. */
  3965. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  3966. /**
  3967. * Stores a perspective projection for WebVR info a given matrix
  3968. * @param fov defines the field of view
  3969. * @param znear defines the near clip plane
  3970. * @param zfar defines the far clip plane
  3971. * @param result defines the target matrix
  3972. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  3973. */
  3974. static PerspectiveFovWebVRToRef(fov: {
  3975. upDegrees: number;
  3976. downDegrees: number;
  3977. leftDegrees: number;
  3978. rightDegrees: number;
  3979. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  3980. /**
  3981. * Computes a complete transformation matrix
  3982. * @param viewport defines the viewport to use
  3983. * @param world defines the world matrix
  3984. * @param view defines the view matrix
  3985. * @param projection defines the projection matrix
  3986. * @param zmin defines the near clip plane
  3987. * @param zmax defines the far clip plane
  3988. * @returns the transformation matrix
  3989. */
  3990. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  3991. /**
  3992. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  3993. * @param matrix defines the matrix to use
  3994. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  3995. */
  3996. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  3997. /**
  3998. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  3999. * @param matrix defines the matrix to use
  4000. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  4001. */
  4002. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  4003. /**
  4004. * Compute the transpose of a given matrix
  4005. * @param matrix defines the matrix to transpose
  4006. * @returns the new matrix
  4007. */
  4008. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  4009. /**
  4010. * Compute the transpose of a matrix and store it in a target matrix
  4011. * @param matrix defines the matrix to transpose
  4012. * @param result defines the target matrix
  4013. */
  4014. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  4015. /**
  4016. * Computes a reflection matrix from a plane
  4017. * @param plane defines the reflection plane
  4018. * @returns a new matrix
  4019. */
  4020. static Reflection(plane: DeepImmutable<IPlaneLike>): Matrix;
  4021. /**
  4022. * Computes a reflection matrix from a plane
  4023. * @param plane defines the reflection plane
  4024. * @param result defines the target matrix
  4025. */
  4026. static ReflectionToRef(plane: DeepImmutable<IPlaneLike>, result: Matrix): void;
  4027. /**
  4028. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  4029. * @param xaxis defines the value of the 1st axis
  4030. * @param yaxis defines the value of the 2nd axis
  4031. * @param zaxis defines the value of the 3rd axis
  4032. * @param result defines the target matrix
  4033. */
  4034. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  4035. /**
  4036. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  4037. * @param quat defines the quaternion to use
  4038. * @param result defines the target matrix
  4039. */
  4040. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  4041. }
  4042. /**
  4043. * @hidden
  4044. */
  4045. export class TmpVectors {
  4046. static Vector2: Vector2[];
  4047. static Vector3: Vector3[];
  4048. static Vector4: Vector4[];
  4049. static Quaternion: Quaternion[];
  4050. static Matrix: Matrix[];
  4051. }
  4052. }
  4053. declare module "babylonjs/Engines/constants" {
  4054. /** Defines the cross module used constants to avoid circular dependncies */
  4055. export class Constants {
  4056. /** Defines that alpha blending is disabled */
  4057. static readonly ALPHA_DISABLE: number;
  4058. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  4059. static readonly ALPHA_ADD: number;
  4060. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  4061. static readonly ALPHA_COMBINE: number;
  4062. /** Defines that alpha blending to DEST - SRC * DEST */
  4063. static readonly ALPHA_SUBTRACT: number;
  4064. /** Defines that alpha blending to SRC * DEST */
  4065. static readonly ALPHA_MULTIPLY: number;
  4066. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  4067. static readonly ALPHA_MAXIMIZED: number;
  4068. /** Defines that alpha blending to SRC + DEST */
  4069. static readonly ALPHA_ONEONE: number;
  4070. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  4071. static readonly ALPHA_PREMULTIPLIED: number;
  4072. /**
  4073. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  4074. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  4075. */
  4076. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  4077. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  4078. static readonly ALPHA_INTERPOLATE: number;
  4079. /**
  4080. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  4081. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  4082. */
  4083. static readonly ALPHA_SCREENMODE: number;
  4084. /** Defines that the ressource is not delayed*/
  4085. static readonly DELAYLOADSTATE_NONE: number;
  4086. /** Defines that the ressource was successfully delay loaded */
  4087. static readonly DELAYLOADSTATE_LOADED: number;
  4088. /** Defines that the ressource is currently delay loading */
  4089. static readonly DELAYLOADSTATE_LOADING: number;
  4090. /** Defines that the ressource is delayed and has not started loading */
  4091. static readonly DELAYLOADSTATE_NOTLOADED: number;
  4092. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  4093. static readonly NEVER: number;
  4094. /** 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 */
  4095. static readonly ALWAYS: number;
  4096. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  4097. static readonly LESS: number;
  4098. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  4099. static readonly EQUAL: number;
  4100. /** 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 */
  4101. static readonly LEQUAL: number;
  4102. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  4103. static readonly GREATER: number;
  4104. /** 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 */
  4105. static readonly GEQUAL: number;
  4106. /** 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 */
  4107. static readonly NOTEQUAL: number;
  4108. /** Passed to stencilOperation to specify that stencil value must be kept */
  4109. static readonly KEEP: number;
  4110. /** Passed to stencilOperation to specify that stencil value must be replaced */
  4111. static readonly REPLACE: number;
  4112. /** Passed to stencilOperation to specify that stencil value must be incremented */
  4113. static readonly INCR: number;
  4114. /** Passed to stencilOperation to specify that stencil value must be decremented */
  4115. static readonly DECR: number;
  4116. /** Passed to stencilOperation to specify that stencil value must be inverted */
  4117. static readonly INVERT: number;
  4118. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  4119. static readonly INCR_WRAP: number;
  4120. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  4121. static readonly DECR_WRAP: number;
  4122. /** Texture is not repeating outside of 0..1 UVs */
  4123. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  4124. /** Texture is repeating outside of 0..1 UVs */
  4125. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  4126. /** Texture is repeating and mirrored */
  4127. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  4128. /** ALPHA */
  4129. static readonly TEXTUREFORMAT_ALPHA: number;
  4130. /** LUMINANCE */
  4131. static readonly TEXTUREFORMAT_LUMINANCE: number;
  4132. /** LUMINANCE_ALPHA */
  4133. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  4134. /** RGB */
  4135. static readonly TEXTUREFORMAT_RGB: number;
  4136. /** RGBA */
  4137. static readonly TEXTUREFORMAT_RGBA: number;
  4138. /** RED */
  4139. static readonly TEXTUREFORMAT_RED: number;
  4140. /** RED (2nd reference) */
  4141. static readonly TEXTUREFORMAT_R: number;
  4142. /** RG */
  4143. static readonly TEXTUREFORMAT_RG: number;
  4144. /** RED_INTEGER */
  4145. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  4146. /** RED_INTEGER (2nd reference) */
  4147. static readonly TEXTUREFORMAT_R_INTEGER: number;
  4148. /** RG_INTEGER */
  4149. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  4150. /** RGB_INTEGER */
  4151. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  4152. /** RGBA_INTEGER */
  4153. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  4154. /** UNSIGNED_BYTE */
  4155. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  4156. /** UNSIGNED_BYTE (2nd reference) */
  4157. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  4158. /** FLOAT */
  4159. static readonly TEXTURETYPE_FLOAT: number;
  4160. /** HALF_FLOAT */
  4161. static readonly TEXTURETYPE_HALF_FLOAT: number;
  4162. /** BYTE */
  4163. static readonly TEXTURETYPE_BYTE: number;
  4164. /** SHORT */
  4165. static readonly TEXTURETYPE_SHORT: number;
  4166. /** UNSIGNED_SHORT */
  4167. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  4168. /** INT */
  4169. static readonly TEXTURETYPE_INT: number;
  4170. /** UNSIGNED_INT */
  4171. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  4172. /** UNSIGNED_SHORT_4_4_4_4 */
  4173. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  4174. /** UNSIGNED_SHORT_5_5_5_1 */
  4175. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  4176. /** UNSIGNED_SHORT_5_6_5 */
  4177. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  4178. /** UNSIGNED_INT_2_10_10_10_REV */
  4179. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  4180. /** UNSIGNED_INT_24_8 */
  4181. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  4182. /** UNSIGNED_INT_10F_11F_11F_REV */
  4183. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  4184. /** UNSIGNED_INT_5_9_9_9_REV */
  4185. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  4186. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  4187. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  4188. /** nearest is mag = nearest and min = nearest and mip = linear */
  4189. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  4190. /** Bilinear is mag = linear and min = linear and mip = nearest */
  4191. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  4192. /** Trilinear is mag = linear and min = linear and mip = linear */
  4193. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  4194. /** nearest is mag = nearest and min = nearest and mip = linear */
  4195. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  4196. /** Bilinear is mag = linear and min = linear and mip = nearest */
  4197. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  4198. /** Trilinear is mag = linear and min = linear and mip = linear */
  4199. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  4200. /** mag = nearest and min = nearest and mip = nearest */
  4201. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  4202. /** mag = nearest and min = linear and mip = nearest */
  4203. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  4204. /** mag = nearest and min = linear and mip = linear */
  4205. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  4206. /** mag = nearest and min = linear and mip = none */
  4207. static readonly TEXTURE_NEAREST_LINEAR: number;
  4208. /** mag = nearest and min = nearest and mip = none */
  4209. static readonly TEXTURE_NEAREST_NEAREST: number;
  4210. /** mag = linear and min = nearest and mip = nearest */
  4211. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  4212. /** mag = linear and min = nearest and mip = linear */
  4213. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  4214. /** mag = linear and min = linear and mip = none */
  4215. static readonly TEXTURE_LINEAR_LINEAR: number;
  4216. /** mag = linear and min = nearest and mip = none */
  4217. static readonly TEXTURE_LINEAR_NEAREST: number;
  4218. /** Explicit coordinates mode */
  4219. static readonly TEXTURE_EXPLICIT_MODE: number;
  4220. /** Spherical coordinates mode */
  4221. static readonly TEXTURE_SPHERICAL_MODE: number;
  4222. /** Planar coordinates mode */
  4223. static readonly TEXTURE_PLANAR_MODE: number;
  4224. /** Cubic coordinates mode */
  4225. static readonly TEXTURE_CUBIC_MODE: number;
  4226. /** Projection coordinates mode */
  4227. static readonly TEXTURE_PROJECTION_MODE: number;
  4228. /** Skybox coordinates mode */
  4229. static readonly TEXTURE_SKYBOX_MODE: number;
  4230. /** Inverse Cubic coordinates mode */
  4231. static readonly TEXTURE_INVCUBIC_MODE: number;
  4232. /** Equirectangular coordinates mode */
  4233. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  4234. /** Equirectangular Fixed coordinates mode */
  4235. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  4236. /** Equirectangular Fixed Mirrored coordinates mode */
  4237. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  4238. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  4239. static readonly SCALEMODE_FLOOR: number;
  4240. /** Defines that texture rescaling will look for the nearest power of 2 size */
  4241. static readonly SCALEMODE_NEAREST: number;
  4242. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  4243. static readonly SCALEMODE_CEILING: number;
  4244. /**
  4245. * The dirty texture flag value
  4246. */
  4247. static readonly MATERIAL_TextureDirtyFlag: number;
  4248. /**
  4249. * The dirty light flag value
  4250. */
  4251. static readonly MATERIAL_LightDirtyFlag: number;
  4252. /**
  4253. * The dirty fresnel flag value
  4254. */
  4255. static readonly MATERIAL_FresnelDirtyFlag: number;
  4256. /**
  4257. * The dirty attribute flag value
  4258. */
  4259. static readonly MATERIAL_AttributesDirtyFlag: number;
  4260. /**
  4261. * The dirty misc flag value
  4262. */
  4263. static readonly MATERIAL_MiscDirtyFlag: number;
  4264. /**
  4265. * The all dirty flag value
  4266. */
  4267. static readonly MATERIAL_AllDirtyFlag: number;
  4268. /**
  4269. * Returns the triangle fill mode
  4270. */
  4271. static readonly MATERIAL_TriangleFillMode: number;
  4272. /**
  4273. * Returns the wireframe mode
  4274. */
  4275. static readonly MATERIAL_WireFrameFillMode: number;
  4276. /**
  4277. * Returns the point fill mode
  4278. */
  4279. static readonly MATERIAL_PointFillMode: number;
  4280. /**
  4281. * Returns the point list draw mode
  4282. */
  4283. static readonly MATERIAL_PointListDrawMode: number;
  4284. /**
  4285. * Returns the line list draw mode
  4286. */
  4287. static readonly MATERIAL_LineListDrawMode: number;
  4288. /**
  4289. * Returns the line loop draw mode
  4290. */
  4291. static readonly MATERIAL_LineLoopDrawMode: number;
  4292. /**
  4293. * Returns the line strip draw mode
  4294. */
  4295. static readonly MATERIAL_LineStripDrawMode: number;
  4296. /**
  4297. * Returns the triangle strip draw mode
  4298. */
  4299. static readonly MATERIAL_TriangleStripDrawMode: number;
  4300. /**
  4301. * Returns the triangle fan draw mode
  4302. */
  4303. static readonly MATERIAL_TriangleFanDrawMode: number;
  4304. /**
  4305. * Stores the clock-wise side orientation
  4306. */
  4307. static readonly MATERIAL_ClockWiseSideOrientation: number;
  4308. /**
  4309. * Stores the counter clock-wise side orientation
  4310. */
  4311. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  4312. /**
  4313. * Nothing
  4314. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4315. */
  4316. static readonly ACTION_NothingTrigger: number;
  4317. /**
  4318. * On pick
  4319. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4320. */
  4321. static readonly ACTION_OnPickTrigger: number;
  4322. /**
  4323. * On left pick
  4324. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4325. */
  4326. static readonly ACTION_OnLeftPickTrigger: number;
  4327. /**
  4328. * On right pick
  4329. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4330. */
  4331. static readonly ACTION_OnRightPickTrigger: number;
  4332. /**
  4333. * On center pick
  4334. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4335. */
  4336. static readonly ACTION_OnCenterPickTrigger: number;
  4337. /**
  4338. * On pick down
  4339. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4340. */
  4341. static readonly ACTION_OnPickDownTrigger: number;
  4342. /**
  4343. * On double pick
  4344. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4345. */
  4346. static readonly ACTION_OnDoublePickTrigger: number;
  4347. /**
  4348. * On pick up
  4349. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4350. */
  4351. static readonly ACTION_OnPickUpTrigger: number;
  4352. /**
  4353. * On pick out.
  4354. * This trigger will only be raised if you also declared a OnPickDown
  4355. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4356. */
  4357. static readonly ACTION_OnPickOutTrigger: number;
  4358. /**
  4359. * On long press
  4360. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4361. */
  4362. static readonly ACTION_OnLongPressTrigger: number;
  4363. /**
  4364. * On pointer over
  4365. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4366. */
  4367. static readonly ACTION_OnPointerOverTrigger: number;
  4368. /**
  4369. * On pointer out
  4370. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4371. */
  4372. static readonly ACTION_OnPointerOutTrigger: number;
  4373. /**
  4374. * On every frame
  4375. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4376. */
  4377. static readonly ACTION_OnEveryFrameTrigger: number;
  4378. /**
  4379. * On intersection enter
  4380. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4381. */
  4382. static readonly ACTION_OnIntersectionEnterTrigger: number;
  4383. /**
  4384. * On intersection exit
  4385. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4386. */
  4387. static readonly ACTION_OnIntersectionExitTrigger: number;
  4388. /**
  4389. * On key down
  4390. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4391. */
  4392. static readonly ACTION_OnKeyDownTrigger: number;
  4393. /**
  4394. * On key up
  4395. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4396. */
  4397. static readonly ACTION_OnKeyUpTrigger: number;
  4398. /**
  4399. * Billboard mode will only apply to Y axis
  4400. */
  4401. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  4402. /**
  4403. * Billboard mode will apply to all axes
  4404. */
  4405. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  4406. /**
  4407. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  4408. */
  4409. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  4410. /**
  4411. * Gets or sets base Assets URL
  4412. */
  4413. static PARTICLES_BaseAssetsUrl: string;
  4414. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  4415. * Test order :
  4416. * Is the bounding sphere outside the frustum ?
  4417. * If not, are the bounding box vertices outside the frustum ?
  4418. * It not, then the cullable object is in the frustum.
  4419. */
  4420. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  4421. /** Culling strategy : Bounding Sphere Only.
  4422. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  4423. * It's also less accurate than the standard because some not visible objects can still be selected.
  4424. * Test : is the bounding sphere outside the frustum ?
  4425. * If not, then the cullable object is in the frustum.
  4426. */
  4427. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  4428. /** Culling strategy : Optimistic Inclusion.
  4429. * This in an inclusion test first, then the standard exclusion test.
  4430. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  4431. * 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.
  4432. * Anyway, it's as accurate as the standard strategy.
  4433. * Test :
  4434. * Is the cullable object bounding sphere center in the frustum ?
  4435. * If not, apply the default culling strategy.
  4436. */
  4437. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  4438. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  4439. * This in an inclusion test first, then the bounding sphere only exclusion test.
  4440. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  4441. * 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.
  4442. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  4443. * Test :
  4444. * Is the cullable object bounding sphere center in the frustum ?
  4445. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  4446. */
  4447. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  4448. /**
  4449. * No logging while loading
  4450. */
  4451. static readonly SCENELOADER_NO_LOGGING: number;
  4452. /**
  4453. * Minimal logging while loading
  4454. */
  4455. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  4456. /**
  4457. * Summary logging while loading
  4458. */
  4459. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  4460. /**
  4461. * Detailled logging while loading
  4462. */
  4463. static readonly SCENELOADER_DETAILED_LOGGING: number;
  4464. }
  4465. }
  4466. declare module "babylonjs/Engines/IPipelineContext" {
  4467. /**
  4468. * Class used to store and describe the pipeline context associated with an effect
  4469. */
  4470. export interface IPipelineContext {
  4471. /**
  4472. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  4473. */
  4474. isAsync: boolean;
  4475. /**
  4476. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  4477. */
  4478. isReady: boolean;
  4479. /** @hidden */
  4480. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  4481. }
  4482. }
  4483. declare module "babylonjs/Engines/Processors/iShaderProcessor" {
  4484. /** @hidden */
  4485. export interface IShaderProcessor {
  4486. attributeProcessor?: (attribute: string) => string;
  4487. varyingProcessor?: (varying: string, isFragment: boolean) => string;
  4488. uniformProcessor?: (uniform: string, isFragment: boolean) => string;
  4489. uniformBufferProcessor?: (uniformBuffer: string, isFragment: boolean) => string;
  4490. endOfUniformBufferProcessor?: (closingBracketLine: string, isFragment: boolean) => string;
  4491. lineProcessor?: (line: string, isFragment: boolean) => string;
  4492. preProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  4493. postProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  4494. }
  4495. }
  4496. declare module "babylonjs/Engines/Processors/shaderProcessingOptions" {
  4497. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  4498. /** @hidden */
  4499. export interface ProcessingOptions {
  4500. defines: string[];
  4501. indexParameters: any;
  4502. isFragment: boolean;
  4503. shouldUseHighPrecisionShader: boolean;
  4504. supportsUniformBuffers: boolean;
  4505. shadersRepository: string;
  4506. includesShadersStore: {
  4507. [key: string]: string;
  4508. };
  4509. processor?: IShaderProcessor;
  4510. version: string;
  4511. platformName: string;
  4512. lookForClosingBracketForUniformBuffer?: boolean;
  4513. }
  4514. }
  4515. declare module "babylonjs/Misc/stringTools" {
  4516. /**
  4517. * Helper to manipulate strings
  4518. */
  4519. export class StringTools {
  4520. /**
  4521. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  4522. * @param str Source string
  4523. * @param suffix Suffix to search for in the source string
  4524. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  4525. */
  4526. static EndsWith(str: string, suffix: string): boolean;
  4527. /**
  4528. * Checks for a matching suffix at the beginning of a string (for ES5 and lower)
  4529. * @param str Source string
  4530. * @param suffix Suffix to search for in the source string
  4531. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  4532. */
  4533. static StartsWith(str: string, suffix: string): boolean;
  4534. }
  4535. }
  4536. declare module "babylonjs/Engines/Processors/shaderCodeNode" {
  4537. import { ProcessingOptions } from "babylonjs/Engines/Processors/shaderProcessingOptions";
  4538. /** @hidden */
  4539. export class ShaderCodeNode {
  4540. line: string;
  4541. children: ShaderCodeNode[];
  4542. additionalDefineKey?: string;
  4543. additionalDefineValue?: string;
  4544. isValid(preprocessors: {
  4545. [key: string]: string;
  4546. }): boolean;
  4547. process(preprocessors: {
  4548. [key: string]: string;
  4549. }, options: ProcessingOptions): string;
  4550. }
  4551. }
  4552. declare module "babylonjs/Engines/Processors/shaderCodeCursor" {
  4553. /** @hidden */
  4554. export class ShaderCodeCursor {
  4555. private _lines;
  4556. lineIndex: number;
  4557. readonly currentLine: string;
  4558. readonly canRead: boolean;
  4559. lines: string[];
  4560. }
  4561. }
  4562. declare module "babylonjs/Engines/Processors/shaderCodeConditionNode" {
  4563. import { ShaderCodeNode } from "babylonjs/Engines/Processors/shaderCodeNode";
  4564. import { ProcessingOptions } from "babylonjs/Engines/Processors/shaderProcessingOptions";
  4565. /** @hidden */
  4566. export class ShaderCodeConditionNode extends ShaderCodeNode {
  4567. process(preprocessors: {
  4568. [key: string]: string;
  4569. }, options: ProcessingOptions): string;
  4570. }
  4571. }
  4572. declare module "babylonjs/Engines/Processors/Expressions/shaderDefineExpression" {
  4573. /** @hidden */
  4574. export class ShaderDefineExpression {
  4575. isTrue(preprocessors: {
  4576. [key: string]: string;
  4577. }): boolean;
  4578. }
  4579. }
  4580. declare module "babylonjs/Engines/Processors/shaderCodeTestNode" {
  4581. import { ShaderCodeNode } from "babylonjs/Engines/Processors/shaderCodeNode";
  4582. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  4583. /** @hidden */
  4584. export class ShaderCodeTestNode extends ShaderCodeNode {
  4585. testExpression: ShaderDefineExpression;
  4586. isValid(preprocessors: {
  4587. [key: string]: string;
  4588. }): boolean;
  4589. }
  4590. }
  4591. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineIsDefinedOperator" {
  4592. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  4593. /** @hidden */
  4594. export class ShaderDefineIsDefinedOperator extends ShaderDefineExpression {
  4595. define: string;
  4596. not: boolean;
  4597. constructor(define: string, not?: boolean);
  4598. isTrue(preprocessors: {
  4599. [key: string]: string;
  4600. }): boolean;
  4601. }
  4602. }
  4603. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineOrOperator" {
  4604. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  4605. /** @hidden */
  4606. export class ShaderDefineOrOperator extends ShaderDefineExpression {
  4607. leftOperand: ShaderDefineExpression;
  4608. rightOperand: ShaderDefineExpression;
  4609. isTrue(preprocessors: {
  4610. [key: string]: string;
  4611. }): boolean;
  4612. }
  4613. }
  4614. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineAndOperator" {
  4615. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  4616. /** @hidden */
  4617. export class ShaderDefineAndOperator extends ShaderDefineExpression {
  4618. leftOperand: ShaderDefineExpression;
  4619. rightOperand: ShaderDefineExpression;
  4620. isTrue(preprocessors: {
  4621. [key: string]: string;
  4622. }): boolean;
  4623. }
  4624. }
  4625. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineArithmeticOperator" {
  4626. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  4627. /** @hidden */
  4628. export class ShaderDefineArithmeticOperator extends ShaderDefineExpression {
  4629. define: string;
  4630. operand: string;
  4631. testValue: string;
  4632. constructor(define: string, operand: string, testValue: string);
  4633. isTrue(preprocessors: {
  4634. [key: string]: string;
  4635. }): boolean;
  4636. }
  4637. }
  4638. declare module "babylonjs/Misc/loadFileError" {
  4639. import { WebRequest } from "babylonjs/Misc/webRequest";
  4640. /**
  4641. * @ignore
  4642. * Application error to support additional information when loading a file
  4643. */
  4644. export class LoadFileError extends Error {
  4645. /** defines the optional web request */
  4646. request?: WebRequest | undefined;
  4647. private static _setPrototypeOf;
  4648. /**
  4649. * Creates a new LoadFileError
  4650. * @param message defines the message of the error
  4651. * @param request defines the optional web request
  4652. */
  4653. constructor(message: string,
  4654. /** defines the optional web request */
  4655. request?: WebRequest | undefined);
  4656. }
  4657. }
  4658. declare module "babylonjs/Offline/IOfflineProvider" {
  4659. /**
  4660. * Class used to enable access to offline support
  4661. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  4662. */
  4663. export interface IOfflineProvider {
  4664. /**
  4665. * Gets a boolean indicating if scene must be saved in the database
  4666. */
  4667. enableSceneOffline: boolean;
  4668. /**
  4669. * Gets a boolean indicating if textures must be saved in the database
  4670. */
  4671. enableTexturesOffline: boolean;
  4672. /**
  4673. * Open the offline support and make it available
  4674. * @param successCallback defines the callback to call on success
  4675. * @param errorCallback defines the callback to call on error
  4676. */
  4677. open(successCallback: () => void, errorCallback: () => void): void;
  4678. /**
  4679. * Loads an image from the offline support
  4680. * @param url defines the url to load from
  4681. * @param image defines the target DOM image
  4682. */
  4683. loadImage(url: string, image: HTMLImageElement): void;
  4684. /**
  4685. * Loads a file from offline support
  4686. * @param url defines the URL to load from
  4687. * @param sceneLoaded defines a callback to call on success
  4688. * @param progressCallBack defines a callback to call when progress changed
  4689. * @param errorCallback defines a callback to call on error
  4690. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  4691. */
  4692. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  4693. }
  4694. }
  4695. declare module "babylonjs/Misc/filesInputStore" {
  4696. /**
  4697. * Class used to help managing file picking and drag'n'drop
  4698. * File Storage
  4699. */
  4700. export class FilesInputStore {
  4701. /**
  4702. * List of files ready to be loaded
  4703. */
  4704. static FilesToLoad: {
  4705. [key: string]: File;
  4706. };
  4707. }
  4708. }
  4709. declare module "babylonjs/Misc/retryStrategy" {
  4710. import { WebRequest } from "babylonjs/Misc/webRequest";
  4711. /**
  4712. * Class used to define a retry strategy when error happens while loading assets
  4713. */
  4714. export class RetryStrategy {
  4715. /**
  4716. * Function used to defines an exponential back off strategy
  4717. * @param maxRetries defines the maximum number of retries (3 by default)
  4718. * @param baseInterval defines the interval between retries
  4719. * @returns the strategy function to use
  4720. */
  4721. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  4722. }
  4723. }
  4724. declare module "babylonjs/Misc/fileTools" {
  4725. import { WebRequest } from "babylonjs/Misc/webRequest";
  4726. import { Nullable } from "babylonjs/types";
  4727. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  4728. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  4729. /**
  4730. * @hidden
  4731. */
  4732. export class FileTools {
  4733. /**
  4734. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  4735. */
  4736. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  4737. /**
  4738. * Gets or sets the base URL to use to load assets
  4739. */
  4740. static BaseUrl: string;
  4741. /**
  4742. * Default behaviour for cors in the application.
  4743. * It can be a string if the expected behavior is identical in the entire app.
  4744. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  4745. */
  4746. static CorsBehavior: string | ((url: string | string[]) => string);
  4747. /**
  4748. * Gets or sets a function used to pre-process url before using them to load assets
  4749. */
  4750. static PreprocessUrl: (url: string) => string;
  4751. /**
  4752. * Removes unwanted characters from an url
  4753. * @param url defines the url to clean
  4754. * @returns the cleaned url
  4755. */
  4756. private static _CleanUrl;
  4757. /**
  4758. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  4759. * @param url define the url we are trying
  4760. * @param element define the dom element where to configure the cors policy
  4761. */
  4762. static SetCorsBehavior(url: string | string[], element: {
  4763. crossOrigin: string | null;
  4764. }): void;
  4765. /**
  4766. * Loads an image as an HTMLImageElement.
  4767. * @param input url string, ArrayBuffer, or Blob to load
  4768. * @param onLoad callback called when the image successfully loads
  4769. * @param onError callback called when the image fails to load
  4770. * @param offlineProvider offline provider for caching
  4771. * @returns the HTMLImageElement of the loaded image
  4772. */
  4773. static LoadImage(input: string | ArrayBuffer | ArrayBufferView | Blob, onLoad: (img: HTMLImageElement) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>): HTMLImageElement;
  4774. /**
  4775. * Loads a file
  4776. * @param fileToLoad defines the file to load
  4777. * @param callback defines the callback to call when data is loaded
  4778. * @param progressCallBack defines the callback to call during loading process
  4779. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  4780. * @returns a file request object
  4781. */
  4782. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  4783. /**
  4784. * Loads a file
  4785. * @param url url string, ArrayBuffer, or Blob to load
  4786. * @param onSuccess callback called when the file successfully loads
  4787. * @param onProgress callback called while file is loading (if the server supports this mode)
  4788. * @param offlineProvider defines the offline provider for caching
  4789. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  4790. * @param onError callback called when the file fails to load
  4791. * @returns a file request object
  4792. */
  4793. 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;
  4794. /**
  4795. * Checks if the loaded document was accessed via `file:`-Protocol.
  4796. * @returns boolean
  4797. */
  4798. static IsFileURL(): boolean;
  4799. }
  4800. }
  4801. declare module "babylonjs/Engines/Processors/shaderProcessor" {
  4802. import { ProcessingOptions } from "babylonjs/Engines/Processors/shaderProcessingOptions";
  4803. /** @hidden */
  4804. export class ShaderProcessor {
  4805. static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void): void;
  4806. private static _ProcessPrecision;
  4807. private static _ExtractOperation;
  4808. private static _BuildSubExpression;
  4809. private static _BuildExpression;
  4810. private static _MoveCursorWithinIf;
  4811. private static _MoveCursor;
  4812. private static _EvaluatePreProcessors;
  4813. private static _PreparePreProcessors;
  4814. private static _ProcessShaderConversion;
  4815. private static _ProcessIncludes;
  4816. }
  4817. }
  4818. declare module "babylonjs/Maths/math.color" {
  4819. import { DeepImmutable, FloatArray } from "babylonjs/types";
  4820. /**
  4821. * Class used to hold a RBG color
  4822. */
  4823. export class Color3 {
  4824. /**
  4825. * Defines the red component (between 0 and 1, default is 0)
  4826. */
  4827. r: number;
  4828. /**
  4829. * Defines the green component (between 0 and 1, default is 0)
  4830. */
  4831. g: number;
  4832. /**
  4833. * Defines the blue component (between 0 and 1, default is 0)
  4834. */
  4835. b: number;
  4836. /**
  4837. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  4838. * @param r defines the red component (between 0 and 1, default is 0)
  4839. * @param g defines the green component (between 0 and 1, default is 0)
  4840. * @param b defines the blue component (between 0 and 1, default is 0)
  4841. */
  4842. constructor(
  4843. /**
  4844. * Defines the red component (between 0 and 1, default is 0)
  4845. */
  4846. r?: number,
  4847. /**
  4848. * Defines the green component (between 0 and 1, default is 0)
  4849. */
  4850. g?: number,
  4851. /**
  4852. * Defines the blue component (between 0 and 1, default is 0)
  4853. */
  4854. b?: number);
  4855. /**
  4856. * Creates a string with the Color3 current values
  4857. * @returns the string representation of the Color3 object
  4858. */
  4859. toString(): string;
  4860. /**
  4861. * Returns the string "Color3"
  4862. * @returns "Color3"
  4863. */
  4864. getClassName(): string;
  4865. /**
  4866. * Compute the Color3 hash code
  4867. * @returns an unique number that can be used to hash Color3 objects
  4868. */
  4869. getHashCode(): number;
  4870. /**
  4871. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  4872. * @param array defines the array where to store the r,g,b components
  4873. * @param index defines an optional index in the target array to define where to start storing values
  4874. * @returns the current Color3 object
  4875. */
  4876. toArray(array: FloatArray, index?: number): Color3;
  4877. /**
  4878. * Returns a new Color4 object from the current Color3 and the given alpha
  4879. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  4880. * @returns a new Color4 object
  4881. */
  4882. toColor4(alpha?: number): Color4;
  4883. /**
  4884. * Returns a new array populated with 3 numeric elements : red, green and blue values
  4885. * @returns the new array
  4886. */
  4887. asArray(): number[];
  4888. /**
  4889. * Returns the luminance value
  4890. * @returns a float value
  4891. */
  4892. toLuminance(): number;
  4893. /**
  4894. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  4895. * @param otherColor defines the second operand
  4896. * @returns the new Color3 object
  4897. */
  4898. multiply(otherColor: DeepImmutable<Color3>): Color3;
  4899. /**
  4900. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  4901. * @param otherColor defines the second operand
  4902. * @param result defines the Color3 object where to store the result
  4903. * @returns the current Color3
  4904. */
  4905. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  4906. /**
  4907. * Determines equality between Color3 objects
  4908. * @param otherColor defines the second operand
  4909. * @returns true if the rgb values are equal to the given ones
  4910. */
  4911. equals(otherColor: DeepImmutable<Color3>): boolean;
  4912. /**
  4913. * Determines equality between the current Color3 object and a set of r,b,g values
  4914. * @param r defines the red component to check
  4915. * @param g defines the green component to check
  4916. * @param b defines the blue component to check
  4917. * @returns true if the rgb values are equal to the given ones
  4918. */
  4919. equalsFloats(r: number, g: number, b: number): boolean;
  4920. /**
  4921. * Multiplies in place each rgb value by scale
  4922. * @param scale defines the scaling factor
  4923. * @returns the updated Color3
  4924. */
  4925. scale(scale: number): Color3;
  4926. /**
  4927. * Multiplies the rgb values by scale and stores the result into "result"
  4928. * @param scale defines the scaling factor
  4929. * @param result defines the Color3 object where to store the result
  4930. * @returns the unmodified current Color3
  4931. */
  4932. scaleToRef(scale: number, result: Color3): Color3;
  4933. /**
  4934. * Scale the current Color3 values by a factor and add the result to a given Color3
  4935. * @param scale defines the scale factor
  4936. * @param result defines color to store the result into
  4937. * @returns the unmodified current Color3
  4938. */
  4939. scaleAndAddToRef(scale: number, result: Color3): Color3;
  4940. /**
  4941. * Clamps the rgb values by the min and max values and stores the result into "result"
  4942. * @param min defines minimum clamping value (default is 0)
  4943. * @param max defines maximum clamping value (default is 1)
  4944. * @param result defines color to store the result into
  4945. * @returns the original Color3
  4946. */
  4947. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  4948. /**
  4949. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  4950. * @param otherColor defines the second operand
  4951. * @returns the new Color3
  4952. */
  4953. add(otherColor: DeepImmutable<Color3>): Color3;
  4954. /**
  4955. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  4956. * @param otherColor defines the second operand
  4957. * @param result defines Color3 object to store the result into
  4958. * @returns the unmodified current Color3
  4959. */
  4960. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  4961. /**
  4962. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  4963. * @param otherColor defines the second operand
  4964. * @returns the new Color3
  4965. */
  4966. subtract(otherColor: DeepImmutable<Color3>): Color3;
  4967. /**
  4968. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  4969. * @param otherColor defines the second operand
  4970. * @param result defines Color3 object to store the result into
  4971. * @returns the unmodified current Color3
  4972. */
  4973. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  4974. /**
  4975. * Copy the current object
  4976. * @returns a new Color3 copied the current one
  4977. */
  4978. clone(): Color3;
  4979. /**
  4980. * Copies the rgb values from the source in the current Color3
  4981. * @param source defines the source Color3 object
  4982. * @returns the updated Color3 object
  4983. */
  4984. copyFrom(source: DeepImmutable<Color3>): Color3;
  4985. /**
  4986. * Updates the Color3 rgb values from the given floats
  4987. * @param r defines the red component to read from
  4988. * @param g defines the green component to read from
  4989. * @param b defines the blue component to read from
  4990. * @returns the current Color3 object
  4991. */
  4992. copyFromFloats(r: number, g: number, b: number): Color3;
  4993. /**
  4994. * Updates the Color3 rgb values from the given floats
  4995. * @param r defines the red component to read from
  4996. * @param g defines the green component to read from
  4997. * @param b defines the blue component to read from
  4998. * @returns the current Color3 object
  4999. */
  5000. set(r: number, g: number, b: number): Color3;
  5001. /**
  5002. * Compute the Color3 hexadecimal code as a string
  5003. * @returns a string containing the hexadecimal representation of the Color3 object
  5004. */
  5005. toHexString(): string;
  5006. /**
  5007. * Computes a new Color3 converted from the current one to linear space
  5008. * @returns a new Color3 object
  5009. */
  5010. toLinearSpace(): Color3;
  5011. /**
  5012. * Converts current color in rgb space to HSV values
  5013. * @returns a new color3 representing the HSV values
  5014. */
  5015. toHSV(): Color3;
  5016. /**
  5017. * Converts current color in rgb space to HSV values
  5018. * @param result defines the Color3 where to store the HSV values
  5019. */
  5020. toHSVToRef(result: Color3): void;
  5021. /**
  5022. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  5023. * @param convertedColor defines the Color3 object where to store the linear space version
  5024. * @returns the unmodified Color3
  5025. */
  5026. toLinearSpaceToRef(convertedColor: Color3): Color3;
  5027. /**
  5028. * Computes a new Color3 converted from the current one to gamma space
  5029. * @returns a new Color3 object
  5030. */
  5031. toGammaSpace(): Color3;
  5032. /**
  5033. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  5034. * @param convertedColor defines the Color3 object where to store the gamma space version
  5035. * @returns the unmodified Color3
  5036. */
  5037. toGammaSpaceToRef(convertedColor: Color3): Color3;
  5038. private static _BlackReadOnly;
  5039. /**
  5040. * Convert Hue, saturation and value to a Color3 (RGB)
  5041. * @param hue defines the hue
  5042. * @param saturation defines the saturation
  5043. * @param value defines the value
  5044. * @param result defines the Color3 where to store the RGB values
  5045. */
  5046. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  5047. /**
  5048. * Creates a new Color3 from the string containing valid hexadecimal values
  5049. * @param hex defines a string containing valid hexadecimal values
  5050. * @returns a new Color3 object
  5051. */
  5052. static FromHexString(hex: string): Color3;
  5053. /**
  5054. * Creates a new Color3 from the starting index of the given array
  5055. * @param array defines the source array
  5056. * @param offset defines an offset in the source array
  5057. * @returns a new Color3 object
  5058. */
  5059. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  5060. /**
  5061. * Creates a new Color3 from integer values (< 256)
  5062. * @param r defines the red component to read from (value between 0 and 255)
  5063. * @param g defines the green component to read from (value between 0 and 255)
  5064. * @param b defines the blue component to read from (value between 0 and 255)
  5065. * @returns a new Color3 object
  5066. */
  5067. static FromInts(r: number, g: number, b: number): Color3;
  5068. /**
  5069. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  5070. * @param start defines the start Color3 value
  5071. * @param end defines the end Color3 value
  5072. * @param amount defines the gradient value between start and end
  5073. * @returns a new Color3 object
  5074. */
  5075. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  5076. /**
  5077. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  5078. * @param left defines the start value
  5079. * @param right defines the end value
  5080. * @param amount defines the gradient factor
  5081. * @param result defines the Color3 object where to store the result
  5082. */
  5083. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  5084. /**
  5085. * Returns a Color3 value containing a red color
  5086. * @returns a new Color3 object
  5087. */
  5088. static Red(): Color3;
  5089. /**
  5090. * Returns a Color3 value containing a green color
  5091. * @returns a new Color3 object
  5092. */
  5093. static Green(): Color3;
  5094. /**
  5095. * Returns a Color3 value containing a blue color
  5096. * @returns a new Color3 object
  5097. */
  5098. static Blue(): Color3;
  5099. /**
  5100. * Returns a Color3 value containing a black color
  5101. * @returns a new Color3 object
  5102. */
  5103. static Black(): Color3;
  5104. /**
  5105. * Gets a Color3 value containing a black color that must not be updated
  5106. */
  5107. static readonly BlackReadOnly: DeepImmutable<Color3>;
  5108. /**
  5109. * Returns a Color3 value containing a white color
  5110. * @returns a new Color3 object
  5111. */
  5112. static White(): Color3;
  5113. /**
  5114. * Returns a Color3 value containing a purple color
  5115. * @returns a new Color3 object
  5116. */
  5117. static Purple(): Color3;
  5118. /**
  5119. * Returns a Color3 value containing a magenta color
  5120. * @returns a new Color3 object
  5121. */
  5122. static Magenta(): Color3;
  5123. /**
  5124. * Returns a Color3 value containing a yellow color
  5125. * @returns a new Color3 object
  5126. */
  5127. static Yellow(): Color3;
  5128. /**
  5129. * Returns a Color3 value containing a gray color
  5130. * @returns a new Color3 object
  5131. */
  5132. static Gray(): Color3;
  5133. /**
  5134. * Returns a Color3 value containing a teal color
  5135. * @returns a new Color3 object
  5136. */
  5137. static Teal(): Color3;
  5138. /**
  5139. * Returns a Color3 value containing a random color
  5140. * @returns a new Color3 object
  5141. */
  5142. static Random(): Color3;
  5143. }
  5144. /**
  5145. * Class used to hold a RBGA color
  5146. */
  5147. export class Color4 {
  5148. /**
  5149. * Defines the red component (between 0 and 1, default is 0)
  5150. */
  5151. r: number;
  5152. /**
  5153. * Defines the green component (between 0 and 1, default is 0)
  5154. */
  5155. g: number;
  5156. /**
  5157. * Defines the blue component (between 0 and 1, default is 0)
  5158. */
  5159. b: number;
  5160. /**
  5161. * Defines the alpha component (between 0 and 1, default is 1)
  5162. */
  5163. a: number;
  5164. /**
  5165. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  5166. * @param r defines the red component (between 0 and 1, default is 0)
  5167. * @param g defines the green component (between 0 and 1, default is 0)
  5168. * @param b defines the blue component (between 0 and 1, default is 0)
  5169. * @param a defines the alpha component (between 0 and 1, default is 1)
  5170. */
  5171. constructor(
  5172. /**
  5173. * Defines the red component (between 0 and 1, default is 0)
  5174. */
  5175. r?: number,
  5176. /**
  5177. * Defines the green component (between 0 and 1, default is 0)
  5178. */
  5179. g?: number,
  5180. /**
  5181. * Defines the blue component (between 0 and 1, default is 0)
  5182. */
  5183. b?: number,
  5184. /**
  5185. * Defines the alpha component (between 0 and 1, default is 1)
  5186. */
  5187. a?: number);
  5188. /**
  5189. * Adds in place the given Color4 values to the current Color4 object
  5190. * @param right defines the second operand
  5191. * @returns the current updated Color4 object
  5192. */
  5193. addInPlace(right: DeepImmutable<Color4>): Color4;
  5194. /**
  5195. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  5196. * @returns the new array
  5197. */
  5198. asArray(): number[];
  5199. /**
  5200. * Stores from the starting index in the given array the Color4 successive values
  5201. * @param array defines the array where to store the r,g,b components
  5202. * @param index defines an optional index in the target array to define where to start storing values
  5203. * @returns the current Color4 object
  5204. */
  5205. toArray(array: number[], index?: number): Color4;
  5206. /**
  5207. * Determines equality between Color4 objects
  5208. * @param otherColor defines the second operand
  5209. * @returns true if the rgba values are equal to the given ones
  5210. */
  5211. equals(otherColor: DeepImmutable<Color4>): boolean;
  5212. /**
  5213. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  5214. * @param right defines the second operand
  5215. * @returns a new Color4 object
  5216. */
  5217. add(right: DeepImmutable<Color4>): Color4;
  5218. /**
  5219. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  5220. * @param right defines the second operand
  5221. * @returns a new Color4 object
  5222. */
  5223. subtract(right: DeepImmutable<Color4>): Color4;
  5224. /**
  5225. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  5226. * @param right defines the second operand
  5227. * @param result defines the Color4 object where to store the result
  5228. * @returns the current Color4 object
  5229. */
  5230. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  5231. /**
  5232. * Creates a new Color4 with the current Color4 values multiplied by scale
  5233. * @param scale defines the scaling factor to apply
  5234. * @returns a new Color4 object
  5235. */
  5236. scale(scale: number): Color4;
  5237. /**
  5238. * Multiplies the current Color4 values by scale and stores the result in "result"
  5239. * @param scale defines the scaling factor to apply
  5240. * @param result defines the Color4 object where to store the result
  5241. * @returns the current unmodified Color4
  5242. */
  5243. scaleToRef(scale: number, result: Color4): Color4;
  5244. /**
  5245. * Scale the current Color4 values by a factor and add the result to a given Color4
  5246. * @param scale defines the scale factor
  5247. * @param result defines the Color4 object where to store the result
  5248. * @returns the unmodified current Color4
  5249. */
  5250. scaleAndAddToRef(scale: number, result: Color4): Color4;
  5251. /**
  5252. * Clamps the rgb values by the min and max values and stores the result into "result"
  5253. * @param min defines minimum clamping value (default is 0)
  5254. * @param max defines maximum clamping value (default is 1)
  5255. * @param result defines color to store the result into.
  5256. * @returns the cuurent Color4
  5257. */
  5258. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  5259. /**
  5260. * Multipy an Color4 value by another and return a new Color4 object
  5261. * @param color defines the Color4 value to multiply by
  5262. * @returns a new Color4 object
  5263. */
  5264. multiply(color: Color4): Color4;
  5265. /**
  5266. * Multipy a Color4 value by another and push the result in a reference value
  5267. * @param color defines the Color4 value to multiply by
  5268. * @param result defines the Color4 to fill the result in
  5269. * @returns the result Color4
  5270. */
  5271. multiplyToRef(color: Color4, result: Color4): Color4;
  5272. /**
  5273. * Creates a string with the Color4 current values
  5274. * @returns the string representation of the Color4 object
  5275. */
  5276. toString(): string;
  5277. /**
  5278. * Returns the string "Color4"
  5279. * @returns "Color4"
  5280. */
  5281. getClassName(): string;
  5282. /**
  5283. * Compute the Color4 hash code
  5284. * @returns an unique number that can be used to hash Color4 objects
  5285. */
  5286. getHashCode(): number;
  5287. /**
  5288. * Creates a new Color4 copied from the current one
  5289. * @returns a new Color4 object
  5290. */
  5291. clone(): Color4;
  5292. /**
  5293. * Copies the given Color4 values into the current one
  5294. * @param source defines the source Color4 object
  5295. * @returns the current updated Color4 object
  5296. */
  5297. copyFrom(source: Color4): Color4;
  5298. /**
  5299. * Copies the given float values into the current one
  5300. * @param r defines the red component to read from
  5301. * @param g defines the green component to read from
  5302. * @param b defines the blue component to read from
  5303. * @param a defines the alpha component to read from
  5304. * @returns the current updated Color4 object
  5305. */
  5306. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  5307. /**
  5308. * Copies the given float values into the current one
  5309. * @param r defines the red component to read from
  5310. * @param g defines the green component to read from
  5311. * @param b defines the blue component to read from
  5312. * @param a defines the alpha component to read from
  5313. * @returns the current updated Color4 object
  5314. */
  5315. set(r: number, g: number, b: number, a: number): Color4;
  5316. /**
  5317. * Compute the Color4 hexadecimal code as a string
  5318. * @returns a string containing the hexadecimal representation of the Color4 object
  5319. */
  5320. toHexString(): string;
  5321. /**
  5322. * Computes a new Color4 converted from the current one to linear space
  5323. * @returns a new Color4 object
  5324. */
  5325. toLinearSpace(): Color4;
  5326. /**
  5327. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  5328. * @param convertedColor defines the Color4 object where to store the linear space version
  5329. * @returns the unmodified Color4
  5330. */
  5331. toLinearSpaceToRef(convertedColor: Color4): Color4;
  5332. /**
  5333. * Computes a new Color4 converted from the current one to gamma space
  5334. * @returns a new Color4 object
  5335. */
  5336. toGammaSpace(): Color4;
  5337. /**
  5338. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  5339. * @param convertedColor defines the Color4 object where to store the gamma space version
  5340. * @returns the unmodified Color4
  5341. */
  5342. toGammaSpaceToRef(convertedColor: Color4): Color4;
  5343. /**
  5344. * Creates a new Color4 from the string containing valid hexadecimal values
  5345. * @param hex defines a string containing valid hexadecimal values
  5346. * @returns a new Color4 object
  5347. */
  5348. static FromHexString(hex: string): Color4;
  5349. /**
  5350. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  5351. * @param left defines the start value
  5352. * @param right defines the end value
  5353. * @param amount defines the gradient factor
  5354. * @returns a new Color4 object
  5355. */
  5356. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  5357. /**
  5358. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  5359. * @param left defines the start value
  5360. * @param right defines the end value
  5361. * @param amount defines the gradient factor
  5362. * @param result defines the Color4 object where to store data
  5363. */
  5364. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  5365. /**
  5366. * Creates a new Color4 from a Color3 and an alpha value
  5367. * @param color3 defines the source Color3 to read from
  5368. * @param alpha defines the alpha component (1.0 by default)
  5369. * @returns a new Color4 object
  5370. */
  5371. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  5372. /**
  5373. * Creates a new Color4 from the starting index element of the given array
  5374. * @param array defines the source array to read from
  5375. * @param offset defines the offset in the source array
  5376. * @returns a new Color4 object
  5377. */
  5378. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  5379. /**
  5380. * Creates a new Color3 from integer values (< 256)
  5381. * @param r defines the red component to read from (value between 0 and 255)
  5382. * @param g defines the green component to read from (value between 0 and 255)
  5383. * @param b defines the blue component to read from (value between 0 and 255)
  5384. * @param a defines the alpha component to read from (value between 0 and 255)
  5385. * @returns a new Color3 object
  5386. */
  5387. static FromInts(r: number, g: number, b: number, a: number): Color4;
  5388. /**
  5389. * Check the content of a given array and convert it to an array containing RGBA data
  5390. * If the original array was already containing count * 4 values then it is returned directly
  5391. * @param colors defines the array to check
  5392. * @param count defines the number of RGBA data to expect
  5393. * @returns an array containing count * 4 values (RGBA)
  5394. */
  5395. static CheckColors4(colors: number[], count: number): number[];
  5396. }
  5397. /**
  5398. * @hidden
  5399. */
  5400. export class TmpColors {
  5401. static Color3: Color3[];
  5402. static Color4: Color4[];
  5403. }
  5404. }
  5405. declare module "babylonjs/Maths/sphericalPolynomial" {
  5406. import { Vector3 } from "babylonjs/Maths/math.vector";
  5407. import { Color3 } from "babylonjs/Maths/math.color";
  5408. /**
  5409. * Class representing spherical harmonics coefficients to the 3rd degree
  5410. */
  5411. export class SphericalHarmonics {
  5412. /**
  5413. * Defines whether or not the harmonics have been prescaled for rendering.
  5414. */
  5415. preScaled: boolean;
  5416. /**
  5417. * The l0,0 coefficients of the spherical harmonics
  5418. */
  5419. l00: Vector3;
  5420. /**
  5421. * The l1,-1 coefficients of the spherical harmonics
  5422. */
  5423. l1_1: Vector3;
  5424. /**
  5425. * The l1,0 coefficients of the spherical harmonics
  5426. */
  5427. l10: Vector3;
  5428. /**
  5429. * The l1,1 coefficients of the spherical harmonics
  5430. */
  5431. l11: Vector3;
  5432. /**
  5433. * The l2,-2 coefficients of the spherical harmonics
  5434. */
  5435. l2_2: Vector3;
  5436. /**
  5437. * The l2,-1 coefficients of the spherical harmonics
  5438. */
  5439. l2_1: Vector3;
  5440. /**
  5441. * The l2,0 coefficients of the spherical harmonics
  5442. */
  5443. l20: Vector3;
  5444. /**
  5445. * The l2,1 coefficients of the spherical harmonics
  5446. */
  5447. l21: Vector3;
  5448. /**
  5449. * The l2,2 coefficients of the spherical harmonics
  5450. */
  5451. l22: Vector3;
  5452. /**
  5453. * Adds a light to the spherical harmonics
  5454. * @param direction the direction of the light
  5455. * @param color the color of the light
  5456. * @param deltaSolidAngle the delta solid angle of the light
  5457. */
  5458. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  5459. /**
  5460. * Scales the spherical harmonics by the given amount
  5461. * @param scale the amount to scale
  5462. */
  5463. scaleInPlace(scale: number): void;
  5464. /**
  5465. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  5466. *
  5467. * ```
  5468. * E_lm = A_l * L_lm
  5469. * ```
  5470. *
  5471. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  5472. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  5473. * the scaling factors are given in equation 9.
  5474. */
  5475. convertIncidentRadianceToIrradiance(): void;
  5476. /**
  5477. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  5478. *
  5479. * ```
  5480. * L = (1/pi) * E * rho
  5481. * ```
  5482. *
  5483. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  5484. */
  5485. convertIrradianceToLambertianRadiance(): void;
  5486. /**
  5487. * Integrates the reconstruction coefficients directly in to the SH preventing further
  5488. * required operations at run time.
  5489. *
  5490. * This is simply done by scaling back the SH with Ylm constants parameter.
  5491. * The trigonometric part being applied by the shader at run time.
  5492. */
  5493. preScaleForRendering(): void;
  5494. /**
  5495. * Constructs a spherical harmonics from an array.
  5496. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  5497. * @returns the spherical harmonics
  5498. */
  5499. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  5500. /**
  5501. * Gets the spherical harmonics from polynomial
  5502. * @param polynomial the spherical polynomial
  5503. * @returns the spherical harmonics
  5504. */
  5505. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  5506. }
  5507. /**
  5508. * Class representing spherical polynomial coefficients to the 3rd degree
  5509. */
  5510. export class SphericalPolynomial {
  5511. private _harmonics;
  5512. /**
  5513. * The spherical harmonics used to create the polynomials.
  5514. */
  5515. readonly preScaledHarmonics: SphericalHarmonics;
  5516. /**
  5517. * The x coefficients of the spherical polynomial
  5518. */
  5519. x: Vector3;
  5520. /**
  5521. * The y coefficients of the spherical polynomial
  5522. */
  5523. y: Vector3;
  5524. /**
  5525. * The z coefficients of the spherical polynomial
  5526. */
  5527. z: Vector3;
  5528. /**
  5529. * The xx coefficients of the spherical polynomial
  5530. */
  5531. xx: Vector3;
  5532. /**
  5533. * The yy coefficients of the spherical polynomial
  5534. */
  5535. yy: Vector3;
  5536. /**
  5537. * The zz coefficients of the spherical polynomial
  5538. */
  5539. zz: Vector3;
  5540. /**
  5541. * The xy coefficients of the spherical polynomial
  5542. */
  5543. xy: Vector3;
  5544. /**
  5545. * The yz coefficients of the spherical polynomial
  5546. */
  5547. yz: Vector3;
  5548. /**
  5549. * The zx coefficients of the spherical polynomial
  5550. */
  5551. zx: Vector3;
  5552. /**
  5553. * Adds an ambient color to the spherical polynomial
  5554. * @param color the color to add
  5555. */
  5556. addAmbient(color: Color3): void;
  5557. /**
  5558. * Scales the spherical polynomial by the given amount
  5559. * @param scale the amount to scale
  5560. */
  5561. scaleInPlace(scale: number): void;
  5562. /**
  5563. * Gets the spherical polynomial from harmonics
  5564. * @param harmonics the spherical harmonics
  5565. * @returns the spherical polynomial
  5566. */
  5567. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  5568. /**
  5569. * Constructs a spherical polynomial from an array.
  5570. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  5571. * @returns the spherical polynomial
  5572. */
  5573. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  5574. }
  5575. }
  5576. declare module "babylonjs/Materials/Textures/renderTargetCreationOptions" {
  5577. /**
  5578. * Define options used to create a render target texture
  5579. */
  5580. export class RenderTargetCreationOptions {
  5581. /**
  5582. * Specifies is mipmaps must be generated
  5583. */
  5584. generateMipMaps?: boolean;
  5585. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  5586. generateDepthBuffer?: boolean;
  5587. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  5588. generateStencilBuffer?: boolean;
  5589. /** Defines texture type (int by default) */
  5590. type?: number;
  5591. /** Defines sampling mode (trilinear by default) */
  5592. samplingMode?: number;
  5593. /** Defines format (RGBA by default) */
  5594. format?: number;
  5595. }
  5596. }
  5597. declare module "babylonjs/States/alphaCullingState" {
  5598. /**
  5599. * @hidden
  5600. **/
  5601. export class _AlphaState {
  5602. private _isAlphaBlendDirty;
  5603. private _isBlendFunctionParametersDirty;
  5604. private _isBlendEquationParametersDirty;
  5605. private _isBlendConstantsDirty;
  5606. private _alphaBlend;
  5607. private _blendFunctionParameters;
  5608. private _blendEquationParameters;
  5609. private _blendConstants;
  5610. /**
  5611. * Initializes the state.
  5612. */
  5613. constructor();
  5614. readonly isDirty: boolean;
  5615. alphaBlend: boolean;
  5616. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  5617. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  5618. setAlphaEquationParameters(rgb: number, alpha: number): void;
  5619. reset(): void;
  5620. apply(gl: WebGLRenderingContext): void;
  5621. }
  5622. }
  5623. declare module "babylonjs/States/depthCullingState" {
  5624. import { Nullable } from "babylonjs/types";
  5625. /**
  5626. * @hidden
  5627. **/
  5628. export class _DepthCullingState {
  5629. private _isDepthTestDirty;
  5630. private _isDepthMaskDirty;
  5631. private _isDepthFuncDirty;
  5632. private _isCullFaceDirty;
  5633. private _isCullDirty;
  5634. private _isZOffsetDirty;
  5635. private _isFrontFaceDirty;
  5636. private _depthTest;
  5637. private _depthMask;
  5638. private _depthFunc;
  5639. private _cull;
  5640. private _cullFace;
  5641. private _zOffset;
  5642. private _frontFace;
  5643. /**
  5644. * Initializes the state.
  5645. */
  5646. constructor();
  5647. readonly isDirty: boolean;
  5648. zOffset: number;
  5649. cullFace: Nullable<number>;
  5650. cull: Nullable<boolean>;
  5651. depthFunc: Nullable<number>;
  5652. depthMask: boolean;
  5653. depthTest: boolean;
  5654. frontFace: Nullable<number>;
  5655. reset(): void;
  5656. apply(gl: WebGLRenderingContext): void;
  5657. }
  5658. }
  5659. declare module "babylonjs/States/stencilState" {
  5660. /**
  5661. * @hidden
  5662. **/
  5663. export class _StencilState {
  5664. /** 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 */
  5665. static readonly ALWAYS: number;
  5666. /** Passed to stencilOperation to specify that stencil value must be kept */
  5667. static readonly KEEP: number;
  5668. /** Passed to stencilOperation to specify that stencil value must be replaced */
  5669. static readonly REPLACE: number;
  5670. private _isStencilTestDirty;
  5671. private _isStencilMaskDirty;
  5672. private _isStencilFuncDirty;
  5673. private _isStencilOpDirty;
  5674. private _stencilTest;
  5675. private _stencilMask;
  5676. private _stencilFunc;
  5677. private _stencilFuncRef;
  5678. private _stencilFuncMask;
  5679. private _stencilOpStencilFail;
  5680. private _stencilOpDepthFail;
  5681. private _stencilOpStencilDepthPass;
  5682. readonly isDirty: boolean;
  5683. stencilFunc: number;
  5684. stencilFuncRef: number;
  5685. stencilFuncMask: number;
  5686. stencilOpStencilFail: number;
  5687. stencilOpDepthFail: number;
  5688. stencilOpStencilDepthPass: number;
  5689. stencilMask: number;
  5690. stencilTest: boolean;
  5691. constructor();
  5692. reset(): void;
  5693. apply(gl: WebGLRenderingContext): void;
  5694. }
  5695. }
  5696. declare module "babylonjs/States/index" {
  5697. export * from "babylonjs/States/alphaCullingState";
  5698. export * from "babylonjs/States/depthCullingState";
  5699. export * from "babylonjs/States/stencilState";
  5700. }
  5701. declare module "babylonjs/Instrumentation/timeToken" {
  5702. import { Nullable } from "babylonjs/types";
  5703. /**
  5704. * @hidden
  5705. **/
  5706. export class _TimeToken {
  5707. _startTimeQuery: Nullable<WebGLQuery>;
  5708. _endTimeQuery: Nullable<WebGLQuery>;
  5709. _timeElapsedQuery: Nullable<WebGLQuery>;
  5710. _timeElapsedQueryEnded: boolean;
  5711. }
  5712. }
  5713. declare module "babylonjs/Misc/andOrNotEvaluator" {
  5714. /**
  5715. * Class used to evalaute queries containing `and` and `or` operators
  5716. */
  5717. export class AndOrNotEvaluator {
  5718. /**
  5719. * Evaluate a query
  5720. * @param query defines the query to evaluate
  5721. * @param evaluateCallback defines the callback used to filter result
  5722. * @returns true if the query matches
  5723. */
  5724. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  5725. private static _HandleParenthesisContent;
  5726. private static _SimplifyNegation;
  5727. }
  5728. }
  5729. declare module "babylonjs/Misc/tags" {
  5730. /**
  5731. * Class used to store custom tags
  5732. */
  5733. export class Tags {
  5734. /**
  5735. * Adds support for tags on the given object
  5736. * @param obj defines the object to use
  5737. */
  5738. static EnableFor(obj: any): void;
  5739. /**
  5740. * Removes tags support
  5741. * @param obj defines the object to use
  5742. */
  5743. static DisableFor(obj: any): void;
  5744. /**
  5745. * Gets a boolean indicating if the given object has tags
  5746. * @param obj defines the object to use
  5747. * @returns a boolean
  5748. */
  5749. static HasTags(obj: any): boolean;
  5750. /**
  5751. * Gets the tags available on a given object
  5752. * @param obj defines the object to use
  5753. * @param asString defines if the tags must be returned as a string instead of an array of strings
  5754. * @returns the tags
  5755. */
  5756. static GetTags(obj: any, asString?: boolean): any;
  5757. /**
  5758. * Adds tags to an object
  5759. * @param obj defines the object to use
  5760. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  5761. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  5762. */
  5763. static AddTagsTo(obj: any, tagsString: string): void;
  5764. /**
  5765. * @hidden
  5766. */
  5767. static _AddTagTo(obj: any, tag: string): void;
  5768. /**
  5769. * Removes specific tags from a specific object
  5770. * @param obj defines the object to use
  5771. * @param tagsString defines the tags to remove
  5772. */
  5773. static RemoveTagsFrom(obj: any, tagsString: string): void;
  5774. /**
  5775. * @hidden
  5776. */
  5777. static _RemoveTagFrom(obj: any, tag: string): void;
  5778. /**
  5779. * Defines if tags hosted on an object match a given query
  5780. * @param obj defines the object to use
  5781. * @param tagsQuery defines the tag query
  5782. * @returns a boolean
  5783. */
  5784. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  5785. }
  5786. }
  5787. declare module "babylonjs/Maths/math.path" {
  5788. import { DeepImmutable, Nullable } from "babylonjs/types";
  5789. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  5790. /**
  5791. * Defines potential orientation for back face culling
  5792. */
  5793. export enum Orientation {
  5794. /**
  5795. * Clockwise
  5796. */
  5797. CW = 0,
  5798. /** Counter clockwise */
  5799. CCW = 1
  5800. }
  5801. /** Class used to represent a Bezier curve */
  5802. export class BezierCurve {
  5803. /**
  5804. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  5805. * @param t defines the time
  5806. * @param x1 defines the left coordinate on X axis
  5807. * @param y1 defines the left coordinate on Y axis
  5808. * @param x2 defines the right coordinate on X axis
  5809. * @param y2 defines the right coordinate on Y axis
  5810. * @returns the interpolated value
  5811. */
  5812. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  5813. }
  5814. /**
  5815. * Defines angle representation
  5816. */
  5817. export class Angle {
  5818. private _radians;
  5819. /**
  5820. * Creates an Angle object of "radians" radians (float).
  5821. * @param radians the angle in radians
  5822. */
  5823. constructor(radians: number);
  5824. /**
  5825. * Get value in degrees
  5826. * @returns the Angle value in degrees (float)
  5827. */
  5828. degrees(): number;
  5829. /**
  5830. * Get value in radians
  5831. * @returns the Angle value in radians (float)
  5832. */
  5833. radians(): number;
  5834. /**
  5835. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  5836. * @param a defines first vector
  5837. * @param b defines second vector
  5838. * @returns a new Angle
  5839. */
  5840. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  5841. /**
  5842. * Gets a new Angle object from the given float in radians
  5843. * @param radians defines the angle value in radians
  5844. * @returns a new Angle
  5845. */
  5846. static FromRadians(radians: number): Angle;
  5847. /**
  5848. * Gets a new Angle object from the given float in degrees
  5849. * @param degrees defines the angle value in degrees
  5850. * @returns a new Angle
  5851. */
  5852. static FromDegrees(degrees: number): Angle;
  5853. }
  5854. /**
  5855. * This represents an arc in a 2d space.
  5856. */
  5857. export class Arc2 {
  5858. /** Defines the start point of the arc */
  5859. startPoint: Vector2;
  5860. /** Defines the mid point of the arc */
  5861. midPoint: Vector2;
  5862. /** Defines the end point of the arc */
  5863. endPoint: Vector2;
  5864. /**
  5865. * Defines the center point of the arc.
  5866. */
  5867. centerPoint: Vector2;
  5868. /**
  5869. * Defines the radius of the arc.
  5870. */
  5871. radius: number;
  5872. /**
  5873. * Defines the angle of the arc (from mid point to end point).
  5874. */
  5875. angle: Angle;
  5876. /**
  5877. * Defines the start angle of the arc (from start point to middle point).
  5878. */
  5879. startAngle: Angle;
  5880. /**
  5881. * Defines the orientation of the arc (clock wise/counter clock wise).
  5882. */
  5883. orientation: Orientation;
  5884. /**
  5885. * Creates an Arc object from the three given points : start, middle and end.
  5886. * @param startPoint Defines the start point of the arc
  5887. * @param midPoint Defines the midlle point of the arc
  5888. * @param endPoint Defines the end point of the arc
  5889. */
  5890. constructor(
  5891. /** Defines the start point of the arc */
  5892. startPoint: Vector2,
  5893. /** Defines the mid point of the arc */
  5894. midPoint: Vector2,
  5895. /** Defines the end point of the arc */
  5896. endPoint: Vector2);
  5897. }
  5898. /**
  5899. * Represents a 2D path made up of multiple 2D points
  5900. */
  5901. export class Path2 {
  5902. private _points;
  5903. private _length;
  5904. /**
  5905. * If the path start and end point are the same
  5906. */
  5907. closed: boolean;
  5908. /**
  5909. * Creates a Path2 object from the starting 2D coordinates x and y.
  5910. * @param x the starting points x value
  5911. * @param y the starting points y value
  5912. */
  5913. constructor(x: number, y: number);
  5914. /**
  5915. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  5916. * @param x the added points x value
  5917. * @param y the added points y value
  5918. * @returns the updated Path2.
  5919. */
  5920. addLineTo(x: number, y: number): Path2;
  5921. /**
  5922. * 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.
  5923. * @param midX middle point x value
  5924. * @param midY middle point y value
  5925. * @param endX end point x value
  5926. * @param endY end point y value
  5927. * @param numberOfSegments (default: 36)
  5928. * @returns the updated Path2.
  5929. */
  5930. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  5931. /**
  5932. * Closes the Path2.
  5933. * @returns the Path2.
  5934. */
  5935. close(): Path2;
  5936. /**
  5937. * Gets the sum of the distance between each sequential point in the path
  5938. * @returns the Path2 total length (float).
  5939. */
  5940. length(): number;
  5941. /**
  5942. * Gets the points which construct the path
  5943. * @returns the Path2 internal array of points.
  5944. */
  5945. getPoints(): Vector2[];
  5946. /**
  5947. * Retreives the point at the distance aways from the starting point
  5948. * @param normalizedLengthPosition the length along the path to retreive the point from
  5949. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  5950. */
  5951. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  5952. /**
  5953. * Creates a new path starting from an x and y position
  5954. * @param x starting x value
  5955. * @param y starting y value
  5956. * @returns a new Path2 starting at the coordinates (x, y).
  5957. */
  5958. static StartingAt(x: number, y: number): Path2;
  5959. }
  5960. /**
  5961. * Represents a 3D path made up of multiple 3D points
  5962. */
  5963. export class Path3D {
  5964. /**
  5965. * an array of Vector3, the curve axis of the Path3D
  5966. */
  5967. path: Vector3[];
  5968. private _curve;
  5969. private _distances;
  5970. private _tangents;
  5971. private _normals;
  5972. private _binormals;
  5973. private _raw;
  5974. /**
  5975. * new Path3D(path, normal, raw)
  5976. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  5977. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  5978. * @param path an array of Vector3, the curve axis of the Path3D
  5979. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  5980. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  5981. */
  5982. constructor(
  5983. /**
  5984. * an array of Vector3, the curve axis of the Path3D
  5985. */
  5986. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean);
  5987. /**
  5988. * Returns the Path3D array of successive Vector3 designing its curve.
  5989. * @returns the Path3D array of successive Vector3 designing its curve.
  5990. */
  5991. getCurve(): Vector3[];
  5992. /**
  5993. * Returns an array populated with tangent vectors on each Path3D curve point.
  5994. * @returns an array populated with tangent vectors on each Path3D curve point.
  5995. */
  5996. getTangents(): Vector3[];
  5997. /**
  5998. * Returns an array populated with normal vectors on each Path3D curve point.
  5999. * @returns an array populated with normal vectors on each Path3D curve point.
  6000. */
  6001. getNormals(): Vector3[];
  6002. /**
  6003. * Returns an array populated with binormal vectors on each Path3D curve point.
  6004. * @returns an array populated with binormal vectors on each Path3D curve point.
  6005. */
  6006. getBinormals(): Vector3[];
  6007. /**
  6008. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  6009. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  6010. */
  6011. getDistances(): number[];
  6012. /**
  6013. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  6014. * @param path path which all values are copied into the curves points
  6015. * @param firstNormal which should be projected onto the curve
  6016. * @returns the same object updated.
  6017. */
  6018. update(path: Vector3[], firstNormal?: Nullable<Vector3>): Path3D;
  6019. private _compute;
  6020. private _getFirstNonNullVector;
  6021. private _getLastNonNullVector;
  6022. private _normalVector;
  6023. }
  6024. /**
  6025. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  6026. * A Curve3 is designed from a series of successive Vector3.
  6027. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  6028. */
  6029. export class Curve3 {
  6030. private _points;
  6031. private _length;
  6032. /**
  6033. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  6034. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  6035. * @param v1 (Vector3) the control point
  6036. * @param v2 (Vector3) the end point of the Quadratic Bezier
  6037. * @param nbPoints (integer) the wanted number of points in the curve
  6038. * @returns the created Curve3
  6039. */
  6040. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  6041. /**
  6042. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  6043. * @param v0 (Vector3) the origin point of the Cubic Bezier
  6044. * @param v1 (Vector3) the first control point
  6045. * @param v2 (Vector3) the second control point
  6046. * @param v3 (Vector3) the end point of the Cubic Bezier
  6047. * @param nbPoints (integer) the wanted number of points in the curve
  6048. * @returns the created Curve3
  6049. */
  6050. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  6051. /**
  6052. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  6053. * @param p1 (Vector3) the origin point of the Hermite Spline
  6054. * @param t1 (Vector3) the tangent vector at the origin point
  6055. * @param p2 (Vector3) the end point of the Hermite Spline
  6056. * @param t2 (Vector3) the tangent vector at the end point
  6057. * @param nbPoints (integer) the wanted number of points in the curve
  6058. * @returns the created Curve3
  6059. */
  6060. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  6061. /**
  6062. * Returns a Curve3 object along a CatmullRom Spline curve :
  6063. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  6064. * @param nbPoints (integer) the wanted number of points between each curve control points
  6065. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  6066. * @returns the created Curve3
  6067. */
  6068. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  6069. /**
  6070. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  6071. * A Curve3 is designed from a series of successive Vector3.
  6072. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  6073. * @param points points which make up the curve
  6074. */
  6075. constructor(points: Vector3[]);
  6076. /**
  6077. * @returns the Curve3 stored array of successive Vector3
  6078. */
  6079. getPoints(): Vector3[];
  6080. /**
  6081. * @returns the computed length (float) of the curve.
  6082. */
  6083. length(): number;
  6084. /**
  6085. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  6086. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  6087. * curveA and curveB keep unchanged.
  6088. * @param curve the curve to continue from this curve
  6089. * @returns the newly constructed curve
  6090. */
  6091. continue(curve: DeepImmutable<Curve3>): Curve3;
  6092. private _computeLength;
  6093. }
  6094. }
  6095. declare module "babylonjs/Animations/easing" {
  6096. /**
  6097. * This represents the main contract an easing function should follow.
  6098. * Easing functions are used throughout the animation system.
  6099. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6100. */
  6101. export interface IEasingFunction {
  6102. /**
  6103. * Given an input gradient between 0 and 1, this returns the corrseponding value
  6104. * of the easing function.
  6105. * The link below provides some of the most common examples of easing functions.
  6106. * @see https://easings.net/
  6107. * @param gradient Defines the value between 0 and 1 we want the easing value for
  6108. * @returns the corresponding value on the curve defined by the easing function
  6109. */
  6110. ease(gradient: number): number;
  6111. }
  6112. /**
  6113. * Base class used for every default easing function.
  6114. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6115. */
  6116. export class EasingFunction implements IEasingFunction {
  6117. /**
  6118. * Interpolation follows the mathematical formula associated with the easing function.
  6119. */
  6120. static readonly EASINGMODE_EASEIN: number;
  6121. /**
  6122. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  6123. */
  6124. static readonly EASINGMODE_EASEOUT: number;
  6125. /**
  6126. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  6127. */
  6128. static readonly EASINGMODE_EASEINOUT: number;
  6129. private _easingMode;
  6130. /**
  6131. * Sets the easing mode of the current function.
  6132. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  6133. */
  6134. setEasingMode(easingMode: number): void;
  6135. /**
  6136. * Gets the current easing mode.
  6137. * @returns the easing mode
  6138. */
  6139. getEasingMode(): number;
  6140. /**
  6141. * @hidden
  6142. */
  6143. easeInCore(gradient: number): number;
  6144. /**
  6145. * Given an input gradient between 0 and 1, this returns the corresponding value
  6146. * of the easing function.
  6147. * @param gradient Defines the value between 0 and 1 we want the easing value for
  6148. * @returns the corresponding value on the curve defined by the easing function
  6149. */
  6150. ease(gradient: number): number;
  6151. }
  6152. /**
  6153. * Easing function with a circle shape (see link below).
  6154. * @see https://easings.net/#easeInCirc
  6155. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6156. */
  6157. export class CircleEase extends EasingFunction implements IEasingFunction {
  6158. /** @hidden */
  6159. easeInCore(gradient: number): number;
  6160. }
  6161. /**
  6162. * Easing function with a ease back shape (see link below).
  6163. * @see https://easings.net/#easeInBack
  6164. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6165. */
  6166. export class BackEase extends EasingFunction implements IEasingFunction {
  6167. /** Defines the amplitude of the function */
  6168. amplitude: number;
  6169. /**
  6170. * Instantiates a back ease easing
  6171. * @see https://easings.net/#easeInBack
  6172. * @param amplitude Defines the amplitude of the function
  6173. */
  6174. constructor(
  6175. /** Defines the amplitude of the function */
  6176. amplitude?: number);
  6177. /** @hidden */
  6178. easeInCore(gradient: number): number;
  6179. }
  6180. /**
  6181. * Easing function with a bouncing shape (see link below).
  6182. * @see https://easings.net/#easeInBounce
  6183. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6184. */
  6185. export class BounceEase extends EasingFunction implements IEasingFunction {
  6186. /** Defines the number of bounces */
  6187. bounces: number;
  6188. /** Defines the amplitude of the bounce */
  6189. bounciness: number;
  6190. /**
  6191. * Instantiates a bounce easing
  6192. * @see https://easings.net/#easeInBounce
  6193. * @param bounces Defines the number of bounces
  6194. * @param bounciness Defines the amplitude of the bounce
  6195. */
  6196. constructor(
  6197. /** Defines the number of bounces */
  6198. bounces?: number,
  6199. /** Defines the amplitude of the bounce */
  6200. bounciness?: number);
  6201. /** @hidden */
  6202. easeInCore(gradient: number): number;
  6203. }
  6204. /**
  6205. * Easing function with a power of 3 shape (see link below).
  6206. * @see https://easings.net/#easeInCubic
  6207. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6208. */
  6209. export class CubicEase extends EasingFunction implements IEasingFunction {
  6210. /** @hidden */
  6211. easeInCore(gradient: number): number;
  6212. }
  6213. /**
  6214. * Easing function with an elastic shape (see link below).
  6215. * @see https://easings.net/#easeInElastic
  6216. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6217. */
  6218. export class ElasticEase extends EasingFunction implements IEasingFunction {
  6219. /** Defines the number of oscillations*/
  6220. oscillations: number;
  6221. /** Defines the amplitude of the oscillations*/
  6222. springiness: number;
  6223. /**
  6224. * Instantiates an elastic easing function
  6225. * @see https://easings.net/#easeInElastic
  6226. * @param oscillations Defines the number of oscillations
  6227. * @param springiness Defines the amplitude of the oscillations
  6228. */
  6229. constructor(
  6230. /** Defines the number of oscillations*/
  6231. oscillations?: number,
  6232. /** Defines the amplitude of the oscillations*/
  6233. springiness?: number);
  6234. /** @hidden */
  6235. easeInCore(gradient: number): number;
  6236. }
  6237. /**
  6238. * Easing function with an exponential shape (see link below).
  6239. * @see https://easings.net/#easeInExpo
  6240. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6241. */
  6242. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  6243. /** Defines the exponent of the function */
  6244. exponent: number;
  6245. /**
  6246. * Instantiates an exponential easing function
  6247. * @see https://easings.net/#easeInExpo
  6248. * @param exponent Defines the exponent of the function
  6249. */
  6250. constructor(
  6251. /** Defines the exponent of the function */
  6252. exponent?: number);
  6253. /** @hidden */
  6254. easeInCore(gradient: number): number;
  6255. }
  6256. /**
  6257. * Easing function with a power shape (see link below).
  6258. * @see https://easings.net/#easeInQuad
  6259. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6260. */
  6261. export class PowerEase extends EasingFunction implements IEasingFunction {
  6262. /** Defines the power of the function */
  6263. power: number;
  6264. /**
  6265. * Instantiates an power base easing function
  6266. * @see https://easings.net/#easeInQuad
  6267. * @param power Defines the power of the function
  6268. */
  6269. constructor(
  6270. /** Defines the power of the function */
  6271. power?: number);
  6272. /** @hidden */
  6273. easeInCore(gradient: number): number;
  6274. }
  6275. /**
  6276. * Easing function with a power of 2 shape (see link below).
  6277. * @see https://easings.net/#easeInQuad
  6278. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6279. */
  6280. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  6281. /** @hidden */
  6282. easeInCore(gradient: number): number;
  6283. }
  6284. /**
  6285. * Easing function with a power of 4 shape (see link below).
  6286. * @see https://easings.net/#easeInQuart
  6287. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6288. */
  6289. export class QuarticEase extends EasingFunction implements IEasingFunction {
  6290. /** @hidden */
  6291. easeInCore(gradient: number): number;
  6292. }
  6293. /**
  6294. * Easing function with a power of 5 shape (see link below).
  6295. * @see https://easings.net/#easeInQuint
  6296. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6297. */
  6298. export class QuinticEase extends EasingFunction implements IEasingFunction {
  6299. /** @hidden */
  6300. easeInCore(gradient: number): number;
  6301. }
  6302. /**
  6303. * Easing function with a sin shape (see link below).
  6304. * @see https://easings.net/#easeInSine
  6305. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6306. */
  6307. export class SineEase extends EasingFunction implements IEasingFunction {
  6308. /** @hidden */
  6309. easeInCore(gradient: number): number;
  6310. }
  6311. /**
  6312. * Easing function with a bezier shape (see link below).
  6313. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  6314. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6315. */
  6316. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  6317. /** Defines the x component of the start tangent in the bezier curve */
  6318. x1: number;
  6319. /** Defines the y component of the start tangent in the bezier curve */
  6320. y1: number;
  6321. /** Defines the x component of the end tangent in the bezier curve */
  6322. x2: number;
  6323. /** Defines the y component of the end tangent in the bezier curve */
  6324. y2: number;
  6325. /**
  6326. * Instantiates a bezier function
  6327. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  6328. * @param x1 Defines the x component of the start tangent in the bezier curve
  6329. * @param y1 Defines the y component of the start tangent in the bezier curve
  6330. * @param x2 Defines the x component of the end tangent in the bezier curve
  6331. * @param y2 Defines the y component of the end tangent in the bezier curve
  6332. */
  6333. constructor(
  6334. /** Defines the x component of the start tangent in the bezier curve */
  6335. x1?: number,
  6336. /** Defines the y component of the start tangent in the bezier curve */
  6337. y1?: number,
  6338. /** Defines the x component of the end tangent in the bezier curve */
  6339. x2?: number,
  6340. /** Defines the y component of the end tangent in the bezier curve */
  6341. y2?: number);
  6342. /** @hidden */
  6343. easeInCore(gradient: number): number;
  6344. }
  6345. }
  6346. declare module "babylonjs/Animations/animationKey" {
  6347. /**
  6348. * Defines an interface which represents an animation key frame
  6349. */
  6350. export interface IAnimationKey {
  6351. /**
  6352. * Frame of the key frame
  6353. */
  6354. frame: number;
  6355. /**
  6356. * Value at the specifies key frame
  6357. */
  6358. value: any;
  6359. /**
  6360. * The input tangent for the cubic hermite spline
  6361. */
  6362. inTangent?: any;
  6363. /**
  6364. * The output tangent for the cubic hermite spline
  6365. */
  6366. outTangent?: any;
  6367. /**
  6368. * The animation interpolation type
  6369. */
  6370. interpolation?: AnimationKeyInterpolation;
  6371. }
  6372. /**
  6373. * Enum for the animation key frame interpolation type
  6374. */
  6375. export enum AnimationKeyInterpolation {
  6376. /**
  6377. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  6378. */
  6379. STEP = 1
  6380. }
  6381. }
  6382. declare module "babylonjs/Animations/animationRange" {
  6383. /**
  6384. * Represents the range of an animation
  6385. */
  6386. export class AnimationRange {
  6387. /**The name of the animation range**/
  6388. name: string;
  6389. /**The starting frame of the animation */
  6390. from: number;
  6391. /**The ending frame of the animation*/
  6392. to: number;
  6393. /**
  6394. * Initializes the range of an animation
  6395. * @param name The name of the animation range
  6396. * @param from The starting frame of the animation
  6397. * @param to The ending frame of the animation
  6398. */
  6399. constructor(
  6400. /**The name of the animation range**/
  6401. name: string,
  6402. /**The starting frame of the animation */
  6403. from: number,
  6404. /**The ending frame of the animation*/
  6405. to: number);
  6406. /**
  6407. * Makes a copy of the animation range
  6408. * @returns A copy of the animation range
  6409. */
  6410. clone(): AnimationRange;
  6411. }
  6412. }
  6413. declare module "babylonjs/Animations/animationEvent" {
  6414. /**
  6415. * Composed of a frame, and an action function
  6416. */
  6417. export class AnimationEvent {
  6418. /** The frame for which the event is triggered **/
  6419. frame: number;
  6420. /** The event to perform when triggered **/
  6421. action: (currentFrame: number) => void;
  6422. /** Specifies if the event should be triggered only once**/
  6423. onlyOnce?: boolean | undefined;
  6424. /**
  6425. * Specifies if the animation event is done
  6426. */
  6427. isDone: boolean;
  6428. /**
  6429. * Initializes the animation event
  6430. * @param frame The frame for which the event is triggered
  6431. * @param action The event to perform when triggered
  6432. * @param onlyOnce Specifies if the event should be triggered only once
  6433. */
  6434. constructor(
  6435. /** The frame for which the event is triggered **/
  6436. frame: number,
  6437. /** The event to perform when triggered **/
  6438. action: (currentFrame: number) => void,
  6439. /** Specifies if the event should be triggered only once**/
  6440. onlyOnce?: boolean | undefined);
  6441. /** @hidden */
  6442. _clone(): AnimationEvent;
  6443. }
  6444. }
  6445. declare module "babylonjs/Behaviors/behavior" {
  6446. import { Nullable } from "babylonjs/types";
  6447. /**
  6448. * Interface used to define a behavior
  6449. */
  6450. export interface Behavior<T> {
  6451. /** gets or sets behavior's name */
  6452. name: string;
  6453. /**
  6454. * Function called when the behavior needs to be initialized (after attaching it to a target)
  6455. */
  6456. init(): void;
  6457. /**
  6458. * Called when the behavior is attached to a target
  6459. * @param target defines the target where the behavior is attached to
  6460. */
  6461. attach(target: T): void;
  6462. /**
  6463. * Called when the behavior is detached from its target
  6464. */
  6465. detach(): void;
  6466. }
  6467. /**
  6468. * Interface implemented by classes supporting behaviors
  6469. */
  6470. export interface IBehaviorAware<T> {
  6471. /**
  6472. * Attach a behavior
  6473. * @param behavior defines the behavior to attach
  6474. * @returns the current host
  6475. */
  6476. addBehavior(behavior: Behavior<T>): T;
  6477. /**
  6478. * Remove a behavior from the current object
  6479. * @param behavior defines the behavior to detach
  6480. * @returns the current host
  6481. */
  6482. removeBehavior(behavior: Behavior<T>): T;
  6483. /**
  6484. * Gets a behavior using its name to search
  6485. * @param name defines the name to search
  6486. * @returns the behavior or null if not found
  6487. */
  6488. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  6489. }
  6490. }
  6491. declare module "babylonjs/Misc/smartArray" {
  6492. /**
  6493. * Defines an array and its length.
  6494. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  6495. */
  6496. export interface ISmartArrayLike<T> {
  6497. /**
  6498. * The data of the array.
  6499. */
  6500. data: Array<T>;
  6501. /**
  6502. * The active length of the array.
  6503. */
  6504. length: number;
  6505. }
  6506. /**
  6507. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  6508. */
  6509. export class SmartArray<T> implements ISmartArrayLike<T> {
  6510. /**
  6511. * The full set of data from the array.
  6512. */
  6513. data: Array<T>;
  6514. /**
  6515. * The active length of the array.
  6516. */
  6517. length: number;
  6518. protected _id: number;
  6519. /**
  6520. * Instantiates a Smart Array.
  6521. * @param capacity defines the default capacity of the array.
  6522. */
  6523. constructor(capacity: number);
  6524. /**
  6525. * Pushes a value at the end of the active data.
  6526. * @param value defines the object to push in the array.
  6527. */
  6528. push(value: T): void;
  6529. /**
  6530. * Iterates over the active data and apply the lambda to them.
  6531. * @param func defines the action to apply on each value.
  6532. */
  6533. forEach(func: (content: T) => void): void;
  6534. /**
  6535. * Sorts the full sets of data.
  6536. * @param compareFn defines the comparison function to apply.
  6537. */
  6538. sort(compareFn: (a: T, b: T) => number): void;
  6539. /**
  6540. * Resets the active data to an empty array.
  6541. */
  6542. reset(): void;
  6543. /**
  6544. * Releases all the data from the array as well as the array.
  6545. */
  6546. dispose(): void;
  6547. /**
  6548. * Concats the active data with a given array.
  6549. * @param array defines the data to concatenate with.
  6550. */
  6551. concat(array: any): void;
  6552. /**
  6553. * Returns the position of a value in the active data.
  6554. * @param value defines the value to find the index for
  6555. * @returns the index if found in the active data otherwise -1
  6556. */
  6557. indexOf(value: T): number;
  6558. /**
  6559. * Returns whether an element is part of the active data.
  6560. * @param value defines the value to look for
  6561. * @returns true if found in the active data otherwise false
  6562. */
  6563. contains(value: T): boolean;
  6564. private static _GlobalId;
  6565. }
  6566. /**
  6567. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  6568. * The data in this array can only be present once
  6569. */
  6570. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  6571. private _duplicateId;
  6572. /**
  6573. * Pushes a value at the end of the active data.
  6574. * THIS DOES NOT PREVENT DUPPLICATE DATA
  6575. * @param value defines the object to push in the array.
  6576. */
  6577. push(value: T): void;
  6578. /**
  6579. * Pushes a value at the end of the active data.
  6580. * If the data is already present, it won t be added again
  6581. * @param value defines the object to push in the array.
  6582. * @returns true if added false if it was already present
  6583. */
  6584. pushNoDuplicate(value: T): boolean;
  6585. /**
  6586. * Resets the active data to an empty array.
  6587. */
  6588. reset(): void;
  6589. /**
  6590. * Concats the active data with a given array.
  6591. * This ensures no dupplicate will be present in the result.
  6592. * @param array defines the data to concatenate with.
  6593. */
  6594. concatWithNoDuplicate(array: any): void;
  6595. }
  6596. }
  6597. declare module "babylonjs/Cameras/cameraInputsManager" {
  6598. import { Nullable } from "babylonjs/types";
  6599. import { Camera } from "babylonjs/Cameras/camera";
  6600. /**
  6601. * @ignore
  6602. * This is a list of all the different input types that are available in the application.
  6603. * Fo instance: ArcRotateCameraGamepadInput...
  6604. */
  6605. export var CameraInputTypes: {};
  6606. /**
  6607. * This is the contract to implement in order to create a new input class.
  6608. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  6609. */
  6610. export interface ICameraInput<TCamera extends Camera> {
  6611. /**
  6612. * Defines the camera the input is attached to.
  6613. */
  6614. camera: Nullable<TCamera>;
  6615. /**
  6616. * Gets the class name of the current intput.
  6617. * @returns the class name
  6618. */
  6619. getClassName(): string;
  6620. /**
  6621. * Get the friendly name associated with the input class.
  6622. * @returns the input friendly name
  6623. */
  6624. getSimpleName(): string;
  6625. /**
  6626. * Attach the input controls to a specific dom element to get the input from.
  6627. * @param element Defines the element the controls should be listened from
  6628. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6629. */
  6630. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  6631. /**
  6632. * Detach the current controls from the specified dom element.
  6633. * @param element Defines the element to stop listening the inputs from
  6634. */
  6635. detachControl(element: Nullable<HTMLElement>): void;
  6636. /**
  6637. * Update the current camera state depending on the inputs that have been used this frame.
  6638. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6639. */
  6640. checkInputs?: () => void;
  6641. }
  6642. /**
  6643. * Represents a map of input types to input instance or input index to input instance.
  6644. */
  6645. export interface CameraInputsMap<TCamera extends Camera> {
  6646. /**
  6647. * Accessor to the input by input type.
  6648. */
  6649. [name: string]: ICameraInput<TCamera>;
  6650. /**
  6651. * Accessor to the input by input index.
  6652. */
  6653. [idx: number]: ICameraInput<TCamera>;
  6654. }
  6655. /**
  6656. * This represents the input manager used within a camera.
  6657. * It helps dealing with all the different kind of input attached to a camera.
  6658. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  6659. */
  6660. export class CameraInputsManager<TCamera extends Camera> {
  6661. /**
  6662. * Defines the list of inputs attahed to the camera.
  6663. */
  6664. attached: CameraInputsMap<TCamera>;
  6665. /**
  6666. * Defines the dom element the camera is collecting inputs from.
  6667. * This is null if the controls have not been attached.
  6668. */
  6669. attachedElement: Nullable<HTMLElement>;
  6670. /**
  6671. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6672. */
  6673. noPreventDefault: boolean;
  6674. /**
  6675. * Defined the camera the input manager belongs to.
  6676. */
  6677. camera: TCamera;
  6678. /**
  6679. * Update the current camera state depending on the inputs that have been used this frame.
  6680. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6681. */
  6682. checkInputs: () => void;
  6683. /**
  6684. * Instantiate a new Camera Input Manager.
  6685. * @param camera Defines the camera the input manager blongs to
  6686. */
  6687. constructor(camera: TCamera);
  6688. /**
  6689. * Add an input method to a camera
  6690. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  6691. * @param input camera input method
  6692. */
  6693. add(input: ICameraInput<TCamera>): void;
  6694. /**
  6695. * Remove a specific input method from a camera
  6696. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  6697. * @param inputToRemove camera input method
  6698. */
  6699. remove(inputToRemove: ICameraInput<TCamera>): void;
  6700. /**
  6701. * Remove a specific input type from a camera
  6702. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  6703. * @param inputType the type of the input to remove
  6704. */
  6705. removeByType(inputType: string): void;
  6706. private _addCheckInputs;
  6707. /**
  6708. * Attach the input controls to the currently attached dom element to listen the events from.
  6709. * @param input Defines the input to attach
  6710. */
  6711. attachInput(input: ICameraInput<TCamera>): void;
  6712. /**
  6713. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  6714. * @param element Defines the dom element to collect the events from
  6715. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6716. */
  6717. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  6718. /**
  6719. * Detach the current manager inputs controls from a specific dom element.
  6720. * @param element Defines the dom element to collect the events from
  6721. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  6722. */
  6723. detachElement(element: HTMLElement, disconnect?: boolean): void;
  6724. /**
  6725. * Rebuild the dynamic inputCheck function from the current list of
  6726. * defined inputs in the manager.
  6727. */
  6728. rebuildInputCheck(): void;
  6729. /**
  6730. * Remove all attached input methods from a camera
  6731. */
  6732. clear(): void;
  6733. /**
  6734. * Serialize the current input manager attached to a camera.
  6735. * This ensures than once parsed,
  6736. * the input associated to the camera will be identical to the current ones
  6737. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  6738. */
  6739. serialize(serializedCamera: any): void;
  6740. /**
  6741. * Parses an input manager serialized JSON to restore the previous list of inputs
  6742. * and states associated to a camera.
  6743. * @param parsedCamera Defines the JSON to parse
  6744. */
  6745. parse(parsedCamera: any): void;
  6746. }
  6747. }
  6748. declare module "babylonjs/Collisions/intersectionInfo" {
  6749. import { Nullable } from "babylonjs/types";
  6750. /**
  6751. * @hidden
  6752. */
  6753. export class IntersectionInfo {
  6754. bu: Nullable<number>;
  6755. bv: Nullable<number>;
  6756. distance: number;
  6757. faceId: number;
  6758. subMeshId: number;
  6759. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  6760. }
  6761. }
  6762. declare module "babylonjs/Maths/math.plane" {
  6763. import { DeepImmutable } from "babylonjs/types";
  6764. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  6765. /**
  6766. * Represens a plane by the equation ax + by + cz + d = 0
  6767. */
  6768. export class Plane {
  6769. private static _TmpMatrix;
  6770. /**
  6771. * Normal of the plane (a,b,c)
  6772. */
  6773. normal: Vector3;
  6774. /**
  6775. * d component of the plane
  6776. */
  6777. d: number;
  6778. /**
  6779. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  6780. * @param a a component of the plane
  6781. * @param b b component of the plane
  6782. * @param c c component of the plane
  6783. * @param d d component of the plane
  6784. */
  6785. constructor(a: number, b: number, c: number, d: number);
  6786. /**
  6787. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  6788. */
  6789. asArray(): number[];
  6790. /**
  6791. * @returns a new plane copied from the current Plane.
  6792. */
  6793. clone(): Plane;
  6794. /**
  6795. * @returns the string "Plane".
  6796. */
  6797. getClassName(): string;
  6798. /**
  6799. * @returns the Plane hash code.
  6800. */
  6801. getHashCode(): number;
  6802. /**
  6803. * Normalize the current Plane in place.
  6804. * @returns the updated Plane.
  6805. */
  6806. normalize(): Plane;
  6807. /**
  6808. * Applies a transformation the plane and returns the result
  6809. * @param transformation the transformation matrix to be applied to the plane
  6810. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  6811. */
  6812. transform(transformation: DeepImmutable<Matrix>): Plane;
  6813. /**
  6814. * Calcualtte the dot product between the point and the plane normal
  6815. * @param point point to calculate the dot product with
  6816. * @returns the dot product (float) of the point coordinates and the plane normal.
  6817. */
  6818. dotCoordinate(point: DeepImmutable<Vector3>): number;
  6819. /**
  6820. * Updates the current Plane from the plane defined by the three given points.
  6821. * @param point1 one of the points used to contruct the plane
  6822. * @param point2 one of the points used to contruct the plane
  6823. * @param point3 one of the points used to contruct the plane
  6824. * @returns the updated Plane.
  6825. */
  6826. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  6827. /**
  6828. * Checks if the plane is facing a given direction
  6829. * @param direction the direction to check if the plane is facing
  6830. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  6831. * @returns True is the vector "direction" is the same side than the plane normal.
  6832. */
  6833. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  6834. /**
  6835. * Calculates the distance to a point
  6836. * @param point point to calculate distance to
  6837. * @returns the signed distance (float) from the given point to the Plane.
  6838. */
  6839. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  6840. /**
  6841. * Creates a plane from an array
  6842. * @param array the array to create a plane from
  6843. * @returns a new Plane from the given array.
  6844. */
  6845. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  6846. /**
  6847. * Creates a plane from three points
  6848. * @param point1 point used to create the plane
  6849. * @param point2 point used to create the plane
  6850. * @param point3 point used to create the plane
  6851. * @returns a new Plane defined by the three given points.
  6852. */
  6853. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  6854. /**
  6855. * Creates a plane from an origin point and a normal
  6856. * @param origin origin of the plane to be constructed
  6857. * @param normal normal of the plane to be constructed
  6858. * @returns a new Plane the normal vector to this plane at the given origin point.
  6859. * Note : the vector "normal" is updated because normalized.
  6860. */
  6861. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): Plane;
  6862. /**
  6863. * Calculates the distance from a plane and a point
  6864. * @param origin origin of the plane to be constructed
  6865. * @param normal normal of the plane to be constructed
  6866. * @param point point to calculate distance to
  6867. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  6868. */
  6869. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  6870. }
  6871. }
  6872. declare module "babylonjs/Culling/boundingSphere" {
  6873. import { DeepImmutable } from "babylonjs/types";
  6874. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  6875. import { Plane } from "babylonjs/Maths/math.plane";
  6876. /**
  6877. * Class used to store bounding sphere information
  6878. */
  6879. export class BoundingSphere {
  6880. /**
  6881. * Gets the center of the bounding sphere in local space
  6882. */
  6883. readonly center: Vector3;
  6884. /**
  6885. * Radius of the bounding sphere in local space
  6886. */
  6887. radius: number;
  6888. /**
  6889. * Gets the center of the bounding sphere in world space
  6890. */
  6891. readonly centerWorld: Vector3;
  6892. /**
  6893. * Radius of the bounding sphere in world space
  6894. */
  6895. radiusWorld: number;
  6896. /**
  6897. * Gets the minimum vector in local space
  6898. */
  6899. readonly minimum: Vector3;
  6900. /**
  6901. * Gets the maximum vector in local space
  6902. */
  6903. readonly maximum: Vector3;
  6904. private _worldMatrix;
  6905. private static readonly TmpVector3;
  6906. /**
  6907. * Creates a new bounding sphere
  6908. * @param min defines the minimum vector (in local space)
  6909. * @param max defines the maximum vector (in local space)
  6910. * @param worldMatrix defines the new world matrix
  6911. */
  6912. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6913. /**
  6914. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  6915. * @param min defines the new minimum vector (in local space)
  6916. * @param max defines the new maximum vector (in local space)
  6917. * @param worldMatrix defines the new world matrix
  6918. */
  6919. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6920. /**
  6921. * Scale the current bounding sphere by applying a scale factor
  6922. * @param factor defines the scale factor to apply
  6923. * @returns the current bounding box
  6924. */
  6925. scale(factor: number): BoundingSphere;
  6926. /**
  6927. * Gets the world matrix of the bounding box
  6928. * @returns a matrix
  6929. */
  6930. getWorldMatrix(): DeepImmutable<Matrix>;
  6931. /** @hidden */
  6932. _update(worldMatrix: DeepImmutable<Matrix>): void;
  6933. /**
  6934. * Tests if the bounding sphere is intersecting the frustum planes
  6935. * @param frustumPlanes defines the frustum planes to test
  6936. * @returns true if there is an intersection
  6937. */
  6938. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6939. /**
  6940. * Tests if the bounding sphere center is in between the frustum planes.
  6941. * Used for optimistic fast inclusion.
  6942. * @param frustumPlanes defines the frustum planes to test
  6943. * @returns true if the sphere center is in between the frustum planes
  6944. */
  6945. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6946. /**
  6947. * Tests if a point is inside the bounding sphere
  6948. * @param point defines the point to test
  6949. * @returns true if the point is inside the bounding sphere
  6950. */
  6951. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6952. /**
  6953. * Checks if two sphere intersct
  6954. * @param sphere0 sphere 0
  6955. * @param sphere1 sphere 1
  6956. * @returns true if the speres intersect
  6957. */
  6958. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  6959. }
  6960. }
  6961. declare module "babylonjs/Culling/boundingBox" {
  6962. import { DeepImmutable } from "babylonjs/types";
  6963. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  6964. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  6965. import { ICullable } from "babylonjs/Culling/boundingInfo";
  6966. import { Plane } from "babylonjs/Maths/math.plane";
  6967. /**
  6968. * Class used to store bounding box information
  6969. */
  6970. export class BoundingBox implements ICullable {
  6971. /**
  6972. * Gets the 8 vectors representing the bounding box in local space
  6973. */
  6974. readonly vectors: Vector3[];
  6975. /**
  6976. * Gets the center of the bounding box in local space
  6977. */
  6978. readonly center: Vector3;
  6979. /**
  6980. * Gets the center of the bounding box in world space
  6981. */
  6982. readonly centerWorld: Vector3;
  6983. /**
  6984. * Gets the extend size in local space
  6985. */
  6986. readonly extendSize: Vector3;
  6987. /**
  6988. * Gets the extend size in world space
  6989. */
  6990. readonly extendSizeWorld: Vector3;
  6991. /**
  6992. * Gets the OBB (object bounding box) directions
  6993. */
  6994. readonly directions: Vector3[];
  6995. /**
  6996. * Gets the 8 vectors representing the bounding box in world space
  6997. */
  6998. readonly vectorsWorld: Vector3[];
  6999. /**
  7000. * Gets the minimum vector in world space
  7001. */
  7002. readonly minimumWorld: Vector3;
  7003. /**
  7004. * Gets the maximum vector in world space
  7005. */
  7006. readonly maximumWorld: Vector3;
  7007. /**
  7008. * Gets the minimum vector in local space
  7009. */
  7010. readonly minimum: Vector3;
  7011. /**
  7012. * Gets the maximum vector in local space
  7013. */
  7014. readonly maximum: Vector3;
  7015. private _worldMatrix;
  7016. private static readonly TmpVector3;
  7017. /**
  7018. * @hidden
  7019. */
  7020. _tag: number;
  7021. /**
  7022. * Creates a new bounding box
  7023. * @param min defines the minimum vector (in local space)
  7024. * @param max defines the maximum vector (in local space)
  7025. * @param worldMatrix defines the new world matrix
  7026. */
  7027. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7028. /**
  7029. * Recreates the entire bounding box from scratch as if we call the constructor in place
  7030. * @param min defines the new minimum vector (in local space)
  7031. * @param max defines the new maximum vector (in local space)
  7032. * @param worldMatrix defines the new world matrix
  7033. */
  7034. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7035. /**
  7036. * Scale the current bounding box by applying a scale factor
  7037. * @param factor defines the scale factor to apply
  7038. * @returns the current bounding box
  7039. */
  7040. scale(factor: number): BoundingBox;
  7041. /**
  7042. * Gets the world matrix of the bounding box
  7043. * @returns a matrix
  7044. */
  7045. getWorldMatrix(): DeepImmutable<Matrix>;
  7046. /** @hidden */
  7047. _update(world: DeepImmutable<Matrix>): void;
  7048. /**
  7049. * Tests if the bounding box is intersecting the frustum planes
  7050. * @param frustumPlanes defines the frustum planes to test
  7051. * @returns true if there is an intersection
  7052. */
  7053. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7054. /**
  7055. * Tests if the bounding box is entirely inside the frustum planes
  7056. * @param frustumPlanes defines the frustum planes to test
  7057. * @returns true if there is an inclusion
  7058. */
  7059. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7060. /**
  7061. * Tests if a point is inside the bounding box
  7062. * @param point defines the point to test
  7063. * @returns true if the point is inside the bounding box
  7064. */
  7065. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7066. /**
  7067. * Tests if the bounding box intersects with a bounding sphere
  7068. * @param sphere defines the sphere to test
  7069. * @returns true if there is an intersection
  7070. */
  7071. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  7072. /**
  7073. * Tests if the bounding box intersects with a box defined by a min and max vectors
  7074. * @param min defines the min vector to use
  7075. * @param max defines the max vector to use
  7076. * @returns true if there is an intersection
  7077. */
  7078. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  7079. /**
  7080. * Tests if two bounding boxes are intersections
  7081. * @param box0 defines the first box to test
  7082. * @param box1 defines the second box to test
  7083. * @returns true if there is an intersection
  7084. */
  7085. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  7086. /**
  7087. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  7088. * @param minPoint defines the minimum vector of the bounding box
  7089. * @param maxPoint defines the maximum vector of the bounding box
  7090. * @param sphereCenter defines the sphere center
  7091. * @param sphereRadius defines the sphere radius
  7092. * @returns true if there is an intersection
  7093. */
  7094. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  7095. /**
  7096. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  7097. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7098. * @param frustumPlanes defines the frustum planes to test
  7099. * @return true if there is an inclusion
  7100. */
  7101. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7102. /**
  7103. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  7104. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7105. * @param frustumPlanes defines the frustum planes to test
  7106. * @return true if there is an intersection
  7107. */
  7108. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7109. }
  7110. }
  7111. declare module "babylonjs/Collisions/collider" {
  7112. import { Nullable, IndicesArray } from "babylonjs/types";
  7113. import { Vector3 } from "babylonjs/Maths/math.vector";
  7114. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  7115. import { Plane } from "babylonjs/Maths/math.plane";
  7116. /** @hidden */
  7117. export class Collider {
  7118. /** Define if a collision was found */
  7119. collisionFound: boolean;
  7120. /**
  7121. * Define last intersection point in local space
  7122. */
  7123. intersectionPoint: Vector3;
  7124. /**
  7125. * Define last collided mesh
  7126. */
  7127. collidedMesh: Nullable<AbstractMesh>;
  7128. private _collisionPoint;
  7129. private _planeIntersectionPoint;
  7130. private _tempVector;
  7131. private _tempVector2;
  7132. private _tempVector3;
  7133. private _tempVector4;
  7134. private _edge;
  7135. private _baseToVertex;
  7136. private _destinationPoint;
  7137. private _slidePlaneNormal;
  7138. private _displacementVector;
  7139. /** @hidden */
  7140. _radius: Vector3;
  7141. /** @hidden */
  7142. _retry: number;
  7143. private _velocity;
  7144. private _basePoint;
  7145. private _epsilon;
  7146. /** @hidden */
  7147. _velocityWorldLength: number;
  7148. /** @hidden */
  7149. _basePointWorld: Vector3;
  7150. private _velocityWorld;
  7151. private _normalizedVelocity;
  7152. /** @hidden */
  7153. _initialVelocity: Vector3;
  7154. /** @hidden */
  7155. _initialPosition: Vector3;
  7156. private _nearestDistance;
  7157. private _collisionMask;
  7158. collisionMask: number;
  7159. /**
  7160. * Gets the plane normal used to compute the sliding response (in local space)
  7161. */
  7162. readonly slidePlaneNormal: Vector3;
  7163. /** @hidden */
  7164. _initialize(source: Vector3, dir: Vector3, e: number): void;
  7165. /** @hidden */
  7166. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  7167. /** @hidden */
  7168. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  7169. /** @hidden */
  7170. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  7171. /** @hidden */
  7172. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  7173. /** @hidden */
  7174. _getResponse(pos: Vector3, vel: Vector3): void;
  7175. }
  7176. }
  7177. declare module "babylonjs/Culling/boundingInfo" {
  7178. import { DeepImmutable } from "babylonjs/types";
  7179. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  7180. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  7181. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  7182. import { Plane } from "babylonjs/Maths/math.plane";
  7183. import { Collider } from "babylonjs/Collisions/collider";
  7184. /**
  7185. * Interface for cullable objects
  7186. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  7187. */
  7188. export interface ICullable {
  7189. /**
  7190. * Checks if the object or part of the object is in the frustum
  7191. * @param frustumPlanes Camera near/planes
  7192. * @returns true if the object is in frustum otherwise false
  7193. */
  7194. isInFrustum(frustumPlanes: Plane[]): boolean;
  7195. /**
  7196. * Checks if a cullable object (mesh...) is in the camera frustum
  7197. * Unlike isInFrustum this cheks the full bounding box
  7198. * @param frustumPlanes Camera near/planes
  7199. * @returns true if the object is in frustum otherwise false
  7200. */
  7201. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  7202. }
  7203. /**
  7204. * Info for a bounding data of a mesh
  7205. */
  7206. export class BoundingInfo implements ICullable {
  7207. /**
  7208. * Bounding box for the mesh
  7209. */
  7210. readonly boundingBox: BoundingBox;
  7211. /**
  7212. * Bounding sphere for the mesh
  7213. */
  7214. readonly boundingSphere: BoundingSphere;
  7215. private _isLocked;
  7216. private static readonly TmpVector3;
  7217. /**
  7218. * Constructs bounding info
  7219. * @param minimum min vector of the bounding box/sphere
  7220. * @param maximum max vector of the bounding box/sphere
  7221. * @param worldMatrix defines the new world matrix
  7222. */
  7223. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7224. /**
  7225. * Recreates the entire bounding info from scratch as if we call the constructor in place
  7226. * @param min defines the new minimum vector (in local space)
  7227. * @param max defines the new maximum vector (in local space)
  7228. * @param worldMatrix defines the new world matrix
  7229. */
  7230. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7231. /**
  7232. * min vector of the bounding box/sphere
  7233. */
  7234. readonly minimum: Vector3;
  7235. /**
  7236. * max vector of the bounding box/sphere
  7237. */
  7238. readonly maximum: Vector3;
  7239. /**
  7240. * If the info is locked and won't be updated to avoid perf overhead
  7241. */
  7242. isLocked: boolean;
  7243. /**
  7244. * Updates the bounding sphere and box
  7245. * @param world world matrix to be used to update
  7246. */
  7247. update(world: DeepImmutable<Matrix>): void;
  7248. /**
  7249. * Recreate the bounding info to be centered around a specific point given a specific extend.
  7250. * @param center New center of the bounding info
  7251. * @param extend New extend of the bounding info
  7252. * @returns the current bounding info
  7253. */
  7254. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  7255. /**
  7256. * Scale the current bounding info by applying a scale factor
  7257. * @param factor defines the scale factor to apply
  7258. * @returns the current bounding info
  7259. */
  7260. scale(factor: number): BoundingInfo;
  7261. /**
  7262. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  7263. * @param frustumPlanes defines the frustum to test
  7264. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  7265. * @returns true if the bounding info is in the frustum planes
  7266. */
  7267. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  7268. /**
  7269. * Gets the world distance between the min and max points of the bounding box
  7270. */
  7271. readonly diagonalLength: number;
  7272. /**
  7273. * Checks if a cullable object (mesh...) is in the camera frustum
  7274. * Unlike isInFrustum this cheks the full bounding box
  7275. * @param frustumPlanes Camera near/planes
  7276. * @returns true if the object is in frustum otherwise false
  7277. */
  7278. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7279. /** @hidden */
  7280. _checkCollision(collider: Collider): boolean;
  7281. /**
  7282. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  7283. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7284. * @param point the point to check intersection with
  7285. * @returns if the point intersects
  7286. */
  7287. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7288. /**
  7289. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  7290. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7291. * @param boundingInfo the bounding info to check intersection with
  7292. * @param precise if the intersection should be done using OBB
  7293. * @returns if the bounding info intersects
  7294. */
  7295. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  7296. }
  7297. }
  7298. declare module "babylonjs/Maths/math.functions" {
  7299. import { FloatArray, Nullable, IndicesArray } from "babylonjs/types";
  7300. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  7301. /**
  7302. * Extracts minimum and maximum values from a list of indexed positions
  7303. * @param positions defines the positions to use
  7304. * @param indices defines the indices to the positions
  7305. * @param indexStart defines the start index
  7306. * @param indexCount defines the end index
  7307. * @param bias defines bias value to add to the result
  7308. * @return minimum and maximum values
  7309. */
  7310. export function extractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  7311. minimum: Vector3;
  7312. maximum: Vector3;
  7313. };
  7314. /**
  7315. * Extracts minimum and maximum values from a list of positions
  7316. * @param positions defines the positions to use
  7317. * @param start defines the start index in the positions array
  7318. * @param count defines the number of positions to handle
  7319. * @param bias defines bias value to add to the result
  7320. * @param stride defines the stride size to use (distance between two positions in the positions array)
  7321. * @return minimum and maximum values
  7322. */
  7323. export function extractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  7324. minimum: Vector3;
  7325. maximum: Vector3;
  7326. };
  7327. }
  7328. declare module "babylonjs/Misc/iInspectable" {
  7329. /**
  7330. * Enum that determines the text-wrapping mode to use.
  7331. */
  7332. export enum InspectableType {
  7333. /**
  7334. * Checkbox for booleans
  7335. */
  7336. Checkbox = 0,
  7337. /**
  7338. * Sliders for numbers
  7339. */
  7340. Slider = 1,
  7341. /**
  7342. * Vector3
  7343. */
  7344. Vector3 = 2,
  7345. /**
  7346. * Quaternions
  7347. */
  7348. Quaternion = 3,
  7349. /**
  7350. * Color3
  7351. */
  7352. Color3 = 4,
  7353. /**
  7354. * String
  7355. */
  7356. String = 5
  7357. }
  7358. /**
  7359. * Interface used to define custom inspectable properties.
  7360. * This interface is used by the inspector to display custom property grids
  7361. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  7362. */
  7363. export interface IInspectable {
  7364. /**
  7365. * Gets the label to display
  7366. */
  7367. label: string;
  7368. /**
  7369. * Gets the name of the property to edit
  7370. */
  7371. propertyName: string;
  7372. /**
  7373. * Gets the type of the editor to use
  7374. */
  7375. type: InspectableType;
  7376. /**
  7377. * Gets the minimum value of the property when using in "slider" mode
  7378. */
  7379. min?: number;
  7380. /**
  7381. * Gets the maximum value of the property when using in "slider" mode
  7382. */
  7383. max?: number;
  7384. /**
  7385. * Gets the setp to use when using in "slider" mode
  7386. */
  7387. step?: number;
  7388. }
  7389. }
  7390. declare module "babylonjs/Misc/timingTools" {
  7391. /**
  7392. * Class used to provide helper for timing
  7393. */
  7394. export class TimingTools {
  7395. /**
  7396. * Polyfill for setImmediate
  7397. * @param action defines the action to execute after the current execution block
  7398. */
  7399. static SetImmediate(action: () => void): void;
  7400. }
  7401. }
  7402. declare module "babylonjs/Misc/instantiationTools" {
  7403. /**
  7404. * Class used to enable instatition of objects by class name
  7405. */
  7406. export class InstantiationTools {
  7407. /**
  7408. * Use this object to register external classes like custom textures or material
  7409. * to allow the laoders to instantiate them
  7410. */
  7411. static RegisteredExternalClasses: {
  7412. [key: string]: Object;
  7413. };
  7414. /**
  7415. * Tries to instantiate a new object from a given class name
  7416. * @param className defines the class name to instantiate
  7417. * @returns the new object or null if the system was not able to do the instantiation
  7418. */
  7419. static Instantiate(className: string): any;
  7420. }
  7421. }
  7422. declare module "babylonjs/Materials/Textures/internalTextureLoader" {
  7423. import { Nullable } from "babylonjs/types";
  7424. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  7425. /**
  7426. * This represents the required contract to create a new type of texture loader.
  7427. */
  7428. export interface IInternalTextureLoader {
  7429. /**
  7430. * Defines wether the loader supports cascade loading the different faces.
  7431. */
  7432. supportCascades: boolean;
  7433. /**
  7434. * This returns if the loader support the current file information.
  7435. * @param extension defines the file extension of the file being loaded
  7436. * @param textureFormatInUse defines the current compressed format in use iun the engine
  7437. * @param fallback defines the fallback internal texture if any
  7438. * @param isBase64 defines whether the texture is encoded as a base64
  7439. * @param isBuffer defines whether the texture data are stored as a buffer
  7440. * @returns true if the loader can load the specified file
  7441. */
  7442. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  7443. /**
  7444. * Transform the url before loading if required.
  7445. * @param rootUrl the url of the texture
  7446. * @param textureFormatInUse defines the current compressed format in use iun the engine
  7447. * @returns the transformed texture
  7448. */
  7449. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  7450. /**
  7451. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  7452. * @param rootUrl the url of the texture
  7453. * @param textureFormatInUse defines the current compressed format in use iun the engine
  7454. * @returns the fallback texture
  7455. */
  7456. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  7457. /**
  7458. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  7459. * @param data contains the texture data
  7460. * @param texture defines the BabylonJS internal texture
  7461. * @param createPolynomials will be true if polynomials have been requested
  7462. * @param onLoad defines the callback to trigger once the texture is ready
  7463. * @param onError defines the callback to trigger in case of error
  7464. */
  7465. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  7466. /**
  7467. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  7468. * @param data contains the texture data
  7469. * @param texture defines the BabylonJS internal texture
  7470. * @param callback defines the method to call once ready to upload
  7471. */
  7472. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  7473. }
  7474. }
  7475. declare module "babylonjs/Engines/Extensions/engine.cubeTexture" {
  7476. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  7477. import { Nullable } from "babylonjs/types";
  7478. import { Scene } from "babylonjs/scene";
  7479. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  7480. module "babylonjs/Engines/engine" {
  7481. interface Engine {
  7482. /**
  7483. * Creates a depth stencil cube texture.
  7484. * This is only available in WebGL 2.
  7485. * @param size The size of face edge in the cube texture.
  7486. * @param options The options defining the cube texture.
  7487. * @returns The cube texture
  7488. */
  7489. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  7490. /**
  7491. * Creates a cube texture
  7492. * @param rootUrl defines the url where the files to load is located
  7493. * @param scene defines the current scene
  7494. * @param files defines the list of files to load (1 per face)
  7495. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7496. * @param onLoad defines an optional callback raised when the texture is loaded
  7497. * @param onError defines an optional callback raised if there is an issue to load the texture
  7498. * @param format defines the format of the data
  7499. * @param forcedExtension defines the extension to use to pick the right loader
  7500. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7501. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7502. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7503. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  7504. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (defualt: empty array)
  7505. * @returns the cube texture as an InternalTexture
  7506. */
  7507. 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;
  7508. /**
  7509. * Creates a cube texture
  7510. * @param rootUrl defines the url where the files to load is located
  7511. * @param scene defines the current scene
  7512. * @param files defines the list of files to load (1 per face)
  7513. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7514. * @param onLoad defines an optional callback raised when the texture is loaded
  7515. * @param onError defines an optional callback raised if there is an issue to load the texture
  7516. * @param format defines the format of the data
  7517. * @param forcedExtension defines the extension to use to pick the right loader
  7518. * @returns the cube texture as an InternalTexture
  7519. */
  7520. 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;
  7521. /**
  7522. * Creates a cube texture
  7523. * @param rootUrl defines the url where the files to load is located
  7524. * @param scene defines the current scene
  7525. * @param files defines the list of files to load (1 per face)
  7526. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7527. * @param onLoad defines an optional callback raised when the texture is loaded
  7528. * @param onError defines an optional callback raised if there is an issue to load the texture
  7529. * @param format defines the format of the data
  7530. * @param forcedExtension defines the extension to use to pick the right loader
  7531. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7532. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7533. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7534. * @returns the cube texture as an InternalTexture
  7535. */
  7536. 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;
  7537. /** @hidden */
  7538. _partialLoadFile(url: string, index: number, loadedFiles: (string | ArrayBuffer)[], onfinish: (files: (string | ArrayBuffer)[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  7539. /** @hidden */
  7540. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: (string | ArrayBuffer)[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  7541. /** @hidden */
  7542. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  7543. /** @hidden */
  7544. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  7545. }
  7546. }
  7547. }
  7548. declare module "babylonjs/Materials/Textures/cubeTexture" {
  7549. import { Nullable } from "babylonjs/types";
  7550. import { Scene } from "babylonjs/scene";
  7551. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  7552. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  7553. import "babylonjs/Engines/Extensions/engine.cubeTexture";
  7554. /**
  7555. * Class for creating a cube texture
  7556. */
  7557. export class CubeTexture extends BaseTexture {
  7558. private _delayedOnLoad;
  7559. /**
  7560. * The url of the texture
  7561. */
  7562. url: string;
  7563. /**
  7564. * Gets or sets the center of the bounding box associated with the cube texture.
  7565. * It must define where the camera used to render the texture was set
  7566. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7567. */
  7568. boundingBoxPosition: Vector3;
  7569. private _boundingBoxSize;
  7570. /**
  7571. * Gets or sets the size of the bounding box associated with the cube texture
  7572. * When defined, the cubemap will switch to local mode
  7573. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  7574. * @example https://www.babylonjs-playground.com/#RNASML
  7575. */
  7576. /**
  7577. * Returns the bounding box size
  7578. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7579. */
  7580. boundingBoxSize: Vector3;
  7581. protected _rotationY: number;
  7582. /**
  7583. * Sets texture matrix rotation angle around Y axis in radians.
  7584. */
  7585. /**
  7586. * Gets texture matrix rotation angle around Y axis radians.
  7587. */
  7588. rotationY: number;
  7589. /**
  7590. * Are mip maps generated for this texture or not.
  7591. */
  7592. readonly noMipmap: boolean;
  7593. private _noMipmap;
  7594. private _files;
  7595. private _extensions;
  7596. private _textureMatrix;
  7597. private _format;
  7598. private _createPolynomials;
  7599. /** @hidden */
  7600. _prefiltered: boolean;
  7601. /**
  7602. * Creates a cube texture from an array of image urls
  7603. * @param files defines an array of image urls
  7604. * @param scene defines the hosting scene
  7605. * @param noMipmap specifies if mip maps are not used
  7606. * @returns a cube texture
  7607. */
  7608. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  7609. /**
  7610. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  7611. * @param url defines the url of the prefiltered texture
  7612. * @param scene defines the scene the texture is attached to
  7613. * @param forcedExtension defines the extension of the file if different from the url
  7614. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7615. * @return the prefiltered texture
  7616. */
  7617. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  7618. /**
  7619. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  7620. * as prefiltered data.
  7621. * @param rootUrl defines the url of the texture or the root name of the six images
  7622. * @param scene defines the scene the texture is attached to
  7623. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  7624. * @param noMipmap defines if mipmaps should be created or not
  7625. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  7626. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  7627. * @param onError defines a callback triggered in case of error during load
  7628. * @param format defines the internal format to use for the texture once loaded
  7629. * @param prefiltered defines whether or not the texture is created from prefiltered data
  7630. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  7631. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7632. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7633. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7634. * @return the cube texture
  7635. */
  7636. 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);
  7637. /**
  7638. * Gets a boolean indicating if the cube texture contains prefiltered mips (used to simulate roughness with PBR)
  7639. */
  7640. readonly isPrefiltered: boolean;
  7641. /**
  7642. * Get the current class name of the texture useful for serialization or dynamic coding.
  7643. * @returns "CubeTexture"
  7644. */
  7645. getClassName(): string;
  7646. /**
  7647. * Update the url (and optional buffer) of this texture if url was null during construction.
  7648. * @param url the url of the texture
  7649. * @param forcedExtension defines the extension to use
  7650. * @param onLoad callback called when the texture is loaded (defaults to null)
  7651. */
  7652. updateURL(url: string, forcedExtension?: string, onLoad?: () => void): void;
  7653. /**
  7654. * Delays loading of the cube texture
  7655. * @param forcedExtension defines the extension to use
  7656. */
  7657. delayLoad(forcedExtension?: string): void;
  7658. /**
  7659. * Returns the reflection texture matrix
  7660. * @returns the reflection texture matrix
  7661. */
  7662. getReflectionTextureMatrix(): Matrix;
  7663. /**
  7664. * Sets the reflection texture matrix
  7665. * @param value Reflection texture matrix
  7666. */
  7667. setReflectionTextureMatrix(value: Matrix): void;
  7668. /**
  7669. * Parses text to create a cube texture
  7670. * @param parsedTexture define the serialized text to read from
  7671. * @param scene defines the hosting scene
  7672. * @param rootUrl defines the root url of the cube texture
  7673. * @returns a cube texture
  7674. */
  7675. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  7676. /**
  7677. * Makes a clone, or deep copy, of the cube texture
  7678. * @returns a new cube texture
  7679. */
  7680. clone(): CubeTexture;
  7681. }
  7682. }
  7683. declare module "babylonjs/Materials/materialDefines" {
  7684. /**
  7685. * Manages the defines for the Material
  7686. */
  7687. export class MaterialDefines {
  7688. /** @hidden */
  7689. protected _keys: string[];
  7690. private _isDirty;
  7691. /** @hidden */
  7692. _renderId: number;
  7693. /** @hidden */
  7694. _areLightsDirty: boolean;
  7695. /** @hidden */
  7696. _areLightsDisposed: boolean;
  7697. /** @hidden */
  7698. _areAttributesDirty: boolean;
  7699. /** @hidden */
  7700. _areTexturesDirty: boolean;
  7701. /** @hidden */
  7702. _areFresnelDirty: boolean;
  7703. /** @hidden */
  7704. _areMiscDirty: boolean;
  7705. /** @hidden */
  7706. _areImageProcessingDirty: boolean;
  7707. /** @hidden */
  7708. _normals: boolean;
  7709. /** @hidden */
  7710. _uvs: boolean;
  7711. /** @hidden */
  7712. _needNormals: boolean;
  7713. /** @hidden */
  7714. _needUVs: boolean;
  7715. [id: string]: any;
  7716. /**
  7717. * Specifies if the material needs to be re-calculated
  7718. */
  7719. readonly isDirty: boolean;
  7720. /**
  7721. * Marks the material to indicate that it has been re-calculated
  7722. */
  7723. markAsProcessed(): void;
  7724. /**
  7725. * Marks the material to indicate that it needs to be re-calculated
  7726. */
  7727. markAsUnprocessed(): void;
  7728. /**
  7729. * Marks the material to indicate all of its defines need to be re-calculated
  7730. */
  7731. markAllAsDirty(): void;
  7732. /**
  7733. * Marks the material to indicate that image processing needs to be re-calculated
  7734. */
  7735. markAsImageProcessingDirty(): void;
  7736. /**
  7737. * Marks the material to indicate the lights need to be re-calculated
  7738. * @param disposed Defines whether the light is dirty due to dispose or not
  7739. */
  7740. markAsLightDirty(disposed?: boolean): void;
  7741. /**
  7742. * Marks the attribute state as changed
  7743. */
  7744. markAsAttributesDirty(): void;
  7745. /**
  7746. * Marks the texture state as changed
  7747. */
  7748. markAsTexturesDirty(): void;
  7749. /**
  7750. * Marks the fresnel state as changed
  7751. */
  7752. markAsFresnelDirty(): void;
  7753. /**
  7754. * Marks the misc state as changed
  7755. */
  7756. markAsMiscDirty(): void;
  7757. /**
  7758. * Rebuilds the material defines
  7759. */
  7760. rebuild(): void;
  7761. /**
  7762. * Specifies if two material defines are equal
  7763. * @param other - A material define instance to compare to
  7764. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  7765. */
  7766. isEqual(other: MaterialDefines): boolean;
  7767. /**
  7768. * Clones this instance's defines to another instance
  7769. * @param other - material defines to clone values to
  7770. */
  7771. cloneTo(other: MaterialDefines): void;
  7772. /**
  7773. * Resets the material define values
  7774. */
  7775. reset(): void;
  7776. /**
  7777. * Converts the material define values to a string
  7778. * @returns - String of material define information
  7779. */
  7780. toString(): string;
  7781. }
  7782. }
  7783. declare module "babylonjs/Materials/colorCurves" {
  7784. import { Effect } from "babylonjs/Materials/effect";
  7785. /**
  7786. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  7787. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  7788. * 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;
  7789. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  7790. */
  7791. export class ColorCurves {
  7792. private _dirty;
  7793. private _tempColor;
  7794. private _globalCurve;
  7795. private _highlightsCurve;
  7796. private _midtonesCurve;
  7797. private _shadowsCurve;
  7798. private _positiveCurve;
  7799. private _negativeCurve;
  7800. private _globalHue;
  7801. private _globalDensity;
  7802. private _globalSaturation;
  7803. private _globalExposure;
  7804. /**
  7805. * Gets the global Hue value.
  7806. * 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).
  7807. */
  7808. /**
  7809. * Sets the global Hue value.
  7810. * 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).
  7811. */
  7812. globalHue: number;
  7813. /**
  7814. * Gets the global Density value.
  7815. * 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.
  7816. * Values less than zero provide a filter of opposite hue.
  7817. */
  7818. /**
  7819. * Sets the global Density value.
  7820. * 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.
  7821. * Values less than zero provide a filter of opposite hue.
  7822. */
  7823. globalDensity: number;
  7824. /**
  7825. * Gets the global Saturation value.
  7826. * 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.
  7827. */
  7828. /**
  7829. * Sets the global Saturation value.
  7830. * 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.
  7831. */
  7832. globalSaturation: number;
  7833. /**
  7834. * Gets the global Exposure value.
  7835. * 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.
  7836. */
  7837. /**
  7838. * Sets the global Exposure value.
  7839. * 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.
  7840. */
  7841. globalExposure: number;
  7842. private _highlightsHue;
  7843. private _highlightsDensity;
  7844. private _highlightsSaturation;
  7845. private _highlightsExposure;
  7846. /**
  7847. * Gets the highlights Hue value.
  7848. * 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).
  7849. */
  7850. /**
  7851. * Sets the highlights Hue value.
  7852. * 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).
  7853. */
  7854. highlightsHue: number;
  7855. /**
  7856. * Gets the highlights Density value.
  7857. * 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.
  7858. * Values less than zero provide a filter of opposite hue.
  7859. */
  7860. /**
  7861. * Sets the highlights Density value.
  7862. * 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.
  7863. * Values less than zero provide a filter of opposite hue.
  7864. */
  7865. highlightsDensity: number;
  7866. /**
  7867. * Gets the highlights Saturation value.
  7868. * 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.
  7869. */
  7870. /**
  7871. * Sets the highlights Saturation value.
  7872. * 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.
  7873. */
  7874. highlightsSaturation: number;
  7875. /**
  7876. * Gets the highlights Exposure value.
  7877. * 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.
  7878. */
  7879. /**
  7880. * Sets the highlights Exposure value.
  7881. * 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.
  7882. */
  7883. highlightsExposure: number;
  7884. private _midtonesHue;
  7885. private _midtonesDensity;
  7886. private _midtonesSaturation;
  7887. private _midtonesExposure;
  7888. /**
  7889. * Gets the midtones Hue value.
  7890. * 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).
  7891. */
  7892. /**
  7893. * Sets the midtones Hue value.
  7894. * 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).
  7895. */
  7896. midtonesHue: number;
  7897. /**
  7898. * Gets the midtones Density value.
  7899. * 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.
  7900. * Values less than zero provide a filter of opposite hue.
  7901. */
  7902. /**
  7903. * Sets the midtones Density value.
  7904. * 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.
  7905. * Values less than zero provide a filter of opposite hue.
  7906. */
  7907. midtonesDensity: number;
  7908. /**
  7909. * Gets the midtones Saturation value.
  7910. * 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.
  7911. */
  7912. /**
  7913. * Sets the midtones Saturation value.
  7914. * 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.
  7915. */
  7916. midtonesSaturation: number;
  7917. /**
  7918. * Gets the midtones Exposure value.
  7919. * 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.
  7920. */
  7921. /**
  7922. * Sets the midtones Exposure value.
  7923. * 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.
  7924. */
  7925. midtonesExposure: number;
  7926. private _shadowsHue;
  7927. private _shadowsDensity;
  7928. private _shadowsSaturation;
  7929. private _shadowsExposure;
  7930. /**
  7931. * Gets the shadows Hue value.
  7932. * 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).
  7933. */
  7934. /**
  7935. * Sets the shadows Hue value.
  7936. * 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).
  7937. */
  7938. shadowsHue: number;
  7939. /**
  7940. * Gets the shadows Density value.
  7941. * 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.
  7942. * Values less than zero provide a filter of opposite hue.
  7943. */
  7944. /**
  7945. * Sets the shadows Density value.
  7946. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  7947. * Values less than zero provide a filter of opposite hue.
  7948. */
  7949. shadowsDensity: number;
  7950. /**
  7951. * Gets the shadows Saturation value.
  7952. * 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.
  7953. */
  7954. /**
  7955. * Sets the shadows Saturation value.
  7956. * 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.
  7957. */
  7958. shadowsSaturation: number;
  7959. /**
  7960. * Gets the shadows Exposure value.
  7961. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  7962. */
  7963. /**
  7964. * Sets the shadows Exposure value.
  7965. * 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.
  7966. */
  7967. shadowsExposure: number;
  7968. /**
  7969. * Returns the class name
  7970. * @returns The class name
  7971. */
  7972. getClassName(): string;
  7973. /**
  7974. * Binds the color curves to the shader.
  7975. * @param colorCurves The color curve to bind
  7976. * @param effect The effect to bind to
  7977. * @param positiveUniform The positive uniform shader parameter
  7978. * @param neutralUniform The neutral uniform shader parameter
  7979. * @param negativeUniform The negative uniform shader parameter
  7980. */
  7981. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  7982. /**
  7983. * Prepare the list of uniforms associated with the ColorCurves effects.
  7984. * @param uniformsList The list of uniforms used in the effect
  7985. */
  7986. static PrepareUniforms(uniformsList: string[]): void;
  7987. /**
  7988. * Returns color grading data based on a hue, density, saturation and exposure value.
  7989. * @param filterHue The hue of the color filter.
  7990. * @param filterDensity The density of the color filter.
  7991. * @param saturation The saturation.
  7992. * @param exposure The exposure.
  7993. * @param result The result data container.
  7994. */
  7995. private getColorGradingDataToRef;
  7996. /**
  7997. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  7998. * @param value The input slider value in range [-100,100].
  7999. * @returns Adjusted value.
  8000. */
  8001. private static applyColorGradingSliderNonlinear;
  8002. /**
  8003. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  8004. * @param hue The hue (H) input.
  8005. * @param saturation The saturation (S) input.
  8006. * @param brightness The brightness (B) input.
  8007. * @result An RGBA color represented as Vector4.
  8008. */
  8009. private static fromHSBToRef;
  8010. /**
  8011. * Returns a value clamped between min and max
  8012. * @param value The value to clamp
  8013. * @param min The minimum of value
  8014. * @param max The maximum of value
  8015. * @returns The clamped value.
  8016. */
  8017. private static clamp;
  8018. /**
  8019. * Clones the current color curve instance.
  8020. * @return The cloned curves
  8021. */
  8022. clone(): ColorCurves;
  8023. /**
  8024. * Serializes the current color curve instance to a json representation.
  8025. * @return a JSON representation
  8026. */
  8027. serialize(): any;
  8028. /**
  8029. * Parses the color curve from a json representation.
  8030. * @param source the JSON source to parse
  8031. * @return The parsed curves
  8032. */
  8033. static Parse(source: any): ColorCurves;
  8034. }
  8035. }
  8036. declare module "babylonjs/Materials/imageProcessingConfiguration" {
  8037. import { Observable } from "babylonjs/Misc/observable";
  8038. import { Nullable } from "babylonjs/types";
  8039. import { Color4 } from "babylonjs/Maths/math.color";
  8040. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  8041. import { Effect } from "babylonjs/Materials/effect";
  8042. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  8043. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  8044. /**
  8045. * Interface to follow in your material defines to integrate easily the
  8046. * Image proccessing functions.
  8047. * @hidden
  8048. */
  8049. export interface IImageProcessingConfigurationDefines {
  8050. IMAGEPROCESSING: boolean;
  8051. VIGNETTE: boolean;
  8052. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8053. VIGNETTEBLENDMODEOPAQUE: boolean;
  8054. TONEMAPPING: boolean;
  8055. TONEMAPPING_ACES: boolean;
  8056. CONTRAST: boolean;
  8057. EXPOSURE: boolean;
  8058. COLORCURVES: boolean;
  8059. COLORGRADING: boolean;
  8060. COLORGRADING3D: boolean;
  8061. SAMPLER3DGREENDEPTH: boolean;
  8062. SAMPLER3DBGRMAP: boolean;
  8063. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8064. }
  8065. /**
  8066. * @hidden
  8067. */
  8068. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  8069. IMAGEPROCESSING: boolean;
  8070. VIGNETTE: boolean;
  8071. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8072. VIGNETTEBLENDMODEOPAQUE: boolean;
  8073. TONEMAPPING: boolean;
  8074. TONEMAPPING_ACES: boolean;
  8075. CONTRAST: boolean;
  8076. COLORCURVES: boolean;
  8077. COLORGRADING: boolean;
  8078. COLORGRADING3D: boolean;
  8079. SAMPLER3DGREENDEPTH: boolean;
  8080. SAMPLER3DBGRMAP: boolean;
  8081. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8082. EXPOSURE: boolean;
  8083. constructor();
  8084. }
  8085. /**
  8086. * This groups together the common properties used for image processing either in direct forward pass
  8087. * or through post processing effect depending on the use of the image processing pipeline in your scene
  8088. * or not.
  8089. */
  8090. export class ImageProcessingConfiguration {
  8091. /**
  8092. * Default tone mapping applied in BabylonJS.
  8093. */
  8094. static readonly TONEMAPPING_STANDARD: number;
  8095. /**
  8096. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  8097. * to other engines rendering to increase portability.
  8098. */
  8099. static readonly TONEMAPPING_ACES: number;
  8100. /**
  8101. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  8102. */
  8103. colorCurves: Nullable<ColorCurves>;
  8104. private _colorCurvesEnabled;
  8105. /**
  8106. * Gets wether the color curves effect is enabled.
  8107. */
  8108. /**
  8109. * Sets wether the color curves effect is enabled.
  8110. */
  8111. colorCurvesEnabled: boolean;
  8112. private _colorGradingTexture;
  8113. /**
  8114. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8115. */
  8116. /**
  8117. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8118. */
  8119. colorGradingTexture: Nullable<BaseTexture>;
  8120. private _colorGradingEnabled;
  8121. /**
  8122. * Gets wether the color grading effect is enabled.
  8123. */
  8124. /**
  8125. * Sets wether the color grading effect is enabled.
  8126. */
  8127. colorGradingEnabled: boolean;
  8128. private _colorGradingWithGreenDepth;
  8129. /**
  8130. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  8131. */
  8132. /**
  8133. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  8134. */
  8135. colorGradingWithGreenDepth: boolean;
  8136. private _colorGradingBGR;
  8137. /**
  8138. * Gets wether the color grading texture contains BGR values.
  8139. */
  8140. /**
  8141. * Sets wether the color grading texture contains BGR values.
  8142. */
  8143. colorGradingBGR: boolean;
  8144. /** @hidden */
  8145. _exposure: number;
  8146. /**
  8147. * Gets the Exposure used in the effect.
  8148. */
  8149. /**
  8150. * Sets the Exposure used in the effect.
  8151. */
  8152. exposure: number;
  8153. private _toneMappingEnabled;
  8154. /**
  8155. * Gets wether the tone mapping effect is enabled.
  8156. */
  8157. /**
  8158. * Sets wether the tone mapping effect is enabled.
  8159. */
  8160. toneMappingEnabled: boolean;
  8161. private _toneMappingType;
  8162. /**
  8163. * Gets the type of tone mapping effect.
  8164. */
  8165. /**
  8166. * Sets the type of tone mapping effect used in BabylonJS.
  8167. */
  8168. toneMappingType: number;
  8169. protected _contrast: number;
  8170. /**
  8171. * Gets the contrast used in the effect.
  8172. */
  8173. /**
  8174. * Sets the contrast used in the effect.
  8175. */
  8176. contrast: number;
  8177. /**
  8178. * Vignette stretch size.
  8179. */
  8180. vignetteStretch: number;
  8181. /**
  8182. * Vignette centre X Offset.
  8183. */
  8184. vignetteCentreX: number;
  8185. /**
  8186. * Vignette centre Y Offset.
  8187. */
  8188. vignetteCentreY: number;
  8189. /**
  8190. * Vignette weight or intensity of the vignette effect.
  8191. */
  8192. vignetteWeight: number;
  8193. /**
  8194. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  8195. * if vignetteEnabled is set to true.
  8196. */
  8197. vignetteColor: Color4;
  8198. /**
  8199. * Camera field of view used by the Vignette effect.
  8200. */
  8201. vignetteCameraFov: number;
  8202. private _vignetteBlendMode;
  8203. /**
  8204. * Gets the vignette blend mode allowing different kind of effect.
  8205. */
  8206. /**
  8207. * Sets the vignette blend mode allowing different kind of effect.
  8208. */
  8209. vignetteBlendMode: number;
  8210. private _vignetteEnabled;
  8211. /**
  8212. * Gets wether the vignette effect is enabled.
  8213. */
  8214. /**
  8215. * Sets wether the vignette effect is enabled.
  8216. */
  8217. vignetteEnabled: boolean;
  8218. private _applyByPostProcess;
  8219. /**
  8220. * Gets wether the image processing is applied through a post process or not.
  8221. */
  8222. /**
  8223. * Sets wether the image processing is applied through a post process or not.
  8224. */
  8225. applyByPostProcess: boolean;
  8226. private _isEnabled;
  8227. /**
  8228. * Gets wether the image processing is enabled or not.
  8229. */
  8230. /**
  8231. * Sets wether the image processing is enabled or not.
  8232. */
  8233. isEnabled: boolean;
  8234. /**
  8235. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  8236. */
  8237. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  8238. /**
  8239. * Method called each time the image processing information changes requires to recompile the effect.
  8240. */
  8241. protected _updateParameters(): void;
  8242. /**
  8243. * Gets the current class name.
  8244. * @return "ImageProcessingConfiguration"
  8245. */
  8246. getClassName(): string;
  8247. /**
  8248. * Prepare the list of uniforms associated with the Image Processing effects.
  8249. * @param uniforms The list of uniforms used in the effect
  8250. * @param defines the list of defines currently in use
  8251. */
  8252. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  8253. /**
  8254. * Prepare the list of samplers associated with the Image Processing effects.
  8255. * @param samplersList The list of uniforms used in the effect
  8256. * @param defines the list of defines currently in use
  8257. */
  8258. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  8259. /**
  8260. * Prepare the list of defines associated to the shader.
  8261. * @param defines the list of defines to complete
  8262. * @param forPostProcess Define if we are currently in post process mode or not
  8263. */
  8264. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  8265. /**
  8266. * Returns true if all the image processing information are ready.
  8267. * @returns True if ready, otherwise, false
  8268. */
  8269. isReady(): boolean;
  8270. /**
  8271. * Binds the image processing to the shader.
  8272. * @param effect The effect to bind to
  8273. * @param aspectRatio Define the current aspect ratio of the effect
  8274. */
  8275. bind(effect: Effect, aspectRatio?: number): void;
  8276. /**
  8277. * Clones the current image processing instance.
  8278. * @return The cloned image processing
  8279. */
  8280. clone(): ImageProcessingConfiguration;
  8281. /**
  8282. * Serializes the current image processing instance to a json representation.
  8283. * @return a JSON representation
  8284. */
  8285. serialize(): any;
  8286. /**
  8287. * Parses the image processing from a json representation.
  8288. * @param source the JSON source to parse
  8289. * @return The parsed image processing
  8290. */
  8291. static Parse(source: any): ImageProcessingConfiguration;
  8292. private static _VIGNETTEMODE_MULTIPLY;
  8293. private static _VIGNETTEMODE_OPAQUE;
  8294. /**
  8295. * Used to apply the vignette as a mix with the pixel color.
  8296. */
  8297. static readonly VIGNETTEMODE_MULTIPLY: number;
  8298. /**
  8299. * Used to apply the vignette as a replacement of the pixel color.
  8300. */
  8301. static readonly VIGNETTEMODE_OPAQUE: number;
  8302. }
  8303. }
  8304. declare module "babylonjs/Shaders/postprocess.vertex" {
  8305. /** @hidden */
  8306. export var postprocessVertexShader: {
  8307. name: string;
  8308. shader: string;
  8309. };
  8310. }
  8311. declare module "babylonjs/Maths/math.axis" {
  8312. import { Vector3 } from "babylonjs/Maths/math.vector";
  8313. /** Defines supported spaces */
  8314. export enum Space {
  8315. /** Local (object) space */
  8316. LOCAL = 0,
  8317. /** World space */
  8318. WORLD = 1,
  8319. /** Bone space */
  8320. BONE = 2
  8321. }
  8322. /** Defines the 3 main axes */
  8323. export class Axis {
  8324. /** X axis */
  8325. static X: Vector3;
  8326. /** Y axis */
  8327. static Y: Vector3;
  8328. /** Z axis */
  8329. static Z: Vector3;
  8330. }
  8331. }
  8332. declare module "babylonjs/Cameras/targetCamera" {
  8333. import { Nullable } from "babylonjs/types";
  8334. import { Camera } from "babylonjs/Cameras/camera";
  8335. import { Scene } from "babylonjs/scene";
  8336. import { Quaternion, Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  8337. /**
  8338. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  8339. * This is the base of the follow, arc rotate cameras and Free camera
  8340. * @see http://doc.babylonjs.com/features/cameras
  8341. */
  8342. export class TargetCamera extends Camera {
  8343. private static _RigCamTransformMatrix;
  8344. private static _TargetTransformMatrix;
  8345. private static _TargetFocalPoint;
  8346. /**
  8347. * Define the current direction the camera is moving to
  8348. */
  8349. cameraDirection: Vector3;
  8350. /**
  8351. * Define the current rotation the camera is rotating to
  8352. */
  8353. cameraRotation: Vector2;
  8354. /**
  8355. * When set, the up vector of the camera will be updated by the rotation of the camera
  8356. */
  8357. updateUpVectorFromRotation: boolean;
  8358. private _tmpQuaternion;
  8359. /**
  8360. * Define the current rotation of the camera
  8361. */
  8362. rotation: Vector3;
  8363. /**
  8364. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  8365. */
  8366. rotationQuaternion: Quaternion;
  8367. /**
  8368. * Define the current speed of the camera
  8369. */
  8370. speed: number;
  8371. /**
  8372. * Add cconstraint to the camera to prevent it to move freely in all directions and
  8373. * around all axis.
  8374. */
  8375. noRotationConstraint: boolean;
  8376. /**
  8377. * Define the current target of the camera as an object or a position.
  8378. */
  8379. lockedTarget: any;
  8380. /** @hidden */
  8381. _currentTarget: Vector3;
  8382. /** @hidden */
  8383. _initialFocalDistance: number;
  8384. /** @hidden */
  8385. _viewMatrix: Matrix;
  8386. /** @hidden */
  8387. _camMatrix: Matrix;
  8388. /** @hidden */
  8389. _cameraTransformMatrix: Matrix;
  8390. /** @hidden */
  8391. _cameraRotationMatrix: Matrix;
  8392. /** @hidden */
  8393. _referencePoint: Vector3;
  8394. /** @hidden */
  8395. _transformedReferencePoint: Vector3;
  8396. protected _globalCurrentTarget: Vector3;
  8397. protected _globalCurrentUpVector: Vector3;
  8398. /** @hidden */
  8399. _reset: () => void;
  8400. private _defaultUp;
  8401. /**
  8402. * Instantiates a target camera that takes a mesh or position as a target and continues to look at it while it moves.
  8403. * This is the base of the follow, arc rotate cameras and Free camera
  8404. * @see http://doc.babylonjs.com/features/cameras
  8405. * @param name Defines the name of the camera in the scene
  8406. * @param position Defines the start position of the camera in the scene
  8407. * @param scene Defines the scene the camera belongs to
  8408. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  8409. */
  8410. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  8411. /**
  8412. * Gets the position in front of the camera at a given distance.
  8413. * @param distance The distance from the camera we want the position to be
  8414. * @returns the position
  8415. */
  8416. getFrontPosition(distance: number): Vector3;
  8417. /** @hidden */
  8418. _getLockedTargetPosition(): Nullable<Vector3>;
  8419. private _storedPosition;
  8420. private _storedRotation;
  8421. private _storedRotationQuaternion;
  8422. /**
  8423. * Store current camera state of the camera (fov, position, rotation, etc..)
  8424. * @returns the camera
  8425. */
  8426. storeState(): Camera;
  8427. /**
  8428. * Restored camera state. You must call storeState() first
  8429. * @returns whether it was successful or not
  8430. * @hidden
  8431. */
  8432. _restoreStateValues(): boolean;
  8433. /** @hidden */
  8434. _initCache(): void;
  8435. /** @hidden */
  8436. _updateCache(ignoreParentClass?: boolean): void;
  8437. /** @hidden */
  8438. _isSynchronizedViewMatrix(): boolean;
  8439. /** @hidden */
  8440. _computeLocalCameraSpeed(): number;
  8441. /**
  8442. * Defines the target the camera should look at.
  8443. * @param target Defines the new target as a Vector or a mesh
  8444. */
  8445. setTarget(target: Vector3): void;
  8446. /**
  8447. * Return the current target position of the camera. This value is expressed in local space.
  8448. * @returns the target position
  8449. */
  8450. getTarget(): Vector3;
  8451. /** @hidden */
  8452. _decideIfNeedsToMove(): boolean;
  8453. /** @hidden */
  8454. _updatePosition(): void;
  8455. /** @hidden */
  8456. _checkInputs(): void;
  8457. protected _updateCameraRotationMatrix(): void;
  8458. /**
  8459. * Update the up vector to apply the rotation of the camera (So if you changed the camera rotation.z this will let you update the up vector as well)
  8460. * @returns the current camera
  8461. */
  8462. private _rotateUpVectorWithCameraRotationMatrix;
  8463. private _cachedRotationZ;
  8464. private _cachedQuaternionRotationZ;
  8465. /** @hidden */
  8466. _getViewMatrix(): Matrix;
  8467. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  8468. /**
  8469. * @hidden
  8470. */
  8471. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  8472. /**
  8473. * @hidden
  8474. */
  8475. _updateRigCameras(): void;
  8476. private _getRigCamPositionAndTarget;
  8477. /**
  8478. * Gets the current object class name.
  8479. * @return the class name
  8480. */
  8481. getClassName(): string;
  8482. }
  8483. }
  8484. declare module "babylonjs/Events/keyboardEvents" {
  8485. /**
  8486. * Gather the list of keyboard event types as constants.
  8487. */
  8488. export class KeyboardEventTypes {
  8489. /**
  8490. * The keydown event is fired when a key becomes active (pressed).
  8491. */
  8492. static readonly KEYDOWN: number;
  8493. /**
  8494. * The keyup event is fired when a key has been released.
  8495. */
  8496. static readonly KEYUP: number;
  8497. }
  8498. /**
  8499. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8500. */
  8501. export class KeyboardInfo {
  8502. /**
  8503. * Defines the type of event (KeyboardEventTypes)
  8504. */
  8505. type: number;
  8506. /**
  8507. * Defines the related dom event
  8508. */
  8509. event: KeyboardEvent;
  8510. /**
  8511. * Instantiates a new keyboard info.
  8512. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8513. * @param type Defines the type of event (KeyboardEventTypes)
  8514. * @param event Defines the related dom event
  8515. */
  8516. constructor(
  8517. /**
  8518. * Defines the type of event (KeyboardEventTypes)
  8519. */
  8520. type: number,
  8521. /**
  8522. * Defines the related dom event
  8523. */
  8524. event: KeyboardEvent);
  8525. }
  8526. /**
  8527. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8528. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  8529. */
  8530. export class KeyboardInfoPre extends KeyboardInfo {
  8531. /**
  8532. * Defines the type of event (KeyboardEventTypes)
  8533. */
  8534. type: number;
  8535. /**
  8536. * Defines the related dom event
  8537. */
  8538. event: KeyboardEvent;
  8539. /**
  8540. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  8541. */
  8542. skipOnPointerObservable: boolean;
  8543. /**
  8544. * Instantiates a new keyboard pre info.
  8545. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8546. * @param type Defines the type of event (KeyboardEventTypes)
  8547. * @param event Defines the related dom event
  8548. */
  8549. constructor(
  8550. /**
  8551. * Defines the type of event (KeyboardEventTypes)
  8552. */
  8553. type: number,
  8554. /**
  8555. * Defines the related dom event
  8556. */
  8557. event: KeyboardEvent);
  8558. }
  8559. }
  8560. declare module "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput" {
  8561. import { Nullable } from "babylonjs/types";
  8562. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  8563. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  8564. /**
  8565. * Manage the keyboard inputs to control the movement of a free camera.
  8566. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8567. */
  8568. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  8569. /**
  8570. * Defines the camera the input is attached to.
  8571. */
  8572. camera: FreeCamera;
  8573. /**
  8574. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  8575. */
  8576. keysUp: number[];
  8577. /**
  8578. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  8579. */
  8580. keysDown: number[];
  8581. /**
  8582. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  8583. */
  8584. keysLeft: number[];
  8585. /**
  8586. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  8587. */
  8588. keysRight: number[];
  8589. private _keys;
  8590. private _onCanvasBlurObserver;
  8591. private _onKeyboardObserver;
  8592. private _engine;
  8593. private _scene;
  8594. /**
  8595. * Attach the input controls to a specific dom element to get the input from.
  8596. * @param element Defines the element the controls should be listened from
  8597. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8598. */
  8599. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  8600. /**
  8601. * Detach the current controls from the specified dom element.
  8602. * @param element Defines the element to stop listening the inputs from
  8603. */
  8604. detachControl(element: Nullable<HTMLElement>): void;
  8605. /**
  8606. * Update the current camera state depending on the inputs that have been used this frame.
  8607. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8608. */
  8609. checkInputs(): void;
  8610. /**
  8611. * Gets the class name of the current intput.
  8612. * @returns the class name
  8613. */
  8614. getClassName(): string;
  8615. /** @hidden */
  8616. _onLostFocus(): void;
  8617. /**
  8618. * Get the friendly name associated with the input class.
  8619. * @returns the input friendly name
  8620. */
  8621. getSimpleName(): string;
  8622. }
  8623. }
  8624. declare module "babylonjs/Lights/shadowLight" {
  8625. import { Camera } from "babylonjs/Cameras/camera";
  8626. import { Scene } from "babylonjs/scene";
  8627. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  8628. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  8629. import { Light } from "babylonjs/Lights/light";
  8630. /**
  8631. * Interface describing all the common properties and methods a shadow light needs to implement.
  8632. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  8633. * as well as binding the different shadow properties to the effects.
  8634. */
  8635. export interface IShadowLight extends Light {
  8636. /**
  8637. * The light id in the scene (used in scene.findLighById for instance)
  8638. */
  8639. id: string;
  8640. /**
  8641. * The position the shdow will be casted from.
  8642. */
  8643. position: Vector3;
  8644. /**
  8645. * In 2d mode (needCube being false), the direction used to cast the shadow.
  8646. */
  8647. direction: Vector3;
  8648. /**
  8649. * The transformed position. Position of the light in world space taking parenting in account.
  8650. */
  8651. transformedPosition: Vector3;
  8652. /**
  8653. * The transformed direction. Direction of the light in world space taking parenting in account.
  8654. */
  8655. transformedDirection: Vector3;
  8656. /**
  8657. * The friendly name of the light in the scene.
  8658. */
  8659. name: string;
  8660. /**
  8661. * Defines the shadow projection clipping minimum z value.
  8662. */
  8663. shadowMinZ: number;
  8664. /**
  8665. * Defines the shadow projection clipping maximum z value.
  8666. */
  8667. shadowMaxZ: number;
  8668. /**
  8669. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  8670. * @returns true if the information has been computed, false if it does not need to (no parenting)
  8671. */
  8672. computeTransformedInformation(): boolean;
  8673. /**
  8674. * Gets the scene the light belongs to.
  8675. * @returns The scene
  8676. */
  8677. getScene(): Scene;
  8678. /**
  8679. * Callback defining a custom Projection Matrix Builder.
  8680. * This can be used to override the default projection matrix computation.
  8681. */
  8682. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  8683. /**
  8684. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  8685. * @param matrix The materix to updated with the projection information
  8686. * @param viewMatrix The transform matrix of the light
  8687. * @param renderList The list of mesh to render in the map
  8688. * @returns The current light
  8689. */
  8690. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  8691. /**
  8692. * Gets the current depth scale used in ESM.
  8693. * @returns The scale
  8694. */
  8695. getDepthScale(): number;
  8696. /**
  8697. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  8698. * @returns true if a cube texture needs to be use
  8699. */
  8700. needCube(): boolean;
  8701. /**
  8702. * Detects if the projection matrix requires to be recomputed this frame.
  8703. * @returns true if it requires to be recomputed otherwise, false.
  8704. */
  8705. needProjectionMatrixCompute(): boolean;
  8706. /**
  8707. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  8708. */
  8709. forceProjectionMatrixCompute(): void;
  8710. /**
  8711. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  8712. * @param faceIndex The index of the face we are computed the direction to generate shadow
  8713. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  8714. */
  8715. getShadowDirection(faceIndex?: number): Vector3;
  8716. /**
  8717. * Gets the minZ used for shadow according to both the scene and the light.
  8718. * @param activeCamera The camera we are returning the min for
  8719. * @returns the depth min z
  8720. */
  8721. getDepthMinZ(activeCamera: Camera): number;
  8722. /**
  8723. * Gets the maxZ used for shadow according to both the scene and the light.
  8724. * @param activeCamera The camera we are returning the max for
  8725. * @returns the depth max z
  8726. */
  8727. getDepthMaxZ(activeCamera: Camera): number;
  8728. }
  8729. /**
  8730. * Base implementation IShadowLight
  8731. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  8732. */
  8733. export abstract class ShadowLight extends Light implements IShadowLight {
  8734. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  8735. protected _position: Vector3;
  8736. protected _setPosition(value: Vector3): void;
  8737. /**
  8738. * Sets the position the shadow will be casted from. Also use as the light position for both
  8739. * point and spot lights.
  8740. */
  8741. /**
  8742. * Sets the position the shadow will be casted from. Also use as the light position for both
  8743. * point and spot lights.
  8744. */
  8745. position: Vector3;
  8746. protected _direction: Vector3;
  8747. protected _setDirection(value: Vector3): void;
  8748. /**
  8749. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  8750. * Also use as the light direction on spot and directional lights.
  8751. */
  8752. /**
  8753. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  8754. * Also use as the light direction on spot and directional lights.
  8755. */
  8756. direction: Vector3;
  8757. private _shadowMinZ;
  8758. /**
  8759. * Gets the shadow projection clipping minimum z value.
  8760. */
  8761. /**
  8762. * Sets the shadow projection clipping minimum z value.
  8763. */
  8764. shadowMinZ: number;
  8765. private _shadowMaxZ;
  8766. /**
  8767. * Sets the shadow projection clipping maximum z value.
  8768. */
  8769. /**
  8770. * Gets the shadow projection clipping maximum z value.
  8771. */
  8772. shadowMaxZ: number;
  8773. /**
  8774. * Callback defining a custom Projection Matrix Builder.
  8775. * This can be used to override the default projection matrix computation.
  8776. */
  8777. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  8778. /**
  8779. * The transformed position. Position of the light in world space taking parenting in account.
  8780. */
  8781. transformedPosition: Vector3;
  8782. /**
  8783. * The transformed direction. Direction of the light in world space taking parenting in account.
  8784. */
  8785. transformedDirection: Vector3;
  8786. private _needProjectionMatrixCompute;
  8787. /**
  8788. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  8789. * @returns true if the information has been computed, false if it does not need to (no parenting)
  8790. */
  8791. computeTransformedInformation(): boolean;
  8792. /**
  8793. * Return the depth scale used for the shadow map.
  8794. * @returns the depth scale.
  8795. */
  8796. getDepthScale(): number;
  8797. /**
  8798. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  8799. * @param faceIndex The index of the face we are computed the direction to generate shadow
  8800. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  8801. */
  8802. getShadowDirection(faceIndex?: number): Vector3;
  8803. /**
  8804. * Returns the ShadowLight absolute position in the World.
  8805. * @returns the position vector in world space
  8806. */
  8807. getAbsolutePosition(): Vector3;
  8808. /**
  8809. * Sets the ShadowLight direction toward the passed target.
  8810. * @param target The point to target in local space
  8811. * @returns the updated ShadowLight direction
  8812. */
  8813. setDirectionToTarget(target: Vector3): Vector3;
  8814. /**
  8815. * Returns the light rotation in euler definition.
  8816. * @returns the x y z rotation in local space.
  8817. */
  8818. getRotation(): Vector3;
  8819. /**
  8820. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  8821. * @returns true if a cube texture needs to be use
  8822. */
  8823. needCube(): boolean;
  8824. /**
  8825. * Detects if the projection matrix requires to be recomputed this frame.
  8826. * @returns true if it requires to be recomputed otherwise, false.
  8827. */
  8828. needProjectionMatrixCompute(): boolean;
  8829. /**
  8830. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  8831. */
  8832. forceProjectionMatrixCompute(): void;
  8833. /** @hidden */
  8834. _initCache(): void;
  8835. /** @hidden */
  8836. _isSynchronized(): boolean;
  8837. /**
  8838. * Computes the world matrix of the node
  8839. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  8840. * @returns the world matrix
  8841. */
  8842. computeWorldMatrix(force?: boolean): Matrix;
  8843. /**
  8844. * Gets the minZ used for shadow according to both the scene and the light.
  8845. * @param activeCamera The camera we are returning the min for
  8846. * @returns the depth min z
  8847. */
  8848. getDepthMinZ(activeCamera: Camera): number;
  8849. /**
  8850. * Gets the maxZ used for shadow according to both the scene and the light.
  8851. * @param activeCamera The camera we are returning the max for
  8852. * @returns the depth max z
  8853. */
  8854. getDepthMaxZ(activeCamera: Camera): number;
  8855. /**
  8856. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  8857. * @param matrix The materix to updated with the projection information
  8858. * @param viewMatrix The transform matrix of the light
  8859. * @param renderList The list of mesh to render in the map
  8860. * @returns The current light
  8861. */
  8862. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  8863. }
  8864. }
  8865. declare module "babylonjs/Materials/materialHelper" {
  8866. import { Nullable } from "babylonjs/types";
  8867. import { Scene } from "babylonjs/scene";
  8868. import { Engine } from "babylonjs/Engines/engine";
  8869. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  8870. import { Light } from "babylonjs/Lights/light";
  8871. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  8872. import { Effect, EffectFallbacks, EffectCreationOptions } from "babylonjs/Materials/effect";
  8873. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  8874. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  8875. /**
  8876. * "Static Class" containing the most commonly used helper while dealing with material for
  8877. * rendering purpose.
  8878. *
  8879. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  8880. *
  8881. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  8882. */
  8883. export class MaterialHelper {
  8884. /**
  8885. * Bind the current view position to an effect.
  8886. * @param effect The effect to be bound
  8887. * @param scene The scene the eyes position is used from
  8888. */
  8889. static BindEyePosition(effect: Effect, scene: Scene): void;
  8890. /**
  8891. * Helps preparing the defines values about the UVs in used in the effect.
  8892. * UVs are shared as much as we can accross channels in the shaders.
  8893. * @param texture The texture we are preparing the UVs for
  8894. * @param defines The defines to update
  8895. * @param key The channel key "diffuse", "specular"... used in the shader
  8896. */
  8897. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  8898. /**
  8899. * Binds a texture matrix value to its corrsponding uniform
  8900. * @param texture The texture to bind the matrix for
  8901. * @param uniformBuffer The uniform buffer receivin the data
  8902. * @param key The channel key "diffuse", "specular"... used in the shader
  8903. */
  8904. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  8905. /**
  8906. * Gets the current status of the fog (should it be enabled?)
  8907. * @param mesh defines the mesh to evaluate for fog support
  8908. * @param scene defines the hosting scene
  8909. * @returns true if fog must be enabled
  8910. */
  8911. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  8912. /**
  8913. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  8914. * @param mesh defines the current mesh
  8915. * @param scene defines the current scene
  8916. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  8917. * @param pointsCloud defines if point cloud rendering has to be turned on
  8918. * @param fogEnabled defines if fog has to be turned on
  8919. * @param alphaTest defines if alpha testing has to be turned on
  8920. * @param defines defines the current list of defines
  8921. */
  8922. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  8923. /**
  8924. * Helper used to prepare the list of defines associated with frame values for shader compilation
  8925. * @param scene defines the current scene
  8926. * @param engine defines the current engine
  8927. * @param defines specifies the list of active defines
  8928. * @param useInstances defines if instances have to be turned on
  8929. * @param useClipPlane defines if clip plane have to be turned on
  8930. */
  8931. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  8932. /**
  8933. * Prepares the defines for bones
  8934. * @param mesh The mesh containing the geometry data we will draw
  8935. * @param defines The defines to update
  8936. */
  8937. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  8938. /**
  8939. * Prepares the defines for morph targets
  8940. * @param mesh The mesh containing the geometry data we will draw
  8941. * @param defines The defines to update
  8942. */
  8943. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  8944. /**
  8945. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  8946. * @param mesh The mesh containing the geometry data we will draw
  8947. * @param defines The defines to update
  8948. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  8949. * @param useBones Precise whether bones should be used or not (override mesh info)
  8950. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  8951. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  8952. * @returns false if defines are considered not dirty and have not been checked
  8953. */
  8954. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  8955. /**
  8956. * Prepares the defines related to multiview
  8957. * @param scene The scene we are intending to draw
  8958. * @param defines The defines to update
  8959. */
  8960. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  8961. /**
  8962. * Prepares the defines related to the light information passed in parameter
  8963. * @param scene The scene we are intending to draw
  8964. * @param mesh The mesh the effect is compiling for
  8965. * @param light The light the effect is compiling for
  8966. * @param lightIndex The index of the light
  8967. * @param defines The defines to update
  8968. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  8969. * @param state Defines the current state regarding what is needed (normals, etc...)
  8970. */
  8971. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  8972. needNormals: boolean;
  8973. needRebuild: boolean;
  8974. shadowEnabled: boolean;
  8975. specularEnabled: boolean;
  8976. lightmapMode: boolean;
  8977. }): void;
  8978. /**
  8979. * Prepares the defines related to the light information passed in parameter
  8980. * @param scene The scene we are intending to draw
  8981. * @param mesh The mesh the effect is compiling for
  8982. * @param defines The defines to update
  8983. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  8984. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  8985. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  8986. * @returns true if normals will be required for the rest of the effect
  8987. */
  8988. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  8989. /**
  8990. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  8991. * @param lightIndex defines the light index
  8992. * @param uniformsList The uniform list
  8993. * @param samplersList The sampler list
  8994. * @param projectedLightTexture defines if projected texture must be used
  8995. * @param uniformBuffersList defines an optional list of uniform buffers
  8996. */
  8997. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  8998. /**
  8999. * Prepares the uniforms and samplers list to be used in the effect
  9000. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  9001. * @param samplersList The sampler list
  9002. * @param defines The defines helping in the list generation
  9003. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  9004. */
  9005. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | EffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  9006. /**
  9007. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  9008. * @param defines The defines to update while falling back
  9009. * @param fallbacks The authorized effect fallbacks
  9010. * @param maxSimultaneousLights The maximum number of lights allowed
  9011. * @param rank the current rank of the Effect
  9012. * @returns The newly affected rank
  9013. */
  9014. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  9015. private static _TmpMorphInfluencers;
  9016. /**
  9017. * Prepares the list of attributes required for morph targets according to the effect defines.
  9018. * @param attribs The current list of supported attribs
  9019. * @param mesh The mesh to prepare the morph targets attributes for
  9020. * @param influencers The number of influencers
  9021. */
  9022. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  9023. /**
  9024. * Prepares the list of attributes required for morph targets according to the effect defines.
  9025. * @param attribs The current list of supported attribs
  9026. * @param mesh The mesh to prepare the morph targets attributes for
  9027. * @param defines The current Defines of the effect
  9028. */
  9029. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  9030. /**
  9031. * Prepares the list of attributes required for bones according to the effect defines.
  9032. * @param attribs The current list of supported attribs
  9033. * @param mesh The mesh to prepare the bones attributes for
  9034. * @param defines The current Defines of the effect
  9035. * @param fallbacks The current efffect fallback strategy
  9036. */
  9037. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  9038. /**
  9039. * Check and prepare the list of attributes required for instances according to the effect defines.
  9040. * @param attribs The current list of supported attribs
  9041. * @param defines The current MaterialDefines of the effect
  9042. */
  9043. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  9044. /**
  9045. * Add the list of attributes required for instances to the attribs array.
  9046. * @param attribs The current list of supported attribs
  9047. */
  9048. static PushAttributesForInstances(attribs: string[]): void;
  9049. /**
  9050. * Binds the light shadow information to the effect for the given mesh.
  9051. * @param light The light containing the generator
  9052. * @param scene The scene the lights belongs to
  9053. * @param mesh The mesh we are binding the information to render
  9054. * @param lightIndex The light index in the effect used to render the mesh
  9055. * @param effect The effect we are binding the data to
  9056. */
  9057. static BindLightShadow(light: Light, mesh: AbstractMesh, lightIndex: string, effect: Effect): void;
  9058. /**
  9059. * Binds the light information to the effect.
  9060. * @param light The light containing the generator
  9061. * @param effect The effect we are binding the data to
  9062. * @param lightIndex The light index in the effect used to render
  9063. */
  9064. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  9065. /**
  9066. * Binds the lights information from the scene to the effect for the given mesh.
  9067. * @param light Light to bind
  9068. * @param lightIndex Light index
  9069. * @param scene The scene where the light belongs to
  9070. * @param mesh The mesh we are binding the information to render
  9071. * @param effect The effect we are binding the data to
  9072. * @param useSpecular Defines if specular is supported
  9073. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  9074. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  9075. */
  9076. static BindLight(light: Light, lightIndex: number, scene: Scene, mesh: AbstractMesh, effect: Effect, useSpecular: boolean, usePhysicalLightFalloff?: boolean, rebuildInParallel?: boolean): void;
  9077. /**
  9078. * Binds the lights information from the scene to the effect for the given mesh.
  9079. * @param scene The scene the lights belongs to
  9080. * @param mesh The mesh we are binding the information to render
  9081. * @param effect The effect we are binding the data to
  9082. * @param defines The generated defines for the effect
  9083. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  9084. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  9085. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  9086. */
  9087. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, usePhysicalLightFalloff?: boolean, rebuildInParallel?: boolean): void;
  9088. private static _tempFogColor;
  9089. /**
  9090. * Binds the fog information from the scene to the effect for the given mesh.
  9091. * @param scene The scene the lights belongs to
  9092. * @param mesh The mesh we are binding the information to render
  9093. * @param effect The effect we are binding the data to
  9094. * @param linearSpace Defines if the fog effect is applied in linear space
  9095. */
  9096. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  9097. /**
  9098. * Binds the bones information from the mesh to the effect.
  9099. * @param mesh The mesh we are binding the information to render
  9100. * @param effect The effect we are binding the data to
  9101. */
  9102. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  9103. /**
  9104. * Binds the morph targets information from the mesh to the effect.
  9105. * @param abstractMesh The mesh we are binding the information to render
  9106. * @param effect The effect we are binding the data to
  9107. */
  9108. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  9109. /**
  9110. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  9111. * @param defines The generated defines used in the effect
  9112. * @param effect The effect we are binding the data to
  9113. * @param scene The scene we are willing to render with logarithmic scale for
  9114. */
  9115. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  9116. /**
  9117. * Binds the clip plane information from the scene to the effect.
  9118. * @param scene The scene the clip plane information are extracted from
  9119. * @param effect The effect we are binding the data to
  9120. */
  9121. static BindClipPlane(effect: Effect, scene: Scene): void;
  9122. }
  9123. }
  9124. declare module "babylonjs/Shaders/ShadersInclude/packingFunctions" {
  9125. /** @hidden */
  9126. export var packingFunctions: {
  9127. name: string;
  9128. shader: string;
  9129. };
  9130. }
  9131. declare module "babylonjs/Shaders/shadowMap.fragment" {
  9132. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  9133. /** @hidden */
  9134. export var shadowMapPixelShader: {
  9135. name: string;
  9136. shader: string;
  9137. };
  9138. }
  9139. declare module "babylonjs/Shaders/ShadersInclude/bonesDeclaration" {
  9140. /** @hidden */
  9141. export var bonesDeclaration: {
  9142. name: string;
  9143. shader: string;
  9144. };
  9145. }
  9146. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration" {
  9147. /** @hidden */
  9148. export var morphTargetsVertexGlobalDeclaration: {
  9149. name: string;
  9150. shader: string;
  9151. };
  9152. }
  9153. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration" {
  9154. /** @hidden */
  9155. export var morphTargetsVertexDeclaration: {
  9156. name: string;
  9157. shader: string;
  9158. };
  9159. }
  9160. declare module "babylonjs/Shaders/ShadersInclude/instancesDeclaration" {
  9161. /** @hidden */
  9162. export var instancesDeclaration: {
  9163. name: string;
  9164. shader: string;
  9165. };
  9166. }
  9167. declare module "babylonjs/Shaders/ShadersInclude/helperFunctions" {
  9168. /** @hidden */
  9169. export var helperFunctions: {
  9170. name: string;
  9171. shader: string;
  9172. };
  9173. }
  9174. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertex" {
  9175. /** @hidden */
  9176. export var morphTargetsVertex: {
  9177. name: string;
  9178. shader: string;
  9179. };
  9180. }
  9181. declare module "babylonjs/Shaders/ShadersInclude/instancesVertex" {
  9182. /** @hidden */
  9183. export var instancesVertex: {
  9184. name: string;
  9185. shader: string;
  9186. };
  9187. }
  9188. declare module "babylonjs/Shaders/ShadersInclude/bonesVertex" {
  9189. /** @hidden */
  9190. export var bonesVertex: {
  9191. name: string;
  9192. shader: string;
  9193. };
  9194. }
  9195. declare module "babylonjs/Shaders/shadowMap.vertex" {
  9196. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  9197. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  9198. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  9199. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  9200. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  9201. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  9202. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  9203. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  9204. /** @hidden */
  9205. export var shadowMapVertexShader: {
  9206. name: string;
  9207. shader: string;
  9208. };
  9209. }
  9210. declare module "babylonjs/Shaders/depthBoxBlur.fragment" {
  9211. /** @hidden */
  9212. export var depthBoxBlurPixelShader: {
  9213. name: string;
  9214. shader: string;
  9215. };
  9216. }
  9217. declare module "babylonjs/Lights/Shadows/shadowGenerator" {
  9218. import { Nullable } from "babylonjs/types";
  9219. import { Scene } from "babylonjs/scene";
  9220. import { Matrix } from "babylonjs/Maths/math.vector";
  9221. import { SubMesh } from "babylonjs/Meshes/subMesh";
  9222. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9223. import { Mesh } from "babylonjs/Meshes/mesh";
  9224. import { IShadowLight } from "babylonjs/Lights/shadowLight";
  9225. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  9226. import { Effect } from "babylonjs/Materials/effect";
  9227. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  9228. import "babylonjs/Shaders/shadowMap.fragment";
  9229. import "babylonjs/Shaders/shadowMap.vertex";
  9230. import "babylonjs/Shaders/depthBoxBlur.fragment";
  9231. import { Observable } from "babylonjs/Misc/observable";
  9232. /**
  9233. * Defines the options associated with the creation of a custom shader for a shadow generator.
  9234. */
  9235. export interface ICustomShaderOptions {
  9236. /**
  9237. * Gets or sets the custom shader name to use
  9238. */
  9239. shaderName: string;
  9240. /**
  9241. * The list of attribute names used in the shader
  9242. */
  9243. attributes?: string[];
  9244. /**
  9245. * The list of unifrom names used in the shader
  9246. */
  9247. uniforms?: string[];
  9248. /**
  9249. * The list of sampler names used in the shader
  9250. */
  9251. samplers?: string[];
  9252. /**
  9253. * The list of defines used in the shader
  9254. */
  9255. defines?: string[];
  9256. }
  9257. /**
  9258. * Interface to implement to create a shadow generator compatible with BJS.
  9259. */
  9260. export interface IShadowGenerator {
  9261. /**
  9262. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  9263. * @returns The render target texture if present otherwise, null
  9264. */
  9265. getShadowMap(): Nullable<RenderTargetTexture>;
  9266. /**
  9267. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  9268. * @returns The render target texture if the shadow map is present otherwise, null
  9269. */
  9270. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  9271. /**
  9272. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  9273. * @param subMesh The submesh we want to render in the shadow map
  9274. * @param useInstances Defines wether will draw in the map using instances
  9275. * @returns true if ready otherwise, false
  9276. */
  9277. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  9278. /**
  9279. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  9280. * @param defines Defines of the material we want to update
  9281. * @param lightIndex Index of the light in the enabled light list of the material
  9282. */
  9283. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  9284. /**
  9285. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  9286. * defined in the generator but impacting the effect).
  9287. * It implies the unifroms available on the materials are the standard BJS ones.
  9288. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  9289. * @param effect The effect we are binfing the information for
  9290. */
  9291. bindShadowLight(lightIndex: string, effect: Effect): void;
  9292. /**
  9293. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  9294. * (eq to shadow prjection matrix * light transform matrix)
  9295. * @returns The transform matrix used to create the shadow map
  9296. */
  9297. getTransformMatrix(): Matrix;
  9298. /**
  9299. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  9300. * Cube and 2D textures for instance.
  9301. */
  9302. recreateShadowMap(): void;
  9303. /**
  9304. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9305. * @param onCompiled Callback triggered at the and of the effects compilation
  9306. * @param options Sets of optional options forcing the compilation with different modes
  9307. */
  9308. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  9309. useInstances: boolean;
  9310. }>): void;
  9311. /**
  9312. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9313. * @param options Sets of optional options forcing the compilation with different modes
  9314. * @returns A promise that resolves when the compilation completes
  9315. */
  9316. forceCompilationAsync(options?: Partial<{
  9317. useInstances: boolean;
  9318. }>): Promise<void>;
  9319. /**
  9320. * Serializes the shadow generator setup to a json object.
  9321. * @returns The serialized JSON object
  9322. */
  9323. serialize(): any;
  9324. /**
  9325. * Disposes the Shadow map and related Textures and effects.
  9326. */
  9327. dispose(): void;
  9328. }
  9329. /**
  9330. * Default implementation IShadowGenerator.
  9331. * This is the main object responsible of generating shadows in the framework.
  9332. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  9333. */
  9334. export class ShadowGenerator implements IShadowGenerator {
  9335. /**
  9336. * Shadow generator mode None: no filtering applied.
  9337. */
  9338. static readonly FILTER_NONE: number;
  9339. /**
  9340. * Shadow generator mode ESM: Exponential Shadow Mapping.
  9341. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9342. */
  9343. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  9344. /**
  9345. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  9346. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  9347. */
  9348. static readonly FILTER_POISSONSAMPLING: number;
  9349. /**
  9350. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  9351. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9352. */
  9353. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  9354. /**
  9355. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  9356. * edge artifacts on steep falloff.
  9357. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9358. */
  9359. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  9360. /**
  9361. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  9362. * edge artifacts on steep falloff.
  9363. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9364. */
  9365. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  9366. /**
  9367. * Shadow generator mode PCF: Percentage Closer Filtering
  9368. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  9369. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  9370. */
  9371. static readonly FILTER_PCF: number;
  9372. /**
  9373. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  9374. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  9375. * Contact Hardening
  9376. */
  9377. static readonly FILTER_PCSS: number;
  9378. /**
  9379. * Reserved for PCF and PCSS
  9380. * Highest Quality.
  9381. *
  9382. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  9383. *
  9384. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  9385. */
  9386. static readonly QUALITY_HIGH: number;
  9387. /**
  9388. * Reserved for PCF and PCSS
  9389. * Good tradeoff for quality/perf cross devices
  9390. *
  9391. * Execute PCF on a 3*3 kernel.
  9392. *
  9393. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  9394. */
  9395. static readonly QUALITY_MEDIUM: number;
  9396. /**
  9397. * Reserved for PCF and PCSS
  9398. * The lowest quality but the fastest.
  9399. *
  9400. * Execute PCF on a 1*1 kernel.
  9401. *
  9402. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  9403. */
  9404. static readonly QUALITY_LOW: number;
  9405. /** Gets or sets the custom shader name to use */
  9406. customShaderOptions: ICustomShaderOptions;
  9407. /**
  9408. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  9409. */
  9410. onBeforeShadowMapRenderObservable: Observable<Effect>;
  9411. /**
  9412. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  9413. */
  9414. onAfterShadowMapRenderObservable: Observable<Effect>;
  9415. /**
  9416. * Observable triggered before a mesh is rendered in the shadow map.
  9417. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  9418. */
  9419. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  9420. /**
  9421. * Observable triggered after a mesh is rendered in the shadow map.
  9422. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  9423. */
  9424. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  9425. private _bias;
  9426. /**
  9427. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  9428. */
  9429. /**
  9430. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  9431. */
  9432. bias: number;
  9433. private _normalBias;
  9434. /**
  9435. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  9436. */
  9437. /**
  9438. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  9439. */
  9440. normalBias: number;
  9441. private _blurBoxOffset;
  9442. /**
  9443. * Gets the blur box offset: offset applied during the blur pass.
  9444. * Only useful if useKernelBlur = false
  9445. */
  9446. /**
  9447. * Sets the blur box offset: offset applied during the blur pass.
  9448. * Only useful if useKernelBlur = false
  9449. */
  9450. blurBoxOffset: number;
  9451. private _blurScale;
  9452. /**
  9453. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  9454. * 2 means half of the size.
  9455. */
  9456. /**
  9457. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  9458. * 2 means half of the size.
  9459. */
  9460. blurScale: number;
  9461. private _blurKernel;
  9462. /**
  9463. * Gets the blur kernel: kernel size of the blur pass.
  9464. * Only useful if useKernelBlur = true
  9465. */
  9466. /**
  9467. * Sets the blur kernel: kernel size of the blur pass.
  9468. * Only useful if useKernelBlur = true
  9469. */
  9470. blurKernel: number;
  9471. private _useKernelBlur;
  9472. /**
  9473. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  9474. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  9475. */
  9476. /**
  9477. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  9478. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  9479. */
  9480. useKernelBlur: boolean;
  9481. private _depthScale;
  9482. /**
  9483. * Gets the depth scale used in ESM mode.
  9484. */
  9485. /**
  9486. * Sets the depth scale used in ESM mode.
  9487. * This can override the scale stored on the light.
  9488. */
  9489. depthScale: number;
  9490. private _filter;
  9491. /**
  9492. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  9493. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  9494. */
  9495. /**
  9496. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  9497. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  9498. */
  9499. filter: number;
  9500. /**
  9501. * Gets if the current filter is set to Poisson Sampling.
  9502. */
  9503. /**
  9504. * Sets the current filter to Poisson Sampling.
  9505. */
  9506. usePoissonSampling: boolean;
  9507. /**
  9508. * Gets if the current filter is set to ESM.
  9509. */
  9510. /**
  9511. * Sets the current filter is to ESM.
  9512. */
  9513. useExponentialShadowMap: boolean;
  9514. /**
  9515. * Gets if the current filter is set to filtered ESM.
  9516. */
  9517. /**
  9518. * Gets if the current filter is set to filtered ESM.
  9519. */
  9520. useBlurExponentialShadowMap: boolean;
  9521. /**
  9522. * Gets if the current filter is set to "close ESM" (using the inverse of the
  9523. * exponential to prevent steep falloff artifacts).
  9524. */
  9525. /**
  9526. * Sets the current filter to "close ESM" (using the inverse of the
  9527. * exponential to prevent steep falloff artifacts).
  9528. */
  9529. useCloseExponentialShadowMap: boolean;
  9530. /**
  9531. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  9532. * exponential to prevent steep falloff artifacts).
  9533. */
  9534. /**
  9535. * Sets the current filter to filtered "close ESM" (using the inverse of the
  9536. * exponential to prevent steep falloff artifacts).
  9537. */
  9538. useBlurCloseExponentialShadowMap: boolean;
  9539. /**
  9540. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  9541. */
  9542. /**
  9543. * Sets the current filter to "PCF" (percentage closer filtering).
  9544. */
  9545. usePercentageCloserFiltering: boolean;
  9546. private _filteringQuality;
  9547. /**
  9548. * Gets the PCF or PCSS Quality.
  9549. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  9550. */
  9551. /**
  9552. * Sets the PCF or PCSS Quality.
  9553. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  9554. */
  9555. filteringQuality: number;
  9556. /**
  9557. * Gets if the current filter is set to "PCSS" (contact hardening).
  9558. */
  9559. /**
  9560. * Sets the current filter to "PCSS" (contact hardening).
  9561. */
  9562. useContactHardeningShadow: boolean;
  9563. private _contactHardeningLightSizeUVRatio;
  9564. /**
  9565. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  9566. * Using a ratio helps keeping shape stability independently of the map size.
  9567. *
  9568. * It does not account for the light projection as it was having too much
  9569. * instability during the light setup or during light position changes.
  9570. *
  9571. * Only valid if useContactHardeningShadow is true.
  9572. */
  9573. /**
  9574. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  9575. * Using a ratio helps keeping shape stability independently of the map size.
  9576. *
  9577. * It does not account for the light projection as it was having too much
  9578. * instability during the light setup or during light position changes.
  9579. *
  9580. * Only valid if useContactHardeningShadow is true.
  9581. */
  9582. contactHardeningLightSizeUVRatio: number;
  9583. private _darkness;
  9584. /** Gets or sets the actual darkness of a shadow */
  9585. darkness: number;
  9586. /**
  9587. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  9588. * 0 means strongest and 1 would means no shadow.
  9589. * @returns the darkness.
  9590. */
  9591. getDarkness(): number;
  9592. /**
  9593. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  9594. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  9595. * @returns the shadow generator allowing fluent coding.
  9596. */
  9597. setDarkness(darkness: number): ShadowGenerator;
  9598. private _transparencyShadow;
  9599. /** Gets or sets the ability to have transparent shadow */
  9600. transparencyShadow: boolean;
  9601. /**
  9602. * Sets the ability to have transparent shadow (boolean).
  9603. * @param transparent True if transparent else False
  9604. * @returns the shadow generator allowing fluent coding
  9605. */
  9606. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  9607. private _shadowMap;
  9608. private _shadowMap2;
  9609. /**
  9610. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  9611. * @returns The render target texture if present otherwise, null
  9612. */
  9613. getShadowMap(): Nullable<RenderTargetTexture>;
  9614. /**
  9615. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  9616. * @returns The render target texture if the shadow map is present otherwise, null
  9617. */
  9618. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  9619. /**
  9620. * Gets the class name of that object
  9621. * @returns "ShadowGenerator"
  9622. */
  9623. getClassName(): string;
  9624. /**
  9625. * Helper function to add a mesh and its descendants to the list of shadow casters.
  9626. * @param mesh Mesh to add
  9627. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  9628. * @returns the Shadow Generator itself
  9629. */
  9630. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  9631. /**
  9632. * Helper function to remove a mesh and its descendants from the list of shadow casters
  9633. * @param mesh Mesh to remove
  9634. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  9635. * @returns the Shadow Generator itself
  9636. */
  9637. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  9638. /**
  9639. * Controls the extent to which the shadows fade out at the edge of the frustum
  9640. * Used only by directionals and spots
  9641. */
  9642. frustumEdgeFalloff: number;
  9643. private _light;
  9644. /**
  9645. * Returns the associated light object.
  9646. * @returns the light generating the shadow
  9647. */
  9648. getLight(): IShadowLight;
  9649. /**
  9650. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  9651. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  9652. * It might on the other hand introduce peter panning.
  9653. */
  9654. forceBackFacesOnly: boolean;
  9655. private _scene;
  9656. private _lightDirection;
  9657. private _effect;
  9658. private _viewMatrix;
  9659. private _projectionMatrix;
  9660. private _transformMatrix;
  9661. private _cachedPosition;
  9662. private _cachedDirection;
  9663. private _cachedDefines;
  9664. private _currentRenderID;
  9665. private _boxBlurPostprocess;
  9666. private _kernelBlurXPostprocess;
  9667. private _kernelBlurYPostprocess;
  9668. private _blurPostProcesses;
  9669. private _mapSize;
  9670. private _currentFaceIndex;
  9671. private _currentFaceIndexCache;
  9672. private _textureType;
  9673. private _defaultTextureMatrix;
  9674. /** @hidden */
  9675. static _SceneComponentInitialization: (scene: Scene) => void;
  9676. /**
  9677. * Creates a ShadowGenerator object.
  9678. * A ShadowGenerator is the required tool to use the shadows.
  9679. * Each light casting shadows needs to use its own ShadowGenerator.
  9680. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  9681. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  9682. * @param light The light object generating the shadows.
  9683. * @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.
  9684. */
  9685. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  9686. private _initializeGenerator;
  9687. private _initializeShadowMap;
  9688. private _initializeBlurRTTAndPostProcesses;
  9689. private _renderForShadowMap;
  9690. private _renderSubMeshForShadowMap;
  9691. private _applyFilterValues;
  9692. /**
  9693. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9694. * @param onCompiled Callback triggered at the and of the effects compilation
  9695. * @param options Sets of optional options forcing the compilation with different modes
  9696. */
  9697. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  9698. useInstances: boolean;
  9699. }>): void;
  9700. /**
  9701. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9702. * @param options Sets of optional options forcing the compilation with different modes
  9703. * @returns A promise that resolves when the compilation completes
  9704. */
  9705. forceCompilationAsync(options?: Partial<{
  9706. useInstances: boolean;
  9707. }>): Promise<void>;
  9708. /**
  9709. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  9710. * @param subMesh The submesh we want to render in the shadow map
  9711. * @param useInstances Defines wether will draw in the map using instances
  9712. * @returns true if ready otherwise, false
  9713. */
  9714. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  9715. /**
  9716. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  9717. * @param defines Defines of the material we want to update
  9718. * @param lightIndex Index of the light in the enabled light list of the material
  9719. */
  9720. prepareDefines(defines: any, lightIndex: number): void;
  9721. /**
  9722. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  9723. * defined in the generator but impacting the effect).
  9724. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  9725. * @param effect The effect we are binfing the information for
  9726. */
  9727. bindShadowLight(lightIndex: string, effect: Effect): void;
  9728. /**
  9729. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  9730. * (eq to shadow prjection matrix * light transform matrix)
  9731. * @returns The transform matrix used to create the shadow map
  9732. */
  9733. getTransformMatrix(): Matrix;
  9734. /**
  9735. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  9736. * Cube and 2D textures for instance.
  9737. */
  9738. recreateShadowMap(): void;
  9739. private _disposeBlurPostProcesses;
  9740. private _disposeRTTandPostProcesses;
  9741. /**
  9742. * Disposes the ShadowGenerator.
  9743. * Returns nothing.
  9744. */
  9745. dispose(): void;
  9746. /**
  9747. * Serializes the shadow generator setup to a json object.
  9748. * @returns The serialized JSON object
  9749. */
  9750. serialize(): any;
  9751. /**
  9752. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  9753. * @param parsedShadowGenerator The JSON object to parse
  9754. * @param scene The scene to create the shadow map for
  9755. * @returns The parsed shadow generator
  9756. */
  9757. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  9758. }
  9759. }
  9760. declare module "babylonjs/Lights/light" {
  9761. import { Nullable } from "babylonjs/types";
  9762. import { Scene } from "babylonjs/scene";
  9763. import { Vector3 } from "babylonjs/Maths/math.vector";
  9764. import { Color3 } from "babylonjs/Maths/math.color";
  9765. import { Node } from "babylonjs/node";
  9766. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9767. import { Effect } from "babylonjs/Materials/effect";
  9768. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  9769. import { IShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  9770. /**
  9771. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  9772. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  9773. * 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.
  9774. */
  9775. export abstract class Light extends Node {
  9776. /**
  9777. * Falloff Default: light is falling off following the material specification:
  9778. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  9779. */
  9780. static readonly FALLOFF_DEFAULT: number;
  9781. /**
  9782. * Falloff Physical: light is falling off following the inverse squared distance law.
  9783. */
  9784. static readonly FALLOFF_PHYSICAL: number;
  9785. /**
  9786. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  9787. * to enhance interoperability with other engines.
  9788. */
  9789. static readonly FALLOFF_GLTF: number;
  9790. /**
  9791. * Falloff Standard: light is falling off like in the standard material
  9792. * to enhance interoperability with other materials.
  9793. */
  9794. static readonly FALLOFF_STANDARD: number;
  9795. /**
  9796. * If every light affecting the material is in this lightmapMode,
  9797. * material.lightmapTexture adds or multiplies
  9798. * (depends on material.useLightmapAsShadowmap)
  9799. * after every other light calculations.
  9800. */
  9801. static readonly LIGHTMAP_DEFAULT: number;
  9802. /**
  9803. * material.lightmapTexture as only diffuse lighting from this light
  9804. * adds only specular lighting from this light
  9805. * adds dynamic shadows
  9806. */
  9807. static readonly LIGHTMAP_SPECULAR: number;
  9808. /**
  9809. * material.lightmapTexture as only lighting
  9810. * no light calculation from this light
  9811. * only adds dynamic shadows from this light
  9812. */
  9813. static readonly LIGHTMAP_SHADOWSONLY: number;
  9814. /**
  9815. * Each light type uses the default quantity according to its type:
  9816. * point/spot lights use luminous intensity
  9817. * directional lights use illuminance
  9818. */
  9819. static readonly INTENSITYMODE_AUTOMATIC: number;
  9820. /**
  9821. * lumen (lm)
  9822. */
  9823. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  9824. /**
  9825. * candela (lm/sr)
  9826. */
  9827. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  9828. /**
  9829. * lux (lm/m^2)
  9830. */
  9831. static readonly INTENSITYMODE_ILLUMINANCE: number;
  9832. /**
  9833. * nit (cd/m^2)
  9834. */
  9835. static readonly INTENSITYMODE_LUMINANCE: number;
  9836. /**
  9837. * Light type const id of the point light.
  9838. */
  9839. static readonly LIGHTTYPEID_POINTLIGHT: number;
  9840. /**
  9841. * Light type const id of the directional light.
  9842. */
  9843. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  9844. /**
  9845. * Light type const id of the spot light.
  9846. */
  9847. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  9848. /**
  9849. * Light type const id of the hemispheric light.
  9850. */
  9851. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  9852. /**
  9853. * Diffuse gives the basic color to an object.
  9854. */
  9855. diffuse: Color3;
  9856. /**
  9857. * Specular produces a highlight color on an object.
  9858. * Note: This is note affecting PBR materials.
  9859. */
  9860. specular: Color3;
  9861. /**
  9862. * Defines the falloff type for this light. This lets overrriding how punctual light are
  9863. * falling off base on range or angle.
  9864. * This can be set to any values in Light.FALLOFF_x.
  9865. *
  9866. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  9867. * other types of materials.
  9868. */
  9869. falloffType: number;
  9870. /**
  9871. * Strength of the light.
  9872. * Note: By default it is define in the framework own unit.
  9873. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  9874. */
  9875. intensity: number;
  9876. private _range;
  9877. protected _inverseSquaredRange: number;
  9878. /**
  9879. * Defines how far from the source the light is impacting in scene units.
  9880. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  9881. */
  9882. /**
  9883. * Defines how far from the source the light is impacting in scene units.
  9884. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  9885. */
  9886. range: number;
  9887. /**
  9888. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  9889. * of light.
  9890. */
  9891. private _photometricScale;
  9892. private _intensityMode;
  9893. /**
  9894. * Gets the photometric scale used to interpret the intensity.
  9895. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  9896. */
  9897. /**
  9898. * Sets the photometric scale used to interpret the intensity.
  9899. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  9900. */
  9901. intensityMode: number;
  9902. private _radius;
  9903. /**
  9904. * Gets the light radius used by PBR Materials to simulate soft area lights.
  9905. */
  9906. /**
  9907. * sets the light radius used by PBR Materials to simulate soft area lights.
  9908. */
  9909. radius: number;
  9910. private _renderPriority;
  9911. /**
  9912. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  9913. * exceeding the number allowed of the materials.
  9914. */
  9915. renderPriority: number;
  9916. private _shadowEnabled;
  9917. /**
  9918. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  9919. * the current shadow generator.
  9920. */
  9921. /**
  9922. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  9923. * the current shadow generator.
  9924. */
  9925. shadowEnabled: boolean;
  9926. private _includedOnlyMeshes;
  9927. /**
  9928. * Gets the only meshes impacted by this light.
  9929. */
  9930. /**
  9931. * Sets the only meshes impacted by this light.
  9932. */
  9933. includedOnlyMeshes: AbstractMesh[];
  9934. private _excludedMeshes;
  9935. /**
  9936. * Gets the meshes not impacted by this light.
  9937. */
  9938. /**
  9939. * Sets the meshes not impacted by this light.
  9940. */
  9941. excludedMeshes: AbstractMesh[];
  9942. private _excludeWithLayerMask;
  9943. /**
  9944. * Gets the layer id use to find what meshes are not impacted by the light.
  9945. * Inactive if 0
  9946. */
  9947. /**
  9948. * Sets the layer id use to find what meshes are not impacted by the light.
  9949. * Inactive if 0
  9950. */
  9951. excludeWithLayerMask: number;
  9952. private _includeOnlyWithLayerMask;
  9953. /**
  9954. * Gets the layer id use to find what meshes are impacted by the light.
  9955. * Inactive if 0
  9956. */
  9957. /**
  9958. * Sets the layer id use to find what meshes are impacted by the light.
  9959. * Inactive if 0
  9960. */
  9961. includeOnlyWithLayerMask: number;
  9962. private _lightmapMode;
  9963. /**
  9964. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  9965. */
  9966. /**
  9967. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  9968. */
  9969. lightmapMode: number;
  9970. /**
  9971. * Shadow generator associted to the light.
  9972. * @hidden Internal use only.
  9973. */
  9974. _shadowGenerator: Nullable<IShadowGenerator>;
  9975. /**
  9976. * @hidden Internal use only.
  9977. */
  9978. _excludedMeshesIds: string[];
  9979. /**
  9980. * @hidden Internal use only.
  9981. */
  9982. _includedOnlyMeshesIds: string[];
  9983. /**
  9984. * The current light unifom buffer.
  9985. * @hidden Internal use only.
  9986. */
  9987. _uniformBuffer: UniformBuffer;
  9988. /**
  9989. * Creates a Light object in the scene.
  9990. * Documentation : https://doc.babylonjs.com/babylon101/lights
  9991. * @param name The firendly name of the light
  9992. * @param scene The scene the light belongs too
  9993. */
  9994. constructor(name: string, scene: Scene);
  9995. protected abstract _buildUniformLayout(): void;
  9996. /**
  9997. * Sets the passed Effect "effect" with the Light information.
  9998. * @param effect The effect to update
  9999. * @param lightIndex The index of the light in the effect to update
  10000. * @returns The light
  10001. */
  10002. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  10003. /**
  10004. * Sets the passed Effect "effect" with the Light information.
  10005. * @param effect The effect to update
  10006. * @param lightDataUniformName The uniform used to store light data (position or direction)
  10007. * @returns The light
  10008. */
  10009. abstract transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  10010. /**
  10011. * Returns the string "Light".
  10012. * @returns the class name
  10013. */
  10014. getClassName(): string;
  10015. /** @hidden */
  10016. readonly _isLight: boolean;
  10017. /**
  10018. * Converts the light information to a readable string for debug purpose.
  10019. * @param fullDetails Supports for multiple levels of logging within scene loading
  10020. * @returns the human readable light info
  10021. */
  10022. toString(fullDetails?: boolean): string;
  10023. /** @hidden */
  10024. protected _syncParentEnabledState(): void;
  10025. /**
  10026. * Set the enabled state of this node.
  10027. * @param value - the new enabled state
  10028. */
  10029. setEnabled(value: boolean): void;
  10030. /**
  10031. * Returns the Light associated shadow generator if any.
  10032. * @return the associated shadow generator.
  10033. */
  10034. getShadowGenerator(): Nullable<IShadowGenerator>;
  10035. /**
  10036. * Returns a Vector3, the absolute light position in the World.
  10037. * @returns the world space position of the light
  10038. */
  10039. getAbsolutePosition(): Vector3;
  10040. /**
  10041. * Specifies if the light will affect the passed mesh.
  10042. * @param mesh The mesh to test against the light
  10043. * @return true the mesh is affected otherwise, false.
  10044. */
  10045. canAffectMesh(mesh: AbstractMesh): boolean;
  10046. /**
  10047. * Sort function to order lights for rendering.
  10048. * @param a First Light object to compare to second.
  10049. * @param b Second Light object to compare first.
  10050. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  10051. */
  10052. static CompareLightsPriority(a: Light, b: Light): number;
  10053. /**
  10054. * Releases resources associated with this node.
  10055. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  10056. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  10057. */
  10058. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  10059. /**
  10060. * Returns the light type ID (integer).
  10061. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  10062. */
  10063. getTypeID(): number;
  10064. /**
  10065. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  10066. * @returns the scaled intensity in intensity mode unit
  10067. */
  10068. getScaledIntensity(): number;
  10069. /**
  10070. * Returns a new Light object, named "name", from the current one.
  10071. * @param name The name of the cloned light
  10072. * @returns the new created light
  10073. */
  10074. clone(name: string): Nullable<Light>;
  10075. /**
  10076. * Serializes the current light into a Serialization object.
  10077. * @returns the serialized object.
  10078. */
  10079. serialize(): any;
  10080. /**
  10081. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  10082. * This new light is named "name" and added to the passed scene.
  10083. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  10084. * @param name The friendly name of the light
  10085. * @param scene The scene the new light will belong to
  10086. * @returns the constructor function
  10087. */
  10088. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  10089. /**
  10090. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  10091. * @param parsedLight The JSON representation of the light
  10092. * @param scene The scene to create the parsed light in
  10093. * @returns the created light after parsing
  10094. */
  10095. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  10096. private _hookArrayForExcluded;
  10097. private _hookArrayForIncludedOnly;
  10098. private _resyncMeshes;
  10099. /**
  10100. * Forces the meshes to update their light related information in their rendering used effects
  10101. * @hidden Internal Use Only
  10102. */
  10103. _markMeshesAsLightDirty(): void;
  10104. /**
  10105. * Recomputes the cached photometric scale if needed.
  10106. */
  10107. private _computePhotometricScale;
  10108. /**
  10109. * Returns the Photometric Scale according to the light type and intensity mode.
  10110. */
  10111. private _getPhotometricScale;
  10112. /**
  10113. * Reorder the light in the scene according to their defined priority.
  10114. * @hidden Internal Use Only
  10115. */
  10116. _reorderLightsInScene(): void;
  10117. /**
  10118. * Prepares the list of defines specific to the light type.
  10119. * @param defines the list of defines
  10120. * @param lightIndex defines the index of the light for the effect
  10121. */
  10122. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  10123. }
  10124. }
  10125. declare module "babylonjs/Actions/action" {
  10126. import { Observable } from "babylonjs/Misc/observable";
  10127. import { Condition } from "babylonjs/Actions/condition";
  10128. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  10129. import { ActionManager } from "babylonjs/Actions/actionManager";
  10130. import { ActionEvent } from "babylonjs/Actions/actionEvent";
  10131. /**
  10132. * Interface used to define Action
  10133. */
  10134. export interface IAction {
  10135. /**
  10136. * Trigger for the action
  10137. */
  10138. trigger: number;
  10139. /** Options of the trigger */
  10140. triggerOptions: any;
  10141. /**
  10142. * Gets the trigger parameters
  10143. * @returns the trigger parameters
  10144. */
  10145. getTriggerParameter(): any;
  10146. /**
  10147. * Internal only - executes current action event
  10148. * @hidden
  10149. */
  10150. _executeCurrent(evt?: ActionEvent): void;
  10151. /**
  10152. * Serialize placeholder for child classes
  10153. * @param parent of child
  10154. * @returns the serialized object
  10155. */
  10156. serialize(parent: any): any;
  10157. /**
  10158. * Internal only
  10159. * @hidden
  10160. */
  10161. _prepare(): void;
  10162. /**
  10163. * Internal only - manager for action
  10164. * @hidden
  10165. */
  10166. _actionManager: AbstractActionManager;
  10167. /**
  10168. * Adds action to chain of actions, may be a DoNothingAction
  10169. * @param action defines the next action to execute
  10170. * @returns The action passed in
  10171. * @see https://www.babylonjs-playground.com/#1T30HR#0
  10172. */
  10173. then(action: IAction): IAction;
  10174. }
  10175. /**
  10176. * The action to be carried out following a trigger
  10177. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  10178. */
  10179. export class Action implements IAction {
  10180. /** the trigger, with or without parameters, for the action */
  10181. triggerOptions: any;
  10182. /**
  10183. * Trigger for the action
  10184. */
  10185. trigger: number;
  10186. /**
  10187. * Internal only - manager for action
  10188. * @hidden
  10189. */
  10190. _actionManager: ActionManager;
  10191. private _nextActiveAction;
  10192. private _child;
  10193. private _condition?;
  10194. private _triggerParameter;
  10195. /**
  10196. * An event triggered prior to action being executed.
  10197. */
  10198. onBeforeExecuteObservable: Observable<Action>;
  10199. /**
  10200. * Creates a new Action
  10201. * @param triggerOptions the trigger, with or without parameters, for the action
  10202. * @param condition an optional determinant of action
  10203. */
  10204. constructor(
  10205. /** the trigger, with or without parameters, for the action */
  10206. triggerOptions: any, condition?: Condition);
  10207. /**
  10208. * Internal only
  10209. * @hidden
  10210. */
  10211. _prepare(): void;
  10212. /**
  10213. * Gets the trigger parameters
  10214. * @returns the trigger parameters
  10215. */
  10216. getTriggerParameter(): any;
  10217. /**
  10218. * Internal only - executes current action event
  10219. * @hidden
  10220. */
  10221. _executeCurrent(evt?: ActionEvent): void;
  10222. /**
  10223. * Execute placeholder for child classes
  10224. * @param evt optional action event
  10225. */
  10226. execute(evt?: ActionEvent): void;
  10227. /**
  10228. * Skips to next active action
  10229. */
  10230. skipToNextActiveAction(): void;
  10231. /**
  10232. * Adds action to chain of actions, may be a DoNothingAction
  10233. * @param action defines the next action to execute
  10234. * @returns The action passed in
  10235. * @see https://www.babylonjs-playground.com/#1T30HR#0
  10236. */
  10237. then(action: Action): Action;
  10238. /**
  10239. * Internal only
  10240. * @hidden
  10241. */
  10242. _getProperty(propertyPath: string): string;
  10243. /**
  10244. * Internal only
  10245. * @hidden
  10246. */
  10247. _getEffectiveTarget(target: any, propertyPath: string): any;
  10248. /**
  10249. * Serialize placeholder for child classes
  10250. * @param parent of child
  10251. * @returns the serialized object
  10252. */
  10253. serialize(parent: any): any;
  10254. /**
  10255. * Internal only called by serialize
  10256. * @hidden
  10257. */
  10258. protected _serialize(serializedAction: any, parent?: any): any;
  10259. /**
  10260. * Internal only
  10261. * @hidden
  10262. */
  10263. static _SerializeValueAsString: (value: any) => string;
  10264. /**
  10265. * Internal only
  10266. * @hidden
  10267. */
  10268. static _GetTargetProperty: (target: import("babylonjs/node").Node | import("babylonjs/scene").Scene) => {
  10269. name: string;
  10270. targetType: string;
  10271. value: string;
  10272. };
  10273. }
  10274. }
  10275. declare module "babylonjs/Actions/condition" {
  10276. import { ActionManager } from "babylonjs/Actions/actionManager";
  10277. /**
  10278. * A Condition applied to an Action
  10279. */
  10280. export class Condition {
  10281. /**
  10282. * Internal only - manager for action
  10283. * @hidden
  10284. */
  10285. _actionManager: ActionManager;
  10286. /**
  10287. * Internal only
  10288. * @hidden
  10289. */
  10290. _evaluationId: number;
  10291. /**
  10292. * Internal only
  10293. * @hidden
  10294. */
  10295. _currentResult: boolean;
  10296. /**
  10297. * Creates a new Condition
  10298. * @param actionManager the manager of the action the condition is applied to
  10299. */
  10300. constructor(actionManager: ActionManager);
  10301. /**
  10302. * Check if the current condition is valid
  10303. * @returns a boolean
  10304. */
  10305. isValid(): boolean;
  10306. /**
  10307. * Internal only
  10308. * @hidden
  10309. */
  10310. _getProperty(propertyPath: string): string;
  10311. /**
  10312. * Internal only
  10313. * @hidden
  10314. */
  10315. _getEffectiveTarget(target: any, propertyPath: string): any;
  10316. /**
  10317. * Serialize placeholder for child classes
  10318. * @returns the serialized object
  10319. */
  10320. serialize(): any;
  10321. /**
  10322. * Internal only
  10323. * @hidden
  10324. */
  10325. protected _serialize(serializedCondition: any): any;
  10326. }
  10327. /**
  10328. * Defines specific conditional operators as extensions of Condition
  10329. */
  10330. export class ValueCondition extends Condition {
  10331. /** path to specify the property of the target the conditional operator uses */
  10332. propertyPath: string;
  10333. /** the value compared by the conditional operator against the current value of the property */
  10334. value: any;
  10335. /** the conditional operator, default ValueCondition.IsEqual */
  10336. operator: number;
  10337. /**
  10338. * Internal only
  10339. * @hidden
  10340. */
  10341. private static _IsEqual;
  10342. /**
  10343. * Internal only
  10344. * @hidden
  10345. */
  10346. private static _IsDifferent;
  10347. /**
  10348. * Internal only
  10349. * @hidden
  10350. */
  10351. private static _IsGreater;
  10352. /**
  10353. * Internal only
  10354. * @hidden
  10355. */
  10356. private static _IsLesser;
  10357. /**
  10358. * returns the number for IsEqual
  10359. */
  10360. static readonly IsEqual: number;
  10361. /**
  10362. * Returns the number for IsDifferent
  10363. */
  10364. static readonly IsDifferent: number;
  10365. /**
  10366. * Returns the number for IsGreater
  10367. */
  10368. static readonly IsGreater: number;
  10369. /**
  10370. * Returns the number for IsLesser
  10371. */
  10372. static readonly IsLesser: number;
  10373. /**
  10374. * Internal only The action manager for the condition
  10375. * @hidden
  10376. */
  10377. _actionManager: ActionManager;
  10378. /**
  10379. * Internal only
  10380. * @hidden
  10381. */
  10382. private _target;
  10383. /**
  10384. * Internal only
  10385. * @hidden
  10386. */
  10387. private _effectiveTarget;
  10388. /**
  10389. * Internal only
  10390. * @hidden
  10391. */
  10392. private _property;
  10393. /**
  10394. * Creates a new ValueCondition
  10395. * @param actionManager manager for the action the condition applies to
  10396. * @param target for the action
  10397. * @param propertyPath path to specify the property of the target the conditional operator uses
  10398. * @param value the value compared by the conditional operator against the current value of the property
  10399. * @param operator the conditional operator, default ValueCondition.IsEqual
  10400. */
  10401. constructor(actionManager: ActionManager, target: any,
  10402. /** path to specify the property of the target the conditional operator uses */
  10403. propertyPath: string,
  10404. /** the value compared by the conditional operator against the current value of the property */
  10405. value: any,
  10406. /** the conditional operator, default ValueCondition.IsEqual */
  10407. operator?: number);
  10408. /**
  10409. * Compares the given value with the property value for the specified conditional operator
  10410. * @returns the result of the comparison
  10411. */
  10412. isValid(): boolean;
  10413. /**
  10414. * Serialize the ValueCondition into a JSON compatible object
  10415. * @returns serialization object
  10416. */
  10417. serialize(): any;
  10418. /**
  10419. * Gets the name of the conditional operator for the ValueCondition
  10420. * @param operator the conditional operator
  10421. * @returns the name
  10422. */
  10423. static GetOperatorName(operator: number): string;
  10424. }
  10425. /**
  10426. * Defines a predicate condition as an extension of Condition
  10427. */
  10428. export class PredicateCondition extends Condition {
  10429. /** defines the predicate function used to validate the condition */
  10430. predicate: () => boolean;
  10431. /**
  10432. * Internal only - manager for action
  10433. * @hidden
  10434. */
  10435. _actionManager: ActionManager;
  10436. /**
  10437. * Creates a new PredicateCondition
  10438. * @param actionManager manager for the action the condition applies to
  10439. * @param predicate defines the predicate function used to validate the condition
  10440. */
  10441. constructor(actionManager: ActionManager,
  10442. /** defines the predicate function used to validate the condition */
  10443. predicate: () => boolean);
  10444. /**
  10445. * @returns the validity of the predicate condition
  10446. */
  10447. isValid(): boolean;
  10448. }
  10449. /**
  10450. * Defines a state condition as an extension of Condition
  10451. */
  10452. export class StateCondition extends Condition {
  10453. /** Value to compare with target state */
  10454. value: string;
  10455. /**
  10456. * Internal only - manager for action
  10457. * @hidden
  10458. */
  10459. _actionManager: ActionManager;
  10460. /**
  10461. * Internal only
  10462. * @hidden
  10463. */
  10464. private _target;
  10465. /**
  10466. * Creates a new StateCondition
  10467. * @param actionManager manager for the action the condition applies to
  10468. * @param target of the condition
  10469. * @param value to compare with target state
  10470. */
  10471. constructor(actionManager: ActionManager, target: any,
  10472. /** Value to compare with target state */
  10473. value: string);
  10474. /**
  10475. * Gets a boolean indicating if the current condition is met
  10476. * @returns the validity of the state
  10477. */
  10478. isValid(): boolean;
  10479. /**
  10480. * Serialize the StateCondition into a JSON compatible object
  10481. * @returns serialization object
  10482. */
  10483. serialize(): any;
  10484. }
  10485. }
  10486. declare module "babylonjs/Actions/directActions" {
  10487. import { Action } from "babylonjs/Actions/action";
  10488. import { Condition } from "babylonjs/Actions/condition";
  10489. import { ActionEvent } from "babylonjs/Actions/actionEvent";
  10490. /**
  10491. * This defines an action responsible to toggle a boolean once triggered.
  10492. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10493. */
  10494. export class SwitchBooleanAction extends Action {
  10495. /**
  10496. * The path to the boolean property in the target object
  10497. */
  10498. propertyPath: string;
  10499. private _target;
  10500. private _effectiveTarget;
  10501. private _property;
  10502. /**
  10503. * Instantiate the action
  10504. * @param triggerOptions defines the trigger options
  10505. * @param target defines the object containing the boolean
  10506. * @param propertyPath defines the path to the boolean property in the target object
  10507. * @param condition defines the trigger related conditions
  10508. */
  10509. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  10510. /** @hidden */
  10511. _prepare(): void;
  10512. /**
  10513. * Execute the action toggle the boolean value.
  10514. */
  10515. execute(): void;
  10516. /**
  10517. * Serializes the actions and its related information.
  10518. * @param parent defines the object to serialize in
  10519. * @returns the serialized object
  10520. */
  10521. serialize(parent: any): any;
  10522. }
  10523. /**
  10524. * This defines an action responsible to set a the state field of the target
  10525. * to a desired value once triggered.
  10526. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10527. */
  10528. export class SetStateAction extends Action {
  10529. /**
  10530. * The value to store in the state field.
  10531. */
  10532. value: string;
  10533. private _target;
  10534. /**
  10535. * Instantiate the action
  10536. * @param triggerOptions defines the trigger options
  10537. * @param target defines the object containing the state property
  10538. * @param value defines the value to store in the state field
  10539. * @param condition defines the trigger related conditions
  10540. */
  10541. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  10542. /**
  10543. * Execute the action and store the value on the target state property.
  10544. */
  10545. execute(): void;
  10546. /**
  10547. * Serializes the actions and its related information.
  10548. * @param parent defines the object to serialize in
  10549. * @returns the serialized object
  10550. */
  10551. serialize(parent: any): any;
  10552. }
  10553. /**
  10554. * This defines an action responsible to set a property of the target
  10555. * to a desired value once triggered.
  10556. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10557. */
  10558. export class SetValueAction extends Action {
  10559. /**
  10560. * The path of the property to set in the target.
  10561. */
  10562. propertyPath: string;
  10563. /**
  10564. * The value to set in the property
  10565. */
  10566. value: any;
  10567. private _target;
  10568. private _effectiveTarget;
  10569. private _property;
  10570. /**
  10571. * Instantiate the action
  10572. * @param triggerOptions defines the trigger options
  10573. * @param target defines the object containing the property
  10574. * @param propertyPath defines the path of the property to set in the target
  10575. * @param value defines the value to set in the property
  10576. * @param condition defines the trigger related conditions
  10577. */
  10578. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  10579. /** @hidden */
  10580. _prepare(): void;
  10581. /**
  10582. * Execute the action and set the targetted property to the desired value.
  10583. */
  10584. execute(): void;
  10585. /**
  10586. * Serializes the actions and its related information.
  10587. * @param parent defines the object to serialize in
  10588. * @returns the serialized object
  10589. */
  10590. serialize(parent: any): any;
  10591. }
  10592. /**
  10593. * This defines an action responsible to increment the target value
  10594. * to a desired value once triggered.
  10595. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10596. */
  10597. export class IncrementValueAction extends Action {
  10598. /**
  10599. * The path of the property to increment in the target.
  10600. */
  10601. propertyPath: string;
  10602. /**
  10603. * The value we should increment the property by.
  10604. */
  10605. value: any;
  10606. private _target;
  10607. private _effectiveTarget;
  10608. private _property;
  10609. /**
  10610. * Instantiate the action
  10611. * @param triggerOptions defines the trigger options
  10612. * @param target defines the object containing the property
  10613. * @param propertyPath defines the path of the property to increment in the target
  10614. * @param value defines the value value we should increment the property by
  10615. * @param condition defines the trigger related conditions
  10616. */
  10617. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  10618. /** @hidden */
  10619. _prepare(): void;
  10620. /**
  10621. * Execute the action and increment the target of the value amount.
  10622. */
  10623. execute(): void;
  10624. /**
  10625. * Serializes the actions and its related information.
  10626. * @param parent defines the object to serialize in
  10627. * @returns the serialized object
  10628. */
  10629. serialize(parent: any): any;
  10630. }
  10631. /**
  10632. * This defines an action responsible to start an animation once triggered.
  10633. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10634. */
  10635. export class PlayAnimationAction extends Action {
  10636. /**
  10637. * Where the animation should start (animation frame)
  10638. */
  10639. from: number;
  10640. /**
  10641. * Where the animation should stop (animation frame)
  10642. */
  10643. to: number;
  10644. /**
  10645. * Define if the animation should loop or stop after the first play.
  10646. */
  10647. loop?: boolean;
  10648. private _target;
  10649. /**
  10650. * Instantiate the action
  10651. * @param triggerOptions defines the trigger options
  10652. * @param target defines the target animation or animation name
  10653. * @param from defines from where the animation should start (animation frame)
  10654. * @param end defines where the animation should stop (animation frame)
  10655. * @param loop defines if the animation should loop or stop after the first play
  10656. * @param condition defines the trigger related conditions
  10657. */
  10658. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  10659. /** @hidden */
  10660. _prepare(): void;
  10661. /**
  10662. * Execute the action and play the animation.
  10663. */
  10664. execute(): void;
  10665. /**
  10666. * Serializes the actions and its related information.
  10667. * @param parent defines the object to serialize in
  10668. * @returns the serialized object
  10669. */
  10670. serialize(parent: any): any;
  10671. }
  10672. /**
  10673. * This defines an action responsible to stop an animation once triggered.
  10674. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10675. */
  10676. export class StopAnimationAction extends Action {
  10677. private _target;
  10678. /**
  10679. * Instantiate the action
  10680. * @param triggerOptions defines the trigger options
  10681. * @param target defines the target animation or animation name
  10682. * @param condition defines the trigger related conditions
  10683. */
  10684. constructor(triggerOptions: any, target: any, condition?: Condition);
  10685. /** @hidden */
  10686. _prepare(): void;
  10687. /**
  10688. * Execute the action and stop the animation.
  10689. */
  10690. execute(): void;
  10691. /**
  10692. * Serializes the actions and its related information.
  10693. * @param parent defines the object to serialize in
  10694. * @returns the serialized object
  10695. */
  10696. serialize(parent: any): any;
  10697. }
  10698. /**
  10699. * This defines an action responsible that does nothing once triggered.
  10700. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10701. */
  10702. export class DoNothingAction extends Action {
  10703. /**
  10704. * Instantiate the action
  10705. * @param triggerOptions defines the trigger options
  10706. * @param condition defines the trigger related conditions
  10707. */
  10708. constructor(triggerOptions?: any, condition?: Condition);
  10709. /**
  10710. * Execute the action and do nothing.
  10711. */
  10712. execute(): void;
  10713. /**
  10714. * Serializes the actions and its related information.
  10715. * @param parent defines the object to serialize in
  10716. * @returns the serialized object
  10717. */
  10718. serialize(parent: any): any;
  10719. }
  10720. /**
  10721. * This defines an action responsible to trigger several actions once triggered.
  10722. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10723. */
  10724. export class CombineAction extends Action {
  10725. /**
  10726. * The list of aggregated animations to run.
  10727. */
  10728. children: Action[];
  10729. /**
  10730. * Instantiate the action
  10731. * @param triggerOptions defines the trigger options
  10732. * @param children defines the list of aggregated animations to run
  10733. * @param condition defines the trigger related conditions
  10734. */
  10735. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  10736. /** @hidden */
  10737. _prepare(): void;
  10738. /**
  10739. * Execute the action and executes all the aggregated actions.
  10740. */
  10741. execute(evt: ActionEvent): void;
  10742. /**
  10743. * Serializes the actions and its related information.
  10744. * @param parent defines the object to serialize in
  10745. * @returns the serialized object
  10746. */
  10747. serialize(parent: any): any;
  10748. }
  10749. /**
  10750. * This defines an action responsible to run code (external event) once triggered.
  10751. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10752. */
  10753. export class ExecuteCodeAction extends Action {
  10754. /**
  10755. * The callback function to run.
  10756. */
  10757. func: (evt: ActionEvent) => void;
  10758. /**
  10759. * Instantiate the action
  10760. * @param triggerOptions defines the trigger options
  10761. * @param func defines the callback function to run
  10762. * @param condition defines the trigger related conditions
  10763. */
  10764. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  10765. /**
  10766. * Execute the action and run the attached code.
  10767. */
  10768. execute(evt: ActionEvent): void;
  10769. }
  10770. /**
  10771. * This defines an action responsible to set the parent property of the target once triggered.
  10772. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10773. */
  10774. export class SetParentAction extends Action {
  10775. private _parent;
  10776. private _target;
  10777. /**
  10778. * Instantiate the action
  10779. * @param triggerOptions defines the trigger options
  10780. * @param target defines the target containing the parent property
  10781. * @param parent defines from where the animation should start (animation frame)
  10782. * @param condition defines the trigger related conditions
  10783. */
  10784. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  10785. /** @hidden */
  10786. _prepare(): void;
  10787. /**
  10788. * Execute the action and set the parent property.
  10789. */
  10790. execute(): void;
  10791. /**
  10792. * Serializes the actions and its related information.
  10793. * @param parent defines the object to serialize in
  10794. * @returns the serialized object
  10795. */
  10796. serialize(parent: any): any;
  10797. }
  10798. }
  10799. declare module "babylonjs/Actions/actionManager" {
  10800. import { Nullable } from "babylonjs/types";
  10801. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  10802. import { Scene } from "babylonjs/scene";
  10803. import { IAction } from "babylonjs/Actions/action";
  10804. import { IActionEvent } from "babylonjs/Actions/actionEvent";
  10805. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  10806. /**
  10807. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  10808. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  10809. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10810. */
  10811. export class ActionManager extends AbstractActionManager {
  10812. /**
  10813. * Nothing
  10814. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10815. */
  10816. static readonly NothingTrigger: number;
  10817. /**
  10818. * On pick
  10819. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10820. */
  10821. static readonly OnPickTrigger: number;
  10822. /**
  10823. * On left pick
  10824. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10825. */
  10826. static readonly OnLeftPickTrigger: number;
  10827. /**
  10828. * On right pick
  10829. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10830. */
  10831. static readonly OnRightPickTrigger: number;
  10832. /**
  10833. * On center pick
  10834. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10835. */
  10836. static readonly OnCenterPickTrigger: number;
  10837. /**
  10838. * On pick down
  10839. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10840. */
  10841. static readonly OnPickDownTrigger: number;
  10842. /**
  10843. * On double pick
  10844. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10845. */
  10846. static readonly OnDoublePickTrigger: number;
  10847. /**
  10848. * On pick up
  10849. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10850. */
  10851. static readonly OnPickUpTrigger: number;
  10852. /**
  10853. * On pick out.
  10854. * This trigger will only be raised if you also declared a OnPickDown
  10855. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10856. */
  10857. static readonly OnPickOutTrigger: number;
  10858. /**
  10859. * On long press
  10860. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10861. */
  10862. static readonly OnLongPressTrigger: number;
  10863. /**
  10864. * On pointer over
  10865. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10866. */
  10867. static readonly OnPointerOverTrigger: number;
  10868. /**
  10869. * On pointer out
  10870. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10871. */
  10872. static readonly OnPointerOutTrigger: number;
  10873. /**
  10874. * On every frame
  10875. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10876. */
  10877. static readonly OnEveryFrameTrigger: number;
  10878. /**
  10879. * On intersection enter
  10880. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10881. */
  10882. static readonly OnIntersectionEnterTrigger: number;
  10883. /**
  10884. * On intersection exit
  10885. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10886. */
  10887. static readonly OnIntersectionExitTrigger: number;
  10888. /**
  10889. * On key down
  10890. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10891. */
  10892. static readonly OnKeyDownTrigger: number;
  10893. /**
  10894. * On key up
  10895. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10896. */
  10897. static readonly OnKeyUpTrigger: number;
  10898. private _scene;
  10899. /**
  10900. * Creates a new action manager
  10901. * @param scene defines the hosting scene
  10902. */
  10903. constructor(scene: Scene);
  10904. /**
  10905. * Releases all associated resources
  10906. */
  10907. dispose(): void;
  10908. /**
  10909. * Gets hosting scene
  10910. * @returns the hosting scene
  10911. */
  10912. getScene(): Scene;
  10913. /**
  10914. * Does this action manager handles actions of any of the given triggers
  10915. * @param triggers defines the triggers to be tested
  10916. * @return a boolean indicating whether one (or more) of the triggers is handled
  10917. */
  10918. hasSpecificTriggers(triggers: number[]): boolean;
  10919. /**
  10920. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  10921. * speed.
  10922. * @param triggerA defines the trigger to be tested
  10923. * @param triggerB defines the trigger to be tested
  10924. * @return a boolean indicating whether one (or more) of the triggers is handled
  10925. */
  10926. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  10927. /**
  10928. * Does this action manager handles actions of a given trigger
  10929. * @param trigger defines the trigger to be tested
  10930. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  10931. * @return whether the trigger is handled
  10932. */
  10933. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  10934. /**
  10935. * Does this action manager has pointer triggers
  10936. */
  10937. readonly hasPointerTriggers: boolean;
  10938. /**
  10939. * Does this action manager has pick triggers
  10940. */
  10941. readonly hasPickTriggers: boolean;
  10942. /**
  10943. * Registers an action to this action manager
  10944. * @param action defines the action to be registered
  10945. * @return the action amended (prepared) after registration
  10946. */
  10947. registerAction(action: IAction): Nullable<IAction>;
  10948. /**
  10949. * Unregisters an action to this action manager
  10950. * @param action defines the action to be unregistered
  10951. * @return a boolean indicating whether the action has been unregistered
  10952. */
  10953. unregisterAction(action: IAction): Boolean;
  10954. /**
  10955. * Process a specific trigger
  10956. * @param trigger defines the trigger to process
  10957. * @param evt defines the event details to be processed
  10958. */
  10959. processTrigger(trigger: number, evt?: IActionEvent): void;
  10960. /** @hidden */
  10961. _getEffectiveTarget(target: any, propertyPath: string): any;
  10962. /** @hidden */
  10963. _getProperty(propertyPath: string): string;
  10964. /**
  10965. * Serialize this manager to a JSON object
  10966. * @param name defines the property name to store this manager
  10967. * @returns a JSON representation of this manager
  10968. */
  10969. serialize(name: string): any;
  10970. /**
  10971. * Creates a new ActionManager from a JSON data
  10972. * @param parsedActions defines the JSON data to read from
  10973. * @param object defines the hosting mesh
  10974. * @param scene defines the hosting scene
  10975. */
  10976. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  10977. /**
  10978. * Get a trigger name by index
  10979. * @param trigger defines the trigger index
  10980. * @returns a trigger name
  10981. */
  10982. static GetTriggerName(trigger: number): string;
  10983. }
  10984. }
  10985. declare module "babylonjs/Culling/ray" {
  10986. import { DeepImmutable, Nullable, float } from "babylonjs/types";
  10987. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  10988. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  10989. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  10990. import { IntersectionInfo } from "babylonjs/Collisions/intersectionInfo";
  10991. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  10992. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  10993. import { Plane } from "babylonjs/Maths/math.plane";
  10994. /**
  10995. * Class representing a ray with position and direction
  10996. */
  10997. export class Ray {
  10998. /** origin point */
  10999. origin: Vector3;
  11000. /** direction */
  11001. direction: Vector3;
  11002. /** length of the ray */
  11003. length: number;
  11004. private static readonly TmpVector3;
  11005. private _tmpRay;
  11006. /**
  11007. * Creates a new ray
  11008. * @param origin origin point
  11009. * @param direction direction
  11010. * @param length length of the ray
  11011. */
  11012. constructor(
  11013. /** origin point */
  11014. origin: Vector3,
  11015. /** direction */
  11016. direction: Vector3,
  11017. /** length of the ray */
  11018. length?: number);
  11019. /**
  11020. * Checks if the ray intersects a box
  11021. * @param minimum bound of the box
  11022. * @param maximum bound of the box
  11023. * @param intersectionTreshold extra extend to be added to the box in all direction
  11024. * @returns if the box was hit
  11025. */
  11026. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  11027. /**
  11028. * Checks if the ray intersects a box
  11029. * @param box the bounding box to check
  11030. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  11031. * @returns if the box was hit
  11032. */
  11033. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  11034. /**
  11035. * If the ray hits a sphere
  11036. * @param sphere the bounding sphere to check
  11037. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  11038. * @returns true if it hits the sphere
  11039. */
  11040. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  11041. /**
  11042. * If the ray hits a triange
  11043. * @param vertex0 triangle vertex
  11044. * @param vertex1 triangle vertex
  11045. * @param vertex2 triangle vertex
  11046. * @returns intersection information if hit
  11047. */
  11048. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  11049. /**
  11050. * Checks if ray intersects a plane
  11051. * @param plane the plane to check
  11052. * @returns the distance away it was hit
  11053. */
  11054. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  11055. /**
  11056. * Calculate the intercept of a ray on a given axis
  11057. * @param axis to check 'x' | 'y' | 'z'
  11058. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  11059. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  11060. */
  11061. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  11062. /**
  11063. * Checks if ray intersects a mesh
  11064. * @param mesh the mesh to check
  11065. * @param fastCheck if only the bounding box should checked
  11066. * @returns picking info of the intersecton
  11067. */
  11068. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  11069. /**
  11070. * Checks if ray intersects a mesh
  11071. * @param meshes the meshes to check
  11072. * @param fastCheck if only the bounding box should checked
  11073. * @param results array to store result in
  11074. * @returns Array of picking infos
  11075. */
  11076. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  11077. private _comparePickingInfo;
  11078. private static smallnum;
  11079. private static rayl;
  11080. /**
  11081. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  11082. * @param sega the first point of the segment to test the intersection against
  11083. * @param segb the second point of the segment to test the intersection against
  11084. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  11085. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  11086. */
  11087. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  11088. /**
  11089. * Update the ray from viewport position
  11090. * @param x position
  11091. * @param y y position
  11092. * @param viewportWidth viewport width
  11093. * @param viewportHeight viewport height
  11094. * @param world world matrix
  11095. * @param view view matrix
  11096. * @param projection projection matrix
  11097. * @returns this ray updated
  11098. */
  11099. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  11100. /**
  11101. * Creates a ray with origin and direction of 0,0,0
  11102. * @returns the new ray
  11103. */
  11104. static Zero(): Ray;
  11105. /**
  11106. * Creates a new ray from screen space and viewport
  11107. * @param x position
  11108. * @param y y position
  11109. * @param viewportWidth viewport width
  11110. * @param viewportHeight viewport height
  11111. * @param world world matrix
  11112. * @param view view matrix
  11113. * @param projection projection matrix
  11114. * @returns new ray
  11115. */
  11116. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  11117. /**
  11118. * 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
  11119. * transformed to the given world matrix.
  11120. * @param origin The origin point
  11121. * @param end The end point
  11122. * @param world a matrix to transform the ray to. Default is the identity matrix.
  11123. * @returns the new ray
  11124. */
  11125. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  11126. /**
  11127. * Transforms a ray by a matrix
  11128. * @param ray ray to transform
  11129. * @param matrix matrix to apply
  11130. * @returns the resulting new ray
  11131. */
  11132. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  11133. /**
  11134. * Transforms a ray by a matrix
  11135. * @param ray ray to transform
  11136. * @param matrix matrix to apply
  11137. * @param result ray to store result in
  11138. */
  11139. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  11140. /**
  11141. * Unproject a ray from screen space to object space
  11142. * @param sourceX defines the screen space x coordinate to use
  11143. * @param sourceY defines the screen space y coordinate to use
  11144. * @param viewportWidth defines the current width of the viewport
  11145. * @param viewportHeight defines the current height of the viewport
  11146. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  11147. * @param view defines the view matrix to use
  11148. * @param projection defines the projection matrix to use
  11149. */
  11150. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  11151. }
  11152. /**
  11153. * Type used to define predicate used to select faces when a mesh intersection is detected
  11154. */
  11155. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  11156. module "babylonjs/scene" {
  11157. interface Scene {
  11158. /** @hidden */
  11159. _tempPickingRay: Nullable<Ray>;
  11160. /** @hidden */
  11161. _cachedRayForTransform: Ray;
  11162. /** @hidden */
  11163. _pickWithRayInverseMatrix: Matrix;
  11164. /** @hidden */
  11165. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  11166. /** @hidden */
  11167. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  11168. }
  11169. }
  11170. }
  11171. declare module "babylonjs/sceneComponent" {
  11172. import { Scene } from "babylonjs/scene";
  11173. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  11174. import { SubMesh } from "babylonjs/Meshes/subMesh";
  11175. import { _InstancesBatch } from "babylonjs/Meshes/mesh";
  11176. import { SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  11177. import { Nullable } from "babylonjs/types";
  11178. import { Camera } from "babylonjs/Cameras/camera";
  11179. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  11180. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11181. import { AbstractScene } from "babylonjs/abstractScene";
  11182. /**
  11183. * Groups all the scene component constants in one place to ease maintenance.
  11184. * @hidden
  11185. */
  11186. export class SceneComponentConstants {
  11187. static readonly NAME_EFFECTLAYER: string;
  11188. static readonly NAME_LAYER: string;
  11189. static readonly NAME_LENSFLARESYSTEM: string;
  11190. static readonly NAME_BOUNDINGBOXRENDERER: string;
  11191. static readonly NAME_PARTICLESYSTEM: string;
  11192. static readonly NAME_GAMEPAD: string;
  11193. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  11194. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  11195. static readonly NAME_DEPTHRENDERER: string;
  11196. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  11197. static readonly NAME_SPRITE: string;
  11198. static readonly NAME_OUTLINERENDERER: string;
  11199. static readonly NAME_PROCEDURALTEXTURE: string;
  11200. static readonly NAME_SHADOWGENERATOR: string;
  11201. static readonly NAME_OCTREE: string;
  11202. static readonly NAME_PHYSICSENGINE: string;
  11203. static readonly NAME_AUDIO: string;
  11204. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  11205. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  11206. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  11207. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  11208. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  11209. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  11210. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  11211. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  11212. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  11213. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  11214. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  11215. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  11216. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  11217. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  11218. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  11219. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  11220. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  11221. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  11222. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  11223. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  11224. static readonly STEP_AFTERRENDER_AUDIO: number;
  11225. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  11226. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  11227. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  11228. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  11229. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  11230. static readonly STEP_POINTERMOVE_SPRITE: number;
  11231. static readonly STEP_POINTERDOWN_SPRITE: number;
  11232. static readonly STEP_POINTERUP_SPRITE: number;
  11233. }
  11234. /**
  11235. * This represents a scene component.
  11236. *
  11237. * This is used to decouple the dependency the scene is having on the different workloads like
  11238. * layers, post processes...
  11239. */
  11240. export interface ISceneComponent {
  11241. /**
  11242. * The name of the component. Each component must have a unique name.
  11243. */
  11244. name: string;
  11245. /**
  11246. * The scene the component belongs to.
  11247. */
  11248. scene: Scene;
  11249. /**
  11250. * Register the component to one instance of a scene.
  11251. */
  11252. register(): void;
  11253. /**
  11254. * Rebuilds the elements related to this component in case of
  11255. * context lost for instance.
  11256. */
  11257. rebuild(): void;
  11258. /**
  11259. * Disposes the component and the associated ressources.
  11260. */
  11261. dispose(): void;
  11262. }
  11263. /**
  11264. * This represents a SERIALIZABLE scene component.
  11265. *
  11266. * This extends Scene Component to add Serialization methods on top.
  11267. */
  11268. export interface ISceneSerializableComponent extends ISceneComponent {
  11269. /**
  11270. * Adds all the elements from the container to the scene
  11271. * @param container the container holding the elements
  11272. */
  11273. addFromContainer(container: AbstractScene): void;
  11274. /**
  11275. * Removes all the elements in the container from the scene
  11276. * @param container contains the elements to remove
  11277. * @param dispose if the removed element should be disposed (default: false)
  11278. */
  11279. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  11280. /**
  11281. * Serializes the component data to the specified json object
  11282. * @param serializationObject The object to serialize to
  11283. */
  11284. serialize(serializationObject: any): void;
  11285. }
  11286. /**
  11287. * Strong typing of a Mesh related stage step action
  11288. */
  11289. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  11290. /**
  11291. * Strong typing of a Evaluate Sub Mesh related stage step action
  11292. */
  11293. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  11294. /**
  11295. * Strong typing of a Active Mesh related stage step action
  11296. */
  11297. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  11298. /**
  11299. * Strong typing of a Camera related stage step action
  11300. */
  11301. export type CameraStageAction = (camera: Camera) => void;
  11302. /**
  11303. * Strong typing of a Camera Frame buffer related stage step action
  11304. */
  11305. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  11306. /**
  11307. * Strong typing of a Render Target related stage step action
  11308. */
  11309. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  11310. /**
  11311. * Strong typing of a RenderingGroup related stage step action
  11312. */
  11313. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  11314. /**
  11315. * Strong typing of a Mesh Render related stage step action
  11316. */
  11317. export type RenderingMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  11318. /**
  11319. * Strong typing of a simple stage step action
  11320. */
  11321. export type SimpleStageAction = () => void;
  11322. /**
  11323. * Strong typing of a render target action.
  11324. */
  11325. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  11326. /**
  11327. * Strong typing of a pointer move action.
  11328. */
  11329. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, canvas: HTMLCanvasElement) => Nullable<PickingInfo>;
  11330. /**
  11331. * Strong typing of a pointer up/down action.
  11332. */
  11333. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  11334. /**
  11335. * Repressentation of a stage in the scene (Basically a list of ordered steps)
  11336. * @hidden
  11337. */
  11338. export class Stage<T extends Function> extends Array<{
  11339. index: number;
  11340. component: ISceneComponent;
  11341. action: T;
  11342. }> {
  11343. /**
  11344. * Hide ctor from the rest of the world.
  11345. * @param items The items to add.
  11346. */
  11347. private constructor();
  11348. /**
  11349. * Creates a new Stage.
  11350. * @returns A new instance of a Stage
  11351. */
  11352. static Create<T extends Function>(): Stage<T>;
  11353. /**
  11354. * Registers a step in an ordered way in the targeted stage.
  11355. * @param index Defines the position to register the step in
  11356. * @param component Defines the component attached to the step
  11357. * @param action Defines the action to launch during the step
  11358. */
  11359. registerStep(index: number, component: ISceneComponent, action: T): void;
  11360. /**
  11361. * Clears all the steps from the stage.
  11362. */
  11363. clear(): void;
  11364. }
  11365. }
  11366. declare module "babylonjs/Sprites/spriteSceneComponent" {
  11367. import { Nullable } from "babylonjs/types";
  11368. import { Observable } from "babylonjs/Misc/observable";
  11369. import { Scene } from "babylonjs/scene";
  11370. import { Sprite } from "babylonjs/Sprites/sprite";
  11371. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  11372. import { Ray } from "babylonjs/Culling/ray";
  11373. import { Camera } from "babylonjs/Cameras/camera";
  11374. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11375. import { ISceneComponent } from "babylonjs/sceneComponent";
  11376. module "babylonjs/scene" {
  11377. interface Scene {
  11378. /** @hidden */
  11379. _pointerOverSprite: Nullable<Sprite>;
  11380. /** @hidden */
  11381. _pickedDownSprite: Nullable<Sprite>;
  11382. /** @hidden */
  11383. _tempSpritePickingRay: Nullable<Ray>;
  11384. /**
  11385. * All of the sprite managers added to this scene
  11386. * @see http://doc.babylonjs.com/babylon101/sprites
  11387. */
  11388. spriteManagers: Array<ISpriteManager>;
  11389. /**
  11390. * An event triggered when sprites rendering is about to start
  11391. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11392. */
  11393. onBeforeSpritesRenderingObservable: Observable<Scene>;
  11394. /**
  11395. * An event triggered when sprites rendering is done
  11396. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11397. */
  11398. onAfterSpritesRenderingObservable: Observable<Scene>;
  11399. /** @hidden */
  11400. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11401. /** Launch a ray to try to pick a sprite in the scene
  11402. * @param x position on screen
  11403. * @param y position on screen
  11404. * @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
  11405. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  11406. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  11407. * @returns a PickingInfo
  11408. */
  11409. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11410. /** Use the given ray to pick a sprite in the scene
  11411. * @param ray The ray (in world space) to use to pick meshes
  11412. * @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
  11413. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  11414. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  11415. * @returns a PickingInfo
  11416. */
  11417. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11418. /** @hidden */
  11419. _internalMultiPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11420. /** Launch a ray to try to pick sprites in the scene
  11421. * @param x position on screen
  11422. * @param y position on screen
  11423. * @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
  11424. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  11425. * @returns a PickingInfo array
  11426. */
  11427. multiPickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11428. /** Use the given ray to pick sprites in the scene
  11429. * @param ray The ray (in world space) to use to pick meshes
  11430. * @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
  11431. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  11432. * @returns a PickingInfo array
  11433. */
  11434. multiPickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11435. /**
  11436. * Force the sprite under the pointer
  11437. * @param sprite defines the sprite to use
  11438. */
  11439. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  11440. /**
  11441. * Gets the sprite under the pointer
  11442. * @returns a Sprite or null if no sprite is under the pointer
  11443. */
  11444. getPointerOverSprite(): Nullable<Sprite>;
  11445. }
  11446. }
  11447. /**
  11448. * Defines the sprite scene component responsible to manage sprites
  11449. * in a given scene.
  11450. */
  11451. export class SpriteSceneComponent implements ISceneComponent {
  11452. /**
  11453. * The component name helpfull to identify the component in the list of scene components.
  11454. */
  11455. readonly name: string;
  11456. /**
  11457. * The scene the component belongs to.
  11458. */
  11459. scene: Scene;
  11460. /** @hidden */
  11461. private _spritePredicate;
  11462. /**
  11463. * Creates a new instance of the component for the given scene
  11464. * @param scene Defines the scene to register the component in
  11465. */
  11466. constructor(scene: Scene);
  11467. /**
  11468. * Registers the component in a given scene
  11469. */
  11470. register(): void;
  11471. /**
  11472. * Rebuilds the elements related to this component in case of
  11473. * context lost for instance.
  11474. */
  11475. rebuild(): void;
  11476. /**
  11477. * Disposes the component and the associated ressources.
  11478. */
  11479. dispose(): void;
  11480. private _pickSpriteButKeepRay;
  11481. private _pointerMove;
  11482. private _pointerDown;
  11483. private _pointerUp;
  11484. }
  11485. }
  11486. declare module "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration" {
  11487. /** @hidden */
  11488. export var fogFragmentDeclaration: {
  11489. name: string;
  11490. shader: string;
  11491. };
  11492. }
  11493. declare module "babylonjs/Shaders/ShadersInclude/fogFragment" {
  11494. /** @hidden */
  11495. export var fogFragment: {
  11496. name: string;
  11497. shader: string;
  11498. };
  11499. }
  11500. declare module "babylonjs/Shaders/sprites.fragment" {
  11501. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  11502. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  11503. /** @hidden */
  11504. export var spritesPixelShader: {
  11505. name: string;
  11506. shader: string;
  11507. };
  11508. }
  11509. declare module "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration" {
  11510. /** @hidden */
  11511. export var fogVertexDeclaration: {
  11512. name: string;
  11513. shader: string;
  11514. };
  11515. }
  11516. declare module "babylonjs/Shaders/sprites.vertex" {
  11517. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  11518. /** @hidden */
  11519. export var spritesVertexShader: {
  11520. name: string;
  11521. shader: string;
  11522. };
  11523. }
  11524. declare module "babylonjs/Sprites/spriteManager" {
  11525. import { IDisposable, Scene } from "babylonjs/scene";
  11526. import { Nullable } from "babylonjs/types";
  11527. import { Observable } from "babylonjs/Misc/observable";
  11528. import { Sprite } from "babylonjs/Sprites/sprite";
  11529. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11530. import { Camera } from "babylonjs/Cameras/camera";
  11531. import { Texture } from "babylonjs/Materials/Textures/texture";
  11532. import "babylonjs/Shaders/sprites.fragment";
  11533. import "babylonjs/Shaders/sprites.vertex";
  11534. import { Ray } from "babylonjs/Culling/ray";
  11535. /**
  11536. * Defines the minimum interface to fullfil in order to be a sprite manager.
  11537. */
  11538. export interface ISpriteManager extends IDisposable {
  11539. /**
  11540. * Restricts the camera to viewing objects with the same layerMask.
  11541. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  11542. */
  11543. layerMask: number;
  11544. /**
  11545. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  11546. */
  11547. isPickable: boolean;
  11548. /**
  11549. * Specifies the rendering group id for this mesh (0 by default)
  11550. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  11551. */
  11552. renderingGroupId: number;
  11553. /**
  11554. * Defines the list of sprites managed by the manager.
  11555. */
  11556. sprites: Array<Sprite>;
  11557. /**
  11558. * Tests the intersection of a sprite with a specific ray.
  11559. * @param ray The ray we are sending to test the collision
  11560. * @param camera The camera space we are sending rays in
  11561. * @param predicate A predicate allowing excluding sprites from the list of object to test
  11562. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  11563. * @returns picking info or null.
  11564. */
  11565. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11566. /**
  11567. * Intersects the sprites with a ray
  11568. * @param ray defines the ray to intersect with
  11569. * @param camera defines the current active camera
  11570. * @param predicate defines a predicate used to select candidate sprites
  11571. * @returns null if no hit or a PickingInfo array
  11572. */
  11573. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  11574. /**
  11575. * Renders the list of sprites on screen.
  11576. */
  11577. render(): void;
  11578. }
  11579. /**
  11580. * Class used to manage multiple sprites on the same spritesheet
  11581. * @see http://doc.babylonjs.com/babylon101/sprites
  11582. */
  11583. export class SpriteManager implements ISpriteManager {
  11584. /** defines the manager's name */
  11585. name: string;
  11586. /** Gets the list of sprites */
  11587. sprites: Sprite[];
  11588. /** Gets or sets the rendering group id (0 by default) */
  11589. renderingGroupId: number;
  11590. /** Gets or sets camera layer mask */
  11591. layerMask: number;
  11592. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  11593. fogEnabled: boolean;
  11594. /** Gets or sets a boolean indicating if the sprites are pickable */
  11595. isPickable: boolean;
  11596. /** Defines the default width of a cell in the spritesheet */
  11597. cellWidth: number;
  11598. /** Defines the default height of a cell in the spritesheet */
  11599. cellHeight: number;
  11600. /** Associative array from JSON sprite data file */
  11601. private _cellData;
  11602. /** Array of sprite names from JSON sprite data file */
  11603. private _spriteMap;
  11604. /** True when packed cell data from JSON file is ready*/
  11605. private _packedAndReady;
  11606. /**
  11607. * An event triggered when the manager is disposed.
  11608. */
  11609. onDisposeObservable: Observable<SpriteManager>;
  11610. private _onDisposeObserver;
  11611. /**
  11612. * Callback called when the manager is disposed
  11613. */
  11614. onDispose: () => void;
  11615. private _capacity;
  11616. private _fromPacked;
  11617. private _spriteTexture;
  11618. private _epsilon;
  11619. private _scene;
  11620. private _vertexData;
  11621. private _buffer;
  11622. private _vertexBuffers;
  11623. private _indexBuffer;
  11624. private _effectBase;
  11625. private _effectFog;
  11626. /**
  11627. * Gets or sets the spritesheet texture
  11628. */
  11629. texture: Texture;
  11630. /**
  11631. * Creates a new sprite manager
  11632. * @param name defines the manager's name
  11633. * @param imgUrl defines the sprite sheet url
  11634. * @param capacity defines the maximum allowed number of sprites
  11635. * @param cellSize defines the size of a sprite cell
  11636. * @param scene defines the hosting scene
  11637. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  11638. * @param samplingMode defines the smapling mode to use with spritesheet
  11639. * @param fromPacked set to false; do not alter
  11640. * @param spriteJSON null otherwise a JSON object defining sprite sheet data; do not alter
  11641. */
  11642. constructor(
  11643. /** defines the manager's name */
  11644. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number, fromPacked?: boolean, spriteJSON?: string | null);
  11645. private _makePacked;
  11646. private _appendSpriteVertex;
  11647. /**
  11648. * Intersects the sprites with a ray
  11649. * @param ray defines the ray to intersect with
  11650. * @param camera defines the current active camera
  11651. * @param predicate defines a predicate used to select candidate sprites
  11652. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  11653. * @returns null if no hit or a PickingInfo
  11654. */
  11655. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11656. /**
  11657. * Intersects the sprites with a ray
  11658. * @param ray defines the ray to intersect with
  11659. * @param camera defines the current active camera
  11660. * @param predicate defines a predicate used to select candidate sprites
  11661. * @returns null if no hit or a PickingInfo array
  11662. */
  11663. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  11664. /**
  11665. * Render all child sprites
  11666. */
  11667. render(): void;
  11668. /**
  11669. * Release associated resources
  11670. */
  11671. dispose(): void;
  11672. }
  11673. }
  11674. declare module "babylonjs/Sprites/sprite" {
  11675. import { Vector3 } from "babylonjs/Maths/math.vector";
  11676. import { Nullable } from "babylonjs/types";
  11677. import { ActionManager } from "babylonjs/Actions/actionManager";
  11678. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  11679. import { Color4 } from "babylonjs/Maths/math.color";
  11680. /**
  11681. * Class used to represent a sprite
  11682. * @see http://doc.babylonjs.com/babylon101/sprites
  11683. */
  11684. export class Sprite {
  11685. /** defines the name */
  11686. name: string;
  11687. /** Gets or sets the current world position */
  11688. position: Vector3;
  11689. /** Gets or sets the main color */
  11690. color: Color4;
  11691. /** Gets or sets the width */
  11692. width: number;
  11693. /** Gets or sets the height */
  11694. height: number;
  11695. /** Gets or sets rotation angle */
  11696. angle: number;
  11697. /** Gets or sets the cell index in the sprite sheet */
  11698. cellIndex: number;
  11699. /** Gets or sets the cell reference in the sprite sheet, uses sprite's filename when added to sprite sheet */
  11700. cellRef: string;
  11701. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  11702. invertU: number;
  11703. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  11704. invertV: number;
  11705. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  11706. disposeWhenFinishedAnimating: boolean;
  11707. /** Gets the list of attached animations */
  11708. animations: Animation[];
  11709. /** Gets or sets a boolean indicating if the sprite can be picked */
  11710. isPickable: boolean;
  11711. /**
  11712. * Gets or sets the associated action manager
  11713. */
  11714. actionManager: Nullable<ActionManager>;
  11715. private _animationStarted;
  11716. private _loopAnimation;
  11717. private _fromIndex;
  11718. private _toIndex;
  11719. private _delay;
  11720. private _direction;
  11721. private _manager;
  11722. private _time;
  11723. private _onAnimationEnd;
  11724. /**
  11725. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  11726. */
  11727. isVisible: boolean;
  11728. /**
  11729. * Gets or sets the sprite size
  11730. */
  11731. size: number;
  11732. /**
  11733. * Creates a new Sprite
  11734. * @param name defines the name
  11735. * @param manager defines the manager
  11736. */
  11737. constructor(
  11738. /** defines the name */
  11739. name: string, manager: ISpriteManager);
  11740. /**
  11741. * Starts an animation
  11742. * @param from defines the initial key
  11743. * @param to defines the end key
  11744. * @param loop defines if the animation must loop
  11745. * @param delay defines the start delay (in ms)
  11746. * @param onAnimationEnd defines a callback to call when animation ends
  11747. */
  11748. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  11749. /** Stops current animation (if any) */
  11750. stopAnimation(): void;
  11751. /** @hidden */
  11752. _animate(deltaTime: number): void;
  11753. /** Release associated resources */
  11754. dispose(): void;
  11755. }
  11756. }
  11757. declare module "babylonjs/Collisions/pickingInfo" {
  11758. import { Nullable } from "babylonjs/types";
  11759. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  11760. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  11761. import { Sprite } from "babylonjs/Sprites/sprite";
  11762. import { Ray } from "babylonjs/Culling/ray";
  11763. /**
  11764. * Information about the result of picking within a scene
  11765. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  11766. */
  11767. export class PickingInfo {
  11768. /** @hidden */
  11769. _pickingUnavailable: boolean;
  11770. /**
  11771. * If the pick collided with an object
  11772. */
  11773. hit: boolean;
  11774. /**
  11775. * Distance away where the pick collided
  11776. */
  11777. distance: number;
  11778. /**
  11779. * The location of pick collision
  11780. */
  11781. pickedPoint: Nullable<Vector3>;
  11782. /**
  11783. * The mesh corresponding the the pick collision
  11784. */
  11785. pickedMesh: Nullable<AbstractMesh>;
  11786. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  11787. bu: number;
  11788. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  11789. bv: number;
  11790. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  11791. faceId: number;
  11792. /** Id of the the submesh that was picked */
  11793. subMeshId: number;
  11794. /** If a sprite was picked, this will be the sprite the pick collided with */
  11795. pickedSprite: Nullable<Sprite>;
  11796. /**
  11797. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  11798. */
  11799. originMesh: Nullable<AbstractMesh>;
  11800. /**
  11801. * The ray that was used to perform the picking.
  11802. */
  11803. ray: Nullable<Ray>;
  11804. /**
  11805. * Gets the normal correspodning to the face the pick collided with
  11806. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  11807. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  11808. * @returns The normal correspodning to the face the pick collided with
  11809. */
  11810. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  11811. /**
  11812. * Gets the texture coordinates of where the pick occured
  11813. * @returns the vector containing the coordnates of the texture
  11814. */
  11815. getTextureCoordinates(): Nullable<Vector2>;
  11816. }
  11817. }
  11818. declare module "babylonjs/Events/pointerEvents" {
  11819. import { Nullable } from "babylonjs/types";
  11820. import { Vector2 } from "babylonjs/Maths/math.vector";
  11821. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11822. import { Ray } from "babylonjs/Culling/ray";
  11823. /**
  11824. * Gather the list of pointer event types as constants.
  11825. */
  11826. export class PointerEventTypes {
  11827. /**
  11828. * 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.
  11829. */
  11830. static readonly POINTERDOWN: number;
  11831. /**
  11832. * The pointerup event is fired when a pointer is no longer active.
  11833. */
  11834. static readonly POINTERUP: number;
  11835. /**
  11836. * The pointermove event is fired when a pointer changes coordinates.
  11837. */
  11838. static readonly POINTERMOVE: number;
  11839. /**
  11840. * The pointerwheel event is fired when a mouse wheel has been rotated.
  11841. */
  11842. static readonly POINTERWHEEL: number;
  11843. /**
  11844. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  11845. */
  11846. static readonly POINTERPICK: number;
  11847. /**
  11848. * The pointertap event is fired when a the object has been touched and released without drag.
  11849. */
  11850. static readonly POINTERTAP: number;
  11851. /**
  11852. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  11853. */
  11854. static readonly POINTERDOUBLETAP: number;
  11855. }
  11856. /**
  11857. * Base class of pointer info types.
  11858. */
  11859. export class PointerInfoBase {
  11860. /**
  11861. * Defines the type of event (PointerEventTypes)
  11862. */
  11863. type: number;
  11864. /**
  11865. * Defines the related dom event
  11866. */
  11867. event: PointerEvent | MouseWheelEvent;
  11868. /**
  11869. * Instantiates the base class of pointers info.
  11870. * @param type Defines the type of event (PointerEventTypes)
  11871. * @param event Defines the related dom event
  11872. */
  11873. constructor(
  11874. /**
  11875. * Defines the type of event (PointerEventTypes)
  11876. */
  11877. type: number,
  11878. /**
  11879. * Defines the related dom event
  11880. */
  11881. event: PointerEvent | MouseWheelEvent);
  11882. }
  11883. /**
  11884. * This class is used to store pointer related info for the onPrePointerObservable event.
  11885. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  11886. */
  11887. export class PointerInfoPre extends PointerInfoBase {
  11888. /**
  11889. * Ray from a pointer if availible (eg. 6dof controller)
  11890. */
  11891. ray: Nullable<Ray>;
  11892. /**
  11893. * Defines the local position of the pointer on the canvas.
  11894. */
  11895. localPosition: Vector2;
  11896. /**
  11897. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  11898. */
  11899. skipOnPointerObservable: boolean;
  11900. /**
  11901. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  11902. * @param type Defines the type of event (PointerEventTypes)
  11903. * @param event Defines the related dom event
  11904. * @param localX Defines the local x coordinates of the pointer when the event occured
  11905. * @param localY Defines the local y coordinates of the pointer when the event occured
  11906. */
  11907. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  11908. }
  11909. /**
  11910. * This type contains all the data related to a pointer event in Babylon.js.
  11911. * 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.
  11912. */
  11913. export class PointerInfo extends PointerInfoBase {
  11914. /**
  11915. * Defines the picking info associated to the info (if any)\
  11916. */
  11917. pickInfo: Nullable<PickingInfo>;
  11918. /**
  11919. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  11920. * @param type Defines the type of event (PointerEventTypes)
  11921. * @param event Defines the related dom event
  11922. * @param pickInfo Defines the picking info associated to the info (if any)\
  11923. */
  11924. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  11925. /**
  11926. * Defines the picking info associated to the info (if any)\
  11927. */
  11928. pickInfo: Nullable<PickingInfo>);
  11929. }
  11930. /**
  11931. * Data relating to a touch event on the screen.
  11932. */
  11933. export interface PointerTouch {
  11934. /**
  11935. * X coordinate of touch.
  11936. */
  11937. x: number;
  11938. /**
  11939. * Y coordinate of touch.
  11940. */
  11941. y: number;
  11942. /**
  11943. * Id of touch. Unique for each finger.
  11944. */
  11945. pointerId: number;
  11946. /**
  11947. * Event type passed from DOM.
  11948. */
  11949. type: any;
  11950. }
  11951. }
  11952. declare module "babylonjs/Cameras/Inputs/freeCameraMouseInput" {
  11953. import { Observable } from "babylonjs/Misc/observable";
  11954. import { Nullable } from "babylonjs/types";
  11955. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  11956. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  11957. /**
  11958. * Manage the mouse inputs to control the movement of a free camera.
  11959. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  11960. */
  11961. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  11962. /**
  11963. * Define if touch is enabled in the mouse input
  11964. */
  11965. touchEnabled: boolean;
  11966. /**
  11967. * Defines the camera the input is attached to.
  11968. */
  11969. camera: FreeCamera;
  11970. /**
  11971. * Defines the buttons associated with the input to handle camera move.
  11972. */
  11973. buttons: number[];
  11974. /**
  11975. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  11976. */
  11977. angularSensibility: number;
  11978. private _pointerInput;
  11979. private _onMouseMove;
  11980. private _observer;
  11981. private previousPosition;
  11982. /**
  11983. * Observable for when a pointer move event occurs containing the move offset
  11984. */
  11985. onPointerMovedObservable: Observable<{
  11986. offsetX: number;
  11987. offsetY: number;
  11988. }>;
  11989. /**
  11990. * @hidden
  11991. * If the camera should be rotated automatically based on pointer movement
  11992. */
  11993. _allowCameraRotation: boolean;
  11994. /**
  11995. * Manage the mouse inputs to control the movement of a free camera.
  11996. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  11997. * @param touchEnabled Defines if touch is enabled or not
  11998. */
  11999. constructor(
  12000. /**
  12001. * Define if touch is enabled in the mouse input
  12002. */
  12003. touchEnabled?: boolean);
  12004. /**
  12005. * Attach the input controls to a specific dom element to get the input from.
  12006. * @param element Defines the element the controls should be listened from
  12007. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12008. */
  12009. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12010. /**
  12011. * Called on JS contextmenu event.
  12012. * Override this method to provide functionality.
  12013. */
  12014. protected onContextMenu(evt: PointerEvent): void;
  12015. /**
  12016. * Detach the current controls from the specified dom element.
  12017. * @param element Defines the element to stop listening the inputs from
  12018. */
  12019. detachControl(element: Nullable<HTMLElement>): void;
  12020. /**
  12021. * Gets the class name of the current intput.
  12022. * @returns the class name
  12023. */
  12024. getClassName(): string;
  12025. /**
  12026. * Get the friendly name associated with the input class.
  12027. * @returns the input friendly name
  12028. */
  12029. getSimpleName(): string;
  12030. }
  12031. }
  12032. declare module "babylonjs/Cameras/Inputs/freeCameraTouchInput" {
  12033. import { Nullable } from "babylonjs/types";
  12034. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  12035. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  12036. /**
  12037. * Manage the touch inputs to control the movement of a free camera.
  12038. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12039. */
  12040. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  12041. /**
  12042. * Defines the camera the input is attached to.
  12043. */
  12044. camera: FreeCamera;
  12045. /**
  12046. * Defines the touch sensibility for rotation.
  12047. * The higher the faster.
  12048. */
  12049. touchAngularSensibility: number;
  12050. /**
  12051. * Defines the touch sensibility for move.
  12052. * The higher the faster.
  12053. */
  12054. touchMoveSensibility: number;
  12055. private _offsetX;
  12056. private _offsetY;
  12057. private _pointerPressed;
  12058. private _pointerInput;
  12059. private _observer;
  12060. private _onLostFocus;
  12061. /**
  12062. * Attach the input controls to a specific dom element to get the input from.
  12063. * @param element Defines the element the controls should be listened from
  12064. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12065. */
  12066. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12067. /**
  12068. * Detach the current controls from the specified dom element.
  12069. * @param element Defines the element to stop listening the inputs from
  12070. */
  12071. detachControl(element: Nullable<HTMLElement>): void;
  12072. /**
  12073. * Update the current camera state depending on the inputs that have been used this frame.
  12074. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  12075. */
  12076. checkInputs(): void;
  12077. /**
  12078. * Gets the class name of the current intput.
  12079. * @returns the class name
  12080. */
  12081. getClassName(): string;
  12082. /**
  12083. * Get the friendly name associated with the input class.
  12084. * @returns the input friendly name
  12085. */
  12086. getSimpleName(): string;
  12087. }
  12088. }
  12089. declare module "babylonjs/Cameras/freeCameraInputsManager" {
  12090. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  12091. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  12092. import { FreeCameraMouseInput } from "babylonjs/Cameras/Inputs/freeCameraMouseInput";
  12093. import { Nullable } from "babylonjs/types";
  12094. /**
  12095. * Default Inputs manager for the FreeCamera.
  12096. * It groups all the default supported inputs for ease of use.
  12097. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12098. */
  12099. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  12100. /**
  12101. * @hidden
  12102. */
  12103. _mouseInput: Nullable<FreeCameraMouseInput>;
  12104. /**
  12105. * Instantiates a new FreeCameraInputsManager.
  12106. * @param camera Defines the camera the inputs belong to
  12107. */
  12108. constructor(camera: FreeCamera);
  12109. /**
  12110. * Add keyboard input support to the input manager.
  12111. * @returns the current input manager
  12112. */
  12113. addKeyboard(): FreeCameraInputsManager;
  12114. /**
  12115. * Add mouse input support to the input manager.
  12116. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  12117. * @returns the current input manager
  12118. */
  12119. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  12120. /**
  12121. * Removes the mouse input support from the manager
  12122. * @returns the current input manager
  12123. */
  12124. removeMouse(): FreeCameraInputsManager;
  12125. /**
  12126. * Add touch input support to the input manager.
  12127. * @returns the current input manager
  12128. */
  12129. addTouch(): FreeCameraInputsManager;
  12130. /**
  12131. * Remove all attached input methods from a camera
  12132. */
  12133. clear(): void;
  12134. }
  12135. }
  12136. declare module "babylonjs/Cameras/freeCamera" {
  12137. import { Vector3 } from "babylonjs/Maths/math.vector";
  12138. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  12139. import { Scene } from "babylonjs/scene";
  12140. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  12141. import { FreeCameraInputsManager } from "babylonjs/Cameras/freeCameraInputsManager";
  12142. /**
  12143. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  12144. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  12145. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  12146. */
  12147. export class FreeCamera extends TargetCamera {
  12148. /**
  12149. * Define the collision ellipsoid of the camera.
  12150. * This is helpful to simulate a camera body like the player body around the camera
  12151. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  12152. */
  12153. ellipsoid: Vector3;
  12154. /**
  12155. * Define an offset for the position of the ellipsoid around the camera.
  12156. * This can be helpful to determine the center of the body near the gravity center of the body
  12157. * instead of its head.
  12158. */
  12159. ellipsoidOffset: Vector3;
  12160. /**
  12161. * Enable or disable collisions of the camera with the rest of the scene objects.
  12162. */
  12163. checkCollisions: boolean;
  12164. /**
  12165. * Enable or disable gravity on the camera.
  12166. */
  12167. applyGravity: boolean;
  12168. /**
  12169. * Define the input manager associated to the camera.
  12170. */
  12171. inputs: FreeCameraInputsManager;
  12172. /**
  12173. * Gets the input sensibility for a mouse input. (default is 2000.0)
  12174. * Higher values reduce sensitivity.
  12175. */
  12176. /**
  12177. * Sets the input sensibility for a mouse input. (default is 2000.0)
  12178. * Higher values reduce sensitivity.
  12179. */
  12180. angularSensibility: number;
  12181. /**
  12182. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  12183. */
  12184. keysUp: number[];
  12185. /**
  12186. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  12187. */
  12188. keysDown: number[];
  12189. /**
  12190. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  12191. */
  12192. keysLeft: number[];
  12193. /**
  12194. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  12195. */
  12196. keysRight: number[];
  12197. /**
  12198. * Event raised when the camera collide with a mesh in the scene.
  12199. */
  12200. onCollide: (collidedMesh: AbstractMesh) => void;
  12201. private _collider;
  12202. private _needMoveForGravity;
  12203. private _oldPosition;
  12204. private _diffPosition;
  12205. private _newPosition;
  12206. /** @hidden */
  12207. _localDirection: Vector3;
  12208. /** @hidden */
  12209. _transformedDirection: Vector3;
  12210. /**
  12211. * Instantiates a Free Camera.
  12212. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  12213. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  12214. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  12215. * @param name Define the name of the camera in the scene
  12216. * @param position Define the start position of the camera in the scene
  12217. * @param scene Define the scene the camera belongs to
  12218. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  12219. */
  12220. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  12221. /**
  12222. * Attached controls to the current camera.
  12223. * @param element Defines the element the controls should be listened from
  12224. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12225. */
  12226. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12227. /**
  12228. * Detach the current controls from the camera.
  12229. * The camera will stop reacting to inputs.
  12230. * @param element Defines the element to stop listening the inputs from
  12231. */
  12232. detachControl(element: HTMLElement): void;
  12233. private _collisionMask;
  12234. /**
  12235. * Define a collision mask to limit the list of object the camera can collide with
  12236. */
  12237. collisionMask: number;
  12238. /** @hidden */
  12239. _collideWithWorld(displacement: Vector3): void;
  12240. private _onCollisionPositionChange;
  12241. /** @hidden */
  12242. _checkInputs(): void;
  12243. /** @hidden */
  12244. _decideIfNeedsToMove(): boolean;
  12245. /** @hidden */
  12246. _updatePosition(): void;
  12247. /**
  12248. * Destroy the camera and release the current resources hold by it.
  12249. */
  12250. dispose(): void;
  12251. /**
  12252. * Gets the current object class name.
  12253. * @return the class name
  12254. */
  12255. getClassName(): string;
  12256. }
  12257. }
  12258. declare module "babylonjs/Gamepads/gamepad" {
  12259. import { Observable } from "babylonjs/Misc/observable";
  12260. /**
  12261. * Represents a gamepad control stick position
  12262. */
  12263. export class StickValues {
  12264. /**
  12265. * The x component of the control stick
  12266. */
  12267. x: number;
  12268. /**
  12269. * The y component of the control stick
  12270. */
  12271. y: number;
  12272. /**
  12273. * Initializes the gamepad x and y control stick values
  12274. * @param x The x component of the gamepad control stick value
  12275. * @param y The y component of the gamepad control stick value
  12276. */
  12277. constructor(
  12278. /**
  12279. * The x component of the control stick
  12280. */
  12281. x: number,
  12282. /**
  12283. * The y component of the control stick
  12284. */
  12285. y: number);
  12286. }
  12287. /**
  12288. * An interface which manages callbacks for gamepad button changes
  12289. */
  12290. export interface GamepadButtonChanges {
  12291. /**
  12292. * Called when a gamepad has been changed
  12293. */
  12294. changed: boolean;
  12295. /**
  12296. * Called when a gamepad press event has been triggered
  12297. */
  12298. pressChanged: boolean;
  12299. /**
  12300. * Called when a touch event has been triggered
  12301. */
  12302. touchChanged: boolean;
  12303. /**
  12304. * Called when a value has changed
  12305. */
  12306. valueChanged: boolean;
  12307. }
  12308. /**
  12309. * Represents a gamepad
  12310. */
  12311. export class Gamepad {
  12312. /**
  12313. * The id of the gamepad
  12314. */
  12315. id: string;
  12316. /**
  12317. * The index of the gamepad
  12318. */
  12319. index: number;
  12320. /**
  12321. * The browser gamepad
  12322. */
  12323. browserGamepad: any;
  12324. /**
  12325. * Specifies what type of gamepad this represents
  12326. */
  12327. type: number;
  12328. private _leftStick;
  12329. private _rightStick;
  12330. /** @hidden */
  12331. _isConnected: boolean;
  12332. private _leftStickAxisX;
  12333. private _leftStickAxisY;
  12334. private _rightStickAxisX;
  12335. private _rightStickAxisY;
  12336. /**
  12337. * Triggered when the left control stick has been changed
  12338. */
  12339. private _onleftstickchanged;
  12340. /**
  12341. * Triggered when the right control stick has been changed
  12342. */
  12343. private _onrightstickchanged;
  12344. /**
  12345. * Represents a gamepad controller
  12346. */
  12347. static GAMEPAD: number;
  12348. /**
  12349. * Represents a generic controller
  12350. */
  12351. static GENERIC: number;
  12352. /**
  12353. * Represents an XBox controller
  12354. */
  12355. static XBOX: number;
  12356. /**
  12357. * Represents a pose-enabled controller
  12358. */
  12359. static POSE_ENABLED: number;
  12360. /**
  12361. * Represents an Dual Shock controller
  12362. */
  12363. static DUALSHOCK: number;
  12364. /**
  12365. * Specifies whether the left control stick should be Y-inverted
  12366. */
  12367. protected _invertLeftStickY: boolean;
  12368. /**
  12369. * Specifies if the gamepad has been connected
  12370. */
  12371. readonly isConnected: boolean;
  12372. /**
  12373. * Initializes the gamepad
  12374. * @param id The id of the gamepad
  12375. * @param index The index of the gamepad
  12376. * @param browserGamepad The browser gamepad
  12377. * @param leftStickX The x component of the left joystick
  12378. * @param leftStickY The y component of the left joystick
  12379. * @param rightStickX The x component of the right joystick
  12380. * @param rightStickY The y component of the right joystick
  12381. */
  12382. constructor(
  12383. /**
  12384. * The id of the gamepad
  12385. */
  12386. id: string,
  12387. /**
  12388. * The index of the gamepad
  12389. */
  12390. index: number,
  12391. /**
  12392. * The browser gamepad
  12393. */
  12394. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  12395. /**
  12396. * Callback triggered when the left joystick has changed
  12397. * @param callback
  12398. */
  12399. onleftstickchanged(callback: (values: StickValues) => void): void;
  12400. /**
  12401. * Callback triggered when the right joystick has changed
  12402. * @param callback
  12403. */
  12404. onrightstickchanged(callback: (values: StickValues) => void): void;
  12405. /**
  12406. * Gets the left joystick
  12407. */
  12408. /**
  12409. * Sets the left joystick values
  12410. */
  12411. leftStick: StickValues;
  12412. /**
  12413. * Gets the right joystick
  12414. */
  12415. /**
  12416. * Sets the right joystick value
  12417. */
  12418. rightStick: StickValues;
  12419. /**
  12420. * Updates the gamepad joystick positions
  12421. */
  12422. update(): void;
  12423. /**
  12424. * Disposes the gamepad
  12425. */
  12426. dispose(): void;
  12427. }
  12428. /**
  12429. * Represents a generic gamepad
  12430. */
  12431. export class GenericPad extends Gamepad {
  12432. private _buttons;
  12433. private _onbuttondown;
  12434. private _onbuttonup;
  12435. /**
  12436. * Observable triggered when a button has been pressed
  12437. */
  12438. onButtonDownObservable: Observable<number>;
  12439. /**
  12440. * Observable triggered when a button has been released
  12441. */
  12442. onButtonUpObservable: Observable<number>;
  12443. /**
  12444. * Callback triggered when a button has been pressed
  12445. * @param callback Called when a button has been pressed
  12446. */
  12447. onbuttondown(callback: (buttonPressed: number) => void): void;
  12448. /**
  12449. * Callback triggered when a button has been released
  12450. * @param callback Called when a button has been released
  12451. */
  12452. onbuttonup(callback: (buttonReleased: number) => void): void;
  12453. /**
  12454. * Initializes the generic gamepad
  12455. * @param id The id of the generic gamepad
  12456. * @param index The index of the generic gamepad
  12457. * @param browserGamepad The browser gamepad
  12458. */
  12459. constructor(id: string, index: number, browserGamepad: any);
  12460. private _setButtonValue;
  12461. /**
  12462. * Updates the generic gamepad
  12463. */
  12464. update(): void;
  12465. /**
  12466. * Disposes the generic gamepad
  12467. */
  12468. dispose(): void;
  12469. }
  12470. }
  12471. declare module "babylonjs/Engines/Extensions/engine.rawTexture" {
  12472. import { Nullable } from "babylonjs/types";
  12473. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  12474. import { Scene } from "babylonjs/scene";
  12475. module "babylonjs/Engines/engine" {
  12476. interface Engine {
  12477. /**
  12478. * Creates a raw texture
  12479. * @param data defines the data to store in the texture
  12480. * @param width defines the width of the texture
  12481. * @param height defines the height of the texture
  12482. * @param format defines the format of the data
  12483. * @param generateMipMaps defines if the engine should generate the mip levels
  12484. * @param invertY defines if data must be stored with Y axis inverted
  12485. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  12486. * @param compression defines the compression used (null by default)
  12487. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12488. * @returns the raw texture inside an InternalTexture
  12489. */
  12490. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  12491. /**
  12492. * Update a raw texture
  12493. * @param texture defines the texture to update
  12494. * @param data defines the data to store in the texture
  12495. * @param format defines the format of the data
  12496. * @param invertY defines if data must be stored with Y axis inverted
  12497. */
  12498. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  12499. /**
  12500. * Update a raw texture
  12501. * @param texture defines the texture to update
  12502. * @param data defines the data to store in the texture
  12503. * @param format defines the format of the data
  12504. * @param invertY defines if data must be stored with Y axis inverted
  12505. * @param compression defines the compression used (null by default)
  12506. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12507. */
  12508. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  12509. /**
  12510. * Creates a new raw cube texture
  12511. * @param data defines the array of data to use to create each face
  12512. * @param size defines the size of the textures
  12513. * @param format defines the format of the data
  12514. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  12515. * @param generateMipMaps defines if the engine should generate the mip levels
  12516. * @param invertY defines if data must be stored with Y axis inverted
  12517. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  12518. * @param compression defines the compression used (null by default)
  12519. * @returns the cube texture as an InternalTexture
  12520. */
  12521. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  12522. /**
  12523. * Update a raw cube texture
  12524. * @param texture defines the texture to udpdate
  12525. * @param data defines the data to store
  12526. * @param format defines the data format
  12527. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12528. * @param invertY defines if data must be stored with Y axis inverted
  12529. */
  12530. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  12531. /**
  12532. * Update a raw cube texture
  12533. * @param texture defines the texture to udpdate
  12534. * @param data defines the data to store
  12535. * @param format defines the data format
  12536. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12537. * @param invertY defines if data must be stored with Y axis inverted
  12538. * @param compression defines the compression used (null by default)
  12539. */
  12540. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  12541. /**
  12542. * Update a raw cube texture
  12543. * @param texture defines the texture to udpdate
  12544. * @param data defines the data to store
  12545. * @param format defines the data format
  12546. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12547. * @param invertY defines if data must be stored with Y axis inverted
  12548. * @param compression defines the compression used (null by default)
  12549. * @param level defines which level of the texture to update
  12550. */
  12551. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  12552. /**
  12553. * Creates a new raw cube texture from a specified url
  12554. * @param url defines the url where the data is located
  12555. * @param scene defines the current scene
  12556. * @param size defines the size of the textures
  12557. * @param format defines the format of the data
  12558. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  12559. * @param noMipmap defines if the engine should avoid generating the mip levels
  12560. * @param callback defines a callback used to extract texture data from loaded data
  12561. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  12562. * @param onLoad defines a callback called when texture is loaded
  12563. * @param onError defines a callback called if there is an error
  12564. * @returns the cube texture as an InternalTexture
  12565. */
  12566. 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;
  12567. /**
  12568. * Creates a new raw cube texture from a specified url
  12569. * @param url defines the url where the data is located
  12570. * @param scene defines the current scene
  12571. * @param size defines the size of the textures
  12572. * @param format defines the format of the data
  12573. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  12574. * @param noMipmap defines if the engine should avoid generating the mip levels
  12575. * @param callback defines a callback used to extract texture data from loaded data
  12576. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  12577. * @param onLoad defines a callback called when texture is loaded
  12578. * @param onError defines a callback called if there is an error
  12579. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  12580. * @param invertY defines if data must be stored with Y axis inverted
  12581. * @returns the cube texture as an InternalTexture
  12582. */
  12583. 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;
  12584. /**
  12585. * Creates a new raw 3D texture
  12586. * @param data defines the data used to create the texture
  12587. * @param width defines the width of the texture
  12588. * @param height defines the height of the texture
  12589. * @param depth defines the depth of the texture
  12590. * @param format defines the format of the texture
  12591. * @param generateMipMaps defines if the engine must generate mip levels
  12592. * @param invertY defines if data must be stored with Y axis inverted
  12593. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  12594. * @param compression defines the compressed used (can be null)
  12595. * @param textureType defines the compressed used (can be null)
  12596. * @returns a new raw 3D texture (stored in an InternalTexture)
  12597. */
  12598. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  12599. /**
  12600. * Update a raw 3D texture
  12601. * @param texture defines the texture to update
  12602. * @param data defines the data to store
  12603. * @param format defines the data format
  12604. * @param invertY defines if data must be stored with Y axis inverted
  12605. */
  12606. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  12607. /**
  12608. * Update a raw 3D texture
  12609. * @param texture defines the texture to update
  12610. * @param data defines the data to store
  12611. * @param format defines the data format
  12612. * @param invertY defines if data must be stored with Y axis inverted
  12613. * @param compression defines the used compression (can be null)
  12614. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  12615. */
  12616. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  12617. }
  12618. }
  12619. }
  12620. declare module "babylonjs/Materials/Textures/rawTexture" {
  12621. import { Scene } from "babylonjs/scene";
  12622. import { Texture } from "babylonjs/Materials/Textures/texture";
  12623. import "babylonjs/Engines/Extensions/engine.rawTexture";
  12624. /**
  12625. * Raw texture can help creating a texture directly from an array of data.
  12626. * This can be super useful if you either get the data from an uncompressed source or
  12627. * if you wish to create your texture pixel by pixel.
  12628. */
  12629. export class RawTexture extends Texture {
  12630. /**
  12631. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  12632. */
  12633. format: number;
  12634. private _engine;
  12635. /**
  12636. * Instantiates a new RawTexture.
  12637. * Raw texture can help creating a texture directly from an array of data.
  12638. * This can be super useful if you either get the data from an uncompressed source or
  12639. * if you wish to create your texture pixel by pixel.
  12640. * @param data define the array of data to use to create the texture
  12641. * @param width define the width of the texture
  12642. * @param height define the height of the texture
  12643. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  12644. * @param scene define the scene the texture belongs to
  12645. * @param generateMipMaps define whether mip maps should be generated or not
  12646. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12647. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12648. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  12649. */
  12650. constructor(data: ArrayBufferView, width: number, height: number,
  12651. /**
  12652. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  12653. */
  12654. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  12655. /**
  12656. * Updates the texture underlying data.
  12657. * @param data Define the new data of the texture
  12658. */
  12659. update(data: ArrayBufferView): void;
  12660. /**
  12661. * Creates a luminance texture from some data.
  12662. * @param data Define the texture data
  12663. * @param width Define the width of the texture
  12664. * @param height Define the height of the texture
  12665. * @param scene Define the scene the texture belongs to
  12666. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12667. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12668. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12669. * @returns the luminance texture
  12670. */
  12671. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  12672. /**
  12673. * Creates a luminance alpha texture from some data.
  12674. * @param data Define the texture data
  12675. * @param width Define the width of the texture
  12676. * @param height Define the height of the texture
  12677. * @param scene Define the scene the texture belongs to
  12678. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12679. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12680. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12681. * @returns the luminance alpha texture
  12682. */
  12683. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  12684. /**
  12685. * Creates an alpha texture from some data.
  12686. * @param data Define the texture data
  12687. * @param width Define the width of the texture
  12688. * @param height Define the height of the texture
  12689. * @param scene Define the scene the texture belongs to
  12690. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12691. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12692. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12693. * @returns the alpha texture
  12694. */
  12695. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  12696. /**
  12697. * Creates a RGB texture from some data.
  12698. * @param data Define the texture data
  12699. * @param width Define the width of the texture
  12700. * @param height Define the height of the texture
  12701. * @param scene Define the scene the texture belongs to
  12702. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12703. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12704. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12705. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  12706. * @returns the RGB alpha texture
  12707. */
  12708. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  12709. /**
  12710. * Creates a RGBA texture from some data.
  12711. * @param data Define the texture data
  12712. * @param width Define the width of the texture
  12713. * @param height Define the height of the texture
  12714. * @param scene Define the scene the texture belongs to
  12715. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12716. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12717. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12718. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  12719. * @returns the RGBA texture
  12720. */
  12721. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  12722. /**
  12723. * Creates a R texture from some data.
  12724. * @param data Define the texture data
  12725. * @param width Define the width of the texture
  12726. * @param height Define the height of the texture
  12727. * @param scene Define the scene the texture belongs to
  12728. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12729. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12730. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12731. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  12732. * @returns the R texture
  12733. */
  12734. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  12735. }
  12736. }
  12737. declare module "babylonjs/Maths/math.size" {
  12738. /**
  12739. * Interface for the size containing width and height
  12740. */
  12741. export interface ISize {
  12742. /**
  12743. * Width
  12744. */
  12745. width: number;
  12746. /**
  12747. * Heighht
  12748. */
  12749. height: number;
  12750. }
  12751. /**
  12752. * Size containing widht and height
  12753. */
  12754. export class Size implements ISize {
  12755. /**
  12756. * Width
  12757. */
  12758. width: number;
  12759. /**
  12760. * Height
  12761. */
  12762. height: number;
  12763. /**
  12764. * Creates a Size object from the given width and height (floats).
  12765. * @param width width of the new size
  12766. * @param height height of the new size
  12767. */
  12768. constructor(width: number, height: number);
  12769. /**
  12770. * Returns a string with the Size width and height
  12771. * @returns a string with the Size width and height
  12772. */
  12773. toString(): string;
  12774. /**
  12775. * "Size"
  12776. * @returns the string "Size"
  12777. */
  12778. getClassName(): string;
  12779. /**
  12780. * Returns the Size hash code.
  12781. * @returns a hash code for a unique width and height
  12782. */
  12783. getHashCode(): number;
  12784. /**
  12785. * Updates the current size from the given one.
  12786. * @param src the given size
  12787. */
  12788. copyFrom(src: Size): void;
  12789. /**
  12790. * Updates in place the current Size from the given floats.
  12791. * @param width width of the new size
  12792. * @param height height of the new size
  12793. * @returns the updated Size.
  12794. */
  12795. copyFromFloats(width: number, height: number): Size;
  12796. /**
  12797. * Updates in place the current Size from the given floats.
  12798. * @param width width to set
  12799. * @param height height to set
  12800. * @returns the updated Size.
  12801. */
  12802. set(width: number, height: number): Size;
  12803. /**
  12804. * Multiplies the width and height by numbers
  12805. * @param w factor to multiple the width by
  12806. * @param h factor to multiple the height by
  12807. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  12808. */
  12809. multiplyByFloats(w: number, h: number): Size;
  12810. /**
  12811. * Clones the size
  12812. * @returns a new Size copied from the given one.
  12813. */
  12814. clone(): Size;
  12815. /**
  12816. * True if the current Size and the given one width and height are strictly equal.
  12817. * @param other the other size to compare against
  12818. * @returns True if the current Size and the given one width and height are strictly equal.
  12819. */
  12820. equals(other: Size): boolean;
  12821. /**
  12822. * The surface of the Size : width * height (float).
  12823. */
  12824. readonly surface: number;
  12825. /**
  12826. * Create a new size of zero
  12827. * @returns a new Size set to (0.0, 0.0)
  12828. */
  12829. static Zero(): Size;
  12830. /**
  12831. * Sums the width and height of two sizes
  12832. * @param otherSize size to add to this size
  12833. * @returns a new Size set as the addition result of the current Size and the given one.
  12834. */
  12835. add(otherSize: Size): Size;
  12836. /**
  12837. * Subtracts the width and height of two
  12838. * @param otherSize size to subtract to this size
  12839. * @returns a new Size set as the subtraction result of the given one from the current Size.
  12840. */
  12841. subtract(otherSize: Size): Size;
  12842. /**
  12843. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  12844. * @param start starting size to lerp between
  12845. * @param end end size to lerp between
  12846. * @param amount amount to lerp between the start and end values
  12847. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  12848. */
  12849. static Lerp(start: Size, end: Size, amount: number): Size;
  12850. }
  12851. }
  12852. declare module "babylonjs/Animations/runtimeAnimation" {
  12853. import { Animation, _IAnimationState } from "babylonjs/Animations/animation";
  12854. import { Animatable } from "babylonjs/Animations/animatable";
  12855. import { Scene } from "babylonjs/scene";
  12856. /**
  12857. * Defines a runtime animation
  12858. */
  12859. export class RuntimeAnimation {
  12860. private _events;
  12861. /**
  12862. * The current frame of the runtime animation
  12863. */
  12864. private _currentFrame;
  12865. /**
  12866. * The animation used by the runtime animation
  12867. */
  12868. private _animation;
  12869. /**
  12870. * The target of the runtime animation
  12871. */
  12872. private _target;
  12873. /**
  12874. * The initiating animatable
  12875. */
  12876. private _host;
  12877. /**
  12878. * The original value of the runtime animation
  12879. */
  12880. private _originalValue;
  12881. /**
  12882. * The original blend value of the runtime animation
  12883. */
  12884. private _originalBlendValue;
  12885. /**
  12886. * The offsets cache of the runtime animation
  12887. */
  12888. private _offsetsCache;
  12889. /**
  12890. * The high limits cache of the runtime animation
  12891. */
  12892. private _highLimitsCache;
  12893. /**
  12894. * Specifies if the runtime animation has been stopped
  12895. */
  12896. private _stopped;
  12897. /**
  12898. * The blending factor of the runtime animation
  12899. */
  12900. private _blendingFactor;
  12901. /**
  12902. * The BabylonJS scene
  12903. */
  12904. private _scene;
  12905. /**
  12906. * The current value of the runtime animation
  12907. */
  12908. private _currentValue;
  12909. /** @hidden */
  12910. _animationState: _IAnimationState;
  12911. /**
  12912. * The active target of the runtime animation
  12913. */
  12914. private _activeTargets;
  12915. private _currentActiveTarget;
  12916. private _directTarget;
  12917. /**
  12918. * The target path of the runtime animation
  12919. */
  12920. private _targetPath;
  12921. /**
  12922. * The weight of the runtime animation
  12923. */
  12924. private _weight;
  12925. /**
  12926. * The ratio offset of the runtime animation
  12927. */
  12928. private _ratioOffset;
  12929. /**
  12930. * The previous delay of the runtime animation
  12931. */
  12932. private _previousDelay;
  12933. /**
  12934. * The previous ratio of the runtime animation
  12935. */
  12936. private _previousRatio;
  12937. private _enableBlending;
  12938. private _keys;
  12939. private _minFrame;
  12940. private _maxFrame;
  12941. private _minValue;
  12942. private _maxValue;
  12943. private _targetIsArray;
  12944. /**
  12945. * Gets the current frame of the runtime animation
  12946. */
  12947. readonly currentFrame: number;
  12948. /**
  12949. * Gets the weight of the runtime animation
  12950. */
  12951. readonly weight: number;
  12952. /**
  12953. * Gets the current value of the runtime animation
  12954. */
  12955. readonly currentValue: any;
  12956. /**
  12957. * Gets the target path of the runtime animation
  12958. */
  12959. readonly targetPath: string;
  12960. /**
  12961. * Gets the actual target of the runtime animation
  12962. */
  12963. readonly target: any;
  12964. /** @hidden */
  12965. _onLoop: () => void;
  12966. /**
  12967. * Create a new RuntimeAnimation object
  12968. * @param target defines the target of the animation
  12969. * @param animation defines the source animation object
  12970. * @param scene defines the hosting scene
  12971. * @param host defines the initiating Animatable
  12972. */
  12973. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  12974. private _preparePath;
  12975. /**
  12976. * Gets the animation from the runtime animation
  12977. */
  12978. readonly animation: Animation;
  12979. /**
  12980. * Resets the runtime animation to the beginning
  12981. * @param restoreOriginal defines whether to restore the target property to the original value
  12982. */
  12983. reset(restoreOriginal?: boolean): void;
  12984. /**
  12985. * Specifies if the runtime animation is stopped
  12986. * @returns Boolean specifying if the runtime animation is stopped
  12987. */
  12988. isStopped(): boolean;
  12989. /**
  12990. * Disposes of the runtime animation
  12991. */
  12992. dispose(): void;
  12993. /**
  12994. * Apply the interpolated value to the target
  12995. * @param currentValue defines the value computed by the animation
  12996. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  12997. */
  12998. setValue(currentValue: any, weight: number): void;
  12999. private _getOriginalValues;
  13000. private _setValue;
  13001. /**
  13002. * Gets the loop pmode of the runtime animation
  13003. * @returns Loop Mode
  13004. */
  13005. private _getCorrectLoopMode;
  13006. /**
  13007. * Move the current animation to a given frame
  13008. * @param frame defines the frame to move to
  13009. */
  13010. goToFrame(frame: number): void;
  13011. /**
  13012. * @hidden Internal use only
  13013. */
  13014. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  13015. /**
  13016. * Execute the current animation
  13017. * @param delay defines the delay to add to the current frame
  13018. * @param from defines the lower bound of the animation range
  13019. * @param to defines the upper bound of the animation range
  13020. * @param loop defines if the current animation must loop
  13021. * @param speedRatio defines the current speed ratio
  13022. * @param weight defines the weight of the animation (default is -1 so no weight)
  13023. * @param onLoop optional callback called when animation loops
  13024. * @returns a boolean indicating if the animation is running
  13025. */
  13026. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  13027. }
  13028. }
  13029. declare module "babylonjs/Animations/animatable" {
  13030. import { Animation } from "babylonjs/Animations/animation";
  13031. import { RuntimeAnimation } from "babylonjs/Animations/runtimeAnimation";
  13032. import { Nullable } from "babylonjs/types";
  13033. import { Observable } from "babylonjs/Misc/observable";
  13034. import { Scene } from "babylonjs/scene";
  13035. import { Matrix, Quaternion, Vector3 } from "babylonjs/Maths/math.vector";
  13036. import { Node } from "babylonjs/node";
  13037. /**
  13038. * Class used to store an actual running animation
  13039. */
  13040. export class Animatable {
  13041. /** defines the target object */
  13042. target: any;
  13043. /** defines the starting frame number (default is 0) */
  13044. fromFrame: number;
  13045. /** defines the ending frame number (default is 100) */
  13046. toFrame: number;
  13047. /** defines if the animation must loop (default is false) */
  13048. loopAnimation: boolean;
  13049. /** defines a callback to call when animation ends if it is not looping */
  13050. onAnimationEnd?: (() => void) | null | undefined;
  13051. /** defines a callback to call when animation loops */
  13052. onAnimationLoop?: (() => void) | null | undefined;
  13053. private _localDelayOffset;
  13054. private _pausedDelay;
  13055. private _runtimeAnimations;
  13056. private _paused;
  13057. private _scene;
  13058. private _speedRatio;
  13059. private _weight;
  13060. private _syncRoot;
  13061. /**
  13062. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  13063. * This will only apply for non looping animation (default is true)
  13064. */
  13065. disposeOnEnd: boolean;
  13066. /**
  13067. * Gets a boolean indicating if the animation has started
  13068. */
  13069. animationStarted: boolean;
  13070. /**
  13071. * Observer raised when the animation ends
  13072. */
  13073. onAnimationEndObservable: Observable<Animatable>;
  13074. /**
  13075. * Observer raised when the animation loops
  13076. */
  13077. onAnimationLoopObservable: Observable<Animatable>;
  13078. /**
  13079. * Gets the root Animatable used to synchronize and normalize animations
  13080. */
  13081. readonly syncRoot: Nullable<Animatable>;
  13082. /**
  13083. * Gets the current frame of the first RuntimeAnimation
  13084. * Used to synchronize Animatables
  13085. */
  13086. readonly masterFrame: number;
  13087. /**
  13088. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  13089. */
  13090. weight: number;
  13091. /**
  13092. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  13093. */
  13094. speedRatio: number;
  13095. /**
  13096. * Creates a new Animatable
  13097. * @param scene defines the hosting scene
  13098. * @param target defines the target object
  13099. * @param fromFrame defines the starting frame number (default is 0)
  13100. * @param toFrame defines the ending frame number (default is 100)
  13101. * @param loopAnimation defines if the animation must loop (default is false)
  13102. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  13103. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  13104. * @param animations defines a group of animation to add to the new Animatable
  13105. * @param onAnimationLoop defines a callback to call when animation loops
  13106. */
  13107. constructor(scene: Scene,
  13108. /** defines the target object */
  13109. target: any,
  13110. /** defines the starting frame number (default is 0) */
  13111. fromFrame?: number,
  13112. /** defines the ending frame number (default is 100) */
  13113. toFrame?: number,
  13114. /** defines if the animation must loop (default is false) */
  13115. loopAnimation?: boolean, speedRatio?: number,
  13116. /** defines a callback to call when animation ends if it is not looping */
  13117. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  13118. /** defines a callback to call when animation loops */
  13119. onAnimationLoop?: (() => void) | null | undefined);
  13120. /**
  13121. * Synchronize and normalize current Animatable with a source Animatable
  13122. * This is useful when using animation weights and when animations are not of the same length
  13123. * @param root defines the root Animatable to synchronize with
  13124. * @returns the current Animatable
  13125. */
  13126. syncWith(root: Animatable): Animatable;
  13127. /**
  13128. * Gets the list of runtime animations
  13129. * @returns an array of RuntimeAnimation
  13130. */
  13131. getAnimations(): RuntimeAnimation[];
  13132. /**
  13133. * Adds more animations to the current animatable
  13134. * @param target defines the target of the animations
  13135. * @param animations defines the new animations to add
  13136. */
  13137. appendAnimations(target: any, animations: Animation[]): void;
  13138. /**
  13139. * Gets the source animation for a specific property
  13140. * @param property defines the propertyu to look for
  13141. * @returns null or the source animation for the given property
  13142. */
  13143. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  13144. /**
  13145. * Gets the runtime animation for a specific property
  13146. * @param property defines the propertyu to look for
  13147. * @returns null or the runtime animation for the given property
  13148. */
  13149. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  13150. /**
  13151. * Resets the animatable to its original state
  13152. */
  13153. reset(): void;
  13154. /**
  13155. * Allows the animatable to blend with current running animations
  13156. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  13157. * @param blendingSpeed defines the blending speed to use
  13158. */
  13159. enableBlending(blendingSpeed: number): void;
  13160. /**
  13161. * Disable animation blending
  13162. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  13163. */
  13164. disableBlending(): void;
  13165. /**
  13166. * Jump directly to a given frame
  13167. * @param frame defines the frame to jump to
  13168. */
  13169. goToFrame(frame: number): void;
  13170. /**
  13171. * Pause the animation
  13172. */
  13173. pause(): void;
  13174. /**
  13175. * Restart the animation
  13176. */
  13177. restart(): void;
  13178. private _raiseOnAnimationEnd;
  13179. /**
  13180. * Stop and delete the current animation
  13181. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  13182. * @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)
  13183. */
  13184. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  13185. /**
  13186. * Wait asynchronously for the animation to end
  13187. * @returns a promise which will be fullfilled when the animation ends
  13188. */
  13189. waitAsync(): Promise<Animatable>;
  13190. /** @hidden */
  13191. _animate(delay: number): boolean;
  13192. }
  13193. module "babylonjs/scene" {
  13194. interface Scene {
  13195. /** @hidden */
  13196. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  13197. /** @hidden */
  13198. _processLateAnimationBindingsForMatrices(holder: {
  13199. totalWeight: number;
  13200. animations: RuntimeAnimation[];
  13201. originalValue: Matrix;
  13202. }): any;
  13203. /** @hidden */
  13204. _processLateAnimationBindingsForQuaternions(holder: {
  13205. totalWeight: number;
  13206. animations: RuntimeAnimation[];
  13207. originalValue: Quaternion;
  13208. }, refQuaternion: Quaternion): Quaternion;
  13209. /** @hidden */
  13210. _processLateAnimationBindings(): void;
  13211. /**
  13212. * Will start the animation sequence of a given target
  13213. * @param target defines the target
  13214. * @param from defines from which frame should animation start
  13215. * @param to defines until which frame should animation run.
  13216. * @param weight defines the weight to apply to the animation (1.0 by default)
  13217. * @param loop defines if the animation loops
  13218. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  13219. * @param onAnimationEnd defines the function to be executed when the animation ends
  13220. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  13221. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  13222. * @param onAnimationLoop defines the callback to call when an animation loops
  13223. * @returns the animatable object created for this animation
  13224. */
  13225. beginWeightedAnimation(target: any, from: number, to: number, weight: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  13226. /**
  13227. * Will start the animation sequence of a given target
  13228. * @param target defines the target
  13229. * @param from defines from which frame should animation start
  13230. * @param to defines until which frame should animation run.
  13231. * @param loop defines if the animation loops
  13232. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  13233. * @param onAnimationEnd defines the function to be executed when the animation ends
  13234. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  13235. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  13236. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  13237. * @param onAnimationLoop defines the callback to call when an animation loops
  13238. * @returns the animatable object created for this animation
  13239. */
  13240. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  13241. /**
  13242. * Will start the animation sequence of a given target and its hierarchy
  13243. * @param target defines the target
  13244. * @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.
  13245. * @param from defines from which frame should animation start
  13246. * @param to defines until which frame should animation run.
  13247. * @param loop defines if the animation loops
  13248. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  13249. * @param onAnimationEnd defines the function to be executed when the animation ends
  13250. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  13251. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  13252. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  13253. * @param onAnimationLoop defines the callback to call when an animation loops
  13254. * @returns the list of created animatables
  13255. */
  13256. 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[];
  13257. /**
  13258. * Begin a new animation on a given node
  13259. * @param target defines the target where the animation will take place
  13260. * @param animations defines the list of animations to start
  13261. * @param from defines the initial value
  13262. * @param to defines the final value
  13263. * @param loop defines if you want animation to loop (off by default)
  13264. * @param speedRatio defines the speed ratio to apply to all animations
  13265. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  13266. * @param onAnimationLoop defines the callback to call when an animation loops
  13267. * @returns the list of created animatables
  13268. */
  13269. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable;
  13270. /**
  13271. * Begin a new animation on a given node and its hierarchy
  13272. * @param target defines the root node where the animation will take place
  13273. * @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.
  13274. * @param animations defines the list of animations to start
  13275. * @param from defines the initial value
  13276. * @param to defines the final value
  13277. * @param loop defines if you want animation to loop (off by default)
  13278. * @param speedRatio defines the speed ratio to apply to all animations
  13279. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  13280. * @param onAnimationLoop defines the callback to call when an animation loops
  13281. * @returns the list of animatables created for all nodes
  13282. */
  13283. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable[];
  13284. /**
  13285. * Gets the animatable associated with a specific target
  13286. * @param target defines the target of the animatable
  13287. * @returns the required animatable if found
  13288. */
  13289. getAnimatableByTarget(target: any): Nullable<Animatable>;
  13290. /**
  13291. * Gets all animatables associated with a given target
  13292. * @param target defines the target to look animatables for
  13293. * @returns an array of Animatables
  13294. */
  13295. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  13296. /**
  13297. * Stops and removes all animations that have been applied to the scene
  13298. */
  13299. stopAllAnimations(): void;
  13300. }
  13301. }
  13302. module "babylonjs/Bones/bone" {
  13303. interface Bone {
  13304. /**
  13305. * Copy an animation range from another bone
  13306. * @param source defines the source bone
  13307. * @param rangeName defines the range name to copy
  13308. * @param frameOffset defines the frame offset
  13309. * @param rescaleAsRequired defines if rescaling must be applied if required
  13310. * @param skelDimensionsRatio defines the scaling ratio
  13311. * @returns true if operation was successful
  13312. */
  13313. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  13314. }
  13315. }
  13316. }
  13317. declare module "babylonjs/Animations/animationPropertiesOverride" {
  13318. /**
  13319. * Class used to override all child animations of a given target
  13320. */
  13321. export class AnimationPropertiesOverride {
  13322. /**
  13323. * Gets or sets a value indicating if animation blending must be used
  13324. */
  13325. enableBlending: boolean;
  13326. /**
  13327. * Gets or sets the blending speed to use when enableBlending is true
  13328. */
  13329. blendingSpeed: number;
  13330. /**
  13331. * Gets or sets the default loop mode to use
  13332. */
  13333. loopMode: number;
  13334. }
  13335. }
  13336. declare module "babylonjs/Bones/skeleton" {
  13337. import { Bone } from "babylonjs/Bones/bone";
  13338. import { Observable } from "babylonjs/Misc/observable";
  13339. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  13340. import { Scene } from "babylonjs/scene";
  13341. import { Nullable } from "babylonjs/types";
  13342. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  13343. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  13344. import { Animatable } from "babylonjs/Animations/animatable";
  13345. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  13346. import { Animation } from "babylonjs/Animations/animation";
  13347. import { AnimationRange } from "babylonjs/Animations/animationRange";
  13348. import { IInspectable } from "babylonjs/Misc/iInspectable";
  13349. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  13350. /**
  13351. * Class used to handle skinning animations
  13352. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  13353. */
  13354. export class Skeleton implements IAnimatable {
  13355. /** defines the skeleton name */
  13356. name: string;
  13357. /** defines the skeleton Id */
  13358. id: string;
  13359. /**
  13360. * Defines the list of child bones
  13361. */
  13362. bones: Bone[];
  13363. /**
  13364. * Defines an estimate of the dimension of the skeleton at rest
  13365. */
  13366. dimensionsAtRest: Vector3;
  13367. /**
  13368. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  13369. */
  13370. needInitialSkinMatrix: boolean;
  13371. /**
  13372. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  13373. */
  13374. overrideMesh: Nullable<AbstractMesh>;
  13375. /**
  13376. * Gets the list of animations attached to this skeleton
  13377. */
  13378. animations: Array<Animation>;
  13379. private _scene;
  13380. private _isDirty;
  13381. private _transformMatrices;
  13382. private _transformMatrixTexture;
  13383. private _meshesWithPoseMatrix;
  13384. private _animatables;
  13385. private _identity;
  13386. private _synchronizedWithMesh;
  13387. private _ranges;
  13388. private _lastAbsoluteTransformsUpdateId;
  13389. private _canUseTextureForBones;
  13390. private _uniqueId;
  13391. /** @hidden */
  13392. _numBonesWithLinkedTransformNode: number;
  13393. /** @hidden */
  13394. _hasWaitingData: Nullable<boolean>;
  13395. /**
  13396. * Specifies if the skeleton should be serialized
  13397. */
  13398. doNotSerialize: boolean;
  13399. private _useTextureToStoreBoneMatrices;
  13400. /**
  13401. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  13402. * Please note that this option is not available if the hardware does not support it
  13403. */
  13404. useTextureToStoreBoneMatrices: boolean;
  13405. private _animationPropertiesOverride;
  13406. /**
  13407. * Gets or sets the animation properties override
  13408. */
  13409. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  13410. /**
  13411. * List of inspectable custom properties (used by the Inspector)
  13412. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  13413. */
  13414. inspectableCustomProperties: IInspectable[];
  13415. /**
  13416. * An observable triggered before computing the skeleton's matrices
  13417. */
  13418. onBeforeComputeObservable: Observable<Skeleton>;
  13419. /**
  13420. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  13421. */
  13422. readonly isUsingTextureForMatrices: boolean;
  13423. /**
  13424. * Gets the unique ID of this skeleton
  13425. */
  13426. readonly uniqueId: number;
  13427. /**
  13428. * Creates a new skeleton
  13429. * @param name defines the skeleton name
  13430. * @param id defines the skeleton Id
  13431. * @param scene defines the hosting scene
  13432. */
  13433. constructor(
  13434. /** defines the skeleton name */
  13435. name: string,
  13436. /** defines the skeleton Id */
  13437. id: string, scene: Scene);
  13438. /**
  13439. * Gets the current object class name.
  13440. * @return the class name
  13441. */
  13442. getClassName(): string;
  13443. /**
  13444. * Returns an array containing the root bones
  13445. * @returns an array containing the root bones
  13446. */
  13447. getChildren(): Array<Bone>;
  13448. /**
  13449. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  13450. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  13451. * @returns a Float32Array containing matrices data
  13452. */
  13453. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  13454. /**
  13455. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  13456. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  13457. * @returns a raw texture containing the data
  13458. */
  13459. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  13460. /**
  13461. * Gets the current hosting scene
  13462. * @returns a scene object
  13463. */
  13464. getScene(): Scene;
  13465. /**
  13466. * Gets a string representing the current skeleton data
  13467. * @param fullDetails defines a boolean indicating if we want a verbose version
  13468. * @returns a string representing the current skeleton data
  13469. */
  13470. toString(fullDetails?: boolean): string;
  13471. /**
  13472. * Get bone's index searching by name
  13473. * @param name defines bone's name to search for
  13474. * @return the indice of the bone. Returns -1 if not found
  13475. */
  13476. getBoneIndexByName(name: string): number;
  13477. /**
  13478. * Creater a new animation range
  13479. * @param name defines the name of the range
  13480. * @param from defines the start key
  13481. * @param to defines the end key
  13482. */
  13483. createAnimationRange(name: string, from: number, to: number): void;
  13484. /**
  13485. * Delete a specific animation range
  13486. * @param name defines the name of the range
  13487. * @param deleteFrames defines if frames must be removed as well
  13488. */
  13489. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  13490. /**
  13491. * Gets a specific animation range
  13492. * @param name defines the name of the range to look for
  13493. * @returns the requested animation range or null if not found
  13494. */
  13495. getAnimationRange(name: string): Nullable<AnimationRange>;
  13496. /**
  13497. * Gets the list of all animation ranges defined on this skeleton
  13498. * @returns an array
  13499. */
  13500. getAnimationRanges(): Nullable<AnimationRange>[];
  13501. /**
  13502. * Copy animation range from a source skeleton.
  13503. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  13504. * @param source defines the source skeleton
  13505. * @param name defines the name of the range to copy
  13506. * @param rescaleAsRequired defines if rescaling must be applied if required
  13507. * @returns true if operation was successful
  13508. */
  13509. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  13510. /**
  13511. * Forces the skeleton to go to rest pose
  13512. */
  13513. returnToRest(): void;
  13514. private _getHighestAnimationFrame;
  13515. /**
  13516. * Begin a specific animation range
  13517. * @param name defines the name of the range to start
  13518. * @param loop defines if looping must be turned on (false by default)
  13519. * @param speedRatio defines the speed ratio to apply (1 by default)
  13520. * @param onAnimationEnd defines a callback which will be called when animation will end
  13521. * @returns a new animatable
  13522. */
  13523. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  13524. /** @hidden */
  13525. _markAsDirty(): void;
  13526. /** @hidden */
  13527. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  13528. /** @hidden */
  13529. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  13530. private _computeTransformMatrices;
  13531. /**
  13532. * Build all resources required to render a skeleton
  13533. */
  13534. prepare(): void;
  13535. /**
  13536. * Gets the list of animatables currently running for this skeleton
  13537. * @returns an array of animatables
  13538. */
  13539. getAnimatables(): IAnimatable[];
  13540. /**
  13541. * Clone the current skeleton
  13542. * @param name defines the name of the new skeleton
  13543. * @param id defines the id of the new skeleton
  13544. * @returns the new skeleton
  13545. */
  13546. clone(name: string, id: string): Skeleton;
  13547. /**
  13548. * Enable animation blending for this skeleton
  13549. * @param blendingSpeed defines the blending speed to apply
  13550. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  13551. */
  13552. enableBlending(blendingSpeed?: number): void;
  13553. /**
  13554. * Releases all resources associated with the current skeleton
  13555. */
  13556. dispose(): void;
  13557. /**
  13558. * Serialize the skeleton in a JSON object
  13559. * @returns a JSON object
  13560. */
  13561. serialize(): any;
  13562. /**
  13563. * Creates a new skeleton from serialized data
  13564. * @param parsedSkeleton defines the serialized data
  13565. * @param scene defines the hosting scene
  13566. * @returns a new skeleton
  13567. */
  13568. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  13569. /**
  13570. * Compute all node absolute transforms
  13571. * @param forceUpdate defines if computation must be done even if cache is up to date
  13572. */
  13573. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  13574. /**
  13575. * Gets the root pose matrix
  13576. * @returns a matrix
  13577. */
  13578. getPoseMatrix(): Nullable<Matrix>;
  13579. /**
  13580. * Sorts bones per internal index
  13581. */
  13582. sortBones(): void;
  13583. private _sortBones;
  13584. }
  13585. }
  13586. declare module "babylonjs/Bones/bone" {
  13587. import { Skeleton } from "babylonjs/Bones/skeleton";
  13588. import { Vector3, Quaternion, Matrix } from "babylonjs/Maths/math.vector";
  13589. import { Nullable } from "babylonjs/types";
  13590. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  13591. import { TransformNode } from "babylonjs/Meshes/transformNode";
  13592. import { Node } from "babylonjs/node";
  13593. import { Space } from "babylonjs/Maths/math.axis";
  13594. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  13595. /**
  13596. * Class used to store bone information
  13597. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  13598. */
  13599. export class Bone extends Node {
  13600. /**
  13601. * defines the bone name
  13602. */
  13603. name: string;
  13604. private static _tmpVecs;
  13605. private static _tmpQuat;
  13606. private static _tmpMats;
  13607. /**
  13608. * Gets the list of child bones
  13609. */
  13610. children: Bone[];
  13611. /** Gets the animations associated with this bone */
  13612. animations: import("babylonjs/Animations/animation").Animation[];
  13613. /**
  13614. * Gets or sets bone length
  13615. */
  13616. length: number;
  13617. /**
  13618. * @hidden Internal only
  13619. * Set this value to map this bone to a different index in the transform matrices
  13620. * Set this value to -1 to exclude the bone from the transform matrices
  13621. */
  13622. _index: Nullable<number>;
  13623. private _skeleton;
  13624. private _localMatrix;
  13625. private _restPose;
  13626. private _baseMatrix;
  13627. private _absoluteTransform;
  13628. private _invertedAbsoluteTransform;
  13629. private _parent;
  13630. private _scalingDeterminant;
  13631. private _worldTransform;
  13632. private _localScaling;
  13633. private _localRotation;
  13634. private _localPosition;
  13635. private _needToDecompose;
  13636. private _needToCompose;
  13637. /** @hidden */
  13638. _linkedTransformNode: Nullable<TransformNode>;
  13639. /** @hidden */
  13640. _waitingTransformNodeId: Nullable<string>;
  13641. /** @hidden */
  13642. /** @hidden */
  13643. _matrix: Matrix;
  13644. /**
  13645. * Create a new bone
  13646. * @param name defines the bone name
  13647. * @param skeleton defines the parent skeleton
  13648. * @param parentBone defines the parent (can be null if the bone is the root)
  13649. * @param localMatrix defines the local matrix
  13650. * @param restPose defines the rest pose matrix
  13651. * @param baseMatrix defines the base matrix
  13652. * @param index defines index of the bone in the hiearchy
  13653. */
  13654. constructor(
  13655. /**
  13656. * defines the bone name
  13657. */
  13658. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  13659. /**
  13660. * Gets the current object class name.
  13661. * @return the class name
  13662. */
  13663. getClassName(): string;
  13664. /**
  13665. * Gets the parent skeleton
  13666. * @returns a skeleton
  13667. */
  13668. getSkeleton(): Skeleton;
  13669. /**
  13670. * Gets parent bone
  13671. * @returns a bone or null if the bone is the root of the bone hierarchy
  13672. */
  13673. getParent(): Nullable<Bone>;
  13674. /**
  13675. * Returns an array containing the root bones
  13676. * @returns an array containing the root bones
  13677. */
  13678. getChildren(): Array<Bone>;
  13679. /**
  13680. * Sets the parent bone
  13681. * @param parent defines the parent (can be null if the bone is the root)
  13682. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  13683. */
  13684. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  13685. /**
  13686. * Gets the local matrix
  13687. * @returns a matrix
  13688. */
  13689. getLocalMatrix(): Matrix;
  13690. /**
  13691. * Gets the base matrix (initial matrix which remains unchanged)
  13692. * @returns a matrix
  13693. */
  13694. getBaseMatrix(): Matrix;
  13695. /**
  13696. * Gets the rest pose matrix
  13697. * @returns a matrix
  13698. */
  13699. getRestPose(): Matrix;
  13700. /**
  13701. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  13702. */
  13703. getWorldMatrix(): Matrix;
  13704. /**
  13705. * Sets the local matrix to rest pose matrix
  13706. */
  13707. returnToRest(): void;
  13708. /**
  13709. * Gets the inverse of the absolute transform matrix.
  13710. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  13711. * @returns a matrix
  13712. */
  13713. getInvertedAbsoluteTransform(): Matrix;
  13714. /**
  13715. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  13716. * @returns a matrix
  13717. */
  13718. getAbsoluteTransform(): Matrix;
  13719. /**
  13720. * Links with the given transform node.
  13721. * The local matrix of this bone is copied from the transform node every frame.
  13722. * @param transformNode defines the transform node to link to
  13723. */
  13724. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  13725. /**
  13726. * Gets the node used to drive the bone's transformation
  13727. * @returns a transform node or null
  13728. */
  13729. getTransformNode(): Nullable<TransformNode>;
  13730. /** Gets or sets current position (in local space) */
  13731. position: Vector3;
  13732. /** Gets or sets current rotation (in local space) */
  13733. rotation: Vector3;
  13734. /** Gets or sets current rotation quaternion (in local space) */
  13735. rotationQuaternion: Quaternion;
  13736. /** Gets or sets current scaling (in local space) */
  13737. scaling: Vector3;
  13738. /**
  13739. * Gets the animation properties override
  13740. */
  13741. readonly animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  13742. private _decompose;
  13743. private _compose;
  13744. /**
  13745. * Update the base and local matrices
  13746. * @param matrix defines the new base or local matrix
  13747. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  13748. * @param updateLocalMatrix defines if the local matrix should be updated
  13749. */
  13750. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  13751. /** @hidden */
  13752. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  13753. /**
  13754. * Flag the bone as dirty (Forcing it to update everything)
  13755. */
  13756. markAsDirty(): void;
  13757. /** @hidden */
  13758. _markAsDirtyAndCompose(): void;
  13759. private _markAsDirtyAndDecompose;
  13760. /**
  13761. * Translate the bone in local or world space
  13762. * @param vec The amount to translate the bone
  13763. * @param space The space that the translation is in
  13764. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13765. */
  13766. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  13767. /**
  13768. * Set the postion of the bone in local or world space
  13769. * @param position The position to set the bone
  13770. * @param space The space that the position is in
  13771. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13772. */
  13773. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  13774. /**
  13775. * Set the absolute position of the bone (world space)
  13776. * @param position The position to set the bone
  13777. * @param mesh The mesh that this bone is attached to
  13778. */
  13779. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  13780. /**
  13781. * Scale the bone on the x, y and z axes (in local space)
  13782. * @param x The amount to scale the bone on the x axis
  13783. * @param y The amount to scale the bone on the y axis
  13784. * @param z The amount to scale the bone on the z axis
  13785. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  13786. */
  13787. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  13788. /**
  13789. * Set the bone scaling in local space
  13790. * @param scale defines the scaling vector
  13791. */
  13792. setScale(scale: Vector3): void;
  13793. /**
  13794. * Gets the current scaling in local space
  13795. * @returns the current scaling vector
  13796. */
  13797. getScale(): Vector3;
  13798. /**
  13799. * Gets the current scaling in local space and stores it in a target vector
  13800. * @param result defines the target vector
  13801. */
  13802. getScaleToRef(result: Vector3): void;
  13803. /**
  13804. * Set the yaw, pitch, and roll of the bone in local or world space
  13805. * @param yaw The rotation of the bone on the y axis
  13806. * @param pitch The rotation of the bone on the x axis
  13807. * @param roll The rotation of the bone on the z axis
  13808. * @param space The space that the axes of rotation are in
  13809. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13810. */
  13811. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  13812. /**
  13813. * Add a rotation to the bone on an axis in local or world space
  13814. * @param axis The axis to rotate the bone on
  13815. * @param amount The amount to rotate the bone
  13816. * @param space The space that the axis is in
  13817. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13818. */
  13819. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  13820. /**
  13821. * Set the rotation of the bone to a particular axis angle in local or world space
  13822. * @param axis The axis to rotate the bone on
  13823. * @param angle The angle that the bone should be rotated to
  13824. * @param space The space that the axis is in
  13825. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13826. */
  13827. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  13828. /**
  13829. * Set the euler rotation of the bone in local of world space
  13830. * @param rotation The euler rotation that the bone should be set to
  13831. * @param space The space that the rotation is in
  13832. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13833. */
  13834. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  13835. /**
  13836. * Set the quaternion rotation of the bone in local of world space
  13837. * @param quat The quaternion rotation that the bone should be set to
  13838. * @param space The space that the rotation is in
  13839. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13840. */
  13841. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  13842. /**
  13843. * Set the rotation matrix of the bone in local of world space
  13844. * @param rotMat The rotation matrix that the bone should be set to
  13845. * @param space The space that the rotation is in
  13846. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13847. */
  13848. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  13849. private _rotateWithMatrix;
  13850. private _getNegativeRotationToRef;
  13851. /**
  13852. * Get the position of the bone in local or world space
  13853. * @param space The space that the returned position is in
  13854. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13855. * @returns The position of the bone
  13856. */
  13857. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  13858. /**
  13859. * Copy the position of the bone to a vector3 in local or world space
  13860. * @param space The space that the returned position is in
  13861. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13862. * @param result The vector3 to copy the position to
  13863. */
  13864. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  13865. /**
  13866. * Get the absolute position of the bone (world space)
  13867. * @param mesh The mesh that this bone is attached to
  13868. * @returns The absolute position of the bone
  13869. */
  13870. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  13871. /**
  13872. * Copy the absolute position of the bone (world space) to the result param
  13873. * @param mesh The mesh that this bone is attached to
  13874. * @param result The vector3 to copy the absolute position to
  13875. */
  13876. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  13877. /**
  13878. * Compute the absolute transforms of this bone and its children
  13879. */
  13880. computeAbsoluteTransforms(): void;
  13881. /**
  13882. * Get the world direction from an axis that is in the local space of the bone
  13883. * @param localAxis The local direction that is used to compute the world direction
  13884. * @param mesh The mesh that this bone is attached to
  13885. * @returns The world direction
  13886. */
  13887. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  13888. /**
  13889. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  13890. * @param localAxis The local direction that is used to compute the world direction
  13891. * @param mesh The mesh that this bone is attached to
  13892. * @param result The vector3 that the world direction will be copied to
  13893. */
  13894. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  13895. /**
  13896. * Get the euler rotation of the bone in local or world space
  13897. * @param space The space that the rotation should be in
  13898. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13899. * @returns The euler rotation
  13900. */
  13901. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  13902. /**
  13903. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  13904. * @param space The space that the rotation should be in
  13905. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13906. * @param result The vector3 that the rotation should be copied to
  13907. */
  13908. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  13909. /**
  13910. * Get the quaternion rotation of the bone in either local or world space
  13911. * @param space The space that the rotation should be in
  13912. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13913. * @returns The quaternion rotation
  13914. */
  13915. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  13916. /**
  13917. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  13918. * @param space The space that the rotation should be in
  13919. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13920. * @param result The quaternion that the rotation should be copied to
  13921. */
  13922. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  13923. /**
  13924. * Get the rotation matrix of the bone in local or world space
  13925. * @param space The space that the rotation should be in
  13926. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13927. * @returns The rotation matrix
  13928. */
  13929. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  13930. /**
  13931. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  13932. * @param space The space that the rotation should be in
  13933. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13934. * @param result The quaternion that the rotation should be copied to
  13935. */
  13936. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  13937. /**
  13938. * Get the world position of a point that is in the local space of the bone
  13939. * @param position The local position
  13940. * @param mesh The mesh that this bone is attached to
  13941. * @returns The world position
  13942. */
  13943. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  13944. /**
  13945. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  13946. * @param position The local position
  13947. * @param mesh The mesh that this bone is attached to
  13948. * @param result The vector3 that the world position should be copied to
  13949. */
  13950. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  13951. /**
  13952. * Get the local position of a point that is in world space
  13953. * @param position The world position
  13954. * @param mesh The mesh that this bone is attached to
  13955. * @returns The local position
  13956. */
  13957. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  13958. /**
  13959. * Get the local position of a point that is in world space and copy it to the result param
  13960. * @param position The world position
  13961. * @param mesh The mesh that this bone is attached to
  13962. * @param result The vector3 that the local position should be copied to
  13963. */
  13964. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  13965. }
  13966. }
  13967. declare module "babylonjs/Meshes/transformNode" {
  13968. import { DeepImmutable } from "babylonjs/types";
  13969. import { Observable } from "babylonjs/Misc/observable";
  13970. import { Nullable } from "babylonjs/types";
  13971. import { Camera } from "babylonjs/Cameras/camera";
  13972. import { Scene } from "babylonjs/scene";
  13973. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  13974. import { Node } from "babylonjs/node";
  13975. import { Bone } from "babylonjs/Bones/bone";
  13976. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  13977. import { Space } from "babylonjs/Maths/math.axis";
  13978. /**
  13979. * 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.
  13980. * @see https://doc.babylonjs.com/how_to/transformnode
  13981. */
  13982. export class TransformNode extends Node {
  13983. /**
  13984. * Object will not rotate to face the camera
  13985. */
  13986. static BILLBOARDMODE_NONE: number;
  13987. /**
  13988. * Object will rotate to face the camera but only on the x axis
  13989. */
  13990. static BILLBOARDMODE_X: number;
  13991. /**
  13992. * Object will rotate to face the camera but only on the y axis
  13993. */
  13994. static BILLBOARDMODE_Y: number;
  13995. /**
  13996. * Object will rotate to face the camera but only on the z axis
  13997. */
  13998. static BILLBOARDMODE_Z: number;
  13999. /**
  14000. * Object will rotate to face the camera
  14001. */
  14002. static BILLBOARDMODE_ALL: number;
  14003. /**
  14004. * Object will rotate to face the camera's position instead of orientation
  14005. */
  14006. static BILLBOARDMODE_USE_POSITION: number;
  14007. private _forward;
  14008. private _forwardInverted;
  14009. private _up;
  14010. private _right;
  14011. private _rightInverted;
  14012. private _position;
  14013. private _rotation;
  14014. private _rotationQuaternion;
  14015. protected _scaling: Vector3;
  14016. protected _isDirty: boolean;
  14017. private _transformToBoneReferal;
  14018. private _isAbsoluteSynced;
  14019. private _billboardMode;
  14020. /**
  14021. * Gets or sets the billboard mode. Default is 0.
  14022. *
  14023. * | Value | Type | Description |
  14024. * | --- | --- | --- |
  14025. * | 0 | BILLBOARDMODE_NONE | |
  14026. * | 1 | BILLBOARDMODE_X | |
  14027. * | 2 | BILLBOARDMODE_Y | |
  14028. * | 4 | BILLBOARDMODE_Z | |
  14029. * | 7 | BILLBOARDMODE_ALL | |
  14030. *
  14031. */
  14032. billboardMode: number;
  14033. private _preserveParentRotationForBillboard;
  14034. /**
  14035. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  14036. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  14037. */
  14038. preserveParentRotationForBillboard: boolean;
  14039. /**
  14040. * 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
  14041. */
  14042. scalingDeterminant: number;
  14043. private _infiniteDistance;
  14044. /**
  14045. * Gets or sets the distance of the object to max, often used by skybox
  14046. */
  14047. infiniteDistance: boolean;
  14048. /**
  14049. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  14050. * By default the system will update normals to compensate
  14051. */
  14052. ignoreNonUniformScaling: boolean;
  14053. /**
  14054. * 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
  14055. */
  14056. reIntegrateRotationIntoRotationQuaternion: boolean;
  14057. /** @hidden */
  14058. _poseMatrix: Nullable<Matrix>;
  14059. /** @hidden */
  14060. _localMatrix: Matrix;
  14061. private _usePivotMatrix;
  14062. private _absolutePosition;
  14063. private _absoluteScaling;
  14064. private _absoluteRotationQuaternion;
  14065. private _pivotMatrix;
  14066. private _pivotMatrixInverse;
  14067. protected _postMultiplyPivotMatrix: boolean;
  14068. protected _isWorldMatrixFrozen: boolean;
  14069. /** @hidden */
  14070. _indexInSceneTransformNodesArray: number;
  14071. /**
  14072. * An event triggered after the world matrix is updated
  14073. */
  14074. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  14075. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  14076. /**
  14077. * Gets a string identifying the name of the class
  14078. * @returns "TransformNode" string
  14079. */
  14080. getClassName(): string;
  14081. /**
  14082. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  14083. */
  14084. position: Vector3;
  14085. /**
  14086. * 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)).
  14087. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  14088. */
  14089. rotation: Vector3;
  14090. /**
  14091. * 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)).
  14092. */
  14093. scaling: Vector3;
  14094. /**
  14095. * 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).
  14096. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  14097. */
  14098. rotationQuaternion: Nullable<Quaternion>;
  14099. /**
  14100. * The forward direction of that transform in world space.
  14101. */
  14102. readonly forward: Vector3;
  14103. /**
  14104. * The up direction of that transform in world space.
  14105. */
  14106. readonly up: Vector3;
  14107. /**
  14108. * The right direction of that transform in world space.
  14109. */
  14110. readonly right: Vector3;
  14111. /**
  14112. * Copies the parameter passed Matrix into the mesh Pose matrix.
  14113. * @param matrix the matrix to copy the pose from
  14114. * @returns this TransformNode.
  14115. */
  14116. updatePoseMatrix(matrix: Matrix): TransformNode;
  14117. /**
  14118. * Returns the mesh Pose matrix.
  14119. * @returns the pose matrix
  14120. */
  14121. getPoseMatrix(): Matrix;
  14122. /** @hidden */
  14123. _isSynchronized(): boolean;
  14124. /** @hidden */
  14125. _initCache(): void;
  14126. /**
  14127. * Flag the transform node as dirty (Forcing it to update everything)
  14128. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  14129. * @returns this transform node
  14130. */
  14131. markAsDirty(property: string): TransformNode;
  14132. /**
  14133. * Returns the current mesh absolute position.
  14134. * Returns a Vector3.
  14135. */
  14136. readonly absolutePosition: Vector3;
  14137. /**
  14138. * Returns the current mesh absolute scaling.
  14139. * Returns a Vector3.
  14140. */
  14141. readonly absoluteScaling: Vector3;
  14142. /**
  14143. * Returns the current mesh absolute rotation.
  14144. * Returns a Quaternion.
  14145. */
  14146. readonly absoluteRotationQuaternion: Quaternion;
  14147. /**
  14148. * Sets a new matrix to apply before all other transformation
  14149. * @param matrix defines the transform matrix
  14150. * @returns the current TransformNode
  14151. */
  14152. setPreTransformMatrix(matrix: Matrix): TransformNode;
  14153. /**
  14154. * Sets a new pivot matrix to the current node
  14155. * @param matrix defines the new pivot matrix to use
  14156. * @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
  14157. * @returns the current TransformNode
  14158. */
  14159. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  14160. /**
  14161. * Returns the mesh pivot matrix.
  14162. * Default : Identity.
  14163. * @returns the matrix
  14164. */
  14165. getPivotMatrix(): Matrix;
  14166. /**
  14167. * Instantiate (when possible) or clone that node with its hierarchy
  14168. * @param newParent defines the new parent to use for the instance (or clone)
  14169. * @returns an instance (or a clone) of the current node with its hiearchy
  14170. */
  14171. instantiateHierarychy(newParent?: Nullable<TransformNode>): Nullable<TransformNode>;
  14172. /**
  14173. * Prevents the World matrix to be computed any longer
  14174. * @param newWorldMatrix defines an optional matrix to use as world matrix
  14175. * @returns the TransformNode.
  14176. */
  14177. freezeWorldMatrix(newWorldMatrix?: Nullable<Matrix>): TransformNode;
  14178. /**
  14179. * Allows back the World matrix computation.
  14180. * @returns the TransformNode.
  14181. */
  14182. unfreezeWorldMatrix(): this;
  14183. /**
  14184. * True if the World matrix has been frozen.
  14185. */
  14186. readonly isWorldMatrixFrozen: boolean;
  14187. /**
  14188. * Retuns the mesh absolute position in the World.
  14189. * @returns a Vector3.
  14190. */
  14191. getAbsolutePosition(): Vector3;
  14192. /**
  14193. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  14194. * @param absolutePosition the absolute position to set
  14195. * @returns the TransformNode.
  14196. */
  14197. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  14198. /**
  14199. * Sets the mesh position in its local space.
  14200. * @param vector3 the position to set in localspace
  14201. * @returns the TransformNode.
  14202. */
  14203. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  14204. /**
  14205. * Returns the mesh position in the local space from the current World matrix values.
  14206. * @returns a new Vector3.
  14207. */
  14208. getPositionExpressedInLocalSpace(): Vector3;
  14209. /**
  14210. * Translates the mesh along the passed Vector3 in its local space.
  14211. * @param vector3 the distance to translate in localspace
  14212. * @returns the TransformNode.
  14213. */
  14214. locallyTranslate(vector3: Vector3): TransformNode;
  14215. private static _lookAtVectorCache;
  14216. /**
  14217. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  14218. * @param targetPoint the position (must be in same space as current mesh) to look at
  14219. * @param yawCor optional yaw (y-axis) correction in radians
  14220. * @param pitchCor optional pitch (x-axis) correction in radians
  14221. * @param rollCor optional roll (z-axis) correction in radians
  14222. * @param space the choosen space of the target
  14223. * @returns the TransformNode.
  14224. */
  14225. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  14226. /**
  14227. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  14228. * This Vector3 is expressed in the World space.
  14229. * @param localAxis axis to rotate
  14230. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  14231. */
  14232. getDirection(localAxis: Vector3): Vector3;
  14233. /**
  14234. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  14235. * localAxis is expressed in the mesh local space.
  14236. * result is computed in the Wordl space from the mesh World matrix.
  14237. * @param localAxis axis to rotate
  14238. * @param result the resulting transformnode
  14239. * @returns this TransformNode.
  14240. */
  14241. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  14242. /**
  14243. * Sets this transform node rotation to the given local axis.
  14244. * @param localAxis the axis in local space
  14245. * @param yawCor optional yaw (y-axis) correction in radians
  14246. * @param pitchCor optional pitch (x-axis) correction in radians
  14247. * @param rollCor optional roll (z-axis) correction in radians
  14248. * @returns this TransformNode
  14249. */
  14250. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  14251. /**
  14252. * Sets a new pivot point to the current node
  14253. * @param point defines the new pivot point to use
  14254. * @param space defines if the point is in world or local space (local by default)
  14255. * @returns the current TransformNode
  14256. */
  14257. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  14258. /**
  14259. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  14260. * @returns the pivot point
  14261. */
  14262. getPivotPoint(): Vector3;
  14263. /**
  14264. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  14265. * @param result the vector3 to store the result
  14266. * @returns this TransformNode.
  14267. */
  14268. getPivotPointToRef(result: Vector3): TransformNode;
  14269. /**
  14270. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  14271. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  14272. */
  14273. getAbsolutePivotPoint(): Vector3;
  14274. /**
  14275. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  14276. * @param result vector3 to store the result
  14277. * @returns this TransformNode.
  14278. */
  14279. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  14280. /**
  14281. * Defines the passed node as the parent of the current node.
  14282. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  14283. * @see https://doc.babylonjs.com/how_to/parenting
  14284. * @param node the node ot set as the parent
  14285. * @returns this TransformNode.
  14286. */
  14287. setParent(node: Nullable<Node>): TransformNode;
  14288. private _nonUniformScaling;
  14289. /**
  14290. * True if the scaling property of this object is non uniform eg. (1,2,1)
  14291. */
  14292. readonly nonUniformScaling: boolean;
  14293. /** @hidden */
  14294. _updateNonUniformScalingState(value: boolean): boolean;
  14295. /**
  14296. * Attach the current TransformNode to another TransformNode associated with a bone
  14297. * @param bone Bone affecting the TransformNode
  14298. * @param affectedTransformNode TransformNode associated with the bone
  14299. * @returns this object
  14300. */
  14301. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  14302. /**
  14303. * Detach the transform node if its associated with a bone
  14304. * @returns this object
  14305. */
  14306. detachFromBone(): TransformNode;
  14307. private static _rotationAxisCache;
  14308. /**
  14309. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  14310. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  14311. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  14312. * The passed axis is also normalized.
  14313. * @param axis the axis to rotate around
  14314. * @param amount the amount to rotate in radians
  14315. * @param space Space to rotate in (Default: local)
  14316. * @returns the TransformNode.
  14317. */
  14318. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  14319. /**
  14320. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  14321. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  14322. * The passed axis is also normalized. .
  14323. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  14324. * @param point the point to rotate around
  14325. * @param axis the axis to rotate around
  14326. * @param amount the amount to rotate in radians
  14327. * @returns the TransformNode
  14328. */
  14329. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  14330. /**
  14331. * Translates the mesh along the axis vector for the passed distance in the given space.
  14332. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  14333. * @param axis the axis to translate in
  14334. * @param distance the distance to translate
  14335. * @param space Space to rotate in (Default: local)
  14336. * @returns the TransformNode.
  14337. */
  14338. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  14339. /**
  14340. * Adds a rotation step to the mesh current rotation.
  14341. * x, y, z are Euler angles expressed in radians.
  14342. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  14343. * This means this rotation is made in the mesh local space only.
  14344. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  14345. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  14346. * ```javascript
  14347. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  14348. * ```
  14349. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  14350. * 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.
  14351. * @param x Rotation to add
  14352. * @param y Rotation to add
  14353. * @param z Rotation to add
  14354. * @returns the TransformNode.
  14355. */
  14356. addRotation(x: number, y: number, z: number): TransformNode;
  14357. /**
  14358. * @hidden
  14359. */
  14360. protected _getEffectiveParent(): Nullable<Node>;
  14361. /**
  14362. * Computes the world matrix of the node
  14363. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  14364. * @returns the world matrix
  14365. */
  14366. computeWorldMatrix(force?: boolean): Matrix;
  14367. protected _afterComputeWorldMatrix(): void;
  14368. /**
  14369. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  14370. * @param func callback function to add
  14371. *
  14372. * @returns the TransformNode.
  14373. */
  14374. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  14375. /**
  14376. * Removes a registered callback function.
  14377. * @param func callback function to remove
  14378. * @returns the TransformNode.
  14379. */
  14380. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  14381. /**
  14382. * Gets the position of the current mesh in camera space
  14383. * @param camera defines the camera to use
  14384. * @returns a position
  14385. */
  14386. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  14387. /**
  14388. * Returns the distance from the mesh to the active camera
  14389. * @param camera defines the camera to use
  14390. * @returns the distance
  14391. */
  14392. getDistanceToCamera(camera?: Nullable<Camera>): number;
  14393. /**
  14394. * Clone the current transform node
  14395. * @param name Name of the new clone
  14396. * @param newParent New parent for the clone
  14397. * @param doNotCloneChildren Do not clone children hierarchy
  14398. * @returns the new transform node
  14399. */
  14400. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  14401. /**
  14402. * Serializes the objects information.
  14403. * @param currentSerializationObject defines the object to serialize in
  14404. * @returns the serialized object
  14405. */
  14406. serialize(currentSerializationObject?: any): any;
  14407. /**
  14408. * Returns a new TransformNode object parsed from the source provided.
  14409. * @param parsedTransformNode is the source.
  14410. * @param scene the scne the object belongs to
  14411. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  14412. * @returns a new TransformNode object parsed from the source provided.
  14413. */
  14414. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  14415. /**
  14416. * Get all child-transformNodes of this node
  14417. * @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
  14418. * @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
  14419. * @returns an array of TransformNode
  14420. */
  14421. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  14422. /**
  14423. * Releases resources associated with this transform node.
  14424. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  14425. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  14426. */
  14427. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  14428. /**
  14429. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  14430. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  14431. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  14432. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  14433. * @returns the current mesh
  14434. */
  14435. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  14436. private _syncAbsoluteScalingAndRotation;
  14437. }
  14438. }
  14439. declare module "babylonjs/Gamepads/Controllers/poseEnabledController" {
  14440. import { Observable } from "babylonjs/Misc/observable";
  14441. import { Nullable } from "babylonjs/types";
  14442. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  14443. import { TransformNode } from "babylonjs/Meshes/transformNode";
  14444. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  14445. import { Ray } from "babylonjs/Culling/ray";
  14446. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  14447. import { PoseControlled, DevicePose } from "babylonjs/Cameras/VR/webVRCamera";
  14448. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  14449. /**
  14450. * Defines the types of pose enabled controllers that are supported
  14451. */
  14452. export enum PoseEnabledControllerType {
  14453. /**
  14454. * HTC Vive
  14455. */
  14456. VIVE = 0,
  14457. /**
  14458. * Oculus Rift
  14459. */
  14460. OCULUS = 1,
  14461. /**
  14462. * Windows mixed reality
  14463. */
  14464. WINDOWS = 2,
  14465. /**
  14466. * Samsung gear VR
  14467. */
  14468. GEAR_VR = 3,
  14469. /**
  14470. * Google Daydream
  14471. */
  14472. DAYDREAM = 4,
  14473. /**
  14474. * Generic
  14475. */
  14476. GENERIC = 5
  14477. }
  14478. /**
  14479. * Defines the MutableGamepadButton interface for the state of a gamepad button
  14480. */
  14481. export interface MutableGamepadButton {
  14482. /**
  14483. * Value of the button/trigger
  14484. */
  14485. value: number;
  14486. /**
  14487. * If the button/trigger is currently touched
  14488. */
  14489. touched: boolean;
  14490. /**
  14491. * If the button/trigger is currently pressed
  14492. */
  14493. pressed: boolean;
  14494. }
  14495. /**
  14496. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  14497. * @hidden
  14498. */
  14499. export interface ExtendedGamepadButton extends GamepadButton {
  14500. /**
  14501. * If the button/trigger is currently pressed
  14502. */
  14503. readonly pressed: boolean;
  14504. /**
  14505. * If the button/trigger is currently touched
  14506. */
  14507. readonly touched: boolean;
  14508. /**
  14509. * Value of the button/trigger
  14510. */
  14511. readonly value: number;
  14512. }
  14513. /** @hidden */
  14514. export interface _GamePadFactory {
  14515. /**
  14516. * Returns wether or not the current gamepad can be created for this type of controller.
  14517. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  14518. * @returns true if it can be created, otherwise false
  14519. */
  14520. canCreate(gamepadInfo: any): boolean;
  14521. /**
  14522. * Creates a new instance of the Gamepad.
  14523. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  14524. * @returns the new gamepad instance
  14525. */
  14526. create(gamepadInfo: any): Gamepad;
  14527. }
  14528. /**
  14529. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  14530. */
  14531. export class PoseEnabledControllerHelper {
  14532. /** @hidden */
  14533. static _ControllerFactories: _GamePadFactory[];
  14534. /** @hidden */
  14535. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  14536. /**
  14537. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  14538. * @param vrGamepad the gamepad to initialized
  14539. * @returns a vr controller of the type the gamepad identified as
  14540. */
  14541. static InitiateController(vrGamepad: any): Gamepad;
  14542. }
  14543. /**
  14544. * Defines the PoseEnabledController object that contains state of a vr capable controller
  14545. */
  14546. export class PoseEnabledController extends Gamepad implements PoseControlled {
  14547. /**
  14548. * If the controller is used in a webXR session
  14549. */
  14550. isXR: boolean;
  14551. private _deviceRoomPosition;
  14552. private _deviceRoomRotationQuaternion;
  14553. /**
  14554. * The device position in babylon space
  14555. */
  14556. devicePosition: Vector3;
  14557. /**
  14558. * The device rotation in babylon space
  14559. */
  14560. deviceRotationQuaternion: Quaternion;
  14561. /**
  14562. * The scale factor of the device in babylon space
  14563. */
  14564. deviceScaleFactor: number;
  14565. /**
  14566. * (Likely devicePosition should be used instead) The device position in its room space
  14567. */
  14568. position: Vector3;
  14569. /**
  14570. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  14571. */
  14572. rotationQuaternion: Quaternion;
  14573. /**
  14574. * The type of controller (Eg. Windows mixed reality)
  14575. */
  14576. controllerType: PoseEnabledControllerType;
  14577. protected _calculatedPosition: Vector3;
  14578. private _calculatedRotation;
  14579. /**
  14580. * The raw pose from the device
  14581. */
  14582. rawPose: DevicePose;
  14583. private _trackPosition;
  14584. private _maxRotationDistFromHeadset;
  14585. private _draggedRoomRotation;
  14586. /**
  14587. * @hidden
  14588. */
  14589. _disableTrackPosition(fixedPosition: Vector3): void;
  14590. /**
  14591. * Internal, the mesh attached to the controller
  14592. * @hidden
  14593. */
  14594. _mesh: Nullable<AbstractMesh>;
  14595. private _poseControlledCamera;
  14596. private _leftHandSystemQuaternion;
  14597. /**
  14598. * Internal, matrix used to convert room space to babylon space
  14599. * @hidden
  14600. */
  14601. _deviceToWorld: Matrix;
  14602. /**
  14603. * Node to be used when casting a ray from the controller
  14604. * @hidden
  14605. */
  14606. _pointingPoseNode: Nullable<TransformNode>;
  14607. /**
  14608. * Name of the child mesh that can be used to cast a ray from the controller
  14609. */
  14610. static readonly POINTING_POSE: string;
  14611. /**
  14612. * Creates a new PoseEnabledController from a gamepad
  14613. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  14614. */
  14615. constructor(browserGamepad: any);
  14616. private _workingMatrix;
  14617. /**
  14618. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  14619. */
  14620. update(): void;
  14621. /**
  14622. * Updates only the pose device and mesh without doing any button event checking
  14623. */
  14624. protected _updatePoseAndMesh(): void;
  14625. /**
  14626. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  14627. * @param poseData raw pose fromthe device
  14628. */
  14629. updateFromDevice(poseData: DevicePose): void;
  14630. /**
  14631. * @hidden
  14632. */
  14633. _meshAttachedObservable: Observable<AbstractMesh>;
  14634. /**
  14635. * Attaches a mesh to the controller
  14636. * @param mesh the mesh to be attached
  14637. */
  14638. attachToMesh(mesh: AbstractMesh): void;
  14639. /**
  14640. * Attaches the controllers mesh to a camera
  14641. * @param camera the camera the mesh should be attached to
  14642. */
  14643. attachToPoseControlledCamera(camera: TargetCamera): void;
  14644. /**
  14645. * Disposes of the controller
  14646. */
  14647. dispose(): void;
  14648. /**
  14649. * The mesh that is attached to the controller
  14650. */
  14651. readonly mesh: Nullable<AbstractMesh>;
  14652. /**
  14653. * Gets the ray of the controller in the direction the controller is pointing
  14654. * @param length the length the resulting ray should be
  14655. * @returns a ray in the direction the controller is pointing
  14656. */
  14657. getForwardRay(length?: number): Ray;
  14658. }
  14659. }
  14660. declare module "babylonjs/Gamepads/Controllers/webVRController" {
  14661. import { Observable } from "babylonjs/Misc/observable";
  14662. import { Scene } from "babylonjs/scene";
  14663. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  14664. import { PoseEnabledController, ExtendedGamepadButton, MutableGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  14665. import { StickValues, GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  14666. /**
  14667. * Defines the WebVRController object that represents controllers tracked in 3D space
  14668. */
  14669. export abstract class WebVRController extends PoseEnabledController {
  14670. /**
  14671. * Internal, the default controller model for the controller
  14672. */
  14673. protected _defaultModel: AbstractMesh;
  14674. /**
  14675. * Fired when the trigger state has changed
  14676. */
  14677. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  14678. /**
  14679. * Fired when the main button state has changed
  14680. */
  14681. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  14682. /**
  14683. * Fired when the secondary button state has changed
  14684. */
  14685. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  14686. /**
  14687. * Fired when the pad state has changed
  14688. */
  14689. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  14690. /**
  14691. * Fired when controllers stick values have changed
  14692. */
  14693. onPadValuesChangedObservable: Observable<StickValues>;
  14694. /**
  14695. * Array of button availible on the controller
  14696. */
  14697. protected _buttons: Array<MutableGamepadButton>;
  14698. private _onButtonStateChange;
  14699. /**
  14700. * Fired when a controller button's state has changed
  14701. * @param callback the callback containing the button that was modified
  14702. */
  14703. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  14704. /**
  14705. * X and Y axis corresponding to the controllers joystick
  14706. */
  14707. pad: StickValues;
  14708. /**
  14709. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  14710. */
  14711. hand: string;
  14712. /**
  14713. * The default controller model for the controller
  14714. */
  14715. readonly defaultModel: AbstractMesh;
  14716. /**
  14717. * Creates a new WebVRController from a gamepad
  14718. * @param vrGamepad the gamepad that the WebVRController should be created from
  14719. */
  14720. constructor(vrGamepad: any);
  14721. /**
  14722. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  14723. */
  14724. update(): void;
  14725. /**
  14726. * Function to be called when a button is modified
  14727. */
  14728. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  14729. /**
  14730. * Loads a mesh and attaches it to the controller
  14731. * @param scene the scene the mesh should be added to
  14732. * @param meshLoaded callback for when the mesh has been loaded
  14733. */
  14734. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  14735. private _setButtonValue;
  14736. private _changes;
  14737. private _checkChanges;
  14738. /**
  14739. * Disposes of th webVRCOntroller
  14740. */
  14741. dispose(): void;
  14742. }
  14743. }
  14744. declare module "babylonjs/Lights/hemisphericLight" {
  14745. import { Nullable } from "babylonjs/types";
  14746. import { Scene } from "babylonjs/scene";
  14747. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  14748. import { Color3 } from "babylonjs/Maths/math.color";
  14749. import { Effect } from "babylonjs/Materials/effect";
  14750. import { Light } from "babylonjs/Lights/light";
  14751. import { IShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  14752. /**
  14753. * The HemisphericLight simulates the ambient environment light,
  14754. * so the passed direction is the light reflection direction, not the incoming direction.
  14755. */
  14756. export class HemisphericLight extends Light {
  14757. /**
  14758. * The groundColor is the light in the opposite direction to the one specified during creation.
  14759. * 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.
  14760. */
  14761. groundColor: Color3;
  14762. /**
  14763. * The light reflection direction, not the incoming direction.
  14764. */
  14765. direction: Vector3;
  14766. /**
  14767. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  14768. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  14769. * The HemisphericLight can't cast shadows.
  14770. * Documentation : https://doc.babylonjs.com/babylon101/lights
  14771. * @param name The friendly name of the light
  14772. * @param direction The direction of the light reflection
  14773. * @param scene The scene the light belongs to
  14774. */
  14775. constructor(name: string, direction: Vector3, scene: Scene);
  14776. protected _buildUniformLayout(): void;
  14777. /**
  14778. * Returns the string "HemisphericLight".
  14779. * @return The class name
  14780. */
  14781. getClassName(): string;
  14782. /**
  14783. * Sets the HemisphericLight direction towards the passed target (Vector3).
  14784. * Returns the updated direction.
  14785. * @param target The target the direction should point to
  14786. * @return The computed direction
  14787. */
  14788. setDirectionToTarget(target: Vector3): Vector3;
  14789. /**
  14790. * Returns the shadow generator associated to the light.
  14791. * @returns Always null for hemispheric lights because it does not support shadows.
  14792. */
  14793. getShadowGenerator(): Nullable<IShadowGenerator>;
  14794. /**
  14795. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  14796. * @param effect The effect to update
  14797. * @param lightIndex The index of the light in the effect to update
  14798. * @returns The hemispheric light
  14799. */
  14800. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  14801. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  14802. /**
  14803. * Computes the world matrix of the node
  14804. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  14805. * @param useWasUpdatedFlag defines a reserved property
  14806. * @returns the world matrix
  14807. */
  14808. computeWorldMatrix(): Matrix;
  14809. /**
  14810. * Returns the integer 3.
  14811. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  14812. */
  14813. getTypeID(): number;
  14814. /**
  14815. * Prepares the list of defines specific to the light type.
  14816. * @param defines the list of defines
  14817. * @param lightIndex defines the index of the light for the effect
  14818. */
  14819. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  14820. }
  14821. }
  14822. declare module "babylonjs/Shaders/vrMultiviewToSingleview.fragment" {
  14823. /** @hidden */
  14824. export var vrMultiviewToSingleviewPixelShader: {
  14825. name: string;
  14826. shader: string;
  14827. };
  14828. }
  14829. declare module "babylonjs/Materials/Textures/MultiviewRenderTarget" {
  14830. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  14831. import { Scene } from "babylonjs/scene";
  14832. /**
  14833. * Renders to multiple views with a single draw call
  14834. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  14835. */
  14836. export class MultiviewRenderTarget extends RenderTargetTexture {
  14837. /**
  14838. * Creates a multiview render target
  14839. * @param scene scene used with the render target
  14840. * @param size the size of the render target (used for each view)
  14841. */
  14842. constructor(scene: Scene, size?: number | {
  14843. width: number;
  14844. height: number;
  14845. } | {
  14846. ratio: number;
  14847. });
  14848. /**
  14849. * @hidden
  14850. * @param faceIndex the face index, if its a cube texture
  14851. */
  14852. _bindFrameBuffer(faceIndex?: number): void;
  14853. /**
  14854. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  14855. * @returns the view count
  14856. */
  14857. getViewCount(): number;
  14858. }
  14859. }
  14860. declare module "babylonjs/Maths/math.frustum" {
  14861. import { Matrix } from "babylonjs/Maths/math.vector";
  14862. import { DeepImmutable } from "babylonjs/types";
  14863. import { Plane } from "babylonjs/Maths/math.plane";
  14864. /**
  14865. * Reprasents a camera frustum
  14866. */
  14867. export class Frustum {
  14868. /**
  14869. * Gets the planes representing the frustum
  14870. * @param transform matrix to be applied to the returned planes
  14871. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  14872. */
  14873. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  14874. /**
  14875. * Gets the near frustum plane transformed by the transform matrix
  14876. * @param transform transformation matrix to be applied to the resulting frustum plane
  14877. * @param frustumPlane the resuling frustum plane
  14878. */
  14879. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14880. /**
  14881. * Gets the far frustum plane transformed by the transform matrix
  14882. * @param transform transformation matrix to be applied to the resulting frustum plane
  14883. * @param frustumPlane the resuling frustum plane
  14884. */
  14885. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14886. /**
  14887. * Gets the left frustum plane transformed by the transform matrix
  14888. * @param transform transformation matrix to be applied to the resulting frustum plane
  14889. * @param frustumPlane the resuling frustum plane
  14890. */
  14891. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14892. /**
  14893. * Gets the right frustum plane transformed by the transform matrix
  14894. * @param transform transformation matrix to be applied to the resulting frustum plane
  14895. * @param frustumPlane the resuling frustum plane
  14896. */
  14897. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14898. /**
  14899. * Gets the top frustum plane transformed by the transform matrix
  14900. * @param transform transformation matrix to be applied to the resulting frustum plane
  14901. * @param frustumPlane the resuling frustum plane
  14902. */
  14903. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14904. /**
  14905. * Gets the bottom frustum plane transformed by the transform matrix
  14906. * @param transform transformation matrix to be applied to the resulting frustum plane
  14907. * @param frustumPlane the resuling frustum plane
  14908. */
  14909. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14910. /**
  14911. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  14912. * @param transform transformation matrix to be applied to the resulting frustum planes
  14913. * @param frustumPlanes the resuling frustum planes
  14914. */
  14915. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  14916. }
  14917. }
  14918. declare module "babylonjs/Engines/Extensions/engine.multiview" {
  14919. import { Camera } from "babylonjs/Cameras/camera";
  14920. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  14921. import { Nullable } from "babylonjs/types";
  14922. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  14923. import { Matrix } from "babylonjs/Maths/math.vector";
  14924. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  14925. module "babylonjs/Engines/engine" {
  14926. interface Engine {
  14927. /**
  14928. * Creates a new multiview render target
  14929. * @param width defines the width of the texture
  14930. * @param height defines the height of the texture
  14931. * @returns the created multiview texture
  14932. */
  14933. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  14934. /**
  14935. * Binds a multiview framebuffer to be drawn to
  14936. * @param multiviewTexture texture to bind
  14937. */
  14938. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  14939. }
  14940. }
  14941. module "babylonjs/Cameras/camera" {
  14942. interface Camera {
  14943. /**
  14944. * @hidden
  14945. * 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)
  14946. */
  14947. _useMultiviewToSingleView: boolean;
  14948. /**
  14949. * @hidden
  14950. * 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)
  14951. */
  14952. _multiviewTexture: Nullable<RenderTargetTexture>;
  14953. /**
  14954. * @hidden
  14955. * ensures the multiview texture of the camera exists and has the specified width/height
  14956. * @param width height to set on the multiview texture
  14957. * @param height width to set on the multiview texture
  14958. */
  14959. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  14960. }
  14961. }
  14962. module "babylonjs/scene" {
  14963. interface Scene {
  14964. /** @hidden */
  14965. _transformMatrixR: Matrix;
  14966. /** @hidden */
  14967. _multiviewSceneUbo: Nullable<UniformBuffer>;
  14968. /** @hidden */
  14969. _createMultiviewUbo(): void;
  14970. /** @hidden */
  14971. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  14972. /** @hidden */
  14973. _renderMultiviewToSingleView(camera: Camera): void;
  14974. }
  14975. }
  14976. }
  14977. declare module "babylonjs/PostProcesses/vrMultiviewToSingleviewPostProcess" {
  14978. import { Camera } from "babylonjs/Cameras/camera";
  14979. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  14980. import "babylonjs/Shaders/vrMultiviewToSingleview.fragment";
  14981. import "babylonjs/Engines/Extensions/engine.multiview";
  14982. /**
  14983. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  14984. * This will not be used for webXR as it supports displaying texture arrays directly
  14985. */
  14986. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  14987. /**
  14988. * Initializes a VRMultiviewToSingleview
  14989. * @param name name of the post process
  14990. * @param camera camera to be applied to
  14991. * @param scaleFactor scaling factor to the size of the output texture
  14992. */
  14993. constructor(name: string, camera: Camera, scaleFactor: number);
  14994. }
  14995. }
  14996. declare module "babylonjs/Cameras/RigModes/webVRRigMode" { }
  14997. declare module "babylonjs/Engines/Extensions/engine.webVR" {
  14998. import { Nullable } from "babylonjs/types";
  14999. import { Size } from "babylonjs/Maths/math.size";
  15000. import { Observable } from "babylonjs/Misc/observable";
  15001. module "babylonjs/Engines/engine" {
  15002. interface Engine {
  15003. /** @hidden */
  15004. _vrDisplay: any;
  15005. /** @hidden */
  15006. _vrSupported: boolean;
  15007. /** @hidden */
  15008. _oldSize: Size;
  15009. /** @hidden */
  15010. _oldHardwareScaleFactor: number;
  15011. /** @hidden */
  15012. _vrExclusivePointerMode: boolean;
  15013. /** @hidden */
  15014. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  15015. /** @hidden */
  15016. _onVRDisplayPointerRestricted: () => void;
  15017. /** @hidden */
  15018. _onVRDisplayPointerUnrestricted: () => void;
  15019. /** @hidden */
  15020. _onVrDisplayConnect: Nullable<(display: any) => void>;
  15021. /** @hidden */
  15022. _onVrDisplayDisconnect: Nullable<() => void>;
  15023. /** @hidden */
  15024. _onVrDisplayPresentChange: Nullable<() => void>;
  15025. /**
  15026. * Observable signaled when VR display mode changes
  15027. */
  15028. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  15029. /**
  15030. * Observable signaled when VR request present is complete
  15031. */
  15032. onVRRequestPresentComplete: Observable<boolean>;
  15033. /**
  15034. * Observable signaled when VR request present starts
  15035. */
  15036. onVRRequestPresentStart: Observable<Engine>;
  15037. /**
  15038. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  15039. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  15040. */
  15041. isInVRExclusivePointerMode: boolean;
  15042. /**
  15043. * Gets a boolean indicating if a webVR device was detected
  15044. * @returns true if a webVR device was detected
  15045. */
  15046. isVRDevicePresent(): boolean;
  15047. /**
  15048. * Gets the current webVR device
  15049. * @returns the current webVR device (or null)
  15050. */
  15051. getVRDevice(): any;
  15052. /**
  15053. * Initializes a webVR display and starts listening to display change events
  15054. * The onVRDisplayChangedObservable will be notified upon these changes
  15055. * @returns A promise containing a VRDisplay and if vr is supported
  15056. */
  15057. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  15058. /** @hidden */
  15059. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  15060. /**
  15061. * Call this function to switch to webVR mode
  15062. * Will do nothing if webVR is not supported or if there is no webVR device
  15063. * @see http://doc.babylonjs.com/how_to/webvr_camera
  15064. */
  15065. enableVR(): void;
  15066. /** @hidden */
  15067. _onVRFullScreenTriggered(): void;
  15068. }
  15069. }
  15070. }
  15071. declare module "babylonjs/Cameras/VR/webVRCamera" {
  15072. import { Nullable } from "babylonjs/types";
  15073. import { Observable } from "babylonjs/Misc/observable";
  15074. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  15075. import { Scene } from "babylonjs/scene";
  15076. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  15077. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  15078. import { Node } from "babylonjs/node";
  15079. import { Ray } from "babylonjs/Culling/ray";
  15080. import "babylonjs/Cameras/RigModes/webVRRigMode";
  15081. import "babylonjs/Engines/Extensions/engine.webVR";
  15082. /**
  15083. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  15084. * IMPORTANT!! The data is right-hand data.
  15085. * @export
  15086. * @interface DevicePose
  15087. */
  15088. export interface DevicePose {
  15089. /**
  15090. * The position of the device, values in array are [x,y,z].
  15091. */
  15092. readonly position: Nullable<Float32Array>;
  15093. /**
  15094. * The linearVelocity of the device, values in array are [x,y,z].
  15095. */
  15096. readonly linearVelocity: Nullable<Float32Array>;
  15097. /**
  15098. * The linearAcceleration of the device, values in array are [x,y,z].
  15099. */
  15100. readonly linearAcceleration: Nullable<Float32Array>;
  15101. /**
  15102. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  15103. */
  15104. readonly orientation: Nullable<Float32Array>;
  15105. /**
  15106. * The angularVelocity of the device, values in array are [x,y,z].
  15107. */
  15108. readonly angularVelocity: Nullable<Float32Array>;
  15109. /**
  15110. * The angularAcceleration of the device, values in array are [x,y,z].
  15111. */
  15112. readonly angularAcceleration: Nullable<Float32Array>;
  15113. }
  15114. /**
  15115. * Interface representing a pose controlled object in Babylon.
  15116. * A pose controlled object has both regular pose values as well as pose values
  15117. * from an external device such as a VR head mounted display
  15118. */
  15119. export interface PoseControlled {
  15120. /**
  15121. * The position of the object in babylon space.
  15122. */
  15123. position: Vector3;
  15124. /**
  15125. * The rotation quaternion of the object in babylon space.
  15126. */
  15127. rotationQuaternion: Quaternion;
  15128. /**
  15129. * The position of the device in babylon space.
  15130. */
  15131. devicePosition?: Vector3;
  15132. /**
  15133. * The rotation quaternion of the device in babylon space.
  15134. */
  15135. deviceRotationQuaternion: Quaternion;
  15136. /**
  15137. * The raw pose coming from the device.
  15138. */
  15139. rawPose: Nullable<DevicePose>;
  15140. /**
  15141. * The scale of the device to be used when translating from device space to babylon space.
  15142. */
  15143. deviceScaleFactor: number;
  15144. /**
  15145. * Updates the poseControlled values based on the input device pose.
  15146. * @param poseData the pose data to update the object with
  15147. */
  15148. updateFromDevice(poseData: DevicePose): void;
  15149. }
  15150. /**
  15151. * Set of options to customize the webVRCamera
  15152. */
  15153. export interface WebVROptions {
  15154. /**
  15155. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  15156. */
  15157. trackPosition?: boolean;
  15158. /**
  15159. * Sets the scale of the vrDevice in babylon space. (default: 1)
  15160. */
  15161. positionScale?: number;
  15162. /**
  15163. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  15164. */
  15165. displayName?: string;
  15166. /**
  15167. * Should the native controller meshes be initialized. (default: true)
  15168. */
  15169. controllerMeshes?: boolean;
  15170. /**
  15171. * Creating a default HemiLight only on controllers. (default: true)
  15172. */
  15173. defaultLightingOnControllers?: boolean;
  15174. /**
  15175. * If you don't want to use the default VR button of the helper. (default: false)
  15176. */
  15177. useCustomVRButton?: boolean;
  15178. /**
  15179. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  15180. */
  15181. customVRButton?: HTMLButtonElement;
  15182. /**
  15183. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  15184. */
  15185. rayLength?: number;
  15186. /**
  15187. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  15188. */
  15189. defaultHeight?: number;
  15190. /**
  15191. * If multiview should be used if availible (default: false)
  15192. */
  15193. useMultiview?: boolean;
  15194. }
  15195. /**
  15196. * This represents a WebVR camera.
  15197. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  15198. * @example http://doc.babylonjs.com/how_to/webvr_camera
  15199. */
  15200. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  15201. private webVROptions;
  15202. /**
  15203. * @hidden
  15204. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  15205. */
  15206. _vrDevice: any;
  15207. /**
  15208. * The rawPose of the vrDevice.
  15209. */
  15210. rawPose: Nullable<DevicePose>;
  15211. private _onVREnabled;
  15212. private _specsVersion;
  15213. private _attached;
  15214. private _frameData;
  15215. protected _descendants: Array<Node>;
  15216. private _deviceRoomPosition;
  15217. /** @hidden */
  15218. _deviceRoomRotationQuaternion: Quaternion;
  15219. private _standingMatrix;
  15220. /**
  15221. * Represents device position in babylon space.
  15222. */
  15223. devicePosition: Vector3;
  15224. /**
  15225. * Represents device rotation in babylon space.
  15226. */
  15227. deviceRotationQuaternion: Quaternion;
  15228. /**
  15229. * The scale of the device to be used when translating from device space to babylon space.
  15230. */
  15231. deviceScaleFactor: number;
  15232. private _deviceToWorld;
  15233. private _worldToDevice;
  15234. /**
  15235. * References to the webVR controllers for the vrDevice.
  15236. */
  15237. controllers: Array<WebVRController>;
  15238. /**
  15239. * Emits an event when a controller is attached.
  15240. */
  15241. onControllersAttachedObservable: Observable<WebVRController[]>;
  15242. /**
  15243. * Emits an event when a controller's mesh has been loaded;
  15244. */
  15245. onControllerMeshLoadedObservable: Observable<WebVRController>;
  15246. /**
  15247. * Emits an event when the HMD's pose has been updated.
  15248. */
  15249. onPoseUpdatedFromDeviceObservable: Observable<any>;
  15250. private _poseSet;
  15251. /**
  15252. * If the rig cameras be used as parent instead of this camera.
  15253. */
  15254. rigParenting: boolean;
  15255. private _lightOnControllers;
  15256. private _defaultHeight?;
  15257. /**
  15258. * Instantiates a WebVRFreeCamera.
  15259. * @param name The name of the WebVRFreeCamera
  15260. * @param position The starting anchor position for the camera
  15261. * @param scene The scene the camera belongs to
  15262. * @param webVROptions a set of customizable options for the webVRCamera
  15263. */
  15264. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  15265. /**
  15266. * Gets the device distance from the ground in meters.
  15267. * @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.
  15268. */
  15269. deviceDistanceToRoomGround(): number;
  15270. /**
  15271. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  15272. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  15273. */
  15274. useStandingMatrix(callback?: (bool: boolean) => void): void;
  15275. /**
  15276. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  15277. * @returns A promise with a boolean set to if the standing matrix is supported.
  15278. */
  15279. useStandingMatrixAsync(): Promise<boolean>;
  15280. /**
  15281. * Disposes the camera
  15282. */
  15283. dispose(): void;
  15284. /**
  15285. * Gets a vrController by name.
  15286. * @param name The name of the controller to retreive
  15287. * @returns the controller matching the name specified or null if not found
  15288. */
  15289. getControllerByName(name: string): Nullable<WebVRController>;
  15290. private _leftController;
  15291. /**
  15292. * The controller corresponding to the users left hand.
  15293. */
  15294. readonly leftController: Nullable<WebVRController>;
  15295. private _rightController;
  15296. /**
  15297. * The controller corresponding to the users right hand.
  15298. */
  15299. readonly rightController: Nullable<WebVRController>;
  15300. /**
  15301. * Casts a ray forward from the vrCamera's gaze.
  15302. * @param length Length of the ray (default: 100)
  15303. * @returns the ray corresponding to the gaze
  15304. */
  15305. getForwardRay(length?: number): Ray;
  15306. /**
  15307. * @hidden
  15308. * Updates the camera based on device's frame data
  15309. */
  15310. _checkInputs(): void;
  15311. /**
  15312. * Updates the poseControlled values based on the input device pose.
  15313. * @param poseData Pose coming from the device
  15314. */
  15315. updateFromDevice(poseData: DevicePose): void;
  15316. private _htmlElementAttached;
  15317. private _detachIfAttached;
  15318. /**
  15319. * WebVR's attach control will start broadcasting frames to the device.
  15320. * Note that in certain browsers (chrome for example) this function must be called
  15321. * within a user-interaction callback. Example:
  15322. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  15323. *
  15324. * @param element html element to attach the vrDevice to
  15325. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  15326. */
  15327. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  15328. /**
  15329. * Detaches the camera from the html element and disables VR
  15330. *
  15331. * @param element html element to detach from
  15332. */
  15333. detachControl(element: HTMLElement): void;
  15334. /**
  15335. * @returns the name of this class
  15336. */
  15337. getClassName(): string;
  15338. /**
  15339. * Calls resetPose on the vrDisplay
  15340. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  15341. */
  15342. resetToCurrentRotation(): void;
  15343. /**
  15344. * @hidden
  15345. * Updates the rig cameras (left and right eye)
  15346. */
  15347. _updateRigCameras(): void;
  15348. private _workingVector;
  15349. private _oneVector;
  15350. private _workingMatrix;
  15351. private updateCacheCalled;
  15352. private _correctPositionIfNotTrackPosition;
  15353. /**
  15354. * @hidden
  15355. * Updates the cached values of the camera
  15356. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  15357. */
  15358. _updateCache(ignoreParentClass?: boolean): void;
  15359. /**
  15360. * @hidden
  15361. * Get current device position in babylon world
  15362. */
  15363. _computeDevicePosition(): void;
  15364. /**
  15365. * Updates the current device position and rotation in the babylon world
  15366. */
  15367. update(): void;
  15368. /**
  15369. * @hidden
  15370. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  15371. * @returns an identity matrix
  15372. */
  15373. _getViewMatrix(): Matrix;
  15374. private _tmpMatrix;
  15375. /**
  15376. * This function is called by the two RIG cameras.
  15377. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  15378. * @hidden
  15379. */
  15380. _getWebVRViewMatrix(): Matrix;
  15381. /** @hidden */
  15382. _getWebVRProjectionMatrix(): Matrix;
  15383. private _onGamepadConnectedObserver;
  15384. private _onGamepadDisconnectedObserver;
  15385. private _updateCacheWhenTrackingDisabledObserver;
  15386. /**
  15387. * Initializes the controllers and their meshes
  15388. */
  15389. initControllers(): void;
  15390. }
  15391. }
  15392. declare module "babylonjs/PostProcesses/postProcess" {
  15393. import { Nullable } from "babylonjs/types";
  15394. import { SmartArray } from "babylonjs/Misc/smartArray";
  15395. import { Observable } from "babylonjs/Misc/observable";
  15396. import { Vector2 } from "babylonjs/Maths/math.vector";
  15397. import { Camera } from "babylonjs/Cameras/camera";
  15398. import { Effect } from "babylonjs/Materials/effect";
  15399. import "babylonjs/Shaders/postprocess.vertex";
  15400. import { IInspectable } from "babylonjs/Misc/iInspectable";
  15401. import { Engine } from "babylonjs/Engines/engine";
  15402. import { Color4 } from "babylonjs/Maths/math.color";
  15403. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  15404. /**
  15405. * Size options for a post process
  15406. */
  15407. export type PostProcessOptions = {
  15408. width: number;
  15409. height: number;
  15410. };
  15411. /**
  15412. * PostProcess can be used to apply a shader to a texture after it has been rendered
  15413. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  15414. */
  15415. export class PostProcess {
  15416. /** Name of the PostProcess. */
  15417. name: string;
  15418. /**
  15419. * Gets or sets the unique id of the post process
  15420. */
  15421. uniqueId: number;
  15422. /**
  15423. * Width of the texture to apply the post process on
  15424. */
  15425. width: number;
  15426. /**
  15427. * Height of the texture to apply the post process on
  15428. */
  15429. height: number;
  15430. /**
  15431. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  15432. * @hidden
  15433. */
  15434. _outputTexture: Nullable<InternalTexture>;
  15435. /**
  15436. * Sampling mode used by the shader
  15437. * See https://doc.babylonjs.com/classes/3.1/texture
  15438. */
  15439. renderTargetSamplingMode: number;
  15440. /**
  15441. * Clear color to use when screen clearing
  15442. */
  15443. clearColor: Color4;
  15444. /**
  15445. * If the buffer needs to be cleared before applying the post process. (default: true)
  15446. * Should be set to false if shader will overwrite all previous pixels.
  15447. */
  15448. autoClear: boolean;
  15449. /**
  15450. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  15451. */
  15452. alphaMode: number;
  15453. /**
  15454. * Sets the setAlphaBlendConstants of the babylon engine
  15455. */
  15456. alphaConstants: Color4;
  15457. /**
  15458. * Animations to be used for the post processing
  15459. */
  15460. animations: import("babylonjs/Animations/animation").Animation[];
  15461. /**
  15462. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  15463. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  15464. */
  15465. enablePixelPerfectMode: boolean;
  15466. /**
  15467. * Force the postprocess to be applied without taking in account viewport
  15468. */
  15469. forceFullscreenViewport: boolean;
  15470. /**
  15471. * List of inspectable custom properties (used by the Inspector)
  15472. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  15473. */
  15474. inspectableCustomProperties: IInspectable[];
  15475. /**
  15476. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  15477. *
  15478. * | Value | Type | Description |
  15479. * | ----- | ----------------------------------- | ----------- |
  15480. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  15481. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  15482. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  15483. *
  15484. */
  15485. scaleMode: number;
  15486. /**
  15487. * Force textures to be a power of two (default: false)
  15488. */
  15489. alwaysForcePOT: boolean;
  15490. private _samples;
  15491. /**
  15492. * Number of sample textures (default: 1)
  15493. */
  15494. samples: number;
  15495. /**
  15496. * Modify the scale of the post process to be the same as the viewport (default: false)
  15497. */
  15498. adaptScaleToCurrentViewport: boolean;
  15499. private _camera;
  15500. private _scene;
  15501. private _engine;
  15502. private _options;
  15503. private _reusable;
  15504. private _textureType;
  15505. /**
  15506. * Smart array of input and output textures for the post process.
  15507. * @hidden
  15508. */
  15509. _textures: SmartArray<import("babylonjs/Materials/Textures/internalTexture").InternalTexture>;
  15510. /**
  15511. * The index in _textures that corresponds to the output texture.
  15512. * @hidden
  15513. */
  15514. _currentRenderTextureInd: number;
  15515. private _effect;
  15516. private _samplers;
  15517. private _fragmentUrl;
  15518. private _vertexUrl;
  15519. private _parameters;
  15520. private _scaleRatio;
  15521. protected _indexParameters: any;
  15522. private _shareOutputWithPostProcess;
  15523. private _texelSize;
  15524. private _forcedOutputTexture;
  15525. /**
  15526. * Returns the fragment url or shader name used in the post process.
  15527. * @returns the fragment url or name in the shader store.
  15528. */
  15529. getEffectName(): string;
  15530. /**
  15531. * An event triggered when the postprocess is activated.
  15532. */
  15533. onActivateObservable: Observable<Camera>;
  15534. private _onActivateObserver;
  15535. /**
  15536. * A function that is added to the onActivateObservable
  15537. */
  15538. onActivate: Nullable<(camera: Camera) => void>;
  15539. /**
  15540. * An event triggered when the postprocess changes its size.
  15541. */
  15542. onSizeChangedObservable: Observable<PostProcess>;
  15543. private _onSizeChangedObserver;
  15544. /**
  15545. * A function that is added to the onSizeChangedObservable
  15546. */
  15547. onSizeChanged: (postProcess: PostProcess) => void;
  15548. /**
  15549. * An event triggered when the postprocess applies its effect.
  15550. */
  15551. onApplyObservable: Observable<Effect>;
  15552. private _onApplyObserver;
  15553. /**
  15554. * A function that is added to the onApplyObservable
  15555. */
  15556. onApply: (effect: Effect) => void;
  15557. /**
  15558. * An event triggered before rendering the postprocess
  15559. */
  15560. onBeforeRenderObservable: Observable<Effect>;
  15561. private _onBeforeRenderObserver;
  15562. /**
  15563. * A function that is added to the onBeforeRenderObservable
  15564. */
  15565. onBeforeRender: (effect: Effect) => void;
  15566. /**
  15567. * An event triggered after rendering the postprocess
  15568. */
  15569. onAfterRenderObservable: Observable<Effect>;
  15570. private _onAfterRenderObserver;
  15571. /**
  15572. * A function that is added to the onAfterRenderObservable
  15573. */
  15574. onAfterRender: (efect: Effect) => void;
  15575. /**
  15576. * 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
  15577. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  15578. */
  15579. inputTexture: InternalTexture;
  15580. /**
  15581. * Gets the camera which post process is applied to.
  15582. * @returns The camera the post process is applied to.
  15583. */
  15584. getCamera(): Camera;
  15585. /**
  15586. * Gets the texel size of the postprocess.
  15587. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  15588. */
  15589. readonly texelSize: Vector2;
  15590. /**
  15591. * Creates a new instance PostProcess
  15592. * @param name The name of the PostProcess.
  15593. * @param fragmentUrl The url of the fragment shader to be used.
  15594. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  15595. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  15596. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  15597. * @param camera The camera to apply the render pass to.
  15598. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  15599. * @param engine The engine which the post process will be applied. (default: current engine)
  15600. * @param reusable If the post process can be reused on the same frame. (default: false)
  15601. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  15602. * @param textureType Type of textures used when performing the post process. (default: 0)
  15603. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  15604. * @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
  15605. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  15606. */
  15607. constructor(
  15608. /** Name of the PostProcess. */
  15609. 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);
  15610. /**
  15611. * Gets a string idenfifying the name of the class
  15612. * @returns "PostProcess" string
  15613. */
  15614. getClassName(): string;
  15615. /**
  15616. * Gets the engine which this post process belongs to.
  15617. * @returns The engine the post process was enabled with.
  15618. */
  15619. getEngine(): Engine;
  15620. /**
  15621. * The effect that is created when initializing the post process.
  15622. * @returns The created effect corresponding the the postprocess.
  15623. */
  15624. getEffect(): Effect;
  15625. /**
  15626. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  15627. * @param postProcess The post process to share the output with.
  15628. * @returns This post process.
  15629. */
  15630. shareOutputWith(postProcess: PostProcess): PostProcess;
  15631. /**
  15632. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  15633. * This should be called if the post process that shares output with this post process is disabled/disposed.
  15634. */
  15635. useOwnOutput(): void;
  15636. /**
  15637. * Updates the effect with the current post process compile time values and recompiles the shader.
  15638. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  15639. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  15640. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  15641. * @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
  15642. * @param onCompiled Called when the shader has been compiled.
  15643. * @param onError Called if there is an error when compiling a shader.
  15644. */
  15645. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  15646. /**
  15647. * The post process is reusable if it can be used multiple times within one frame.
  15648. * @returns If the post process is reusable
  15649. */
  15650. isReusable(): boolean;
  15651. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  15652. markTextureDirty(): void;
  15653. /**
  15654. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  15655. * 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.
  15656. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  15657. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  15658. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  15659. * @returns The target texture that was bound to be written to.
  15660. */
  15661. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  15662. /**
  15663. * If the post process is supported.
  15664. */
  15665. readonly isSupported: boolean;
  15666. /**
  15667. * The aspect ratio of the output texture.
  15668. */
  15669. readonly aspectRatio: number;
  15670. /**
  15671. * Get a value indicating if the post-process is ready to be used
  15672. * @returns true if the post-process is ready (shader is compiled)
  15673. */
  15674. isReady(): boolean;
  15675. /**
  15676. * Binds all textures and uniforms to the shader, this will be run on every pass.
  15677. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  15678. */
  15679. apply(): Nullable<Effect>;
  15680. private _disposeTextures;
  15681. /**
  15682. * Disposes the post process.
  15683. * @param camera The camera to dispose the post process on.
  15684. */
  15685. dispose(camera?: Camera): void;
  15686. }
  15687. }
  15688. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration" {
  15689. /** @hidden */
  15690. export var kernelBlurVaryingDeclaration: {
  15691. name: string;
  15692. shader: string;
  15693. };
  15694. }
  15695. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurFragment" {
  15696. /** @hidden */
  15697. export var kernelBlurFragment: {
  15698. name: string;
  15699. shader: string;
  15700. };
  15701. }
  15702. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurFragment2" {
  15703. /** @hidden */
  15704. export var kernelBlurFragment2: {
  15705. name: string;
  15706. shader: string;
  15707. };
  15708. }
  15709. declare module "babylonjs/Shaders/kernelBlur.fragment" {
  15710. import "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration";
  15711. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  15712. import "babylonjs/Shaders/ShadersInclude/kernelBlurFragment";
  15713. import "babylonjs/Shaders/ShadersInclude/kernelBlurFragment2";
  15714. /** @hidden */
  15715. export var kernelBlurPixelShader: {
  15716. name: string;
  15717. shader: string;
  15718. };
  15719. }
  15720. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurVertex" {
  15721. /** @hidden */
  15722. export var kernelBlurVertex: {
  15723. name: string;
  15724. shader: string;
  15725. };
  15726. }
  15727. declare module "babylonjs/Shaders/kernelBlur.vertex" {
  15728. import "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration";
  15729. import "babylonjs/Shaders/ShadersInclude/kernelBlurVertex";
  15730. /** @hidden */
  15731. export var kernelBlurVertexShader: {
  15732. name: string;
  15733. shader: string;
  15734. };
  15735. }
  15736. declare module "babylonjs/PostProcesses/blurPostProcess" {
  15737. import { Vector2 } from "babylonjs/Maths/math.vector";
  15738. import { Nullable } from "babylonjs/types";
  15739. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  15740. import { Camera } from "babylonjs/Cameras/camera";
  15741. import { Effect } from "babylonjs/Materials/effect";
  15742. import { Engine } from "babylonjs/Engines/engine";
  15743. import "babylonjs/Shaders/kernelBlur.fragment";
  15744. import "babylonjs/Shaders/kernelBlur.vertex";
  15745. /**
  15746. * The Blur Post Process which blurs an image based on a kernel and direction.
  15747. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  15748. */
  15749. export class BlurPostProcess extends PostProcess {
  15750. /** The direction in which to blur the image. */
  15751. direction: Vector2;
  15752. private blockCompilation;
  15753. protected _kernel: number;
  15754. protected _idealKernel: number;
  15755. protected _packedFloat: boolean;
  15756. private _staticDefines;
  15757. /**
  15758. * Sets the length in pixels of the blur sample region
  15759. */
  15760. /**
  15761. * Gets the length in pixels of the blur sample region
  15762. */
  15763. kernel: number;
  15764. /**
  15765. * Sets wether or not the blur needs to unpack/repack floats
  15766. */
  15767. /**
  15768. * Gets wether or not the blur is unpacking/repacking floats
  15769. */
  15770. packedFloat: boolean;
  15771. /**
  15772. * Creates a new instance BlurPostProcess
  15773. * @param name The name of the effect.
  15774. * @param direction The direction in which to blur the image.
  15775. * @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.
  15776. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  15777. * @param camera The camera to apply the render pass to.
  15778. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  15779. * @param engine The engine which the post process will be applied. (default: current engine)
  15780. * @param reusable If the post process can be reused on the same frame. (default: false)
  15781. * @param textureType Type of textures used when performing the post process. (default: 0)
  15782. * @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)
  15783. */
  15784. constructor(name: string,
  15785. /** The direction in which to blur the image. */
  15786. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  15787. /**
  15788. * Updates the effect with the current post process compile time values and recompiles the shader.
  15789. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  15790. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  15791. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  15792. * @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
  15793. * @param onCompiled Called when the shader has been compiled.
  15794. * @param onError Called if there is an error when compiling a shader.
  15795. */
  15796. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  15797. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  15798. /**
  15799. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  15800. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  15801. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  15802. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  15803. * The gaps between physical kernels are compensated for in the weighting of the samples
  15804. * @param idealKernel Ideal blur kernel.
  15805. * @return Nearest best kernel.
  15806. */
  15807. protected _nearestBestKernel(idealKernel: number): number;
  15808. /**
  15809. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  15810. * @param x The point on the Gaussian distribution to sample.
  15811. * @return the value of the Gaussian function at x.
  15812. */
  15813. protected _gaussianWeight(x: number): number;
  15814. /**
  15815. * Generates a string that can be used as a floating point number in GLSL.
  15816. * @param x Value to print.
  15817. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  15818. * @return GLSL float string.
  15819. */
  15820. protected _glslFloat(x: number, decimalFigures?: number): string;
  15821. }
  15822. }
  15823. declare module "babylonjs/Materials/Textures/mirrorTexture" {
  15824. import { Scene } from "babylonjs/scene";
  15825. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  15826. import { Plane } from "babylonjs/Maths/math.plane";
  15827. /**
  15828. * Mirror texture can be used to simulate the view from a mirror in a scene.
  15829. * It will dynamically be rendered every frame to adapt to the camera point of view.
  15830. * You can then easily use it as a reflectionTexture on a flat surface.
  15831. * In case the surface is not a plane, please consider relying on reflection probes.
  15832. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  15833. */
  15834. export class MirrorTexture extends RenderTargetTexture {
  15835. private scene;
  15836. /**
  15837. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  15838. * 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.
  15839. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  15840. */
  15841. mirrorPlane: Plane;
  15842. /**
  15843. * Define the blur ratio used to blur the reflection if needed.
  15844. */
  15845. blurRatio: number;
  15846. /**
  15847. * Define the adaptive blur kernel used to blur the reflection if needed.
  15848. * This will autocompute the closest best match for the `blurKernel`
  15849. */
  15850. adaptiveBlurKernel: number;
  15851. /**
  15852. * Define the blur kernel used to blur the reflection if needed.
  15853. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  15854. */
  15855. blurKernel: number;
  15856. /**
  15857. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  15858. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  15859. */
  15860. blurKernelX: number;
  15861. /**
  15862. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  15863. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  15864. */
  15865. blurKernelY: number;
  15866. private _autoComputeBlurKernel;
  15867. protected _onRatioRescale(): void;
  15868. private _updateGammaSpace;
  15869. private _imageProcessingConfigChangeObserver;
  15870. private _transformMatrix;
  15871. private _mirrorMatrix;
  15872. private _savedViewMatrix;
  15873. private _blurX;
  15874. private _blurY;
  15875. private _adaptiveBlurKernel;
  15876. private _blurKernelX;
  15877. private _blurKernelY;
  15878. private _blurRatio;
  15879. /**
  15880. * Instantiates a Mirror Texture.
  15881. * Mirror texture can be used to simulate the view from a mirror in a scene.
  15882. * It will dynamically be rendered every frame to adapt to the camera point of view.
  15883. * You can then easily use it as a reflectionTexture on a flat surface.
  15884. * In case the surface is not a plane, please consider relying on reflection probes.
  15885. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  15886. * @param name
  15887. * @param size
  15888. * @param scene
  15889. * @param generateMipMaps
  15890. * @param type
  15891. * @param samplingMode
  15892. * @param generateDepthBuffer
  15893. */
  15894. constructor(name: string, size: number | {
  15895. width: number;
  15896. height: number;
  15897. } | {
  15898. ratio: number;
  15899. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  15900. private _preparePostProcesses;
  15901. /**
  15902. * Clone the mirror texture.
  15903. * @returns the cloned texture
  15904. */
  15905. clone(): MirrorTexture;
  15906. /**
  15907. * Serialize the texture to a JSON representation you could use in Parse later on
  15908. * @returns the serialized JSON representation
  15909. */
  15910. serialize(): any;
  15911. /**
  15912. * Dispose the texture and release its associated resources.
  15913. */
  15914. dispose(): void;
  15915. }
  15916. }
  15917. declare module "babylonjs/Materials/Textures/texture" {
  15918. import { Observable } from "babylonjs/Misc/observable";
  15919. import { Nullable } from "babylonjs/types";
  15920. import { Scene } from "babylonjs/scene";
  15921. import { Matrix } from "babylonjs/Maths/math.vector";
  15922. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  15923. import { IInspectable } from "babylonjs/Misc/iInspectable";
  15924. import { Engine } from "babylonjs/Engines/engine";
  15925. /**
  15926. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  15927. * @see http://doc.babylonjs.com/babylon101/materials#texture
  15928. */
  15929. export class Texture extends BaseTexture {
  15930. /** @hidden */
  15931. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => import("babylonjs/Materials/Textures/cubeTexture").CubeTexture;
  15932. /** @hidden */
  15933. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => import("babylonjs/Materials/Textures/mirrorTexture").MirrorTexture;
  15934. /** @hidden */
  15935. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => import("babylonjs/Materials/Textures/renderTargetTexture").RenderTargetTexture;
  15936. /** nearest is mag = nearest and min = nearest and mip = linear */
  15937. static readonly NEAREST_SAMPLINGMODE: number;
  15938. /** nearest is mag = nearest and min = nearest and mip = linear */
  15939. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  15940. /** Bilinear is mag = linear and min = linear and mip = nearest */
  15941. static readonly BILINEAR_SAMPLINGMODE: number;
  15942. /** Bilinear is mag = linear and min = linear and mip = nearest */
  15943. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  15944. /** Trilinear is mag = linear and min = linear and mip = linear */
  15945. static readonly TRILINEAR_SAMPLINGMODE: number;
  15946. /** Trilinear is mag = linear and min = linear and mip = linear */
  15947. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  15948. /** mag = nearest and min = nearest and mip = nearest */
  15949. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  15950. /** mag = nearest and min = linear and mip = nearest */
  15951. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  15952. /** mag = nearest and min = linear and mip = linear */
  15953. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  15954. /** mag = nearest and min = linear and mip = none */
  15955. static readonly NEAREST_LINEAR: number;
  15956. /** mag = nearest and min = nearest and mip = none */
  15957. static readonly NEAREST_NEAREST: number;
  15958. /** mag = linear and min = nearest and mip = nearest */
  15959. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  15960. /** mag = linear and min = nearest and mip = linear */
  15961. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  15962. /** mag = linear and min = linear and mip = none */
  15963. static readonly LINEAR_LINEAR: number;
  15964. /** mag = linear and min = nearest and mip = none */
  15965. static readonly LINEAR_NEAREST: number;
  15966. /** Explicit coordinates mode */
  15967. static readonly EXPLICIT_MODE: number;
  15968. /** Spherical coordinates mode */
  15969. static readonly SPHERICAL_MODE: number;
  15970. /** Planar coordinates mode */
  15971. static readonly PLANAR_MODE: number;
  15972. /** Cubic coordinates mode */
  15973. static readonly CUBIC_MODE: number;
  15974. /** Projection coordinates mode */
  15975. static readonly PROJECTION_MODE: number;
  15976. /** Inverse Cubic coordinates mode */
  15977. static readonly SKYBOX_MODE: number;
  15978. /** Inverse Cubic coordinates mode */
  15979. static readonly INVCUBIC_MODE: number;
  15980. /** Equirectangular coordinates mode */
  15981. static readonly EQUIRECTANGULAR_MODE: number;
  15982. /** Equirectangular Fixed coordinates mode */
  15983. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  15984. /** Equirectangular Fixed Mirrored coordinates mode */
  15985. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  15986. /** Texture is not repeating outside of 0..1 UVs */
  15987. static readonly CLAMP_ADDRESSMODE: number;
  15988. /** Texture is repeating outside of 0..1 UVs */
  15989. static readonly WRAP_ADDRESSMODE: number;
  15990. /** Texture is repeating and mirrored */
  15991. static readonly MIRROR_ADDRESSMODE: number;
  15992. /**
  15993. * 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
  15994. */
  15995. static UseSerializedUrlIfAny: boolean;
  15996. /**
  15997. * Define the url of the texture.
  15998. */
  15999. url: Nullable<string>;
  16000. /**
  16001. * Define an offset on the texture to offset the u coordinates of the UVs
  16002. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  16003. */
  16004. uOffset: number;
  16005. /**
  16006. * Define an offset on the texture to offset the v coordinates of the UVs
  16007. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  16008. */
  16009. vOffset: number;
  16010. /**
  16011. * Define an offset on the texture to scale the u coordinates of the UVs
  16012. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  16013. */
  16014. uScale: number;
  16015. /**
  16016. * Define an offset on the texture to scale the v coordinates of the UVs
  16017. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  16018. */
  16019. vScale: number;
  16020. /**
  16021. * Define an offset on the texture to rotate around the u coordinates of the UVs
  16022. * @see http://doc.babylonjs.com/how_to/more_materials
  16023. */
  16024. uAng: number;
  16025. /**
  16026. * Define an offset on the texture to rotate around the v coordinates of the UVs
  16027. * @see http://doc.babylonjs.com/how_to/more_materials
  16028. */
  16029. vAng: number;
  16030. /**
  16031. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  16032. * @see http://doc.babylonjs.com/how_to/more_materials
  16033. */
  16034. wAng: number;
  16035. /**
  16036. * Defines the center of rotation (U)
  16037. */
  16038. uRotationCenter: number;
  16039. /**
  16040. * Defines the center of rotation (V)
  16041. */
  16042. vRotationCenter: number;
  16043. /**
  16044. * Defines the center of rotation (W)
  16045. */
  16046. wRotationCenter: number;
  16047. /**
  16048. * Are mip maps generated for this texture or not.
  16049. */
  16050. readonly noMipmap: boolean;
  16051. /**
  16052. * List of inspectable custom properties (used by the Inspector)
  16053. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  16054. */
  16055. inspectableCustomProperties: Nullable<IInspectable[]>;
  16056. private _noMipmap;
  16057. /** @hidden */
  16058. _invertY: boolean;
  16059. private _rowGenerationMatrix;
  16060. private _cachedTextureMatrix;
  16061. private _projectionModeMatrix;
  16062. private _t0;
  16063. private _t1;
  16064. private _t2;
  16065. private _cachedUOffset;
  16066. private _cachedVOffset;
  16067. private _cachedUScale;
  16068. private _cachedVScale;
  16069. private _cachedUAng;
  16070. private _cachedVAng;
  16071. private _cachedWAng;
  16072. private _cachedProjectionMatrixId;
  16073. private _cachedCoordinatesMode;
  16074. /** @hidden */
  16075. protected _initialSamplingMode: number;
  16076. /** @hidden */
  16077. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>;
  16078. private _deleteBuffer;
  16079. protected _format: Nullable<number>;
  16080. private _delayedOnLoad;
  16081. private _delayedOnError;
  16082. /**
  16083. * Observable triggered once the texture has been loaded.
  16084. */
  16085. onLoadObservable: Observable<Texture>;
  16086. protected _isBlocking: boolean;
  16087. /**
  16088. * Is the texture preventing material to render while loading.
  16089. * If false, a default texture will be used instead of the loading one during the preparation step.
  16090. */
  16091. isBlocking: boolean;
  16092. /**
  16093. * Get the current sampling mode associated with the texture.
  16094. */
  16095. readonly samplingMode: number;
  16096. /**
  16097. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  16098. */
  16099. readonly invertY: boolean;
  16100. /**
  16101. * Instantiates a new texture.
  16102. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  16103. * @see http://doc.babylonjs.com/babylon101/materials#texture
  16104. * @param url define the url of the picture to load as a texture
  16105. * @param scene define the scene or engine the texture will belong to
  16106. * @param noMipmap define if the texture will require mip maps or not
  16107. * @param invertY define if the texture needs to be inverted on the y axis during loading
  16108. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  16109. * @param onLoad define a callback triggered when the texture has been loaded
  16110. * @param onError define a callback triggered when an error occurred during the loading session
  16111. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  16112. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  16113. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  16114. */
  16115. constructor(url: Nullable<string>, sceneOrEngine: Nullable<Scene | Engine>, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, deleteBuffer?: boolean, format?: number);
  16116. /**
  16117. * Update the url (and optional buffer) of this texture if url was null during construction.
  16118. * @param url the url of the texture
  16119. * @param buffer the buffer of the texture (defaults to null)
  16120. * @param onLoad callback called when the texture is loaded (defaults to null)
  16121. */
  16122. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, onLoad?: () => void): void;
  16123. /**
  16124. * Finish the loading sequence of a texture flagged as delayed load.
  16125. * @hidden
  16126. */
  16127. delayLoad(): void;
  16128. private _prepareRowForTextureGeneration;
  16129. /**
  16130. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  16131. * @returns the transform matrix of the texture.
  16132. */
  16133. getTextureMatrix(): Matrix;
  16134. /**
  16135. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  16136. * @returns The reflection texture transform
  16137. */
  16138. getReflectionTextureMatrix(): Matrix;
  16139. /**
  16140. * Clones the texture.
  16141. * @returns the cloned texture
  16142. */
  16143. clone(): Texture;
  16144. /**
  16145. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  16146. * @returns The JSON representation of the texture
  16147. */
  16148. serialize(): any;
  16149. /**
  16150. * Get the current class name of the texture useful for serialization or dynamic coding.
  16151. * @returns "Texture"
  16152. */
  16153. getClassName(): string;
  16154. /**
  16155. * Dispose the texture and release its associated resources.
  16156. */
  16157. dispose(): void;
  16158. /**
  16159. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  16160. * @param parsedTexture Define the JSON representation of the texture
  16161. * @param scene Define the scene the parsed texture should be instantiated in
  16162. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  16163. * @returns The parsed texture if successful
  16164. */
  16165. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  16166. /**
  16167. * Creates a texture from its base 64 representation.
  16168. * @param data Define the base64 payload without the data: prefix
  16169. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  16170. * @param scene Define the scene the texture should belong to
  16171. * @param noMipmap Forces the texture to not create mip map information if true
  16172. * @param invertY define if the texture needs to be inverted on the y axis during loading
  16173. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  16174. * @param onLoad define a callback triggered when the texture has been loaded
  16175. * @param onError define a callback triggered when an error occurred during the loading session
  16176. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  16177. * @returns the created texture
  16178. */
  16179. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  16180. /**
  16181. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  16182. * @param data Define the base64 payload without the data: prefix
  16183. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  16184. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  16185. * @param scene Define the scene the texture should belong to
  16186. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  16187. * @param noMipmap Forces the texture to not create mip map information if true
  16188. * @param invertY define if the texture needs to be inverted on the y axis during loading
  16189. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  16190. * @param onLoad define a callback triggered when the texture has been loaded
  16191. * @param onError define a callback triggered when an error occurred during the loading session
  16192. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  16193. * @returns the created texture
  16194. */
  16195. 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;
  16196. }
  16197. }
  16198. declare module "babylonjs/PostProcesses/postProcessManager" {
  16199. import { Nullable } from "babylonjs/types";
  16200. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  16201. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  16202. import { Scene } from "babylonjs/scene";
  16203. /**
  16204. * PostProcessManager is used to manage one or more post processes or post process pipelines
  16205. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  16206. */
  16207. export class PostProcessManager {
  16208. private _scene;
  16209. private _indexBuffer;
  16210. private _vertexBuffers;
  16211. /**
  16212. * Creates a new instance PostProcess
  16213. * @param scene The scene that the post process is associated with.
  16214. */
  16215. constructor(scene: Scene);
  16216. private _prepareBuffers;
  16217. private _buildIndexBuffer;
  16218. /**
  16219. * Rebuilds the vertex buffers of the manager.
  16220. * @hidden
  16221. */
  16222. _rebuild(): void;
  16223. /**
  16224. * Prepares a frame to be run through a post process.
  16225. * @param sourceTexture The input texture to the post procesess. (default: null)
  16226. * @param postProcesses An array of post processes to be run. (default: null)
  16227. * @returns True if the post processes were able to be run.
  16228. * @hidden
  16229. */
  16230. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  16231. /**
  16232. * Manually render a set of post processes to a texture.
  16233. * @param postProcesses An array of post processes to be run.
  16234. * @param targetTexture The target texture to render to.
  16235. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  16236. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  16237. * @param lodLevel defines which lod of the texture to render to
  16238. */
  16239. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  16240. /**
  16241. * Finalize the result of the output of the postprocesses.
  16242. * @param doNotPresent If true the result will not be displayed to the screen.
  16243. * @param targetTexture The target texture to render to.
  16244. * @param faceIndex The index of the face to bind the target texture to.
  16245. * @param postProcesses The array of post processes to render.
  16246. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  16247. * @hidden
  16248. */
  16249. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  16250. /**
  16251. * Disposes of the post process manager.
  16252. */
  16253. dispose(): void;
  16254. }
  16255. }
  16256. declare module "babylonjs/Misc/gradients" {
  16257. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  16258. /** Interface used by value gradients (color, factor, ...) */
  16259. export interface IValueGradient {
  16260. /**
  16261. * Gets or sets the gradient value (between 0 and 1)
  16262. */
  16263. gradient: number;
  16264. }
  16265. /** Class used to store color4 gradient */
  16266. export class ColorGradient implements IValueGradient {
  16267. /**
  16268. * Gets or sets the gradient value (between 0 and 1)
  16269. */
  16270. gradient: number;
  16271. /**
  16272. * Gets or sets first associated color
  16273. */
  16274. color1: Color4;
  16275. /**
  16276. * Gets or sets second associated color
  16277. */
  16278. color2?: Color4;
  16279. /**
  16280. * Will get a color picked randomly between color1 and color2.
  16281. * If color2 is undefined then color1 will be used
  16282. * @param result defines the target Color4 to store the result in
  16283. */
  16284. getColorToRef(result: Color4): void;
  16285. }
  16286. /** Class used to store color 3 gradient */
  16287. export class Color3Gradient implements IValueGradient {
  16288. /**
  16289. * Gets or sets the gradient value (between 0 and 1)
  16290. */
  16291. gradient: number;
  16292. /**
  16293. * Gets or sets the associated color
  16294. */
  16295. color: Color3;
  16296. }
  16297. /** Class used to store factor gradient */
  16298. export class FactorGradient implements IValueGradient {
  16299. /**
  16300. * Gets or sets the gradient value (between 0 and 1)
  16301. */
  16302. gradient: number;
  16303. /**
  16304. * Gets or sets first associated factor
  16305. */
  16306. factor1: number;
  16307. /**
  16308. * Gets or sets second associated factor
  16309. */
  16310. factor2?: number;
  16311. /**
  16312. * Will get a number picked randomly between factor1 and factor2.
  16313. * If factor2 is undefined then factor1 will be used
  16314. * @returns the picked number
  16315. */
  16316. getFactor(): number;
  16317. }
  16318. /**
  16319. * Helper used to simplify some generic gradient tasks
  16320. */
  16321. export class GradientHelper {
  16322. /**
  16323. * Gets the current gradient from an array of IValueGradient
  16324. * @param ratio defines the current ratio to get
  16325. * @param gradients defines the array of IValueGradient
  16326. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  16327. */
  16328. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  16329. }
  16330. }
  16331. declare module "babylonjs/Materials/Textures/Procedurals/proceduralTextureSceneComponent" {
  16332. import { Scene } from "babylonjs/scene";
  16333. import { ISceneComponent } from "babylonjs/sceneComponent";
  16334. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  16335. module "babylonjs/abstractScene" {
  16336. interface AbstractScene {
  16337. /**
  16338. * The list of procedural textures added to the scene
  16339. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  16340. */
  16341. proceduralTextures: Array<ProceduralTexture>;
  16342. }
  16343. }
  16344. /**
  16345. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  16346. * in a given scene.
  16347. */
  16348. export class ProceduralTextureSceneComponent implements ISceneComponent {
  16349. /**
  16350. * The component name helpfull to identify the component in the list of scene components.
  16351. */
  16352. readonly name: string;
  16353. /**
  16354. * The scene the component belongs to.
  16355. */
  16356. scene: Scene;
  16357. /**
  16358. * Creates a new instance of the component for the given scene
  16359. * @param scene Defines the scene to register the component in
  16360. */
  16361. constructor(scene: Scene);
  16362. /**
  16363. * Registers the component in a given scene
  16364. */
  16365. register(): void;
  16366. /**
  16367. * Rebuilds the elements related to this component in case of
  16368. * context lost for instance.
  16369. */
  16370. rebuild(): void;
  16371. /**
  16372. * Disposes the component and the associated ressources.
  16373. */
  16374. dispose(): void;
  16375. private _beforeClear;
  16376. }
  16377. }
  16378. declare module "babylonjs/Engines/Extensions/engine.renderTarget" {
  16379. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  16380. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  16381. module "babylonjs/Engines/engine" {
  16382. interface Engine {
  16383. /**
  16384. * Creates a new render target cube texture
  16385. * @param size defines the size of the texture
  16386. * @param options defines the options used to create the texture
  16387. * @returns a new render target cube texture stored in an InternalTexture
  16388. */
  16389. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  16390. }
  16391. }
  16392. }
  16393. declare module "babylonjs/Shaders/procedural.vertex" {
  16394. /** @hidden */
  16395. export var proceduralVertexShader: {
  16396. name: string;
  16397. shader: string;
  16398. };
  16399. }
  16400. declare module "babylonjs/Materials/Textures/Procedurals/proceduralTexture" {
  16401. import { Observable } from "babylonjs/Misc/observable";
  16402. import { Nullable } from "babylonjs/types";
  16403. import { Scene } from "babylonjs/scene";
  16404. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  16405. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  16406. import { Effect } from "babylonjs/Materials/effect";
  16407. import { Texture } from "babylonjs/Materials/Textures/texture";
  16408. import "babylonjs/Engines/Extensions/engine.renderTarget";
  16409. import "babylonjs/Shaders/procedural.vertex";
  16410. /**
  16411. * 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.
  16412. * This is the base class of any Procedural texture and contains most of the shareable code.
  16413. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  16414. */
  16415. export class ProceduralTexture extends Texture {
  16416. isCube: boolean;
  16417. /**
  16418. * Define if the texture is enabled or not (disabled texture will not render)
  16419. */
  16420. isEnabled: boolean;
  16421. /**
  16422. * Define if the texture must be cleared before rendering (default is true)
  16423. */
  16424. autoClear: boolean;
  16425. /**
  16426. * Callback called when the texture is generated
  16427. */
  16428. onGenerated: () => void;
  16429. /**
  16430. * Event raised when the texture is generated
  16431. */
  16432. onGeneratedObservable: Observable<ProceduralTexture>;
  16433. /** @hidden */
  16434. _generateMipMaps: boolean;
  16435. /** @hidden **/
  16436. _effect: Effect;
  16437. /** @hidden */
  16438. _textures: {
  16439. [key: string]: Texture;
  16440. };
  16441. private _size;
  16442. private _currentRefreshId;
  16443. private _refreshRate;
  16444. private _vertexBuffers;
  16445. private _indexBuffer;
  16446. private _uniforms;
  16447. private _samplers;
  16448. private _fragment;
  16449. private _floats;
  16450. private _ints;
  16451. private _floatsArrays;
  16452. private _colors3;
  16453. private _colors4;
  16454. private _vectors2;
  16455. private _vectors3;
  16456. private _matrices;
  16457. private _fallbackTexture;
  16458. private _fallbackTextureUsed;
  16459. private _engine;
  16460. private _cachedDefines;
  16461. private _contentUpdateId;
  16462. private _contentData;
  16463. /**
  16464. * Instantiates a new procedural texture.
  16465. * 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.
  16466. * This is the base class of any Procedural texture and contains most of the shareable code.
  16467. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  16468. * @param name Define the name of the texture
  16469. * @param size Define the size of the texture to create
  16470. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  16471. * @param scene Define the scene the texture belongs to
  16472. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  16473. * @param generateMipMaps Define if the texture should creates mip maps or not
  16474. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  16475. */
  16476. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  16477. /**
  16478. * The effect that is created when initializing the post process.
  16479. * @returns The created effect corresponding the the postprocess.
  16480. */
  16481. getEffect(): Effect;
  16482. /**
  16483. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  16484. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  16485. */
  16486. getContent(): Nullable<ArrayBufferView>;
  16487. private _createIndexBuffer;
  16488. /** @hidden */
  16489. _rebuild(): void;
  16490. /**
  16491. * Resets the texture in order to recreate its associated resources.
  16492. * This can be called in case of context loss
  16493. */
  16494. reset(): void;
  16495. protected _getDefines(): string;
  16496. /**
  16497. * Is the texture ready to be used ? (rendered at least once)
  16498. * @returns true if ready, otherwise, false.
  16499. */
  16500. isReady(): boolean;
  16501. /**
  16502. * Resets the refresh counter of the texture and start bak from scratch.
  16503. * Could be useful to regenerate the texture if it is setup to render only once.
  16504. */
  16505. resetRefreshCounter(): void;
  16506. /**
  16507. * Set the fragment shader to use in order to render the texture.
  16508. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  16509. */
  16510. setFragment(fragment: any): void;
  16511. /**
  16512. * Define the refresh rate of the texture or the rendering frequency.
  16513. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  16514. */
  16515. refreshRate: number;
  16516. /** @hidden */
  16517. _shouldRender(): boolean;
  16518. /**
  16519. * Get the size the texture is rendering at.
  16520. * @returns the size (texture is always squared)
  16521. */
  16522. getRenderSize(): number;
  16523. /**
  16524. * Resize the texture to new value.
  16525. * @param size Define the new size the texture should have
  16526. * @param generateMipMaps Define whether the new texture should create mip maps
  16527. */
  16528. resize(size: number, generateMipMaps: boolean): void;
  16529. private _checkUniform;
  16530. /**
  16531. * Set a texture in the shader program used to render.
  16532. * @param name Define the name of the uniform samplers as defined in the shader
  16533. * @param texture Define the texture to bind to this sampler
  16534. * @return the texture itself allowing "fluent" like uniform updates
  16535. */
  16536. setTexture(name: string, texture: Texture): ProceduralTexture;
  16537. /**
  16538. * Set a float in the shader.
  16539. * @param name Define the name of the uniform as defined in the shader
  16540. * @param value Define the value to give to the uniform
  16541. * @return the texture itself allowing "fluent" like uniform updates
  16542. */
  16543. setFloat(name: string, value: number): ProceduralTexture;
  16544. /**
  16545. * Set a int in the shader.
  16546. * @param name Define the name of the uniform as defined in the shader
  16547. * @param value Define the value to give to the uniform
  16548. * @return the texture itself allowing "fluent" like uniform updates
  16549. */
  16550. setInt(name: string, value: number): ProceduralTexture;
  16551. /**
  16552. * Set an array of floats in the shader.
  16553. * @param name Define the name of the uniform as defined in the shader
  16554. * @param value Define the value to give to the uniform
  16555. * @return the texture itself allowing "fluent" like uniform updates
  16556. */
  16557. setFloats(name: string, value: number[]): ProceduralTexture;
  16558. /**
  16559. * Set a vec3 in the shader from a Color3.
  16560. * @param name Define the name of the uniform as defined in the shader
  16561. * @param value Define the value to give to the uniform
  16562. * @return the texture itself allowing "fluent" like uniform updates
  16563. */
  16564. setColor3(name: string, value: Color3): ProceduralTexture;
  16565. /**
  16566. * Set a vec4 in the shader from a Color4.
  16567. * @param name Define the name of the uniform as defined in the shader
  16568. * @param value Define the value to give to the uniform
  16569. * @return the texture itself allowing "fluent" like uniform updates
  16570. */
  16571. setColor4(name: string, value: Color4): ProceduralTexture;
  16572. /**
  16573. * Set a vec2 in the shader from a Vector2.
  16574. * @param name Define the name of the uniform as defined in the shader
  16575. * @param value Define the value to give to the uniform
  16576. * @return the texture itself allowing "fluent" like uniform updates
  16577. */
  16578. setVector2(name: string, value: Vector2): ProceduralTexture;
  16579. /**
  16580. * Set a vec3 in the shader from a Vector3.
  16581. * @param name Define the name of the uniform as defined in the shader
  16582. * @param value Define the value to give to the uniform
  16583. * @return the texture itself allowing "fluent" like uniform updates
  16584. */
  16585. setVector3(name: string, value: Vector3): ProceduralTexture;
  16586. /**
  16587. * Set a mat4 in the shader from a MAtrix.
  16588. * @param name Define the name of the uniform as defined in the shader
  16589. * @param value Define the value to give to the uniform
  16590. * @return the texture itself allowing "fluent" like uniform updates
  16591. */
  16592. setMatrix(name: string, value: Matrix): ProceduralTexture;
  16593. /**
  16594. * Render the texture to its associated render target.
  16595. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  16596. */
  16597. render(useCameraPostProcess?: boolean): void;
  16598. /**
  16599. * Clone the texture.
  16600. * @returns the cloned texture
  16601. */
  16602. clone(): ProceduralTexture;
  16603. /**
  16604. * Dispose the texture and release its asoociated resources.
  16605. */
  16606. dispose(): void;
  16607. }
  16608. }
  16609. declare module "babylonjs/Particles/baseParticleSystem" {
  16610. import { Nullable } from "babylonjs/types";
  16611. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  16612. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  16613. import { ImageProcessingConfiguration, ImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  16614. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  16615. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  16616. import { Scene } from "babylonjs/scene";
  16617. import { ColorGradient, FactorGradient, Color3Gradient, IValueGradient } from "babylonjs/Misc/gradients";
  16618. import { BoxParticleEmitter, IParticleEmitterType, PointParticleEmitter, HemisphericParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter, CylinderParticleEmitter, CylinderDirectedParticleEmitter, ConeParticleEmitter } from "babylonjs/Particles/EmitterTypes/index";
  16619. import { Texture } from "babylonjs/Materials/Textures/texture";
  16620. import { Color4 } from "babylonjs/Maths/math.color";
  16621. import { Animation } from "babylonjs/Animations/animation";
  16622. /**
  16623. * This represents the base class for particle system in Babylon.
  16624. * 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.
  16625. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  16626. * @example https://doc.babylonjs.com/babylon101/particles
  16627. */
  16628. export class BaseParticleSystem {
  16629. /**
  16630. * Source color is added to the destination color without alpha affecting the result
  16631. */
  16632. static BLENDMODE_ONEONE: number;
  16633. /**
  16634. * Blend current color and particle color using particle’s alpha
  16635. */
  16636. static BLENDMODE_STANDARD: number;
  16637. /**
  16638. * Add current color and particle color multiplied by particle’s alpha
  16639. */
  16640. static BLENDMODE_ADD: number;
  16641. /**
  16642. * Multiply current color with particle color
  16643. */
  16644. static BLENDMODE_MULTIPLY: number;
  16645. /**
  16646. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  16647. */
  16648. static BLENDMODE_MULTIPLYADD: number;
  16649. /**
  16650. * List of animations used by the particle system.
  16651. */
  16652. animations: Animation[];
  16653. /**
  16654. * The id of the Particle system.
  16655. */
  16656. id: string;
  16657. /**
  16658. * The friendly name of the Particle system.
  16659. */
  16660. name: string;
  16661. /**
  16662. * The rendering group used by the Particle system to chose when to render.
  16663. */
  16664. renderingGroupId: number;
  16665. /**
  16666. * The emitter represents the Mesh or position we are attaching the particle system to.
  16667. */
  16668. emitter: Nullable<AbstractMesh | Vector3>;
  16669. /**
  16670. * The maximum number of particles to emit per frame
  16671. */
  16672. emitRate: number;
  16673. /**
  16674. * If you want to launch only a few particles at once, that can be done, as well.
  16675. */
  16676. manualEmitCount: number;
  16677. /**
  16678. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  16679. */
  16680. updateSpeed: number;
  16681. /**
  16682. * The amount of time the particle system is running (depends of the overall update speed).
  16683. */
  16684. targetStopDuration: number;
  16685. /**
  16686. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  16687. */
  16688. disposeOnStop: boolean;
  16689. /**
  16690. * Minimum power of emitting particles.
  16691. */
  16692. minEmitPower: number;
  16693. /**
  16694. * Maximum power of emitting particles.
  16695. */
  16696. maxEmitPower: number;
  16697. /**
  16698. * Minimum life time of emitting particles.
  16699. */
  16700. minLifeTime: number;
  16701. /**
  16702. * Maximum life time of emitting particles.
  16703. */
  16704. maxLifeTime: number;
  16705. /**
  16706. * Minimum Size of emitting particles.
  16707. */
  16708. minSize: number;
  16709. /**
  16710. * Maximum Size of emitting particles.
  16711. */
  16712. maxSize: number;
  16713. /**
  16714. * Minimum scale of emitting particles on X axis.
  16715. */
  16716. minScaleX: number;
  16717. /**
  16718. * Maximum scale of emitting particles on X axis.
  16719. */
  16720. maxScaleX: number;
  16721. /**
  16722. * Minimum scale of emitting particles on Y axis.
  16723. */
  16724. minScaleY: number;
  16725. /**
  16726. * Maximum scale of emitting particles on Y axis.
  16727. */
  16728. maxScaleY: number;
  16729. /**
  16730. * Gets or sets the minimal initial rotation in radians.
  16731. */
  16732. minInitialRotation: number;
  16733. /**
  16734. * Gets or sets the maximal initial rotation in radians.
  16735. */
  16736. maxInitialRotation: number;
  16737. /**
  16738. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  16739. */
  16740. minAngularSpeed: number;
  16741. /**
  16742. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  16743. */
  16744. maxAngularSpeed: number;
  16745. /**
  16746. * The texture used to render each particle. (this can be a spritesheet)
  16747. */
  16748. particleTexture: Nullable<Texture>;
  16749. /**
  16750. * The layer mask we are rendering the particles through.
  16751. */
  16752. layerMask: number;
  16753. /**
  16754. * This can help using your own shader to render the particle system.
  16755. * The according effect will be created
  16756. */
  16757. customShader: any;
  16758. /**
  16759. * By default particle system starts as soon as they are created. This prevents the
  16760. * automatic start to happen and let you decide when to start emitting particles.
  16761. */
  16762. preventAutoStart: boolean;
  16763. private _noiseTexture;
  16764. /**
  16765. * Gets or sets a texture used to add random noise to particle positions
  16766. */
  16767. noiseTexture: Nullable<ProceduralTexture>;
  16768. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  16769. noiseStrength: Vector3;
  16770. /**
  16771. * Callback triggered when the particle animation is ending.
  16772. */
  16773. onAnimationEnd: Nullable<() => void>;
  16774. /**
  16775. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  16776. */
  16777. blendMode: number;
  16778. /**
  16779. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  16780. * to override the particles.
  16781. */
  16782. forceDepthWrite: boolean;
  16783. /** 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 */
  16784. preWarmCycles: number;
  16785. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  16786. preWarmStepOffset: number;
  16787. /**
  16788. * 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)
  16789. */
  16790. spriteCellChangeSpeed: number;
  16791. /**
  16792. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  16793. */
  16794. startSpriteCellID: number;
  16795. /**
  16796. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  16797. */
  16798. endSpriteCellID: number;
  16799. /**
  16800. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  16801. */
  16802. spriteCellWidth: number;
  16803. /**
  16804. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  16805. */
  16806. spriteCellHeight: number;
  16807. /**
  16808. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  16809. */
  16810. spriteRandomStartCell: boolean;
  16811. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  16812. translationPivot: Vector2;
  16813. /** @hidden */
  16814. protected _isAnimationSheetEnabled: boolean;
  16815. /**
  16816. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  16817. */
  16818. beginAnimationOnStart: boolean;
  16819. /**
  16820. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  16821. */
  16822. beginAnimationFrom: number;
  16823. /**
  16824. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  16825. */
  16826. beginAnimationTo: number;
  16827. /**
  16828. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  16829. */
  16830. beginAnimationLoop: boolean;
  16831. /**
  16832. * Gets or sets a world offset applied to all particles
  16833. */
  16834. worldOffset: Vector3;
  16835. /**
  16836. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  16837. */
  16838. isAnimationSheetEnabled: boolean;
  16839. /**
  16840. * Get hosting scene
  16841. * @returns the scene
  16842. */
  16843. getScene(): Scene;
  16844. /**
  16845. * You can use gravity if you want to give an orientation to your particles.
  16846. */
  16847. gravity: Vector3;
  16848. protected _colorGradients: Nullable<Array<ColorGradient>>;
  16849. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  16850. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  16851. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  16852. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  16853. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  16854. protected _dragGradients: Nullable<Array<FactorGradient>>;
  16855. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  16856. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  16857. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  16858. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  16859. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  16860. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  16861. /**
  16862. * Defines the delay in milliseconds before starting the system (0 by default)
  16863. */
  16864. startDelay: number;
  16865. /**
  16866. * Gets the current list of drag gradients.
  16867. * You must use addDragGradient and removeDragGradient to udpate this list
  16868. * @returns the list of drag gradients
  16869. */
  16870. getDragGradients(): Nullable<Array<FactorGradient>>;
  16871. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  16872. limitVelocityDamping: number;
  16873. /**
  16874. * Gets the current list of limit velocity gradients.
  16875. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  16876. * @returns the list of limit velocity gradients
  16877. */
  16878. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  16879. /**
  16880. * Gets the current list of color gradients.
  16881. * You must use addColorGradient and removeColorGradient to udpate this list
  16882. * @returns the list of color gradients
  16883. */
  16884. getColorGradients(): Nullable<Array<ColorGradient>>;
  16885. /**
  16886. * Gets the current list of size gradients.
  16887. * You must use addSizeGradient and removeSizeGradient to udpate this list
  16888. * @returns the list of size gradients
  16889. */
  16890. getSizeGradients(): Nullable<Array<FactorGradient>>;
  16891. /**
  16892. * Gets the current list of color remap gradients.
  16893. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  16894. * @returns the list of color remap gradients
  16895. */
  16896. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  16897. /**
  16898. * Gets the current list of alpha remap gradients.
  16899. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  16900. * @returns the list of alpha remap gradients
  16901. */
  16902. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  16903. /**
  16904. * Gets the current list of life time gradients.
  16905. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  16906. * @returns the list of life time gradients
  16907. */
  16908. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  16909. /**
  16910. * Gets the current list of angular speed gradients.
  16911. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  16912. * @returns the list of angular speed gradients
  16913. */
  16914. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  16915. /**
  16916. * Gets the current list of velocity gradients.
  16917. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  16918. * @returns the list of velocity gradients
  16919. */
  16920. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  16921. /**
  16922. * Gets the current list of start size gradients.
  16923. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  16924. * @returns the list of start size gradients
  16925. */
  16926. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  16927. /**
  16928. * Gets the current list of emit rate gradients.
  16929. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  16930. * @returns the list of emit rate gradients
  16931. */
  16932. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  16933. /**
  16934. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  16935. * This only works when particleEmitterTyps is a BoxParticleEmitter
  16936. */
  16937. direction1: Vector3;
  16938. /**
  16939. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  16940. * This only works when particleEmitterTyps is a BoxParticleEmitter
  16941. */
  16942. direction2: Vector3;
  16943. /**
  16944. * 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.
  16945. * This only works when particleEmitterTyps is a BoxParticleEmitter
  16946. */
  16947. minEmitBox: Vector3;
  16948. /**
  16949. * 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.
  16950. * This only works when particleEmitterTyps is a BoxParticleEmitter
  16951. */
  16952. maxEmitBox: Vector3;
  16953. /**
  16954. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  16955. */
  16956. color1: Color4;
  16957. /**
  16958. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  16959. */
  16960. color2: Color4;
  16961. /**
  16962. * Color the particle will have at the end of its lifetime
  16963. */
  16964. colorDead: Color4;
  16965. /**
  16966. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  16967. */
  16968. textureMask: Color4;
  16969. /**
  16970. * The particle emitter type defines the emitter used by the particle system.
  16971. * It can be for example box, sphere, or cone...
  16972. */
  16973. particleEmitterType: IParticleEmitterType;
  16974. /** @hidden */
  16975. _isSubEmitter: boolean;
  16976. /**
  16977. * Gets or sets the billboard mode to use when isBillboardBased = true.
  16978. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  16979. */
  16980. billboardMode: number;
  16981. protected _isBillboardBased: boolean;
  16982. /**
  16983. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  16984. */
  16985. isBillboardBased: boolean;
  16986. /**
  16987. * The scene the particle system belongs to.
  16988. */
  16989. protected _scene: Scene;
  16990. /**
  16991. * Local cache of defines for image processing.
  16992. */
  16993. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  16994. /**
  16995. * Default configuration related to image processing available in the standard Material.
  16996. */
  16997. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  16998. /**
  16999. * Gets the image processing configuration used either in this material.
  17000. */
  17001. /**
  17002. * Sets the Default image processing configuration used either in the this material.
  17003. *
  17004. * If sets to null, the scene one is in use.
  17005. */
  17006. imageProcessingConfiguration: ImageProcessingConfiguration;
  17007. /**
  17008. * Attaches a new image processing configuration to the Standard Material.
  17009. * @param configuration
  17010. */
  17011. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  17012. /** @hidden */
  17013. protected _reset(): void;
  17014. /** @hidden */
  17015. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  17016. /**
  17017. * Instantiates a particle system.
  17018. * 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.
  17019. * @param name The name of the particle system
  17020. */
  17021. constructor(name: string);
  17022. /**
  17023. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  17024. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  17025. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  17026. * @returns the emitter
  17027. */
  17028. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  17029. /**
  17030. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  17031. * @param radius The radius of the hemisphere to emit from
  17032. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  17033. * @returns the emitter
  17034. */
  17035. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  17036. /**
  17037. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  17038. * @param radius The radius of the sphere to emit from
  17039. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  17040. * @returns the emitter
  17041. */
  17042. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  17043. /**
  17044. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  17045. * @param radius The radius of the sphere to emit from
  17046. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  17047. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  17048. * @returns the emitter
  17049. */
  17050. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  17051. /**
  17052. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  17053. * @param radius The radius of the emission cylinder
  17054. * @param height The height of the emission cylinder
  17055. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  17056. * @param directionRandomizer How much to randomize the particle direction [0-1]
  17057. * @returns the emitter
  17058. */
  17059. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  17060. /**
  17061. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  17062. * @param radius The radius of the cylinder to emit from
  17063. * @param height The height of the emission cylinder
  17064. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  17065. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  17066. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  17067. * @returns the emitter
  17068. */
  17069. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  17070. /**
  17071. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  17072. * @param radius The radius of the cone to emit from
  17073. * @param angle The base angle of the cone
  17074. * @returns the emitter
  17075. */
  17076. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  17077. /**
  17078. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  17079. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  17080. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  17081. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  17082. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  17083. * @returns the emitter
  17084. */
  17085. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  17086. }
  17087. }
  17088. declare module "babylonjs/Particles/subEmitter" {
  17089. import { Scene } from "babylonjs/scene";
  17090. import { ParticleSystem } from "babylonjs/Particles/particleSystem";
  17091. /**
  17092. * Type of sub emitter
  17093. */
  17094. export enum SubEmitterType {
  17095. /**
  17096. * Attached to the particle over it's lifetime
  17097. */
  17098. ATTACHED = 0,
  17099. /**
  17100. * Created when the particle dies
  17101. */
  17102. END = 1
  17103. }
  17104. /**
  17105. * Sub emitter class used to emit particles from an existing particle
  17106. */
  17107. export class SubEmitter {
  17108. /**
  17109. * the particle system to be used by the sub emitter
  17110. */
  17111. particleSystem: ParticleSystem;
  17112. /**
  17113. * Type of the submitter (Default: END)
  17114. */
  17115. type: SubEmitterType;
  17116. /**
  17117. * 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)
  17118. * Note: This only is supported when using an emitter of type Mesh
  17119. */
  17120. inheritDirection: boolean;
  17121. /**
  17122. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  17123. */
  17124. inheritedVelocityAmount: number;
  17125. /**
  17126. * Creates a sub emitter
  17127. * @param particleSystem the particle system to be used by the sub emitter
  17128. */
  17129. constructor(
  17130. /**
  17131. * the particle system to be used by the sub emitter
  17132. */
  17133. particleSystem: ParticleSystem);
  17134. /**
  17135. * Clones the sub emitter
  17136. * @returns the cloned sub emitter
  17137. */
  17138. clone(): SubEmitter;
  17139. /**
  17140. * Serialize current object to a JSON object
  17141. * @returns the serialized object
  17142. */
  17143. serialize(): any;
  17144. /** @hidden */
  17145. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  17146. /**
  17147. * Creates a new SubEmitter from a serialized JSON version
  17148. * @param serializationObject defines the JSON object to read from
  17149. * @param scene defines the hosting scene
  17150. * @param rootUrl defines the rootUrl for data loading
  17151. * @returns a new SubEmitter
  17152. */
  17153. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  17154. /** Release associated resources */
  17155. dispose(): void;
  17156. }
  17157. }
  17158. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration" {
  17159. /** @hidden */
  17160. export var clipPlaneFragmentDeclaration: {
  17161. name: string;
  17162. shader: string;
  17163. };
  17164. }
  17165. declare module "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration" {
  17166. /** @hidden */
  17167. export var imageProcessingDeclaration: {
  17168. name: string;
  17169. shader: string;
  17170. };
  17171. }
  17172. declare module "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions" {
  17173. /** @hidden */
  17174. export var imageProcessingFunctions: {
  17175. name: string;
  17176. shader: string;
  17177. };
  17178. }
  17179. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragment" {
  17180. /** @hidden */
  17181. export var clipPlaneFragment: {
  17182. name: string;
  17183. shader: string;
  17184. };
  17185. }
  17186. declare module "babylonjs/Shaders/particles.fragment" {
  17187. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  17188. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  17189. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  17190. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  17191. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  17192. /** @hidden */
  17193. export var particlesPixelShader: {
  17194. name: string;
  17195. shader: string;
  17196. };
  17197. }
  17198. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration" {
  17199. /** @hidden */
  17200. export var clipPlaneVertexDeclaration: {
  17201. name: string;
  17202. shader: string;
  17203. };
  17204. }
  17205. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertex" {
  17206. /** @hidden */
  17207. export var clipPlaneVertex: {
  17208. name: string;
  17209. shader: string;
  17210. };
  17211. }
  17212. declare module "babylonjs/Shaders/particles.vertex" {
  17213. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  17214. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  17215. /** @hidden */
  17216. export var particlesVertexShader: {
  17217. name: string;
  17218. shader: string;
  17219. };
  17220. }
  17221. declare module "babylonjs/Particles/particleSystem" {
  17222. import { Nullable } from "babylonjs/types";
  17223. import { FactorGradient, Color3Gradient } from "babylonjs/Misc/gradients";
  17224. import { Observable } from "babylonjs/Misc/observable";
  17225. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  17226. import { Effect } from "babylonjs/Materials/effect";
  17227. import { Scene, IDisposable } from "babylonjs/scene";
  17228. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  17229. import { BaseParticleSystem } from "babylonjs/Particles/baseParticleSystem";
  17230. import { Particle } from "babylonjs/Particles/particle";
  17231. import { SubEmitter } from "babylonjs/Particles/subEmitter";
  17232. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  17233. import "babylonjs/Shaders/particles.fragment";
  17234. import "babylonjs/Shaders/particles.vertex";
  17235. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  17236. /**
  17237. * This represents a particle system in Babylon.
  17238. * 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.
  17239. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  17240. * @example https://doc.babylonjs.com/babylon101/particles
  17241. */
  17242. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  17243. /**
  17244. * Billboard mode will only apply to Y axis
  17245. */
  17246. static readonly BILLBOARDMODE_Y: number;
  17247. /**
  17248. * Billboard mode will apply to all axes
  17249. */
  17250. static readonly BILLBOARDMODE_ALL: number;
  17251. /**
  17252. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  17253. */
  17254. static readonly BILLBOARDMODE_STRETCHED: number;
  17255. /**
  17256. * This function can be defined to provide custom update for active particles.
  17257. * This function will be called instead of regular update (age, position, color, etc.).
  17258. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  17259. */
  17260. updateFunction: (particles: Particle[]) => void;
  17261. private _emitterWorldMatrix;
  17262. /**
  17263. * This function can be defined to specify initial direction for every new particle.
  17264. * It by default use the emitterType defined function
  17265. */
  17266. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  17267. /**
  17268. * This function can be defined to specify initial position for every new particle.
  17269. * It by default use the emitterType defined function
  17270. */
  17271. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  17272. /**
  17273. * @hidden
  17274. */
  17275. _inheritedVelocityOffset: Vector3;
  17276. /**
  17277. * An event triggered when the system is disposed
  17278. */
  17279. onDisposeObservable: Observable<ParticleSystem>;
  17280. private _onDisposeObserver;
  17281. /**
  17282. * Sets a callback that will be triggered when the system is disposed
  17283. */
  17284. onDispose: () => void;
  17285. private _particles;
  17286. private _epsilon;
  17287. private _capacity;
  17288. private _stockParticles;
  17289. private _newPartsExcess;
  17290. private _vertexData;
  17291. private _vertexBuffer;
  17292. private _vertexBuffers;
  17293. private _spriteBuffer;
  17294. private _indexBuffer;
  17295. private _effect;
  17296. private _customEffect;
  17297. private _cachedDefines;
  17298. private _scaledColorStep;
  17299. private _colorDiff;
  17300. private _scaledDirection;
  17301. private _scaledGravity;
  17302. private _currentRenderId;
  17303. private _alive;
  17304. private _useInstancing;
  17305. private _started;
  17306. private _stopped;
  17307. private _actualFrame;
  17308. private _scaledUpdateSpeed;
  17309. private _vertexBufferSize;
  17310. /** @hidden */
  17311. _currentEmitRateGradient: Nullable<FactorGradient>;
  17312. /** @hidden */
  17313. _currentEmitRate1: number;
  17314. /** @hidden */
  17315. _currentEmitRate2: number;
  17316. /** @hidden */
  17317. _currentStartSizeGradient: Nullable<FactorGradient>;
  17318. /** @hidden */
  17319. _currentStartSize1: number;
  17320. /** @hidden */
  17321. _currentStartSize2: number;
  17322. private readonly _rawTextureWidth;
  17323. private _rampGradientsTexture;
  17324. private _useRampGradients;
  17325. /** Gets or sets a boolean indicating that ramp gradients must be used
  17326. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  17327. */
  17328. useRampGradients: boolean;
  17329. /**
  17330. * 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.
  17331. * 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: [])
  17332. */
  17333. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  17334. private _subEmitters;
  17335. /**
  17336. * @hidden
  17337. * If the particle systems emitter should be disposed when the particle system is disposed
  17338. */
  17339. _disposeEmitterOnDispose: boolean;
  17340. /**
  17341. * The current active Sub-systems, this property is used by the root particle system only.
  17342. */
  17343. activeSubSystems: Array<ParticleSystem>;
  17344. private _rootParticleSystem;
  17345. /**
  17346. * Gets the current list of active particles
  17347. */
  17348. readonly particles: Particle[];
  17349. /**
  17350. * Returns the string "ParticleSystem"
  17351. * @returns a string containing the class name
  17352. */
  17353. getClassName(): string;
  17354. /**
  17355. * Instantiates a particle system.
  17356. * 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.
  17357. * @param name The name of the particle system
  17358. * @param capacity The max number of particles alive at the same time
  17359. * @param scene The scene the particle system belongs to
  17360. * @param customEffect a custom effect used to change the way particles are rendered by default
  17361. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  17362. * @param epsilon Offset used to render the particles
  17363. */
  17364. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  17365. private _addFactorGradient;
  17366. private _removeFactorGradient;
  17367. /**
  17368. * Adds a new life time gradient
  17369. * @param gradient defines the gradient to use (between 0 and 1)
  17370. * @param factor defines the life time factor to affect to the specified gradient
  17371. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17372. * @returns the current particle system
  17373. */
  17374. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17375. /**
  17376. * Remove a specific life time gradient
  17377. * @param gradient defines the gradient to remove
  17378. * @returns the current particle system
  17379. */
  17380. removeLifeTimeGradient(gradient: number): IParticleSystem;
  17381. /**
  17382. * Adds a new size gradient
  17383. * @param gradient defines the gradient to use (between 0 and 1)
  17384. * @param factor defines the size factor to affect to the specified gradient
  17385. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17386. * @returns the current particle system
  17387. */
  17388. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17389. /**
  17390. * Remove a specific size gradient
  17391. * @param gradient defines the gradient to remove
  17392. * @returns the current particle system
  17393. */
  17394. removeSizeGradient(gradient: number): IParticleSystem;
  17395. /**
  17396. * Adds a new color remap gradient
  17397. * @param gradient defines the gradient to use (between 0 and 1)
  17398. * @param min defines the color remap minimal range
  17399. * @param max defines the color remap maximal range
  17400. * @returns the current particle system
  17401. */
  17402. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  17403. /**
  17404. * Remove a specific color remap gradient
  17405. * @param gradient defines the gradient to remove
  17406. * @returns the current particle system
  17407. */
  17408. removeColorRemapGradient(gradient: number): IParticleSystem;
  17409. /**
  17410. * Adds a new alpha remap gradient
  17411. * @param gradient defines the gradient to use (between 0 and 1)
  17412. * @param min defines the alpha remap minimal range
  17413. * @param max defines the alpha remap maximal range
  17414. * @returns the current particle system
  17415. */
  17416. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  17417. /**
  17418. * Remove a specific alpha remap gradient
  17419. * @param gradient defines the gradient to remove
  17420. * @returns the current particle system
  17421. */
  17422. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  17423. /**
  17424. * Adds a new angular speed gradient
  17425. * @param gradient defines the gradient to use (between 0 and 1)
  17426. * @param factor defines the angular speed to affect to the specified gradient
  17427. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17428. * @returns the current particle system
  17429. */
  17430. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17431. /**
  17432. * Remove a specific angular speed gradient
  17433. * @param gradient defines the gradient to remove
  17434. * @returns the current particle system
  17435. */
  17436. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  17437. /**
  17438. * Adds a new velocity gradient
  17439. * @param gradient defines the gradient to use (between 0 and 1)
  17440. * @param factor defines the velocity to affect to the specified gradient
  17441. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17442. * @returns the current particle system
  17443. */
  17444. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17445. /**
  17446. * Remove a specific velocity gradient
  17447. * @param gradient defines the gradient to remove
  17448. * @returns the current particle system
  17449. */
  17450. removeVelocityGradient(gradient: number): IParticleSystem;
  17451. /**
  17452. * Adds a new limit velocity gradient
  17453. * @param gradient defines the gradient to use (between 0 and 1)
  17454. * @param factor defines the limit velocity value to affect to the specified gradient
  17455. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17456. * @returns the current particle system
  17457. */
  17458. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17459. /**
  17460. * Remove a specific limit velocity gradient
  17461. * @param gradient defines the gradient to remove
  17462. * @returns the current particle system
  17463. */
  17464. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  17465. /**
  17466. * Adds a new drag gradient
  17467. * @param gradient defines the gradient to use (between 0 and 1)
  17468. * @param factor defines the drag value to affect to the specified gradient
  17469. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17470. * @returns the current particle system
  17471. */
  17472. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17473. /**
  17474. * Remove a specific drag gradient
  17475. * @param gradient defines the gradient to remove
  17476. * @returns the current particle system
  17477. */
  17478. removeDragGradient(gradient: number): IParticleSystem;
  17479. /**
  17480. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  17481. * @param gradient defines the gradient to use (between 0 and 1)
  17482. * @param factor defines the emit rate value to affect to the specified gradient
  17483. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17484. * @returns the current particle system
  17485. */
  17486. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17487. /**
  17488. * Remove a specific emit rate gradient
  17489. * @param gradient defines the gradient to remove
  17490. * @returns the current particle system
  17491. */
  17492. removeEmitRateGradient(gradient: number): IParticleSystem;
  17493. /**
  17494. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  17495. * @param gradient defines the gradient to use (between 0 and 1)
  17496. * @param factor defines the start size value to affect to the specified gradient
  17497. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17498. * @returns the current particle system
  17499. */
  17500. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17501. /**
  17502. * Remove a specific start size gradient
  17503. * @param gradient defines the gradient to remove
  17504. * @returns the current particle system
  17505. */
  17506. removeStartSizeGradient(gradient: number): IParticleSystem;
  17507. private _createRampGradientTexture;
  17508. /**
  17509. * Gets the current list of ramp gradients.
  17510. * You must use addRampGradient and removeRampGradient to udpate this list
  17511. * @returns the list of ramp gradients
  17512. */
  17513. getRampGradients(): Nullable<Array<Color3Gradient>>;
  17514. /**
  17515. * Adds a new ramp gradient used to remap particle colors
  17516. * @param gradient defines the gradient to use (between 0 and 1)
  17517. * @param color defines the color to affect to the specified gradient
  17518. * @returns the current particle system
  17519. */
  17520. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  17521. /**
  17522. * Remove a specific ramp gradient
  17523. * @param gradient defines the gradient to remove
  17524. * @returns the current particle system
  17525. */
  17526. removeRampGradient(gradient: number): ParticleSystem;
  17527. /**
  17528. * Adds a new color gradient
  17529. * @param gradient defines the gradient to use (between 0 and 1)
  17530. * @param color1 defines the color to affect to the specified gradient
  17531. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  17532. * @returns this particle system
  17533. */
  17534. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  17535. /**
  17536. * Remove a specific color gradient
  17537. * @param gradient defines the gradient to remove
  17538. * @returns this particle system
  17539. */
  17540. removeColorGradient(gradient: number): IParticleSystem;
  17541. private _fetchR;
  17542. protected _reset(): void;
  17543. private _resetEffect;
  17544. private _createVertexBuffers;
  17545. private _createIndexBuffer;
  17546. /**
  17547. * Gets the maximum number of particles active at the same time.
  17548. * @returns The max number of active particles.
  17549. */
  17550. getCapacity(): number;
  17551. /**
  17552. * Gets whether there are still active particles in the system.
  17553. * @returns True if it is alive, otherwise false.
  17554. */
  17555. isAlive(): boolean;
  17556. /**
  17557. * Gets if the system has been started. (Note: this will still be true after stop is called)
  17558. * @returns True if it has been started, otherwise false.
  17559. */
  17560. isStarted(): boolean;
  17561. private _prepareSubEmitterInternalArray;
  17562. /**
  17563. * Starts the particle system and begins to emit
  17564. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  17565. */
  17566. start(delay?: number): void;
  17567. /**
  17568. * Stops the particle system.
  17569. * @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.
  17570. */
  17571. stop(stopSubEmitters?: boolean): void;
  17572. /**
  17573. * Remove all active particles
  17574. */
  17575. reset(): void;
  17576. /**
  17577. * @hidden (for internal use only)
  17578. */
  17579. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  17580. /**
  17581. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  17582. * Its lifetime will start back at 0.
  17583. */
  17584. recycleParticle: (particle: Particle) => void;
  17585. private _stopSubEmitters;
  17586. private _createParticle;
  17587. private _removeFromRoot;
  17588. private _emitFromParticle;
  17589. private _update;
  17590. /** @hidden */
  17591. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  17592. /** @hidden */
  17593. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  17594. /** @hidden */
  17595. private _getEffect;
  17596. /**
  17597. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  17598. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  17599. */
  17600. animate(preWarmOnly?: boolean): void;
  17601. private _appendParticleVertices;
  17602. /**
  17603. * Rebuilds the particle system.
  17604. */
  17605. rebuild(): void;
  17606. /**
  17607. * Is this system ready to be used/rendered
  17608. * @return true if the system is ready
  17609. */
  17610. isReady(): boolean;
  17611. private _render;
  17612. /**
  17613. * Renders the particle system in its current state.
  17614. * @returns the current number of particles
  17615. */
  17616. render(): number;
  17617. /**
  17618. * Disposes the particle system and free the associated resources
  17619. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  17620. */
  17621. dispose(disposeTexture?: boolean): void;
  17622. /**
  17623. * Clones the particle system.
  17624. * @param name The name of the cloned object
  17625. * @param newEmitter The new emitter to use
  17626. * @returns the cloned particle system
  17627. */
  17628. clone(name: string, newEmitter: any): ParticleSystem;
  17629. /**
  17630. * Serializes the particle system to a JSON object.
  17631. * @returns the JSON object
  17632. */
  17633. serialize(): any;
  17634. /** @hidden */
  17635. static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  17636. /** @hidden */
  17637. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  17638. /**
  17639. * Parses a JSON object to create a particle system.
  17640. * @param parsedParticleSystem The JSON object to parse
  17641. * @param scene The scene to create the particle system in
  17642. * @param rootUrl The root url to use to load external dependencies like texture
  17643. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  17644. * @returns the Parsed particle system
  17645. */
  17646. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  17647. }
  17648. }
  17649. declare module "babylonjs/Particles/particle" {
  17650. import { Nullable } from "babylonjs/types";
  17651. import { Vector2, Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  17652. import { Color4 } from "babylonjs/Maths/math.color";
  17653. import { ParticleSystem } from "babylonjs/Particles/particleSystem";
  17654. import { SubEmitter } from "babylonjs/Particles/subEmitter";
  17655. import { ColorGradient, FactorGradient } from "babylonjs/Misc/gradients";
  17656. /**
  17657. * A particle represents one of the element emitted by a particle system.
  17658. * This is mainly define by its coordinates, direction, velocity and age.
  17659. */
  17660. export class Particle {
  17661. /**
  17662. * The particle system the particle belongs to.
  17663. */
  17664. particleSystem: ParticleSystem;
  17665. private static _Count;
  17666. /**
  17667. * Unique ID of the particle
  17668. */
  17669. id: number;
  17670. /**
  17671. * The world position of the particle in the scene.
  17672. */
  17673. position: Vector3;
  17674. /**
  17675. * The world direction of the particle in the scene.
  17676. */
  17677. direction: Vector3;
  17678. /**
  17679. * The color of the particle.
  17680. */
  17681. color: Color4;
  17682. /**
  17683. * The color change of the particle per step.
  17684. */
  17685. colorStep: Color4;
  17686. /**
  17687. * Defines how long will the life of the particle be.
  17688. */
  17689. lifeTime: number;
  17690. /**
  17691. * The current age of the particle.
  17692. */
  17693. age: number;
  17694. /**
  17695. * The current size of the particle.
  17696. */
  17697. size: number;
  17698. /**
  17699. * The current scale of the particle.
  17700. */
  17701. scale: Vector2;
  17702. /**
  17703. * The current angle of the particle.
  17704. */
  17705. angle: number;
  17706. /**
  17707. * Defines how fast is the angle changing.
  17708. */
  17709. angularSpeed: number;
  17710. /**
  17711. * Defines the cell index used by the particle to be rendered from a sprite.
  17712. */
  17713. cellIndex: number;
  17714. /**
  17715. * The information required to support color remapping
  17716. */
  17717. remapData: Vector4;
  17718. /** @hidden */
  17719. _randomCellOffset?: number;
  17720. /** @hidden */
  17721. _initialDirection: Nullable<Vector3>;
  17722. /** @hidden */
  17723. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  17724. /** @hidden */
  17725. _initialStartSpriteCellID: number;
  17726. /** @hidden */
  17727. _initialEndSpriteCellID: number;
  17728. /** @hidden */
  17729. _currentColorGradient: Nullable<ColorGradient>;
  17730. /** @hidden */
  17731. _currentColor1: Color4;
  17732. /** @hidden */
  17733. _currentColor2: Color4;
  17734. /** @hidden */
  17735. _currentSizeGradient: Nullable<FactorGradient>;
  17736. /** @hidden */
  17737. _currentSize1: number;
  17738. /** @hidden */
  17739. _currentSize2: number;
  17740. /** @hidden */
  17741. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  17742. /** @hidden */
  17743. _currentAngularSpeed1: number;
  17744. /** @hidden */
  17745. _currentAngularSpeed2: number;
  17746. /** @hidden */
  17747. _currentVelocityGradient: Nullable<FactorGradient>;
  17748. /** @hidden */
  17749. _currentVelocity1: number;
  17750. /** @hidden */
  17751. _currentVelocity2: number;
  17752. /** @hidden */
  17753. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  17754. /** @hidden */
  17755. _currentLimitVelocity1: number;
  17756. /** @hidden */
  17757. _currentLimitVelocity2: number;
  17758. /** @hidden */
  17759. _currentDragGradient: Nullable<FactorGradient>;
  17760. /** @hidden */
  17761. _currentDrag1: number;
  17762. /** @hidden */
  17763. _currentDrag2: number;
  17764. /** @hidden */
  17765. _randomNoiseCoordinates1: Vector3;
  17766. /** @hidden */
  17767. _randomNoiseCoordinates2: Vector3;
  17768. /**
  17769. * Creates a new instance Particle
  17770. * @param particleSystem the particle system the particle belongs to
  17771. */
  17772. constructor(
  17773. /**
  17774. * The particle system the particle belongs to.
  17775. */
  17776. particleSystem: ParticleSystem);
  17777. private updateCellInfoFromSystem;
  17778. /**
  17779. * Defines how the sprite cell index is updated for the particle
  17780. */
  17781. updateCellIndex(): void;
  17782. /** @hidden */
  17783. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  17784. /** @hidden */
  17785. _inheritParticleInfoToSubEmitters(): void;
  17786. /** @hidden */
  17787. _reset(): void;
  17788. /**
  17789. * Copy the properties of particle to another one.
  17790. * @param other the particle to copy the information to.
  17791. */
  17792. copyTo(other: Particle): void;
  17793. }
  17794. }
  17795. declare module "babylonjs/Particles/EmitterTypes/IParticleEmitterType" {
  17796. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  17797. import { Effect } from "babylonjs/Materials/effect";
  17798. import { Particle } from "babylonjs/Particles/particle";
  17799. /**
  17800. * Particle emitter represents a volume emitting particles.
  17801. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  17802. */
  17803. export interface IParticleEmitterType {
  17804. /**
  17805. * Called by the particle System when the direction is computed for the created particle.
  17806. * @param worldMatrix is the world matrix of the particle system
  17807. * @param directionToUpdate is the direction vector to update with the result
  17808. * @param particle is the particle we are computed the direction for
  17809. */
  17810. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  17811. /**
  17812. * Called by the particle System when the position is computed for the created particle.
  17813. * @param worldMatrix is the world matrix of the particle system
  17814. * @param positionToUpdate is the position vector to update with the result
  17815. * @param particle is the particle we are computed the position for
  17816. */
  17817. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  17818. /**
  17819. * Clones the current emitter and returns a copy of it
  17820. * @returns the new emitter
  17821. */
  17822. clone(): IParticleEmitterType;
  17823. /**
  17824. * Called by the GPUParticleSystem to setup the update shader
  17825. * @param effect defines the update shader
  17826. */
  17827. applyToShader(effect: Effect): void;
  17828. /**
  17829. * Returns a string to use to update the GPU particles update shader
  17830. * @returns the effect defines string
  17831. */
  17832. getEffectDefines(): string;
  17833. /**
  17834. * Returns a string representing the class name
  17835. * @returns a string containing the class name
  17836. */
  17837. getClassName(): string;
  17838. /**
  17839. * Serializes the particle system to a JSON object.
  17840. * @returns the JSON object
  17841. */
  17842. serialize(): any;
  17843. /**
  17844. * Parse properties from a JSON object
  17845. * @param serializationObject defines the JSON object
  17846. */
  17847. parse(serializationObject: any): void;
  17848. }
  17849. }
  17850. declare module "babylonjs/Particles/EmitterTypes/boxParticleEmitter" {
  17851. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  17852. import { Effect } from "babylonjs/Materials/effect";
  17853. import { Particle } from "babylonjs/Particles/particle";
  17854. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  17855. /**
  17856. * Particle emitter emitting particles from the inside of a box.
  17857. * It emits the particles randomly between 2 given directions.
  17858. */
  17859. export class BoxParticleEmitter implements IParticleEmitterType {
  17860. /**
  17861. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  17862. */
  17863. direction1: Vector3;
  17864. /**
  17865. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  17866. */
  17867. direction2: Vector3;
  17868. /**
  17869. * 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.
  17870. */
  17871. minEmitBox: Vector3;
  17872. /**
  17873. * 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.
  17874. */
  17875. maxEmitBox: Vector3;
  17876. /**
  17877. * Creates a new instance BoxParticleEmitter
  17878. */
  17879. constructor();
  17880. /**
  17881. * Called by the particle System when the direction is computed for the created particle.
  17882. * @param worldMatrix is the world matrix of the particle system
  17883. * @param directionToUpdate is the direction vector to update with the result
  17884. * @param particle is the particle we are computed the direction for
  17885. */
  17886. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  17887. /**
  17888. * Called by the particle System when the position is computed for the created particle.
  17889. * @param worldMatrix is the world matrix of the particle system
  17890. * @param positionToUpdate is the position vector to update with the result
  17891. * @param particle is the particle we are computed the position for
  17892. */
  17893. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  17894. /**
  17895. * Clones the current emitter and returns a copy of it
  17896. * @returns the new emitter
  17897. */
  17898. clone(): BoxParticleEmitter;
  17899. /**
  17900. * Called by the GPUParticleSystem to setup the update shader
  17901. * @param effect defines the update shader
  17902. */
  17903. applyToShader(effect: Effect): void;
  17904. /**
  17905. * Returns a string to use to update the GPU particles update shader
  17906. * @returns a string containng the defines string
  17907. */
  17908. getEffectDefines(): string;
  17909. /**
  17910. * Returns the string "BoxParticleEmitter"
  17911. * @returns a string containing the class name
  17912. */
  17913. getClassName(): string;
  17914. /**
  17915. * Serializes the particle system to a JSON object.
  17916. * @returns the JSON object
  17917. */
  17918. serialize(): any;
  17919. /**
  17920. * Parse properties from a JSON object
  17921. * @param serializationObject defines the JSON object
  17922. */
  17923. parse(serializationObject: any): void;
  17924. }
  17925. }
  17926. declare module "babylonjs/Particles/EmitterTypes/coneParticleEmitter" {
  17927. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  17928. import { Effect } from "babylonjs/Materials/effect";
  17929. import { Particle } from "babylonjs/Particles/particle";
  17930. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  17931. /**
  17932. * Particle emitter emitting particles from the inside of a cone.
  17933. * It emits the particles alongside the cone volume from the base to the particle.
  17934. * The emission direction might be randomized.
  17935. */
  17936. export class ConeParticleEmitter implements IParticleEmitterType {
  17937. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  17938. directionRandomizer: number;
  17939. private _radius;
  17940. private _angle;
  17941. private _height;
  17942. /**
  17943. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  17944. */
  17945. radiusRange: number;
  17946. /**
  17947. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  17948. */
  17949. heightRange: number;
  17950. /**
  17951. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  17952. */
  17953. emitFromSpawnPointOnly: boolean;
  17954. /**
  17955. * Gets or sets the radius of the emission cone
  17956. */
  17957. radius: number;
  17958. /**
  17959. * Gets or sets the angle of the emission cone
  17960. */
  17961. angle: number;
  17962. private _buildHeight;
  17963. /**
  17964. * Creates a new instance ConeParticleEmitter
  17965. * @param radius the radius of the emission cone (1 by default)
  17966. * @param angle the cone base angle (PI by default)
  17967. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  17968. */
  17969. constructor(radius?: number, angle?: number,
  17970. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  17971. directionRandomizer?: number);
  17972. /**
  17973. * Called by the particle System when the direction is computed for the created particle.
  17974. * @param worldMatrix is the world matrix of the particle system
  17975. * @param directionToUpdate is the direction vector to update with the result
  17976. * @param particle is the particle we are computed the direction for
  17977. */
  17978. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  17979. /**
  17980. * Called by the particle System when the position is computed for the created particle.
  17981. * @param worldMatrix is the world matrix of the particle system
  17982. * @param positionToUpdate is the position vector to update with the result
  17983. * @param particle is the particle we are computed the position for
  17984. */
  17985. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  17986. /**
  17987. * Clones the current emitter and returns a copy of it
  17988. * @returns the new emitter
  17989. */
  17990. clone(): ConeParticleEmitter;
  17991. /**
  17992. * Called by the GPUParticleSystem to setup the update shader
  17993. * @param effect defines the update shader
  17994. */
  17995. applyToShader(effect: Effect): void;
  17996. /**
  17997. * Returns a string to use to update the GPU particles update shader
  17998. * @returns a string containng the defines string
  17999. */
  18000. getEffectDefines(): string;
  18001. /**
  18002. * Returns the string "ConeParticleEmitter"
  18003. * @returns a string containing the class name
  18004. */
  18005. getClassName(): string;
  18006. /**
  18007. * Serializes the particle system to a JSON object.
  18008. * @returns the JSON object
  18009. */
  18010. serialize(): any;
  18011. /**
  18012. * Parse properties from a JSON object
  18013. * @param serializationObject defines the JSON object
  18014. */
  18015. parse(serializationObject: any): void;
  18016. }
  18017. }
  18018. declare module "babylonjs/Particles/EmitterTypes/cylinderParticleEmitter" {
  18019. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  18020. import { Effect } from "babylonjs/Materials/effect";
  18021. import { Particle } from "babylonjs/Particles/particle";
  18022. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  18023. /**
  18024. * Particle emitter emitting particles from the inside of a cylinder.
  18025. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  18026. */
  18027. export class CylinderParticleEmitter implements IParticleEmitterType {
  18028. /**
  18029. * The radius of the emission cylinder.
  18030. */
  18031. radius: number;
  18032. /**
  18033. * The height of the emission cylinder.
  18034. */
  18035. height: number;
  18036. /**
  18037. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18038. */
  18039. radiusRange: number;
  18040. /**
  18041. * How much to randomize the particle direction [0-1].
  18042. */
  18043. directionRandomizer: number;
  18044. /**
  18045. * Creates a new instance CylinderParticleEmitter
  18046. * @param radius the radius of the emission cylinder (1 by default)
  18047. * @param height the height of the emission cylinder (1 by default)
  18048. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  18049. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  18050. */
  18051. constructor(
  18052. /**
  18053. * The radius of the emission cylinder.
  18054. */
  18055. radius?: number,
  18056. /**
  18057. * The height of the emission cylinder.
  18058. */
  18059. height?: number,
  18060. /**
  18061. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18062. */
  18063. radiusRange?: number,
  18064. /**
  18065. * How much to randomize the particle direction [0-1].
  18066. */
  18067. directionRandomizer?: number);
  18068. /**
  18069. * Called by the particle System when the direction is computed for the created particle.
  18070. * @param worldMatrix is the world matrix of the particle system
  18071. * @param directionToUpdate is the direction vector to update with the result
  18072. * @param particle is the particle we are computed the direction for
  18073. */
  18074. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18075. /**
  18076. * Called by the particle System when the position is computed for the created particle.
  18077. * @param worldMatrix is the world matrix of the particle system
  18078. * @param positionToUpdate is the position vector to update with the result
  18079. * @param particle is the particle we are computed the position for
  18080. */
  18081. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18082. /**
  18083. * Clones the current emitter and returns a copy of it
  18084. * @returns the new emitter
  18085. */
  18086. clone(): CylinderParticleEmitter;
  18087. /**
  18088. * Called by the GPUParticleSystem to setup the update shader
  18089. * @param effect defines the update shader
  18090. */
  18091. applyToShader(effect: Effect): void;
  18092. /**
  18093. * Returns a string to use to update the GPU particles update shader
  18094. * @returns a string containng the defines string
  18095. */
  18096. getEffectDefines(): string;
  18097. /**
  18098. * Returns the string "CylinderParticleEmitter"
  18099. * @returns a string containing the class name
  18100. */
  18101. getClassName(): string;
  18102. /**
  18103. * Serializes the particle system to a JSON object.
  18104. * @returns the JSON object
  18105. */
  18106. serialize(): any;
  18107. /**
  18108. * Parse properties from a JSON object
  18109. * @param serializationObject defines the JSON object
  18110. */
  18111. parse(serializationObject: any): void;
  18112. }
  18113. /**
  18114. * Particle emitter emitting particles from the inside of a cylinder.
  18115. * It emits the particles randomly between two vectors.
  18116. */
  18117. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  18118. /**
  18119. * The min limit of the emission direction.
  18120. */
  18121. direction1: Vector3;
  18122. /**
  18123. * The max limit of the emission direction.
  18124. */
  18125. direction2: Vector3;
  18126. /**
  18127. * Creates a new instance CylinderDirectedParticleEmitter
  18128. * @param radius the radius of the emission cylinder (1 by default)
  18129. * @param height the height of the emission cylinder (1 by default)
  18130. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  18131. * @param direction1 the min limit of the emission direction (up vector by default)
  18132. * @param direction2 the max limit of the emission direction (up vector by default)
  18133. */
  18134. constructor(radius?: number, height?: number, radiusRange?: number,
  18135. /**
  18136. * The min limit of the emission direction.
  18137. */
  18138. direction1?: Vector3,
  18139. /**
  18140. * The max limit of the emission direction.
  18141. */
  18142. direction2?: Vector3);
  18143. /**
  18144. * Called by the particle System when the direction is computed for the created particle.
  18145. * @param worldMatrix is the world matrix of the particle system
  18146. * @param directionToUpdate is the direction vector to update with the result
  18147. * @param particle is the particle we are computed the direction for
  18148. */
  18149. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18150. /**
  18151. * Clones the current emitter and returns a copy of it
  18152. * @returns the new emitter
  18153. */
  18154. clone(): CylinderDirectedParticleEmitter;
  18155. /**
  18156. * Called by the GPUParticleSystem to setup the update shader
  18157. * @param effect defines the update shader
  18158. */
  18159. applyToShader(effect: Effect): void;
  18160. /**
  18161. * Returns a string to use to update the GPU particles update shader
  18162. * @returns a string containng the defines string
  18163. */
  18164. getEffectDefines(): string;
  18165. /**
  18166. * Returns the string "CylinderDirectedParticleEmitter"
  18167. * @returns a string containing the class name
  18168. */
  18169. getClassName(): string;
  18170. /**
  18171. * Serializes the particle system to a JSON object.
  18172. * @returns the JSON object
  18173. */
  18174. serialize(): any;
  18175. /**
  18176. * Parse properties from a JSON object
  18177. * @param serializationObject defines the JSON object
  18178. */
  18179. parse(serializationObject: any): void;
  18180. }
  18181. }
  18182. declare module "babylonjs/Particles/EmitterTypes/hemisphericParticleEmitter" {
  18183. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  18184. import { Effect } from "babylonjs/Materials/effect";
  18185. import { Particle } from "babylonjs/Particles/particle";
  18186. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  18187. /**
  18188. * Particle emitter emitting particles from the inside of a hemisphere.
  18189. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  18190. */
  18191. export class HemisphericParticleEmitter implements IParticleEmitterType {
  18192. /**
  18193. * The radius of the emission hemisphere.
  18194. */
  18195. radius: number;
  18196. /**
  18197. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18198. */
  18199. radiusRange: number;
  18200. /**
  18201. * How much to randomize the particle direction [0-1].
  18202. */
  18203. directionRandomizer: number;
  18204. /**
  18205. * Creates a new instance HemisphericParticleEmitter
  18206. * @param radius the radius of the emission hemisphere (1 by default)
  18207. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  18208. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  18209. */
  18210. constructor(
  18211. /**
  18212. * The radius of the emission hemisphere.
  18213. */
  18214. radius?: number,
  18215. /**
  18216. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18217. */
  18218. radiusRange?: number,
  18219. /**
  18220. * How much to randomize the particle direction [0-1].
  18221. */
  18222. directionRandomizer?: number);
  18223. /**
  18224. * Called by the particle System when the direction is computed for the created particle.
  18225. * @param worldMatrix is the world matrix of the particle system
  18226. * @param directionToUpdate is the direction vector to update with the result
  18227. * @param particle is the particle we are computed the direction for
  18228. */
  18229. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18230. /**
  18231. * Called by the particle System when the position is computed for the created particle.
  18232. * @param worldMatrix is the world matrix of the particle system
  18233. * @param positionToUpdate is the position vector to update with the result
  18234. * @param particle is the particle we are computed the position for
  18235. */
  18236. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18237. /**
  18238. * Clones the current emitter and returns a copy of it
  18239. * @returns the new emitter
  18240. */
  18241. clone(): HemisphericParticleEmitter;
  18242. /**
  18243. * Called by the GPUParticleSystem to setup the update shader
  18244. * @param effect defines the update shader
  18245. */
  18246. applyToShader(effect: Effect): void;
  18247. /**
  18248. * Returns a string to use to update the GPU particles update shader
  18249. * @returns a string containng the defines string
  18250. */
  18251. getEffectDefines(): string;
  18252. /**
  18253. * Returns the string "HemisphericParticleEmitter"
  18254. * @returns a string containing the class name
  18255. */
  18256. getClassName(): string;
  18257. /**
  18258. * Serializes the particle system to a JSON object.
  18259. * @returns the JSON object
  18260. */
  18261. serialize(): any;
  18262. /**
  18263. * Parse properties from a JSON object
  18264. * @param serializationObject defines the JSON object
  18265. */
  18266. parse(serializationObject: any): void;
  18267. }
  18268. }
  18269. declare module "babylonjs/Particles/EmitterTypes/pointParticleEmitter" {
  18270. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  18271. import { Effect } from "babylonjs/Materials/effect";
  18272. import { Particle } from "babylonjs/Particles/particle";
  18273. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  18274. /**
  18275. * Particle emitter emitting particles from a point.
  18276. * It emits the particles randomly between 2 given directions.
  18277. */
  18278. export class PointParticleEmitter implements IParticleEmitterType {
  18279. /**
  18280. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  18281. */
  18282. direction1: Vector3;
  18283. /**
  18284. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  18285. */
  18286. direction2: Vector3;
  18287. /**
  18288. * Creates a new instance PointParticleEmitter
  18289. */
  18290. constructor();
  18291. /**
  18292. * Called by the particle System when the direction is computed for the created particle.
  18293. * @param worldMatrix is the world matrix of the particle system
  18294. * @param directionToUpdate is the direction vector to update with the result
  18295. * @param particle is the particle we are computed the direction for
  18296. */
  18297. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18298. /**
  18299. * Called by the particle System when the position is computed for the created particle.
  18300. * @param worldMatrix is the world matrix of the particle system
  18301. * @param positionToUpdate is the position vector to update with the result
  18302. * @param particle is the particle we are computed the position for
  18303. */
  18304. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18305. /**
  18306. * Clones the current emitter and returns a copy of it
  18307. * @returns the new emitter
  18308. */
  18309. clone(): PointParticleEmitter;
  18310. /**
  18311. * Called by the GPUParticleSystem to setup the update shader
  18312. * @param effect defines the update shader
  18313. */
  18314. applyToShader(effect: Effect): void;
  18315. /**
  18316. * Returns a string to use to update the GPU particles update shader
  18317. * @returns a string containng the defines string
  18318. */
  18319. getEffectDefines(): string;
  18320. /**
  18321. * Returns the string "PointParticleEmitter"
  18322. * @returns a string containing the class name
  18323. */
  18324. getClassName(): string;
  18325. /**
  18326. * Serializes the particle system to a JSON object.
  18327. * @returns the JSON object
  18328. */
  18329. serialize(): any;
  18330. /**
  18331. * Parse properties from a JSON object
  18332. * @param serializationObject defines the JSON object
  18333. */
  18334. parse(serializationObject: any): void;
  18335. }
  18336. }
  18337. declare module "babylonjs/Particles/EmitterTypes/sphereParticleEmitter" {
  18338. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  18339. import { Effect } from "babylonjs/Materials/effect";
  18340. import { Particle } from "babylonjs/Particles/particle";
  18341. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  18342. /**
  18343. * Particle emitter emitting particles from the inside of a sphere.
  18344. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  18345. */
  18346. export class SphereParticleEmitter implements IParticleEmitterType {
  18347. /**
  18348. * The radius of the emission sphere.
  18349. */
  18350. radius: number;
  18351. /**
  18352. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18353. */
  18354. radiusRange: number;
  18355. /**
  18356. * How much to randomize the particle direction [0-1].
  18357. */
  18358. directionRandomizer: number;
  18359. /**
  18360. * Creates a new instance SphereParticleEmitter
  18361. * @param radius the radius of the emission sphere (1 by default)
  18362. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  18363. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  18364. */
  18365. constructor(
  18366. /**
  18367. * The radius of the emission sphere.
  18368. */
  18369. radius?: number,
  18370. /**
  18371. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18372. */
  18373. radiusRange?: number,
  18374. /**
  18375. * How much to randomize the particle direction [0-1].
  18376. */
  18377. directionRandomizer?: number);
  18378. /**
  18379. * Called by the particle System when the direction is computed for the created particle.
  18380. * @param worldMatrix is the world matrix of the particle system
  18381. * @param directionToUpdate is the direction vector to update with the result
  18382. * @param particle is the particle we are computed the direction for
  18383. */
  18384. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18385. /**
  18386. * Called by the particle System when the position is computed for the created particle.
  18387. * @param worldMatrix is the world matrix of the particle system
  18388. * @param positionToUpdate is the position vector to update with the result
  18389. * @param particle is the particle we are computed the position for
  18390. */
  18391. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18392. /**
  18393. * Clones the current emitter and returns a copy of it
  18394. * @returns the new emitter
  18395. */
  18396. clone(): SphereParticleEmitter;
  18397. /**
  18398. * Called by the GPUParticleSystem to setup the update shader
  18399. * @param effect defines the update shader
  18400. */
  18401. applyToShader(effect: Effect): void;
  18402. /**
  18403. * Returns a string to use to update the GPU particles update shader
  18404. * @returns a string containng the defines string
  18405. */
  18406. getEffectDefines(): string;
  18407. /**
  18408. * Returns the string "SphereParticleEmitter"
  18409. * @returns a string containing the class name
  18410. */
  18411. getClassName(): string;
  18412. /**
  18413. * Serializes the particle system to a JSON object.
  18414. * @returns the JSON object
  18415. */
  18416. serialize(): any;
  18417. /**
  18418. * Parse properties from a JSON object
  18419. * @param serializationObject defines the JSON object
  18420. */
  18421. parse(serializationObject: any): void;
  18422. }
  18423. /**
  18424. * Particle emitter emitting particles from the inside of a sphere.
  18425. * It emits the particles randomly between two vectors.
  18426. */
  18427. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  18428. /**
  18429. * The min limit of the emission direction.
  18430. */
  18431. direction1: Vector3;
  18432. /**
  18433. * The max limit of the emission direction.
  18434. */
  18435. direction2: Vector3;
  18436. /**
  18437. * Creates a new instance SphereDirectedParticleEmitter
  18438. * @param radius the radius of the emission sphere (1 by default)
  18439. * @param direction1 the min limit of the emission direction (up vector by default)
  18440. * @param direction2 the max limit of the emission direction (up vector by default)
  18441. */
  18442. constructor(radius?: number,
  18443. /**
  18444. * The min limit of the emission direction.
  18445. */
  18446. direction1?: Vector3,
  18447. /**
  18448. * The max limit of the emission direction.
  18449. */
  18450. direction2?: Vector3);
  18451. /**
  18452. * Called by the particle System when the direction is computed for the created particle.
  18453. * @param worldMatrix is the world matrix of the particle system
  18454. * @param directionToUpdate is the direction vector to update with the result
  18455. * @param particle is the particle we are computed the direction for
  18456. */
  18457. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18458. /**
  18459. * Clones the current emitter and returns a copy of it
  18460. * @returns the new emitter
  18461. */
  18462. clone(): SphereDirectedParticleEmitter;
  18463. /**
  18464. * Called by the GPUParticleSystem to setup the update shader
  18465. * @param effect defines the update shader
  18466. */
  18467. applyToShader(effect: Effect): void;
  18468. /**
  18469. * Returns a string to use to update the GPU particles update shader
  18470. * @returns a string containng the defines string
  18471. */
  18472. getEffectDefines(): string;
  18473. /**
  18474. * Returns the string "SphereDirectedParticleEmitter"
  18475. * @returns a string containing the class name
  18476. */
  18477. getClassName(): string;
  18478. /**
  18479. * Serializes the particle system to a JSON object.
  18480. * @returns the JSON object
  18481. */
  18482. serialize(): any;
  18483. /**
  18484. * Parse properties from a JSON object
  18485. * @param serializationObject defines the JSON object
  18486. */
  18487. parse(serializationObject: any): void;
  18488. }
  18489. }
  18490. declare module "babylonjs/Particles/EmitterTypes/index" {
  18491. export * from "babylonjs/Particles/EmitterTypes/boxParticleEmitter";
  18492. export * from "babylonjs/Particles/EmitterTypes/coneParticleEmitter";
  18493. export * from "babylonjs/Particles/EmitterTypes/cylinderParticleEmitter";
  18494. export * from "babylonjs/Particles/EmitterTypes/hemisphericParticleEmitter";
  18495. export * from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  18496. export * from "babylonjs/Particles/EmitterTypes/pointParticleEmitter";
  18497. export * from "babylonjs/Particles/EmitterTypes/sphereParticleEmitter";
  18498. }
  18499. declare module "babylonjs/Particles/IParticleSystem" {
  18500. import { Nullable } from "babylonjs/types";
  18501. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  18502. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  18503. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  18504. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  18505. import { Texture } from "babylonjs/Materials/Textures/texture";
  18506. import { BoxParticleEmitter, IParticleEmitterType, PointParticleEmitter, HemisphericParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter, CylinderParticleEmitter, ConeParticleEmitter } from "babylonjs/Particles/EmitterTypes/index";
  18507. import { Scene } from "babylonjs/scene";
  18508. import { ColorGradient, FactorGradient, Color3Gradient } from "babylonjs/Misc/gradients";
  18509. import { Animation } from "babylonjs/Animations/animation";
  18510. /**
  18511. * Interface representing a particle system in Babylon.js.
  18512. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  18513. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  18514. */
  18515. export interface IParticleSystem {
  18516. /**
  18517. * List of animations used by the particle system.
  18518. */
  18519. animations: Animation[];
  18520. /**
  18521. * The id of the Particle system.
  18522. */
  18523. id: string;
  18524. /**
  18525. * The name of the Particle system.
  18526. */
  18527. name: string;
  18528. /**
  18529. * The emitter represents the Mesh or position we are attaching the particle system to.
  18530. */
  18531. emitter: Nullable<AbstractMesh | Vector3>;
  18532. /**
  18533. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  18534. */
  18535. isBillboardBased: boolean;
  18536. /**
  18537. * The rendering group used by the Particle system to chose when to render.
  18538. */
  18539. renderingGroupId: number;
  18540. /**
  18541. * The layer mask we are rendering the particles through.
  18542. */
  18543. layerMask: number;
  18544. /**
  18545. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  18546. */
  18547. updateSpeed: number;
  18548. /**
  18549. * The amount of time the particle system is running (depends of the overall update speed).
  18550. */
  18551. targetStopDuration: number;
  18552. /**
  18553. * The texture used to render each particle. (this can be a spritesheet)
  18554. */
  18555. particleTexture: Nullable<Texture>;
  18556. /**
  18557. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  18558. */
  18559. blendMode: number;
  18560. /**
  18561. * Minimum life time of emitting particles.
  18562. */
  18563. minLifeTime: number;
  18564. /**
  18565. * Maximum life time of emitting particles.
  18566. */
  18567. maxLifeTime: number;
  18568. /**
  18569. * Minimum Size of emitting particles.
  18570. */
  18571. minSize: number;
  18572. /**
  18573. * Maximum Size of emitting particles.
  18574. */
  18575. maxSize: number;
  18576. /**
  18577. * Minimum scale of emitting particles on X axis.
  18578. */
  18579. minScaleX: number;
  18580. /**
  18581. * Maximum scale of emitting particles on X axis.
  18582. */
  18583. maxScaleX: number;
  18584. /**
  18585. * Minimum scale of emitting particles on Y axis.
  18586. */
  18587. minScaleY: number;
  18588. /**
  18589. * Maximum scale of emitting particles on Y axis.
  18590. */
  18591. maxScaleY: number;
  18592. /**
  18593. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  18594. */
  18595. color1: Color4;
  18596. /**
  18597. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  18598. */
  18599. color2: Color4;
  18600. /**
  18601. * Color the particle will have at the end of its lifetime.
  18602. */
  18603. colorDead: Color4;
  18604. /**
  18605. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  18606. */
  18607. emitRate: number;
  18608. /**
  18609. * You can use gravity if you want to give an orientation to your particles.
  18610. */
  18611. gravity: Vector3;
  18612. /**
  18613. * Minimum power of emitting particles.
  18614. */
  18615. minEmitPower: number;
  18616. /**
  18617. * Maximum power of emitting particles.
  18618. */
  18619. maxEmitPower: number;
  18620. /**
  18621. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  18622. */
  18623. minAngularSpeed: number;
  18624. /**
  18625. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  18626. */
  18627. maxAngularSpeed: number;
  18628. /**
  18629. * Gets or sets the minimal initial rotation in radians.
  18630. */
  18631. minInitialRotation: number;
  18632. /**
  18633. * Gets or sets the maximal initial rotation in radians.
  18634. */
  18635. maxInitialRotation: number;
  18636. /**
  18637. * The particle emitter type defines the emitter used by the particle system.
  18638. * It can be for example box, sphere, or cone...
  18639. */
  18640. particleEmitterType: Nullable<IParticleEmitterType>;
  18641. /**
  18642. * Defines the delay in milliseconds before starting the system (0 by default)
  18643. */
  18644. startDelay: number;
  18645. /**
  18646. * 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
  18647. */
  18648. preWarmCycles: number;
  18649. /**
  18650. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  18651. */
  18652. preWarmStepOffset: number;
  18653. /**
  18654. * 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)
  18655. */
  18656. spriteCellChangeSpeed: number;
  18657. /**
  18658. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  18659. */
  18660. startSpriteCellID: number;
  18661. /**
  18662. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  18663. */
  18664. endSpriteCellID: number;
  18665. /**
  18666. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  18667. */
  18668. spriteCellWidth: number;
  18669. /**
  18670. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  18671. */
  18672. spriteCellHeight: number;
  18673. /**
  18674. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  18675. */
  18676. spriteRandomStartCell: boolean;
  18677. /**
  18678. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  18679. */
  18680. isAnimationSheetEnabled: boolean;
  18681. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  18682. translationPivot: Vector2;
  18683. /**
  18684. * Gets or sets a texture used to add random noise to particle positions
  18685. */
  18686. noiseTexture: Nullable<BaseTexture>;
  18687. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  18688. noiseStrength: Vector3;
  18689. /**
  18690. * Gets or sets the billboard mode to use when isBillboardBased = true.
  18691. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  18692. */
  18693. billboardMode: number;
  18694. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  18695. limitVelocityDamping: number;
  18696. /**
  18697. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  18698. */
  18699. beginAnimationOnStart: boolean;
  18700. /**
  18701. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  18702. */
  18703. beginAnimationFrom: number;
  18704. /**
  18705. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  18706. */
  18707. beginAnimationTo: number;
  18708. /**
  18709. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  18710. */
  18711. beginAnimationLoop: boolean;
  18712. /**
  18713. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  18714. */
  18715. disposeOnStop: boolean;
  18716. /**
  18717. * Gets the maximum number of particles active at the same time.
  18718. * @returns The max number of active particles.
  18719. */
  18720. getCapacity(): number;
  18721. /**
  18722. * Gets if the system has been started. (Note: this will still be true after stop is called)
  18723. * @returns True if it has been started, otherwise false.
  18724. */
  18725. isStarted(): boolean;
  18726. /**
  18727. * Animates the particle system for this frame.
  18728. */
  18729. animate(): void;
  18730. /**
  18731. * Renders the particle system in its current state.
  18732. * @returns the current number of particles
  18733. */
  18734. render(): number;
  18735. /**
  18736. * Dispose the particle system and frees its associated resources.
  18737. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  18738. */
  18739. dispose(disposeTexture?: boolean): void;
  18740. /**
  18741. * Clones the particle system.
  18742. * @param name The name of the cloned object
  18743. * @param newEmitter The new emitter to use
  18744. * @returns the cloned particle system
  18745. */
  18746. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  18747. /**
  18748. * Serializes the particle system to a JSON object.
  18749. * @returns the JSON object
  18750. */
  18751. serialize(): any;
  18752. /**
  18753. * Rebuild the particle system
  18754. */
  18755. rebuild(): void;
  18756. /**
  18757. * Starts the particle system and begins to emit
  18758. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  18759. */
  18760. start(delay?: number): void;
  18761. /**
  18762. * Stops the particle system.
  18763. */
  18764. stop(): void;
  18765. /**
  18766. * Remove all active particles
  18767. */
  18768. reset(): void;
  18769. /**
  18770. * Is this system ready to be used/rendered
  18771. * @return true if the system is ready
  18772. */
  18773. isReady(): boolean;
  18774. /**
  18775. * Adds a new color gradient
  18776. * @param gradient defines the gradient to use (between 0 and 1)
  18777. * @param color1 defines the color to affect to the specified gradient
  18778. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  18779. * @returns the current particle system
  18780. */
  18781. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  18782. /**
  18783. * Remove a specific color gradient
  18784. * @param gradient defines the gradient to remove
  18785. * @returns the current particle system
  18786. */
  18787. removeColorGradient(gradient: number): IParticleSystem;
  18788. /**
  18789. * Adds a new size gradient
  18790. * @param gradient defines the gradient to use (between 0 and 1)
  18791. * @param factor defines the size factor to affect to the specified gradient
  18792. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18793. * @returns the current particle system
  18794. */
  18795. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18796. /**
  18797. * Remove a specific size gradient
  18798. * @param gradient defines the gradient to remove
  18799. * @returns the current particle system
  18800. */
  18801. removeSizeGradient(gradient: number): IParticleSystem;
  18802. /**
  18803. * Gets the current list of color gradients.
  18804. * You must use addColorGradient and removeColorGradient to udpate this list
  18805. * @returns the list of color gradients
  18806. */
  18807. getColorGradients(): Nullable<Array<ColorGradient>>;
  18808. /**
  18809. * Gets the current list of size gradients.
  18810. * You must use addSizeGradient and removeSizeGradient to udpate this list
  18811. * @returns the list of size gradients
  18812. */
  18813. getSizeGradients(): Nullable<Array<FactorGradient>>;
  18814. /**
  18815. * Gets the current list of angular speed gradients.
  18816. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  18817. * @returns the list of angular speed gradients
  18818. */
  18819. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  18820. /**
  18821. * Adds a new angular speed gradient
  18822. * @param gradient defines the gradient to use (between 0 and 1)
  18823. * @param factor defines the angular speed to affect to the specified gradient
  18824. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18825. * @returns the current particle system
  18826. */
  18827. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18828. /**
  18829. * Remove a specific angular speed gradient
  18830. * @param gradient defines the gradient to remove
  18831. * @returns the current particle system
  18832. */
  18833. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  18834. /**
  18835. * Gets the current list of velocity gradients.
  18836. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  18837. * @returns the list of velocity gradients
  18838. */
  18839. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  18840. /**
  18841. * Adds a new velocity gradient
  18842. * @param gradient defines the gradient to use (between 0 and 1)
  18843. * @param factor defines the velocity to affect to the specified gradient
  18844. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18845. * @returns the current particle system
  18846. */
  18847. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18848. /**
  18849. * Remove a specific velocity gradient
  18850. * @param gradient defines the gradient to remove
  18851. * @returns the current particle system
  18852. */
  18853. removeVelocityGradient(gradient: number): IParticleSystem;
  18854. /**
  18855. * Gets the current list of limit velocity gradients.
  18856. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  18857. * @returns the list of limit velocity gradients
  18858. */
  18859. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  18860. /**
  18861. * Adds a new limit velocity gradient
  18862. * @param gradient defines the gradient to use (between 0 and 1)
  18863. * @param factor defines the limit velocity to affect to the specified gradient
  18864. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18865. * @returns the current particle system
  18866. */
  18867. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18868. /**
  18869. * Remove a specific limit velocity gradient
  18870. * @param gradient defines the gradient to remove
  18871. * @returns the current particle system
  18872. */
  18873. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  18874. /**
  18875. * Adds a new drag gradient
  18876. * @param gradient defines the gradient to use (between 0 and 1)
  18877. * @param factor defines the drag to affect to the specified gradient
  18878. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18879. * @returns the current particle system
  18880. */
  18881. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18882. /**
  18883. * Remove a specific drag gradient
  18884. * @param gradient defines the gradient to remove
  18885. * @returns the current particle system
  18886. */
  18887. removeDragGradient(gradient: number): IParticleSystem;
  18888. /**
  18889. * Gets the current list of drag gradients.
  18890. * You must use addDragGradient and removeDragGradient to udpate this list
  18891. * @returns the list of drag gradients
  18892. */
  18893. getDragGradients(): Nullable<Array<FactorGradient>>;
  18894. /**
  18895. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  18896. * @param gradient defines the gradient to use (between 0 and 1)
  18897. * @param factor defines the emit rate to affect to the specified gradient
  18898. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18899. * @returns the current particle system
  18900. */
  18901. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18902. /**
  18903. * Remove a specific emit rate gradient
  18904. * @param gradient defines the gradient to remove
  18905. * @returns the current particle system
  18906. */
  18907. removeEmitRateGradient(gradient: number): IParticleSystem;
  18908. /**
  18909. * Gets the current list of emit rate gradients.
  18910. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  18911. * @returns the list of emit rate gradients
  18912. */
  18913. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  18914. /**
  18915. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  18916. * @param gradient defines the gradient to use (between 0 and 1)
  18917. * @param factor defines the start size to affect to the specified gradient
  18918. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18919. * @returns the current particle system
  18920. */
  18921. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18922. /**
  18923. * Remove a specific start size gradient
  18924. * @param gradient defines the gradient to remove
  18925. * @returns the current particle system
  18926. */
  18927. removeStartSizeGradient(gradient: number): IParticleSystem;
  18928. /**
  18929. * Gets the current list of start size gradients.
  18930. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  18931. * @returns the list of start size gradients
  18932. */
  18933. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  18934. /**
  18935. * Adds a new life time gradient
  18936. * @param gradient defines the gradient to use (between 0 and 1)
  18937. * @param factor defines the life time factor to affect to the specified gradient
  18938. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18939. * @returns the current particle system
  18940. */
  18941. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18942. /**
  18943. * Remove a specific life time gradient
  18944. * @param gradient defines the gradient to remove
  18945. * @returns the current particle system
  18946. */
  18947. removeLifeTimeGradient(gradient: number): IParticleSystem;
  18948. /**
  18949. * Gets the current list of life time gradients.
  18950. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  18951. * @returns the list of life time gradients
  18952. */
  18953. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  18954. /**
  18955. * Gets the current list of color gradients.
  18956. * You must use addColorGradient and removeColorGradient to udpate this list
  18957. * @returns the list of color gradients
  18958. */
  18959. getColorGradients(): Nullable<Array<ColorGradient>>;
  18960. /**
  18961. * Adds a new ramp gradient used to remap particle colors
  18962. * @param gradient defines the gradient to use (between 0 and 1)
  18963. * @param color defines the color to affect to the specified gradient
  18964. * @returns the current particle system
  18965. */
  18966. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  18967. /**
  18968. * Gets the current list of ramp gradients.
  18969. * You must use addRampGradient and removeRampGradient to udpate this list
  18970. * @returns the list of ramp gradients
  18971. */
  18972. getRampGradients(): Nullable<Array<Color3Gradient>>;
  18973. /** Gets or sets a boolean indicating that ramp gradients must be used
  18974. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  18975. */
  18976. useRampGradients: boolean;
  18977. /**
  18978. * Adds a new color remap gradient
  18979. * @param gradient defines the gradient to use (between 0 and 1)
  18980. * @param min defines the color remap minimal range
  18981. * @param max defines the color remap maximal range
  18982. * @returns the current particle system
  18983. */
  18984. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  18985. /**
  18986. * Gets the current list of color remap gradients.
  18987. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  18988. * @returns the list of color remap gradients
  18989. */
  18990. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  18991. /**
  18992. * Adds a new alpha remap gradient
  18993. * @param gradient defines the gradient to use (between 0 and 1)
  18994. * @param min defines the alpha remap minimal range
  18995. * @param max defines the alpha remap maximal range
  18996. * @returns the current particle system
  18997. */
  18998. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  18999. /**
  19000. * Gets the current list of alpha remap gradients.
  19001. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  19002. * @returns the list of alpha remap gradients
  19003. */
  19004. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  19005. /**
  19006. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  19007. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  19008. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  19009. * @returns the emitter
  19010. */
  19011. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  19012. /**
  19013. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  19014. * @param radius The radius of the hemisphere to emit from
  19015. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  19016. * @returns the emitter
  19017. */
  19018. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  19019. /**
  19020. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  19021. * @param radius The radius of the sphere to emit from
  19022. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  19023. * @returns the emitter
  19024. */
  19025. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  19026. /**
  19027. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  19028. * @param radius The radius of the sphere to emit from
  19029. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  19030. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  19031. * @returns the emitter
  19032. */
  19033. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  19034. /**
  19035. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  19036. * @param radius The radius of the emission cylinder
  19037. * @param height The height of the emission cylinder
  19038. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  19039. * @param directionRandomizer How much to randomize the particle direction [0-1]
  19040. * @returns the emitter
  19041. */
  19042. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  19043. /**
  19044. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  19045. * @param radius The radius of the cylinder to emit from
  19046. * @param height The height of the emission cylinder
  19047. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  19048. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  19049. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  19050. * @returns the emitter
  19051. */
  19052. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  19053. /**
  19054. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  19055. * @param radius The radius of the cone to emit from
  19056. * @param angle The base angle of the cone
  19057. * @returns the emitter
  19058. */
  19059. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  19060. /**
  19061. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  19062. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  19063. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  19064. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  19065. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  19066. * @returns the emitter
  19067. */
  19068. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  19069. /**
  19070. * Get hosting scene
  19071. * @returns the scene
  19072. */
  19073. getScene(): Scene;
  19074. }
  19075. }
  19076. declare module "babylonjs/Meshes/instancedMesh" {
  19077. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  19078. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  19079. import { Camera } from "babylonjs/Cameras/camera";
  19080. import { Node } from "babylonjs/node";
  19081. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19082. import { Mesh } from "babylonjs/Meshes/mesh";
  19083. import { Material } from "babylonjs/Materials/material";
  19084. import { Skeleton } from "babylonjs/Bones/skeleton";
  19085. import { Light } from "babylonjs/Lights/light";
  19086. /**
  19087. * Creates an instance based on a source mesh.
  19088. */
  19089. export class InstancedMesh extends AbstractMesh {
  19090. private _sourceMesh;
  19091. private _currentLOD;
  19092. /** @hidden */
  19093. _indexInSourceMeshInstanceArray: number;
  19094. constructor(name: string, source: Mesh);
  19095. /**
  19096. * Returns the string "InstancedMesh".
  19097. */
  19098. getClassName(): string;
  19099. /** Gets the list of lights affecting that mesh */
  19100. readonly lightSources: Light[];
  19101. _resyncLightSources(): void;
  19102. _resyncLighSource(light: Light): void;
  19103. _removeLightSource(light: Light, dispose: boolean): void;
  19104. /**
  19105. * If the source mesh receives shadows
  19106. */
  19107. readonly receiveShadows: boolean;
  19108. /**
  19109. * The material of the source mesh
  19110. */
  19111. readonly material: Nullable<Material>;
  19112. /**
  19113. * Visibility of the source mesh
  19114. */
  19115. readonly visibility: number;
  19116. /**
  19117. * Skeleton of the source mesh
  19118. */
  19119. readonly skeleton: Nullable<Skeleton>;
  19120. /**
  19121. * Rendering ground id of the source mesh
  19122. */
  19123. renderingGroupId: number;
  19124. /**
  19125. * Returns the total number of vertices (integer).
  19126. */
  19127. getTotalVertices(): number;
  19128. /**
  19129. * Returns a positive integer : the total number of indices in this mesh geometry.
  19130. * @returns the numner of indices or zero if the mesh has no geometry.
  19131. */
  19132. getTotalIndices(): number;
  19133. /**
  19134. * The source mesh of the instance
  19135. */
  19136. readonly sourceMesh: Mesh;
  19137. /**
  19138. * Is this node ready to be used/rendered
  19139. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  19140. * @return {boolean} is it ready
  19141. */
  19142. isReady(completeCheck?: boolean): boolean;
  19143. /**
  19144. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  19145. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  19146. * @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.
  19147. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  19148. */
  19149. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  19150. /**
  19151. * Sets the vertex data of the mesh geometry for the requested `kind`.
  19152. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  19153. * The `data` are either a numeric array either a Float32Array.
  19154. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  19155. * 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).
  19156. * Note that a new underlying VertexBuffer object is created each call.
  19157. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  19158. *
  19159. * Possible `kind` values :
  19160. * - VertexBuffer.PositionKind
  19161. * - VertexBuffer.UVKind
  19162. * - VertexBuffer.UV2Kind
  19163. * - VertexBuffer.UV3Kind
  19164. * - VertexBuffer.UV4Kind
  19165. * - VertexBuffer.UV5Kind
  19166. * - VertexBuffer.UV6Kind
  19167. * - VertexBuffer.ColorKind
  19168. * - VertexBuffer.MatricesIndicesKind
  19169. * - VertexBuffer.MatricesIndicesExtraKind
  19170. * - VertexBuffer.MatricesWeightsKind
  19171. * - VertexBuffer.MatricesWeightsExtraKind
  19172. *
  19173. * Returns the Mesh.
  19174. */
  19175. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  19176. /**
  19177. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  19178. * If the mesh has no geometry, it is simply returned as it is.
  19179. * The `data` are either a numeric array either a Float32Array.
  19180. * No new underlying VertexBuffer object is created.
  19181. * 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.
  19182. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  19183. *
  19184. * Possible `kind` values :
  19185. * - VertexBuffer.PositionKind
  19186. * - VertexBuffer.UVKind
  19187. * - VertexBuffer.UV2Kind
  19188. * - VertexBuffer.UV3Kind
  19189. * - VertexBuffer.UV4Kind
  19190. * - VertexBuffer.UV5Kind
  19191. * - VertexBuffer.UV6Kind
  19192. * - VertexBuffer.ColorKind
  19193. * - VertexBuffer.MatricesIndicesKind
  19194. * - VertexBuffer.MatricesIndicesExtraKind
  19195. * - VertexBuffer.MatricesWeightsKind
  19196. * - VertexBuffer.MatricesWeightsExtraKind
  19197. *
  19198. * Returns the Mesh.
  19199. */
  19200. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  19201. /**
  19202. * Sets the mesh indices.
  19203. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  19204. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  19205. * This method creates a new index buffer each call.
  19206. * Returns the Mesh.
  19207. */
  19208. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  19209. /**
  19210. * Boolean : True if the mesh owns the requested kind of data.
  19211. */
  19212. isVerticesDataPresent(kind: string): boolean;
  19213. /**
  19214. * Returns an array of indices (IndicesArray).
  19215. */
  19216. getIndices(): Nullable<IndicesArray>;
  19217. readonly _positions: Nullable<Vector3[]>;
  19218. /**
  19219. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  19220. * This means the mesh underlying bounding box and sphere are recomputed.
  19221. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  19222. * @returns the current mesh
  19223. */
  19224. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  19225. /** @hidden */
  19226. _preActivate(): InstancedMesh;
  19227. /** @hidden */
  19228. _activate(renderId: number, intermediateRendering: boolean): boolean;
  19229. /** @hidden */
  19230. _postActivate(): void;
  19231. getWorldMatrix(): Matrix;
  19232. readonly isAnInstance: boolean;
  19233. /**
  19234. * Returns the current associated LOD AbstractMesh.
  19235. */
  19236. getLOD(camera: Camera): AbstractMesh;
  19237. /** @hidden */
  19238. _syncSubMeshes(): InstancedMesh;
  19239. /** @hidden */
  19240. _generatePointsArray(): boolean;
  19241. /**
  19242. * Creates a new InstancedMesh from the current mesh.
  19243. * - name (string) : the cloned mesh name
  19244. * - newParent (optional Node) : the optional Node to parent the clone to.
  19245. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  19246. *
  19247. * Returns the clone.
  19248. */
  19249. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  19250. /**
  19251. * Disposes the InstancedMesh.
  19252. * Returns nothing.
  19253. */
  19254. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  19255. }
  19256. }
  19257. declare module "babylonjs/Materials/shaderMaterial" {
  19258. import { Scene } from "babylonjs/scene";
  19259. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  19260. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19261. import { Mesh } from "babylonjs/Meshes/mesh";
  19262. import { BaseSubMesh } from "babylonjs/Meshes/subMesh";
  19263. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  19264. import { Texture } from "babylonjs/Materials/Textures/texture";
  19265. import { Material } from "babylonjs/Materials/material";
  19266. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  19267. /**
  19268. * Defines the options associated with the creation of a shader material.
  19269. */
  19270. export interface IShaderMaterialOptions {
  19271. /**
  19272. * Does the material work in alpha blend mode
  19273. */
  19274. needAlphaBlending: boolean;
  19275. /**
  19276. * Does the material work in alpha test mode
  19277. */
  19278. needAlphaTesting: boolean;
  19279. /**
  19280. * The list of attribute names used in the shader
  19281. */
  19282. attributes: string[];
  19283. /**
  19284. * The list of unifrom names used in the shader
  19285. */
  19286. uniforms: string[];
  19287. /**
  19288. * The list of UBO names used in the shader
  19289. */
  19290. uniformBuffers: string[];
  19291. /**
  19292. * The list of sampler names used in the shader
  19293. */
  19294. samplers: string[];
  19295. /**
  19296. * The list of defines used in the shader
  19297. */
  19298. defines: string[];
  19299. }
  19300. /**
  19301. * 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.
  19302. *
  19303. * This returned material effects how the mesh will look based on the code in the shaders.
  19304. *
  19305. * @see http://doc.babylonjs.com/how_to/shader_material
  19306. */
  19307. export class ShaderMaterial extends Material {
  19308. private _shaderPath;
  19309. private _options;
  19310. private _textures;
  19311. private _textureArrays;
  19312. private _floats;
  19313. private _ints;
  19314. private _floatsArrays;
  19315. private _colors3;
  19316. private _colors3Arrays;
  19317. private _colors4;
  19318. private _colors4Arrays;
  19319. private _vectors2;
  19320. private _vectors3;
  19321. private _vectors4;
  19322. private _matrices;
  19323. private _matrices3x3;
  19324. private _matrices2x2;
  19325. private _vectors2Arrays;
  19326. private _vectors3Arrays;
  19327. private _vectors4Arrays;
  19328. private _cachedWorldViewMatrix;
  19329. private _cachedWorldViewProjectionMatrix;
  19330. private _renderId;
  19331. /**
  19332. * Instantiate a new shader material.
  19333. * 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.
  19334. * This returned material effects how the mesh will look based on the code in the shaders.
  19335. * @see http://doc.babylonjs.com/how_to/shader_material
  19336. * @param name Define the name of the material in the scene
  19337. * @param scene Define the scene the material belongs to
  19338. * @param shaderPath Defines the route to the shader code in one of three ways:
  19339. * * object: { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  19340. * * object: { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in script tags
  19341. * * object: { vertexSource: "vertex shader code string", fragmentSource: "fragment shader code string" } using with strings containing the shaders code
  19342. * * string: "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  19343. * @param options Define the options used to create the shader
  19344. */
  19345. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  19346. /**
  19347. * Gets the options used to compile the shader.
  19348. * They can be modified to trigger a new compilation
  19349. */
  19350. readonly options: IShaderMaterialOptions;
  19351. /**
  19352. * Gets the current class name of the material e.g. "ShaderMaterial"
  19353. * Mainly use in serialization.
  19354. * @returns the class name
  19355. */
  19356. getClassName(): string;
  19357. /**
  19358. * Specifies if the material will require alpha blending
  19359. * @returns a boolean specifying if alpha blending is needed
  19360. */
  19361. needAlphaBlending(): boolean;
  19362. /**
  19363. * Specifies if this material should be rendered in alpha test mode
  19364. * @returns a boolean specifying if an alpha test is needed.
  19365. */
  19366. needAlphaTesting(): boolean;
  19367. private _checkUniform;
  19368. /**
  19369. * Set a texture in the shader.
  19370. * @param name Define the name of the uniform samplers as defined in the shader
  19371. * @param texture Define the texture to bind to this sampler
  19372. * @return the material itself allowing "fluent" like uniform updates
  19373. */
  19374. setTexture(name: string, texture: Texture): ShaderMaterial;
  19375. /**
  19376. * Set a texture array in the shader.
  19377. * @param name Define the name of the uniform sampler array as defined in the shader
  19378. * @param textures Define the list of textures to bind to this sampler
  19379. * @return the material itself allowing "fluent" like uniform updates
  19380. */
  19381. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  19382. /**
  19383. * Set a float in the shader.
  19384. * @param name Define the name of the uniform as defined in the shader
  19385. * @param value Define the value to give to the uniform
  19386. * @return the material itself allowing "fluent" like uniform updates
  19387. */
  19388. setFloat(name: string, value: number): ShaderMaterial;
  19389. /**
  19390. * Set a int in the shader.
  19391. * @param name Define the name of the uniform as defined in the shader
  19392. * @param value Define the value to give to the uniform
  19393. * @return the material itself allowing "fluent" like uniform updates
  19394. */
  19395. setInt(name: string, value: number): ShaderMaterial;
  19396. /**
  19397. * Set an array of floats in the shader.
  19398. * @param name Define the name of the uniform as defined in the shader
  19399. * @param value Define the value to give to the uniform
  19400. * @return the material itself allowing "fluent" like uniform updates
  19401. */
  19402. setFloats(name: string, value: number[]): ShaderMaterial;
  19403. /**
  19404. * Set a vec3 in the shader from a Color3.
  19405. * @param name Define the name of the uniform as defined in the shader
  19406. * @param value Define the value to give to the uniform
  19407. * @return the material itself allowing "fluent" like uniform updates
  19408. */
  19409. setColor3(name: string, value: Color3): ShaderMaterial;
  19410. /**
  19411. * Set a vec3 array in the shader from a Color3 array.
  19412. * @param name Define the name of the uniform as defined in the shader
  19413. * @param value Define the value to give to the uniform
  19414. * @return the material itself allowing "fluent" like uniform updates
  19415. */
  19416. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  19417. /**
  19418. * Set a vec4 in the shader from a Color4.
  19419. * @param name Define the name of the uniform as defined in the shader
  19420. * @param value Define the value to give to the uniform
  19421. * @return the material itself allowing "fluent" like uniform updates
  19422. */
  19423. setColor4(name: string, value: Color4): ShaderMaterial;
  19424. /**
  19425. * Set a vec4 array in the shader from a Color4 array.
  19426. * @param name Define the name of the uniform as defined in the shader
  19427. * @param value Define the value to give to the uniform
  19428. * @return the material itself allowing "fluent" like uniform updates
  19429. */
  19430. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  19431. /**
  19432. * Set a vec2 in the shader from a Vector2.
  19433. * @param name Define the name of the uniform as defined in the shader
  19434. * @param value Define the value to give to the uniform
  19435. * @return the material itself allowing "fluent" like uniform updates
  19436. */
  19437. setVector2(name: string, value: Vector2): ShaderMaterial;
  19438. /**
  19439. * Set a vec3 in the shader from a Vector3.
  19440. * @param name Define the name of the uniform as defined in the shader
  19441. * @param value Define the value to give to the uniform
  19442. * @return the material itself allowing "fluent" like uniform updates
  19443. */
  19444. setVector3(name: string, value: Vector3): ShaderMaterial;
  19445. /**
  19446. * Set a vec4 in the shader from a Vector4.
  19447. * @param name Define the name of the uniform as defined in the shader
  19448. * @param value Define the value to give to the uniform
  19449. * @return the material itself allowing "fluent" like uniform updates
  19450. */
  19451. setVector4(name: string, value: Vector4): ShaderMaterial;
  19452. /**
  19453. * Set a mat4 in the shader from a Matrix.
  19454. * @param name Define the name of the uniform as defined in the shader
  19455. * @param value Define the value to give to the uniform
  19456. * @return the material itself allowing "fluent" like uniform updates
  19457. */
  19458. setMatrix(name: string, value: Matrix): ShaderMaterial;
  19459. /**
  19460. * Set a mat3 in the shader from a Float32Array.
  19461. * @param name Define the name of the uniform as defined in the shader
  19462. * @param value Define the value to give to the uniform
  19463. * @return the material itself allowing "fluent" like uniform updates
  19464. */
  19465. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  19466. /**
  19467. * Set a mat2 in the shader from a Float32Array.
  19468. * @param name Define the name of the uniform as defined in the shader
  19469. * @param value Define the value to give to the uniform
  19470. * @return the material itself allowing "fluent" like uniform updates
  19471. */
  19472. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  19473. /**
  19474. * Set a vec2 array in the shader from a number array.
  19475. * @param name Define the name of the uniform as defined in the shader
  19476. * @param value Define the value to give to the uniform
  19477. * @return the material itself allowing "fluent" like uniform updates
  19478. */
  19479. setArray2(name: string, value: number[]): ShaderMaterial;
  19480. /**
  19481. * Set a vec3 array in the shader from a number array.
  19482. * @param name Define the name of the uniform as defined in the shader
  19483. * @param value Define the value to give to the uniform
  19484. * @return the material itself allowing "fluent" like uniform updates
  19485. */
  19486. setArray3(name: string, value: number[]): ShaderMaterial;
  19487. /**
  19488. * Set a vec4 array in the shader from a number array.
  19489. * @param name Define the name of the uniform as defined in the shader
  19490. * @param value Define the value to give to the uniform
  19491. * @return the material itself allowing "fluent" like uniform updates
  19492. */
  19493. setArray4(name: string, value: number[]): ShaderMaterial;
  19494. private _checkCache;
  19495. /**
  19496. * Specifies that the submesh is ready to be used
  19497. * @param mesh defines the mesh to check
  19498. * @param subMesh defines which submesh to check
  19499. * @param useInstances specifies that instances should be used
  19500. * @returns a boolean indicating that the submesh is ready or not
  19501. */
  19502. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  19503. /**
  19504. * Checks if the material is ready to render the requested mesh
  19505. * @param mesh Define the mesh to render
  19506. * @param useInstances Define whether or not the material is used with instances
  19507. * @returns true if ready, otherwise false
  19508. */
  19509. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  19510. /**
  19511. * Binds the world matrix to the material
  19512. * @param world defines the world transformation matrix
  19513. */
  19514. bindOnlyWorldMatrix(world: Matrix): void;
  19515. /**
  19516. * Binds the material to the mesh
  19517. * @param world defines the world transformation matrix
  19518. * @param mesh defines the mesh to bind the material to
  19519. */
  19520. bind(world: Matrix, mesh?: Mesh): void;
  19521. /**
  19522. * Gets the active textures from the material
  19523. * @returns an array of textures
  19524. */
  19525. getActiveTextures(): BaseTexture[];
  19526. /**
  19527. * Specifies if the material uses a texture
  19528. * @param texture defines the texture to check against the material
  19529. * @returns a boolean specifying if the material uses the texture
  19530. */
  19531. hasTexture(texture: BaseTexture): boolean;
  19532. /**
  19533. * Makes a duplicate of the material, and gives it a new name
  19534. * @param name defines the new name for the duplicated material
  19535. * @returns the cloned material
  19536. */
  19537. clone(name: string): ShaderMaterial;
  19538. /**
  19539. * Disposes the material
  19540. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  19541. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  19542. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  19543. */
  19544. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  19545. /**
  19546. * Serializes this material in a JSON representation
  19547. * @returns the serialized material object
  19548. */
  19549. serialize(): any;
  19550. /**
  19551. * Creates a shader material from parsed shader material data
  19552. * @param source defines the JSON represnetation of the material
  19553. * @param scene defines the hosting scene
  19554. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  19555. * @returns a new material
  19556. */
  19557. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  19558. }
  19559. }
  19560. declare module "babylonjs/Shaders/color.fragment" {
  19561. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  19562. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  19563. /** @hidden */
  19564. export var colorPixelShader: {
  19565. name: string;
  19566. shader: string;
  19567. };
  19568. }
  19569. declare module "babylonjs/Shaders/color.vertex" {
  19570. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  19571. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  19572. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  19573. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  19574. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  19575. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  19576. /** @hidden */
  19577. export var colorVertexShader: {
  19578. name: string;
  19579. shader: string;
  19580. };
  19581. }
  19582. declare module "babylonjs/Meshes/linesMesh" {
  19583. import { Nullable } from "babylonjs/types";
  19584. import { Scene } from "babylonjs/scene";
  19585. import { Color3 } from "babylonjs/Maths/math.color";
  19586. import { Node } from "babylonjs/node";
  19587. import { SubMesh } from "babylonjs/Meshes/subMesh";
  19588. import { Mesh } from "babylonjs/Meshes/mesh";
  19589. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  19590. import { Effect } from "babylonjs/Materials/effect";
  19591. import { Material } from "babylonjs/Materials/material";
  19592. import "babylonjs/Shaders/color.fragment";
  19593. import "babylonjs/Shaders/color.vertex";
  19594. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19595. /**
  19596. * Line mesh
  19597. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  19598. */
  19599. export class LinesMesh extends Mesh {
  19600. /**
  19601. * If vertex color should be applied to the mesh
  19602. */
  19603. readonly useVertexColor?: boolean | undefined;
  19604. /**
  19605. * If vertex alpha should be applied to the mesh
  19606. */
  19607. readonly useVertexAlpha?: boolean | undefined;
  19608. /**
  19609. * Color of the line (Default: White)
  19610. */
  19611. color: Color3;
  19612. /**
  19613. * Alpha of the line (Default: 1)
  19614. */
  19615. alpha: number;
  19616. /**
  19617. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  19618. * This margin is expressed in world space coordinates, so its value may vary.
  19619. * Default value is 0.1
  19620. */
  19621. intersectionThreshold: number;
  19622. private _colorShader;
  19623. private color4;
  19624. /**
  19625. * Creates a new LinesMesh
  19626. * @param name defines the name
  19627. * @param scene defines the hosting scene
  19628. * @param parent defines the parent mesh if any
  19629. * @param source defines the optional source LinesMesh used to clone data from
  19630. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  19631. * When false, achieved by calling a clone(), also passing False.
  19632. * This will make creation of children, recursive.
  19633. * @param useVertexColor defines if this LinesMesh supports vertex color
  19634. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  19635. */
  19636. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<LinesMesh>, doNotCloneChildren?: boolean,
  19637. /**
  19638. * If vertex color should be applied to the mesh
  19639. */
  19640. useVertexColor?: boolean | undefined,
  19641. /**
  19642. * If vertex alpha should be applied to the mesh
  19643. */
  19644. useVertexAlpha?: boolean | undefined);
  19645. private _addClipPlaneDefine;
  19646. private _removeClipPlaneDefine;
  19647. isReady(): boolean;
  19648. /**
  19649. * Returns the string "LineMesh"
  19650. */
  19651. getClassName(): string;
  19652. /**
  19653. * @hidden
  19654. */
  19655. /**
  19656. * @hidden
  19657. */
  19658. material: Material;
  19659. /**
  19660. * @hidden
  19661. */
  19662. readonly checkCollisions: boolean;
  19663. /** @hidden */
  19664. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  19665. /** @hidden */
  19666. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  19667. /**
  19668. * Disposes of the line mesh
  19669. * @param doNotRecurse If children should be disposed
  19670. */
  19671. dispose(doNotRecurse?: boolean): void;
  19672. /**
  19673. * Returns a new LineMesh object cloned from the current one.
  19674. */
  19675. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  19676. /**
  19677. * Creates a new InstancedLinesMesh object from the mesh model.
  19678. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  19679. * @param name defines the name of the new instance
  19680. * @returns a new InstancedLinesMesh
  19681. */
  19682. createInstance(name: string): InstancedLinesMesh;
  19683. }
  19684. /**
  19685. * Creates an instance based on a source LinesMesh
  19686. */
  19687. export class InstancedLinesMesh extends InstancedMesh {
  19688. /**
  19689. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  19690. * This margin is expressed in world space coordinates, so its value may vary.
  19691. * Initilized with the intersectionThreshold value of the source LinesMesh
  19692. */
  19693. intersectionThreshold: number;
  19694. constructor(name: string, source: LinesMesh);
  19695. /**
  19696. * Returns the string "InstancedLinesMesh".
  19697. */
  19698. getClassName(): string;
  19699. }
  19700. }
  19701. declare module "babylonjs/Shaders/line.fragment" {
  19702. /** @hidden */
  19703. export var linePixelShader: {
  19704. name: string;
  19705. shader: string;
  19706. };
  19707. }
  19708. declare module "babylonjs/Shaders/line.vertex" {
  19709. /** @hidden */
  19710. export var lineVertexShader: {
  19711. name: string;
  19712. shader: string;
  19713. };
  19714. }
  19715. declare module "babylonjs/Rendering/edgesRenderer" {
  19716. import { Nullable } from "babylonjs/types";
  19717. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  19718. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19719. import { Vector3 } from "babylonjs/Maths/math.vector";
  19720. import { IDisposable } from "babylonjs/scene";
  19721. import { ShaderMaterial } from "babylonjs/Materials/shaderMaterial";
  19722. import "babylonjs/Shaders/line.fragment";
  19723. import "babylonjs/Shaders/line.vertex";
  19724. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  19725. module "babylonjs/Meshes/abstractMesh" {
  19726. interface AbstractMesh {
  19727. /**
  19728. * Gets the edgesRenderer associated with the mesh
  19729. */
  19730. edgesRenderer: Nullable<EdgesRenderer>;
  19731. }
  19732. }
  19733. module "babylonjs/Meshes/linesMesh" {
  19734. interface LinesMesh {
  19735. /**
  19736. * Enables the edge rendering mode on the mesh.
  19737. * This mode makes the mesh edges visible
  19738. * @param epsilon defines the maximal distance between two angles to detect a face
  19739. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  19740. * @returns the currentAbstractMesh
  19741. * @see https://www.babylonjs-playground.com/#19O9TU#0
  19742. */
  19743. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  19744. }
  19745. }
  19746. module "babylonjs/Meshes/linesMesh" {
  19747. interface InstancedLinesMesh {
  19748. /**
  19749. * Enables the edge rendering mode on the mesh.
  19750. * This mode makes the mesh edges visible
  19751. * @param epsilon defines the maximal distance between two angles to detect a face
  19752. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  19753. * @returns the current InstancedLinesMesh
  19754. * @see https://www.babylonjs-playground.com/#19O9TU#0
  19755. */
  19756. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  19757. }
  19758. }
  19759. /**
  19760. * Defines the minimum contract an Edges renderer should follow.
  19761. */
  19762. export interface IEdgesRenderer extends IDisposable {
  19763. /**
  19764. * Gets or sets a boolean indicating if the edgesRenderer is active
  19765. */
  19766. isEnabled: boolean;
  19767. /**
  19768. * Renders the edges of the attached mesh,
  19769. */
  19770. render(): void;
  19771. /**
  19772. * Checks wether or not the edges renderer is ready to render.
  19773. * @return true if ready, otherwise false.
  19774. */
  19775. isReady(): boolean;
  19776. }
  19777. /**
  19778. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  19779. */
  19780. export class EdgesRenderer implements IEdgesRenderer {
  19781. /**
  19782. * Define the size of the edges with an orthographic camera
  19783. */
  19784. edgesWidthScalerForOrthographic: number;
  19785. /**
  19786. * Define the size of the edges with a perspective camera
  19787. */
  19788. edgesWidthScalerForPerspective: number;
  19789. protected _source: AbstractMesh;
  19790. protected _linesPositions: number[];
  19791. protected _linesNormals: number[];
  19792. protected _linesIndices: number[];
  19793. protected _epsilon: number;
  19794. protected _indicesCount: number;
  19795. protected _lineShader: ShaderMaterial;
  19796. protected _ib: DataBuffer;
  19797. protected _buffers: {
  19798. [key: string]: Nullable<VertexBuffer>;
  19799. };
  19800. protected _checkVerticesInsteadOfIndices: boolean;
  19801. private _meshRebuildObserver;
  19802. private _meshDisposeObserver;
  19803. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  19804. isEnabled: boolean;
  19805. /**
  19806. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  19807. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  19808. * @param source Mesh used to create edges
  19809. * @param epsilon sum of angles in adjacency to check for edge
  19810. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  19811. * @param generateEdgesLines - should generate Lines or only prepare resources.
  19812. */
  19813. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  19814. protected _prepareRessources(): void;
  19815. /** @hidden */
  19816. _rebuild(): void;
  19817. /**
  19818. * Releases the required resources for the edges renderer
  19819. */
  19820. dispose(): void;
  19821. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  19822. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  19823. /**
  19824. * Checks if the pair of p0 and p1 is en edge
  19825. * @param faceIndex
  19826. * @param edge
  19827. * @param faceNormals
  19828. * @param p0
  19829. * @param p1
  19830. * @private
  19831. */
  19832. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  19833. /**
  19834. * push line into the position, normal and index buffer
  19835. * @protected
  19836. */
  19837. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  19838. /**
  19839. * Generates lines edges from adjacencjes
  19840. * @private
  19841. */
  19842. _generateEdgesLines(): void;
  19843. /**
  19844. * Checks wether or not the edges renderer is ready to render.
  19845. * @return true if ready, otherwise false.
  19846. */
  19847. isReady(): boolean;
  19848. /**
  19849. * Renders the edges of the attached mesh,
  19850. */
  19851. render(): void;
  19852. }
  19853. /**
  19854. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  19855. */
  19856. export class LineEdgesRenderer extends EdgesRenderer {
  19857. /**
  19858. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  19859. * @param source LineMesh used to generate edges
  19860. * @param epsilon not important (specified angle for edge detection)
  19861. * @param checkVerticesInsteadOfIndices not important for LineMesh
  19862. */
  19863. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  19864. /**
  19865. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  19866. */
  19867. _generateEdgesLines(): void;
  19868. }
  19869. }
  19870. declare module "babylonjs/Rendering/renderingGroup" {
  19871. import { SmartArray } from "babylonjs/Misc/smartArray";
  19872. import { SubMesh } from "babylonjs/Meshes/subMesh";
  19873. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19874. import { Nullable } from "babylonjs/types";
  19875. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  19876. import { IEdgesRenderer } from "babylonjs/Rendering/edgesRenderer";
  19877. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  19878. import { Material } from "babylonjs/Materials/material";
  19879. import { Scene } from "babylonjs/scene";
  19880. /**
  19881. * This represents the object necessary to create a rendering group.
  19882. * This is exclusively used and created by the rendering manager.
  19883. * To modify the behavior, you use the available helpers in your scene or meshes.
  19884. * @hidden
  19885. */
  19886. export class RenderingGroup {
  19887. index: number;
  19888. private static _zeroVector;
  19889. private _scene;
  19890. private _opaqueSubMeshes;
  19891. private _transparentSubMeshes;
  19892. private _alphaTestSubMeshes;
  19893. private _depthOnlySubMeshes;
  19894. private _particleSystems;
  19895. private _spriteManagers;
  19896. private _opaqueSortCompareFn;
  19897. private _alphaTestSortCompareFn;
  19898. private _transparentSortCompareFn;
  19899. private _renderOpaque;
  19900. private _renderAlphaTest;
  19901. private _renderTransparent;
  19902. /** @hidden */
  19903. _edgesRenderers: SmartArray<IEdgesRenderer>;
  19904. onBeforeTransparentRendering: () => void;
  19905. /**
  19906. * Set the opaque sort comparison function.
  19907. * If null the sub meshes will be render in the order they were created
  19908. */
  19909. opaqueSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  19910. /**
  19911. * Set the alpha test sort comparison function.
  19912. * If null the sub meshes will be render in the order they were created
  19913. */
  19914. alphaTestSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  19915. /**
  19916. * Set the transparent sort comparison function.
  19917. * If null the sub meshes will be render in the order they were created
  19918. */
  19919. transparentSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  19920. /**
  19921. * Creates a new rendering group.
  19922. * @param index The rendering group index
  19923. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  19924. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  19925. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  19926. */
  19927. 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>);
  19928. /**
  19929. * Render all the sub meshes contained in the group.
  19930. * @param customRenderFunction Used to override the default render behaviour of the group.
  19931. * @returns true if rendered some submeshes.
  19932. */
  19933. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  19934. /**
  19935. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  19936. * @param subMeshes The submeshes to render
  19937. */
  19938. private renderOpaqueSorted;
  19939. /**
  19940. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  19941. * @param subMeshes The submeshes to render
  19942. */
  19943. private renderAlphaTestSorted;
  19944. /**
  19945. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  19946. * @param subMeshes The submeshes to render
  19947. */
  19948. private renderTransparentSorted;
  19949. /**
  19950. * Renders the submeshes in a specified order.
  19951. * @param subMeshes The submeshes to sort before render
  19952. * @param sortCompareFn The comparison function use to sort
  19953. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  19954. * @param transparent Specifies to activate blending if true
  19955. */
  19956. private static renderSorted;
  19957. /**
  19958. * Renders the submeshes in the order they were dispatched (no sort applied).
  19959. * @param subMeshes The submeshes to render
  19960. */
  19961. private static renderUnsorted;
  19962. /**
  19963. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  19964. * are rendered back to front if in the same alpha index.
  19965. *
  19966. * @param a The first submesh
  19967. * @param b The second submesh
  19968. * @returns The result of the comparison
  19969. */
  19970. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  19971. /**
  19972. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  19973. * are rendered back to front.
  19974. *
  19975. * @param a The first submesh
  19976. * @param b The second submesh
  19977. * @returns The result of the comparison
  19978. */
  19979. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  19980. /**
  19981. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  19982. * are rendered front to back (prevent overdraw).
  19983. *
  19984. * @param a The first submesh
  19985. * @param b The second submesh
  19986. * @returns The result of the comparison
  19987. */
  19988. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  19989. /**
  19990. * Resets the different lists of submeshes to prepare a new frame.
  19991. */
  19992. prepare(): void;
  19993. dispose(): void;
  19994. /**
  19995. * Inserts the submesh in its correct queue depending on its material.
  19996. * @param subMesh The submesh to dispatch
  19997. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  19998. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  19999. */
  20000. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  20001. dispatchSprites(spriteManager: ISpriteManager): void;
  20002. dispatchParticles(particleSystem: IParticleSystem): void;
  20003. private _renderParticles;
  20004. private _renderSprites;
  20005. }
  20006. }
  20007. declare module "babylonjs/Rendering/renderingManager" {
  20008. import { Nullable } from "babylonjs/types";
  20009. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20010. import { SubMesh } from "babylonjs/Meshes/subMesh";
  20011. import { SmartArray } from "babylonjs/Misc/smartArray";
  20012. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  20013. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  20014. import { Material } from "babylonjs/Materials/material";
  20015. import { Scene } from "babylonjs/scene";
  20016. import { Camera } from "babylonjs/Cameras/camera";
  20017. /**
  20018. * Interface describing the different options available in the rendering manager
  20019. * regarding Auto Clear between groups.
  20020. */
  20021. export interface IRenderingManagerAutoClearSetup {
  20022. /**
  20023. * Defines whether or not autoclear is enable.
  20024. */
  20025. autoClear: boolean;
  20026. /**
  20027. * Defines whether or not to autoclear the depth buffer.
  20028. */
  20029. depth: boolean;
  20030. /**
  20031. * Defines whether or not to autoclear the stencil buffer.
  20032. */
  20033. stencil: boolean;
  20034. }
  20035. /**
  20036. * This class is used by the onRenderingGroupObservable
  20037. */
  20038. export class RenderingGroupInfo {
  20039. /**
  20040. * The Scene that being rendered
  20041. */
  20042. scene: Scene;
  20043. /**
  20044. * The camera currently used for the rendering pass
  20045. */
  20046. camera: Nullable<Camera>;
  20047. /**
  20048. * The ID of the renderingGroup being processed
  20049. */
  20050. renderingGroupId: number;
  20051. }
  20052. /**
  20053. * This is the manager responsible of all the rendering for meshes sprites and particles.
  20054. * It is enable to manage the different groups as well as the different necessary sort functions.
  20055. * This should not be used directly aside of the few static configurations
  20056. */
  20057. export class RenderingManager {
  20058. /**
  20059. * The max id used for rendering groups (not included)
  20060. */
  20061. static MAX_RENDERINGGROUPS: number;
  20062. /**
  20063. * The min id used for rendering groups (included)
  20064. */
  20065. static MIN_RENDERINGGROUPS: number;
  20066. /**
  20067. * Used to globally prevent autoclearing scenes.
  20068. */
  20069. static AUTOCLEAR: boolean;
  20070. /**
  20071. * @hidden
  20072. */
  20073. _useSceneAutoClearSetup: boolean;
  20074. private _scene;
  20075. private _renderingGroups;
  20076. private _depthStencilBufferAlreadyCleaned;
  20077. private _autoClearDepthStencil;
  20078. private _customOpaqueSortCompareFn;
  20079. private _customAlphaTestSortCompareFn;
  20080. private _customTransparentSortCompareFn;
  20081. private _renderingGroupInfo;
  20082. /**
  20083. * Instantiates a new rendering group for a particular scene
  20084. * @param scene Defines the scene the groups belongs to
  20085. */
  20086. constructor(scene: Scene);
  20087. private _clearDepthStencilBuffer;
  20088. /**
  20089. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  20090. * @hidden
  20091. */
  20092. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  20093. /**
  20094. * Resets the different information of the group to prepare a new frame
  20095. * @hidden
  20096. */
  20097. reset(): void;
  20098. /**
  20099. * Dispose and release the group and its associated resources.
  20100. * @hidden
  20101. */
  20102. dispose(): void;
  20103. /**
  20104. * Clear the info related to rendering groups preventing retention points during dispose.
  20105. */
  20106. freeRenderingGroups(): void;
  20107. private _prepareRenderingGroup;
  20108. /**
  20109. * Add a sprite manager to the rendering manager in order to render it this frame.
  20110. * @param spriteManager Define the sprite manager to render
  20111. */
  20112. dispatchSprites(spriteManager: ISpriteManager): void;
  20113. /**
  20114. * Add a particle system to the rendering manager in order to render it this frame.
  20115. * @param particleSystem Define the particle system to render
  20116. */
  20117. dispatchParticles(particleSystem: IParticleSystem): void;
  20118. /**
  20119. * Add a submesh to the manager in order to render it this frame
  20120. * @param subMesh The submesh to dispatch
  20121. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  20122. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  20123. */
  20124. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  20125. /**
  20126. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  20127. * This allowed control for front to back rendering or reversly depending of the special needs.
  20128. *
  20129. * @param renderingGroupId The rendering group id corresponding to its index
  20130. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  20131. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  20132. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  20133. */
  20134. 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;
  20135. /**
  20136. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  20137. *
  20138. * @param renderingGroupId The rendering group id corresponding to its index
  20139. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  20140. * @param depth Automatically clears depth between groups if true and autoClear is true.
  20141. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  20142. */
  20143. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  20144. /**
  20145. * Gets the current auto clear configuration for one rendering group of the rendering
  20146. * manager.
  20147. * @param index the rendering group index to get the information for
  20148. * @returns The auto clear setup for the requested rendering group
  20149. */
  20150. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  20151. }
  20152. }
  20153. declare module "babylonjs/Materials/Textures/renderTargetTexture" {
  20154. import { Observable } from "babylonjs/Misc/observable";
  20155. import { SmartArray } from "babylonjs/Misc/smartArray";
  20156. import { Nullable } from "babylonjs/types";
  20157. import { Camera } from "babylonjs/Cameras/camera";
  20158. import { Scene } from "babylonjs/scene";
  20159. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  20160. import { Color4 } from "babylonjs/Maths/math.color";
  20161. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  20162. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20163. import { SubMesh } from "babylonjs/Meshes/subMesh";
  20164. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  20165. import { Texture } from "babylonjs/Materials/Textures/texture";
  20166. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  20167. import { RenderingManager } from "babylonjs/Rendering/renderingManager";
  20168. import "babylonjs/Engines/Extensions/engine.renderTarget";
  20169. import { Engine } from "babylonjs/Engines/engine";
  20170. /**
  20171. * This Helps creating a texture that will be created from a camera in your scene.
  20172. * It is basically a dynamic texture that could be used to create special effects for instance.
  20173. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  20174. */
  20175. export class RenderTargetTexture extends Texture {
  20176. isCube: boolean;
  20177. /**
  20178. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  20179. */
  20180. static readonly REFRESHRATE_RENDER_ONCE: number;
  20181. /**
  20182. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  20183. */
  20184. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  20185. /**
  20186. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  20187. * the central point of your effect and can save a lot of performances.
  20188. */
  20189. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  20190. /**
  20191. * Use this predicate to dynamically define the list of mesh you want to render.
  20192. * If set, the renderList property will be overwritten.
  20193. */
  20194. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  20195. private _renderList;
  20196. /**
  20197. * Use this list to define the list of mesh you want to render.
  20198. */
  20199. renderList: Nullable<Array<AbstractMesh>>;
  20200. private _hookArray;
  20201. /**
  20202. * Define if particles should be rendered in your texture.
  20203. */
  20204. renderParticles: boolean;
  20205. /**
  20206. * Define if sprites should be rendered in your texture.
  20207. */
  20208. renderSprites: boolean;
  20209. /**
  20210. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  20211. */
  20212. coordinatesMode: number;
  20213. /**
  20214. * Define the camera used to render the texture.
  20215. */
  20216. activeCamera: Nullable<Camera>;
  20217. /**
  20218. * Override the render function of the texture with your own one.
  20219. */
  20220. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  20221. /**
  20222. * Define if camera post processes should be use while rendering the texture.
  20223. */
  20224. useCameraPostProcesses: boolean;
  20225. /**
  20226. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  20227. */
  20228. ignoreCameraViewport: boolean;
  20229. private _postProcessManager;
  20230. private _postProcesses;
  20231. private _resizeObserver;
  20232. /**
  20233. * An event triggered when the texture is unbind.
  20234. */
  20235. onBeforeBindObservable: Observable<RenderTargetTexture>;
  20236. /**
  20237. * An event triggered when the texture is unbind.
  20238. */
  20239. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  20240. private _onAfterUnbindObserver;
  20241. /**
  20242. * Set a after unbind callback in the texture.
  20243. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  20244. */
  20245. onAfterUnbind: () => void;
  20246. /**
  20247. * An event triggered before rendering the texture
  20248. */
  20249. onBeforeRenderObservable: Observable<number>;
  20250. private _onBeforeRenderObserver;
  20251. /**
  20252. * Set a before render callback in the texture.
  20253. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  20254. */
  20255. onBeforeRender: (faceIndex: number) => void;
  20256. /**
  20257. * An event triggered after rendering the texture
  20258. */
  20259. onAfterRenderObservable: Observable<number>;
  20260. private _onAfterRenderObserver;
  20261. /**
  20262. * Set a after render callback in the texture.
  20263. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  20264. */
  20265. onAfterRender: (faceIndex: number) => void;
  20266. /**
  20267. * An event triggered after the texture clear
  20268. */
  20269. onClearObservable: Observable<Engine>;
  20270. private _onClearObserver;
  20271. /**
  20272. * Set a clear callback in the texture.
  20273. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  20274. */
  20275. onClear: (Engine: Engine) => void;
  20276. /**
  20277. * An event triggered when the texture is resized.
  20278. */
  20279. onResizeObservable: Observable<RenderTargetTexture>;
  20280. /**
  20281. * Define the clear color of the Render Target if it should be different from the scene.
  20282. */
  20283. clearColor: Color4;
  20284. protected _size: number | {
  20285. width: number;
  20286. height: number;
  20287. };
  20288. protected _initialSizeParameter: number | {
  20289. width: number;
  20290. height: number;
  20291. } | {
  20292. ratio: number;
  20293. };
  20294. protected _sizeRatio: Nullable<number>;
  20295. /** @hidden */
  20296. _generateMipMaps: boolean;
  20297. protected _renderingManager: RenderingManager;
  20298. /** @hidden */
  20299. _waitingRenderList: string[];
  20300. protected _doNotChangeAspectRatio: boolean;
  20301. protected _currentRefreshId: number;
  20302. protected _refreshRate: number;
  20303. protected _textureMatrix: Matrix;
  20304. protected _samples: number;
  20305. protected _renderTargetOptions: RenderTargetCreationOptions;
  20306. /**
  20307. * Gets render target creation options that were used.
  20308. */
  20309. readonly renderTargetOptions: RenderTargetCreationOptions;
  20310. protected _engine: Engine;
  20311. protected _onRatioRescale(): void;
  20312. /**
  20313. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  20314. * It must define where the camera used to render the texture is set
  20315. */
  20316. boundingBoxPosition: Vector3;
  20317. private _boundingBoxSize;
  20318. /**
  20319. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  20320. * When defined, the cubemap will switch to local mode
  20321. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  20322. * @example https://www.babylonjs-playground.com/#RNASML
  20323. */
  20324. boundingBoxSize: Vector3;
  20325. /**
  20326. * In case the RTT has been created with a depth texture, get the associated
  20327. * depth texture.
  20328. * Otherwise, return null.
  20329. */
  20330. depthStencilTexture: Nullable<InternalTexture>;
  20331. /**
  20332. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  20333. * or used a shadow, depth texture...
  20334. * @param name The friendly name of the texture
  20335. * @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)
  20336. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  20337. * @param generateMipMaps True if mip maps need to be generated after render.
  20338. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  20339. * @param type The type of the buffer in the RTT (int, half float, float...)
  20340. * @param isCube True if a cube texture needs to be created
  20341. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  20342. * @param generateDepthBuffer True to generate a depth buffer
  20343. * @param generateStencilBuffer True to generate a stencil buffer
  20344. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  20345. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  20346. * @param delayAllocation if the texture allocation should be delayed (default: false)
  20347. */
  20348. constructor(name: string, size: number | {
  20349. width: number;
  20350. height: number;
  20351. } | {
  20352. ratio: number;
  20353. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  20354. /**
  20355. * Creates a depth stencil texture.
  20356. * This is only available in WebGL 2 or with the depth texture extension available.
  20357. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  20358. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  20359. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  20360. */
  20361. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  20362. private _processSizeParameter;
  20363. /**
  20364. * Define the number of samples to use in case of MSAA.
  20365. * It defaults to one meaning no MSAA has been enabled.
  20366. */
  20367. samples: number;
  20368. /**
  20369. * Resets the refresh counter of the texture and start bak from scratch.
  20370. * Could be useful to regenerate the texture if it is setup to render only once.
  20371. */
  20372. resetRefreshCounter(): void;
  20373. /**
  20374. * Define the refresh rate of the texture or the rendering frequency.
  20375. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  20376. */
  20377. refreshRate: number;
  20378. /**
  20379. * Adds a post process to the render target rendering passes.
  20380. * @param postProcess define the post process to add
  20381. */
  20382. addPostProcess(postProcess: PostProcess): void;
  20383. /**
  20384. * Clear all the post processes attached to the render target
  20385. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  20386. */
  20387. clearPostProcesses(dispose?: boolean): void;
  20388. /**
  20389. * Remove one of the post process from the list of attached post processes to the texture
  20390. * @param postProcess define the post process to remove from the list
  20391. */
  20392. removePostProcess(postProcess: PostProcess): void;
  20393. /** @hidden */
  20394. _shouldRender(): boolean;
  20395. /**
  20396. * Gets the actual render size of the texture.
  20397. * @returns the width of the render size
  20398. */
  20399. getRenderSize(): number;
  20400. /**
  20401. * Gets the actual render width of the texture.
  20402. * @returns the width of the render size
  20403. */
  20404. getRenderWidth(): number;
  20405. /**
  20406. * Gets the actual render height of the texture.
  20407. * @returns the height of the render size
  20408. */
  20409. getRenderHeight(): number;
  20410. /**
  20411. * Get if the texture can be rescaled or not.
  20412. */
  20413. readonly canRescale: boolean;
  20414. /**
  20415. * Resize the texture using a ratio.
  20416. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  20417. */
  20418. scale(ratio: number): void;
  20419. /**
  20420. * Get the texture reflection matrix used to rotate/transform the reflection.
  20421. * @returns the reflection matrix
  20422. */
  20423. getReflectionTextureMatrix(): Matrix;
  20424. /**
  20425. * Resize the texture to a new desired size.
  20426. * Be carrefull as it will recreate all the data in the new texture.
  20427. * @param size Define the new size. It can be:
  20428. * - a number for squared texture,
  20429. * - an object containing { width: number, height: number }
  20430. * - or an object containing a ratio { ratio: number }
  20431. */
  20432. resize(size: number | {
  20433. width: number;
  20434. height: number;
  20435. } | {
  20436. ratio: number;
  20437. }): void;
  20438. /**
  20439. * Renders all the objects from the render list into the texture.
  20440. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  20441. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  20442. */
  20443. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  20444. private _bestReflectionRenderTargetDimension;
  20445. /**
  20446. * @hidden
  20447. * @param faceIndex face index to bind to if this is a cubetexture
  20448. */
  20449. _bindFrameBuffer(faceIndex?: number): void;
  20450. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  20451. private renderToTarget;
  20452. /**
  20453. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  20454. * This allowed control for front to back rendering or reversly depending of the special needs.
  20455. *
  20456. * @param renderingGroupId The rendering group id corresponding to its index
  20457. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  20458. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  20459. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  20460. */
  20461. 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;
  20462. /**
  20463. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  20464. *
  20465. * @param renderingGroupId The rendering group id corresponding to its index
  20466. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  20467. */
  20468. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  20469. /**
  20470. * Clones the texture.
  20471. * @returns the cloned texture
  20472. */
  20473. clone(): RenderTargetTexture;
  20474. /**
  20475. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  20476. * @returns The JSON representation of the texture
  20477. */
  20478. serialize(): any;
  20479. /**
  20480. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  20481. */
  20482. disposeFramebufferObjects(): void;
  20483. /**
  20484. * Dispose the texture and release its associated resources.
  20485. */
  20486. dispose(): void;
  20487. /** @hidden */
  20488. _rebuild(): void;
  20489. /**
  20490. * Clear the info related to rendering groups preventing retention point in material dispose.
  20491. */
  20492. freeRenderingGroups(): void;
  20493. /**
  20494. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  20495. * @returns the view count
  20496. */
  20497. getViewCount(): number;
  20498. }
  20499. }
  20500. declare module "babylonjs/Materials/material" {
  20501. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  20502. import { SmartArray } from "babylonjs/Misc/smartArray";
  20503. import { Observable } from "babylonjs/Misc/observable";
  20504. import { Nullable } from "babylonjs/types";
  20505. import { Scene } from "babylonjs/scene";
  20506. import { Matrix } from "babylonjs/Maths/math.vector";
  20507. import { BaseSubMesh, SubMesh } from "babylonjs/Meshes/subMesh";
  20508. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20509. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  20510. import { Effect } from "babylonjs/Materials/effect";
  20511. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  20512. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  20513. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  20514. import { IInspectable } from "babylonjs/Misc/iInspectable";
  20515. import { Mesh } from "babylonjs/Meshes/mesh";
  20516. import { Animation } from "babylonjs/Animations/animation";
  20517. /**
  20518. * Base class for the main features of a material in Babylon.js
  20519. */
  20520. export class Material implements IAnimatable {
  20521. /**
  20522. * Returns the triangle fill mode
  20523. */
  20524. static readonly TriangleFillMode: number;
  20525. /**
  20526. * Returns the wireframe mode
  20527. */
  20528. static readonly WireFrameFillMode: number;
  20529. /**
  20530. * Returns the point fill mode
  20531. */
  20532. static readonly PointFillMode: number;
  20533. /**
  20534. * Returns the point list draw mode
  20535. */
  20536. static readonly PointListDrawMode: number;
  20537. /**
  20538. * Returns the line list draw mode
  20539. */
  20540. static readonly LineListDrawMode: number;
  20541. /**
  20542. * Returns the line loop draw mode
  20543. */
  20544. static readonly LineLoopDrawMode: number;
  20545. /**
  20546. * Returns the line strip draw mode
  20547. */
  20548. static readonly LineStripDrawMode: number;
  20549. /**
  20550. * Returns the triangle strip draw mode
  20551. */
  20552. static readonly TriangleStripDrawMode: number;
  20553. /**
  20554. * Returns the triangle fan draw mode
  20555. */
  20556. static readonly TriangleFanDrawMode: number;
  20557. /**
  20558. * Stores the clock-wise side orientation
  20559. */
  20560. static readonly ClockWiseSideOrientation: number;
  20561. /**
  20562. * Stores the counter clock-wise side orientation
  20563. */
  20564. static readonly CounterClockWiseSideOrientation: number;
  20565. /**
  20566. * The dirty texture flag value
  20567. */
  20568. static readonly TextureDirtyFlag: number;
  20569. /**
  20570. * The dirty light flag value
  20571. */
  20572. static readonly LightDirtyFlag: number;
  20573. /**
  20574. * The dirty fresnel flag value
  20575. */
  20576. static readonly FresnelDirtyFlag: number;
  20577. /**
  20578. * The dirty attribute flag value
  20579. */
  20580. static readonly AttributesDirtyFlag: number;
  20581. /**
  20582. * The dirty misc flag value
  20583. */
  20584. static readonly MiscDirtyFlag: number;
  20585. /**
  20586. * The all dirty flag value
  20587. */
  20588. static readonly AllDirtyFlag: number;
  20589. /**
  20590. * The ID of the material
  20591. */
  20592. id: string;
  20593. /**
  20594. * Gets or sets the unique id of the material
  20595. */
  20596. uniqueId: number;
  20597. /**
  20598. * The name of the material
  20599. */
  20600. name: string;
  20601. /**
  20602. * Gets or sets user defined metadata
  20603. */
  20604. metadata: any;
  20605. /**
  20606. * For internal use only. Please do not use.
  20607. */
  20608. reservedDataStore: any;
  20609. /**
  20610. * Specifies if the ready state should be checked on each call
  20611. */
  20612. checkReadyOnEveryCall: boolean;
  20613. /**
  20614. * Specifies if the ready state should be checked once
  20615. */
  20616. checkReadyOnlyOnce: boolean;
  20617. /**
  20618. * The state of the material
  20619. */
  20620. state: string;
  20621. /**
  20622. * The alpha value of the material
  20623. */
  20624. protected _alpha: number;
  20625. /**
  20626. * List of inspectable custom properties (used by the Inspector)
  20627. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  20628. */
  20629. inspectableCustomProperties: IInspectable[];
  20630. /**
  20631. * Sets the alpha value of the material
  20632. */
  20633. /**
  20634. * Gets the alpha value of the material
  20635. */
  20636. alpha: number;
  20637. /**
  20638. * Specifies if back face culling is enabled
  20639. */
  20640. protected _backFaceCulling: boolean;
  20641. /**
  20642. * Sets the back-face culling state
  20643. */
  20644. /**
  20645. * Gets the back-face culling state
  20646. */
  20647. backFaceCulling: boolean;
  20648. /**
  20649. * Stores the value for side orientation
  20650. */
  20651. sideOrientation: number;
  20652. /**
  20653. * Callback triggered when the material is compiled
  20654. */
  20655. onCompiled: Nullable<(effect: Effect) => void>;
  20656. /**
  20657. * Callback triggered when an error occurs
  20658. */
  20659. onError: Nullable<(effect: Effect, errors: string) => void>;
  20660. /**
  20661. * Callback triggered to get the render target textures
  20662. */
  20663. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  20664. /**
  20665. * Gets a boolean indicating that current material needs to register RTT
  20666. */
  20667. readonly hasRenderTargetTextures: boolean;
  20668. /**
  20669. * Specifies if the material should be serialized
  20670. */
  20671. doNotSerialize: boolean;
  20672. /**
  20673. * @hidden
  20674. */
  20675. _storeEffectOnSubMeshes: boolean;
  20676. /**
  20677. * Stores the animations for the material
  20678. */
  20679. animations: Nullable<Array<Animation>>;
  20680. /**
  20681. * An event triggered when the material is disposed
  20682. */
  20683. onDisposeObservable: Observable<Material>;
  20684. /**
  20685. * An observer which watches for dispose events
  20686. */
  20687. private _onDisposeObserver;
  20688. private _onUnBindObservable;
  20689. /**
  20690. * Called during a dispose event
  20691. */
  20692. onDispose: () => void;
  20693. private _onBindObservable;
  20694. /**
  20695. * An event triggered when the material is bound
  20696. */
  20697. readonly onBindObservable: Observable<AbstractMesh>;
  20698. /**
  20699. * An observer which watches for bind events
  20700. */
  20701. private _onBindObserver;
  20702. /**
  20703. * Called during a bind event
  20704. */
  20705. onBind: (Mesh: AbstractMesh) => void;
  20706. /**
  20707. * An event triggered when the material is unbound
  20708. */
  20709. readonly onUnBindObservable: Observable<Material>;
  20710. /**
  20711. * Stores the value of the alpha mode
  20712. */
  20713. private _alphaMode;
  20714. /**
  20715. * Sets the value of the alpha mode.
  20716. *
  20717. * | Value | Type | Description |
  20718. * | --- | --- | --- |
  20719. * | 0 | ALPHA_DISABLE | |
  20720. * | 1 | ALPHA_ADD | |
  20721. * | 2 | ALPHA_COMBINE | |
  20722. * | 3 | ALPHA_SUBTRACT | |
  20723. * | 4 | ALPHA_MULTIPLY | |
  20724. * | 5 | ALPHA_MAXIMIZED | |
  20725. * | 6 | ALPHA_ONEONE | |
  20726. * | 7 | ALPHA_PREMULTIPLIED | |
  20727. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  20728. * | 9 | ALPHA_INTERPOLATE | |
  20729. * | 10 | ALPHA_SCREENMODE | |
  20730. *
  20731. */
  20732. /**
  20733. * Gets the value of the alpha mode
  20734. */
  20735. alphaMode: number;
  20736. /**
  20737. * Stores the state of the need depth pre-pass value
  20738. */
  20739. private _needDepthPrePass;
  20740. /**
  20741. * Sets the need depth pre-pass value
  20742. */
  20743. /**
  20744. * Gets the depth pre-pass value
  20745. */
  20746. needDepthPrePass: boolean;
  20747. /**
  20748. * Specifies if depth writing should be disabled
  20749. */
  20750. disableDepthWrite: boolean;
  20751. /**
  20752. * Specifies if depth writing should be forced
  20753. */
  20754. forceDepthWrite: boolean;
  20755. /**
  20756. * Specifies if there should be a separate pass for culling
  20757. */
  20758. separateCullingPass: boolean;
  20759. /**
  20760. * Stores the state specifing if fog should be enabled
  20761. */
  20762. private _fogEnabled;
  20763. /**
  20764. * Sets the state for enabling fog
  20765. */
  20766. /**
  20767. * Gets the value of the fog enabled state
  20768. */
  20769. fogEnabled: boolean;
  20770. /**
  20771. * Stores the size of points
  20772. */
  20773. pointSize: number;
  20774. /**
  20775. * Stores the z offset value
  20776. */
  20777. zOffset: number;
  20778. /**
  20779. * Gets a value specifying if wireframe mode is enabled
  20780. */
  20781. /**
  20782. * Sets the state of wireframe mode
  20783. */
  20784. wireframe: boolean;
  20785. /**
  20786. * Gets the value specifying if point clouds are enabled
  20787. */
  20788. /**
  20789. * Sets the state of point cloud mode
  20790. */
  20791. pointsCloud: boolean;
  20792. /**
  20793. * Gets the material fill mode
  20794. */
  20795. /**
  20796. * Sets the material fill mode
  20797. */
  20798. fillMode: number;
  20799. /**
  20800. * @hidden
  20801. * Stores the effects for the material
  20802. */
  20803. _effect: Nullable<Effect>;
  20804. /**
  20805. * @hidden
  20806. * Specifies if the material was previously ready
  20807. */
  20808. _wasPreviouslyReady: boolean;
  20809. /**
  20810. * Specifies if uniform buffers should be used
  20811. */
  20812. private _useUBO;
  20813. /**
  20814. * Stores a reference to the scene
  20815. */
  20816. private _scene;
  20817. /**
  20818. * Stores the fill mode state
  20819. */
  20820. private _fillMode;
  20821. /**
  20822. * Specifies if the depth write state should be cached
  20823. */
  20824. private _cachedDepthWriteState;
  20825. /**
  20826. * Stores the uniform buffer
  20827. */
  20828. protected _uniformBuffer: UniformBuffer;
  20829. /** @hidden */
  20830. _indexInSceneMaterialArray: number;
  20831. /** @hidden */
  20832. meshMap: Nullable<{
  20833. [id: string]: AbstractMesh | undefined;
  20834. }>;
  20835. /**
  20836. * Creates a material instance
  20837. * @param name defines the name of the material
  20838. * @param scene defines the scene to reference
  20839. * @param doNotAdd specifies if the material should be added to the scene
  20840. */
  20841. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  20842. /**
  20843. * Returns a string representation of the current material
  20844. * @param fullDetails defines a boolean indicating which levels of logging is desired
  20845. * @returns a string with material information
  20846. */
  20847. toString(fullDetails?: boolean): string;
  20848. /**
  20849. * Gets the class name of the material
  20850. * @returns a string with the class name of the material
  20851. */
  20852. getClassName(): string;
  20853. /**
  20854. * Specifies if updates for the material been locked
  20855. */
  20856. readonly isFrozen: boolean;
  20857. /**
  20858. * Locks updates for the material
  20859. */
  20860. freeze(): void;
  20861. /**
  20862. * Unlocks updates for the material
  20863. */
  20864. unfreeze(): void;
  20865. /**
  20866. * Specifies if the material is ready to be used
  20867. * @param mesh defines the mesh to check
  20868. * @param useInstances specifies if instances should be used
  20869. * @returns a boolean indicating if the material is ready to be used
  20870. */
  20871. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  20872. /**
  20873. * Specifies that the submesh is ready to be used
  20874. * @param mesh defines the mesh to check
  20875. * @param subMesh defines which submesh to check
  20876. * @param useInstances specifies that instances should be used
  20877. * @returns a boolean indicating that the submesh is ready or not
  20878. */
  20879. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  20880. /**
  20881. * Returns the material effect
  20882. * @returns the effect associated with the material
  20883. */
  20884. getEffect(): Nullable<Effect>;
  20885. /**
  20886. * Returns the current scene
  20887. * @returns a Scene
  20888. */
  20889. getScene(): Scene;
  20890. /**
  20891. * Specifies if the material will require alpha blending
  20892. * @returns a boolean specifying if alpha blending is needed
  20893. */
  20894. needAlphaBlending(): boolean;
  20895. /**
  20896. * Specifies if the mesh will require alpha blending
  20897. * @param mesh defines the mesh to check
  20898. * @returns a boolean specifying if alpha blending is needed for the mesh
  20899. */
  20900. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  20901. /**
  20902. * Specifies if this material should be rendered in alpha test mode
  20903. * @returns a boolean specifying if an alpha test is needed.
  20904. */
  20905. needAlphaTesting(): boolean;
  20906. /**
  20907. * Gets the texture used for the alpha test
  20908. * @returns the texture to use for alpha testing
  20909. */
  20910. getAlphaTestTexture(): Nullable<BaseTexture>;
  20911. /**
  20912. * Marks the material to indicate that it needs to be re-calculated
  20913. */
  20914. markDirty(): void;
  20915. /** @hidden */
  20916. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  20917. /**
  20918. * Binds the material to the mesh
  20919. * @param world defines the world transformation matrix
  20920. * @param mesh defines the mesh to bind the material to
  20921. */
  20922. bind(world: Matrix, mesh?: Mesh): void;
  20923. /**
  20924. * Binds the submesh to the material
  20925. * @param world defines the world transformation matrix
  20926. * @param mesh defines the mesh containing the submesh
  20927. * @param subMesh defines the submesh to bind the material to
  20928. */
  20929. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  20930. /**
  20931. * Binds the world matrix to the material
  20932. * @param world defines the world transformation matrix
  20933. */
  20934. bindOnlyWorldMatrix(world: Matrix): void;
  20935. /**
  20936. * Binds the scene's uniform buffer to the effect.
  20937. * @param effect defines the effect to bind to the scene uniform buffer
  20938. * @param sceneUbo defines the uniform buffer storing scene data
  20939. */
  20940. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  20941. /**
  20942. * Binds the view matrix to the effect
  20943. * @param effect defines the effect to bind the view matrix to
  20944. */
  20945. bindView(effect: Effect): void;
  20946. /**
  20947. * Binds the view projection matrix to the effect
  20948. * @param effect defines the effect to bind the view projection matrix to
  20949. */
  20950. bindViewProjection(effect: Effect): void;
  20951. /**
  20952. * Specifies if material alpha testing should be turned on for the mesh
  20953. * @param mesh defines the mesh to check
  20954. */
  20955. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  20956. /**
  20957. * Processes to execute after binding the material to a mesh
  20958. * @param mesh defines the rendered mesh
  20959. */
  20960. protected _afterBind(mesh?: Mesh): void;
  20961. /**
  20962. * Unbinds the material from the mesh
  20963. */
  20964. unbind(): void;
  20965. /**
  20966. * Gets the active textures from the material
  20967. * @returns an array of textures
  20968. */
  20969. getActiveTextures(): BaseTexture[];
  20970. /**
  20971. * Specifies if the material uses a texture
  20972. * @param texture defines the texture to check against the material
  20973. * @returns a boolean specifying if the material uses the texture
  20974. */
  20975. hasTexture(texture: BaseTexture): boolean;
  20976. /**
  20977. * Makes a duplicate of the material, and gives it a new name
  20978. * @param name defines the new name for the duplicated material
  20979. * @returns the cloned material
  20980. */
  20981. clone(name: string): Nullable<Material>;
  20982. /**
  20983. * Gets the meshes bound to the material
  20984. * @returns an array of meshes bound to the material
  20985. */
  20986. getBindedMeshes(): AbstractMesh[];
  20987. /**
  20988. * Force shader compilation
  20989. * @param mesh defines the mesh associated with this material
  20990. * @param onCompiled defines a function to execute once the material is compiled
  20991. * @param options defines the options to configure the compilation
  20992. */
  20993. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  20994. clipPlane: boolean;
  20995. }>): void;
  20996. /**
  20997. * Force shader compilation
  20998. * @param mesh defines the mesh that will use this material
  20999. * @param options defines additional options for compiling the shaders
  21000. * @returns a promise that resolves when the compilation completes
  21001. */
  21002. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<{
  21003. clipPlane: boolean;
  21004. }>): Promise<void>;
  21005. private static readonly _AllDirtyCallBack;
  21006. private static readonly _ImageProcessingDirtyCallBack;
  21007. private static readonly _TextureDirtyCallBack;
  21008. private static readonly _FresnelDirtyCallBack;
  21009. private static readonly _MiscDirtyCallBack;
  21010. private static readonly _LightsDirtyCallBack;
  21011. private static readonly _AttributeDirtyCallBack;
  21012. private static _FresnelAndMiscDirtyCallBack;
  21013. private static _TextureAndMiscDirtyCallBack;
  21014. private static readonly _DirtyCallbackArray;
  21015. private static readonly _RunDirtyCallBacks;
  21016. /**
  21017. * Marks a define in the material to indicate that it needs to be re-computed
  21018. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  21019. */
  21020. markAsDirty(flag: number): void;
  21021. /**
  21022. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  21023. * @param func defines a function which checks material defines against the submeshes
  21024. */
  21025. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  21026. /**
  21027. * Indicates that we need to re-calculated for all submeshes
  21028. */
  21029. protected _markAllSubMeshesAsAllDirty(): void;
  21030. /**
  21031. * Indicates that image processing needs to be re-calculated for all submeshes
  21032. */
  21033. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  21034. /**
  21035. * Indicates that textures need to be re-calculated for all submeshes
  21036. */
  21037. protected _markAllSubMeshesAsTexturesDirty(): void;
  21038. /**
  21039. * Indicates that fresnel needs to be re-calculated for all submeshes
  21040. */
  21041. protected _markAllSubMeshesAsFresnelDirty(): void;
  21042. /**
  21043. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  21044. */
  21045. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  21046. /**
  21047. * Indicates that lights need to be re-calculated for all submeshes
  21048. */
  21049. protected _markAllSubMeshesAsLightsDirty(): void;
  21050. /**
  21051. * Indicates that attributes need to be re-calculated for all submeshes
  21052. */
  21053. protected _markAllSubMeshesAsAttributesDirty(): void;
  21054. /**
  21055. * Indicates that misc needs to be re-calculated for all submeshes
  21056. */
  21057. protected _markAllSubMeshesAsMiscDirty(): void;
  21058. /**
  21059. * Indicates that textures and misc need to be re-calculated for all submeshes
  21060. */
  21061. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  21062. /**
  21063. * Disposes the material
  21064. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  21065. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  21066. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  21067. */
  21068. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  21069. /** @hidden */
  21070. private releaseVertexArrayObject;
  21071. /**
  21072. * Serializes this material
  21073. * @returns the serialized material object
  21074. */
  21075. serialize(): any;
  21076. /**
  21077. * Creates a material from parsed material data
  21078. * @param parsedMaterial defines parsed material data
  21079. * @param scene defines the hosting scene
  21080. * @param rootUrl defines the root URL to use to load textures
  21081. * @returns a new material
  21082. */
  21083. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  21084. }
  21085. }
  21086. declare module "babylonjs/Materials/multiMaterial" {
  21087. import { Nullable } from "babylonjs/types";
  21088. import { Scene } from "babylonjs/scene";
  21089. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21090. import { BaseSubMesh } from "babylonjs/Meshes/subMesh";
  21091. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  21092. import { Material } from "babylonjs/Materials/material";
  21093. /**
  21094. * A multi-material is used to apply different materials to different parts of the same object without the need of
  21095. * separate meshes. This can be use to improve performances.
  21096. * @see http://doc.babylonjs.com/how_to/multi_materials
  21097. */
  21098. export class MultiMaterial extends Material {
  21099. private _subMaterials;
  21100. /**
  21101. * Gets or Sets the list of Materials used within the multi material.
  21102. * They need to be ordered according to the submeshes order in the associated mesh
  21103. */
  21104. subMaterials: Nullable<Material>[];
  21105. /**
  21106. * Function used to align with Node.getChildren()
  21107. * @returns the list of Materials used within the multi material
  21108. */
  21109. getChildren(): Nullable<Material>[];
  21110. /**
  21111. * Instantiates a new Multi Material
  21112. * A multi-material is used to apply different materials to different parts of the same object without the need of
  21113. * separate meshes. This can be use to improve performances.
  21114. * @see http://doc.babylonjs.com/how_to/multi_materials
  21115. * @param name Define the name in the scene
  21116. * @param scene Define the scene the material belongs to
  21117. */
  21118. constructor(name: string, scene: Scene);
  21119. private _hookArray;
  21120. /**
  21121. * Get one of the submaterial by its index in the submaterials array
  21122. * @param index The index to look the sub material at
  21123. * @returns The Material if the index has been defined
  21124. */
  21125. getSubMaterial(index: number): Nullable<Material>;
  21126. /**
  21127. * Get the list of active textures for the whole sub materials list.
  21128. * @returns All the textures that will be used during the rendering
  21129. */
  21130. getActiveTextures(): BaseTexture[];
  21131. /**
  21132. * Gets the current class name of the material e.g. "MultiMaterial"
  21133. * Mainly use in serialization.
  21134. * @returns the class name
  21135. */
  21136. getClassName(): string;
  21137. /**
  21138. * Checks if the material is ready to render the requested sub mesh
  21139. * @param mesh Define the mesh the submesh belongs to
  21140. * @param subMesh Define the sub mesh to look readyness for
  21141. * @param useInstances Define whether or not the material is used with instances
  21142. * @returns true if ready, otherwise false
  21143. */
  21144. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  21145. /**
  21146. * Clones the current material and its related sub materials
  21147. * @param name Define the name of the newly cloned material
  21148. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  21149. * @returns the cloned material
  21150. */
  21151. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  21152. /**
  21153. * Serializes the materials into a JSON representation.
  21154. * @returns the JSON representation
  21155. */
  21156. serialize(): any;
  21157. /**
  21158. * Dispose the material and release its associated resources
  21159. * @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)
  21160. * @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)
  21161. * @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)
  21162. */
  21163. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  21164. /**
  21165. * Creates a MultiMaterial from parsed MultiMaterial data.
  21166. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  21167. * @param scene defines the hosting scene
  21168. * @returns a new MultiMaterial
  21169. */
  21170. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  21171. }
  21172. }
  21173. declare module "babylonjs/Meshes/subMesh" {
  21174. import { Nullable, IndicesArray, DeepImmutable, FloatArray } from "babylonjs/types";
  21175. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  21176. import { Engine } from "babylonjs/Engines/engine";
  21177. import { IntersectionInfo } from "babylonjs/Collisions/intersectionInfo";
  21178. import { ICullable, BoundingInfo } from "babylonjs/Culling/boundingInfo";
  21179. import { Effect } from "babylonjs/Materials/effect";
  21180. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  21181. import { Plane } from "babylonjs/Maths/math.plane";
  21182. import { Collider } from "babylonjs/Collisions/collider";
  21183. import { Material } from "babylonjs/Materials/material";
  21184. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  21185. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21186. import { Mesh } from "babylonjs/Meshes/mesh";
  21187. import { Ray } from "babylonjs/Culling/ray";
  21188. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  21189. /**
  21190. * Base class for submeshes
  21191. */
  21192. export class BaseSubMesh {
  21193. /** @hidden */
  21194. _materialDefines: Nullable<MaterialDefines>;
  21195. /** @hidden */
  21196. _materialEffect: Nullable<Effect>;
  21197. /**
  21198. * Gets associated effect
  21199. */
  21200. readonly effect: Nullable<Effect>;
  21201. /**
  21202. * Sets associated effect (effect used to render this submesh)
  21203. * @param effect defines the effect to associate with
  21204. * @param defines defines the set of defines used to compile this effect
  21205. */
  21206. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  21207. }
  21208. /**
  21209. * Defines a subdivision inside a mesh
  21210. */
  21211. export class SubMesh extends BaseSubMesh implements ICullable {
  21212. /** the material index to use */
  21213. materialIndex: number;
  21214. /** vertex index start */
  21215. verticesStart: number;
  21216. /** vertices count */
  21217. verticesCount: number;
  21218. /** index start */
  21219. indexStart: number;
  21220. /** indices count */
  21221. indexCount: number;
  21222. /** @hidden */
  21223. _linesIndexCount: number;
  21224. private _mesh;
  21225. private _renderingMesh;
  21226. private _boundingInfo;
  21227. private _linesIndexBuffer;
  21228. /** @hidden */
  21229. _lastColliderWorldVertices: Nullable<Vector3[]>;
  21230. /** @hidden */
  21231. _trianglePlanes: Plane[];
  21232. /** @hidden */
  21233. _lastColliderTransformMatrix: Nullable<Matrix>;
  21234. /** @hidden */
  21235. _renderId: number;
  21236. /** @hidden */
  21237. _alphaIndex: number;
  21238. /** @hidden */
  21239. _distanceToCamera: number;
  21240. /** @hidden */
  21241. _id: number;
  21242. private _currentMaterial;
  21243. /**
  21244. * Add a new submesh to a mesh
  21245. * @param materialIndex defines the material index to use
  21246. * @param verticesStart defines vertex index start
  21247. * @param verticesCount defines vertices count
  21248. * @param indexStart defines index start
  21249. * @param indexCount defines indices count
  21250. * @param mesh defines the parent mesh
  21251. * @param renderingMesh defines an optional rendering mesh
  21252. * @param createBoundingBox defines if bounding box should be created for this submesh
  21253. * @returns the new submesh
  21254. */
  21255. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  21256. /**
  21257. * Creates a new submesh
  21258. * @param materialIndex defines the material index to use
  21259. * @param verticesStart defines vertex index start
  21260. * @param verticesCount defines vertices count
  21261. * @param indexStart defines index start
  21262. * @param indexCount defines indices count
  21263. * @param mesh defines the parent mesh
  21264. * @param renderingMesh defines an optional rendering mesh
  21265. * @param createBoundingBox defines if bounding box should be created for this submesh
  21266. */
  21267. constructor(
  21268. /** the material index to use */
  21269. materialIndex: number,
  21270. /** vertex index start */
  21271. verticesStart: number,
  21272. /** vertices count */
  21273. verticesCount: number,
  21274. /** index start */
  21275. indexStart: number,
  21276. /** indices count */
  21277. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  21278. /**
  21279. * Returns true if this submesh covers the entire parent mesh
  21280. * @ignorenaming
  21281. */
  21282. readonly IsGlobal: boolean;
  21283. /**
  21284. * Returns the submesh BoudingInfo object
  21285. * @returns current bounding info (or mesh's one if the submesh is global)
  21286. */
  21287. getBoundingInfo(): BoundingInfo;
  21288. /**
  21289. * Sets the submesh BoundingInfo
  21290. * @param boundingInfo defines the new bounding info to use
  21291. * @returns the SubMesh
  21292. */
  21293. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  21294. /**
  21295. * Returns the mesh of the current submesh
  21296. * @return the parent mesh
  21297. */
  21298. getMesh(): AbstractMesh;
  21299. /**
  21300. * Returns the rendering mesh of the submesh
  21301. * @returns the rendering mesh (could be different from parent mesh)
  21302. */
  21303. getRenderingMesh(): Mesh;
  21304. /**
  21305. * Returns the submesh material
  21306. * @returns null or the current material
  21307. */
  21308. getMaterial(): Nullable<Material>;
  21309. /**
  21310. * Sets a new updated BoundingInfo object to the submesh
  21311. * @param data defines an optional position array to use to determine the bounding info
  21312. * @returns the SubMesh
  21313. */
  21314. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  21315. /** @hidden */
  21316. _checkCollision(collider: Collider): boolean;
  21317. /**
  21318. * Updates the submesh BoundingInfo
  21319. * @param world defines the world matrix to use to update the bounding info
  21320. * @returns the submesh
  21321. */
  21322. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  21323. /**
  21324. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  21325. * @param frustumPlanes defines the frustum planes
  21326. * @returns true if the submesh is intersecting with the frustum
  21327. */
  21328. isInFrustum(frustumPlanes: Plane[]): boolean;
  21329. /**
  21330. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  21331. * @param frustumPlanes defines the frustum planes
  21332. * @returns true if the submesh is inside the frustum
  21333. */
  21334. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  21335. /**
  21336. * Renders the submesh
  21337. * @param enableAlphaMode defines if alpha needs to be used
  21338. * @returns the submesh
  21339. */
  21340. render(enableAlphaMode: boolean): SubMesh;
  21341. /**
  21342. * @hidden
  21343. */
  21344. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  21345. /**
  21346. * Checks if the submesh intersects with a ray
  21347. * @param ray defines the ray to test
  21348. * @returns true is the passed ray intersects the submesh bounding box
  21349. */
  21350. canIntersects(ray: Ray): boolean;
  21351. /**
  21352. * Intersects current submesh with a ray
  21353. * @param ray defines the ray to test
  21354. * @param positions defines mesh's positions array
  21355. * @param indices defines mesh's indices array
  21356. * @param fastCheck defines if only bounding info should be used
  21357. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  21358. * @returns intersection info or null if no intersection
  21359. */
  21360. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  21361. /** @hidden */
  21362. private _intersectLines;
  21363. /** @hidden */
  21364. private _intersectUnIndexedLines;
  21365. /** @hidden */
  21366. private _intersectTriangles;
  21367. /** @hidden */
  21368. private _intersectUnIndexedTriangles;
  21369. /** @hidden */
  21370. _rebuild(): void;
  21371. /**
  21372. * Creates a new submesh from the passed mesh
  21373. * @param newMesh defines the new hosting mesh
  21374. * @param newRenderingMesh defines an optional rendering mesh
  21375. * @returns the new submesh
  21376. */
  21377. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  21378. /**
  21379. * Release associated resources
  21380. */
  21381. dispose(): void;
  21382. /**
  21383. * Gets the class name
  21384. * @returns the string "SubMesh".
  21385. */
  21386. getClassName(): string;
  21387. /**
  21388. * Creates a new submesh from indices data
  21389. * @param materialIndex the index of the main mesh material
  21390. * @param startIndex the index where to start the copy in the mesh indices array
  21391. * @param indexCount the number of indices to copy then from the startIndex
  21392. * @param mesh the main mesh to create the submesh from
  21393. * @param renderingMesh the optional rendering mesh
  21394. * @returns a new submesh
  21395. */
  21396. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  21397. }
  21398. }
  21399. declare module "babylonjs/Loading/sceneLoaderFlags" {
  21400. /**
  21401. * Class used to represent data loading progression
  21402. */
  21403. export class SceneLoaderFlags {
  21404. private static _ForceFullSceneLoadingForIncremental;
  21405. private static _ShowLoadingScreen;
  21406. private static _CleanBoneMatrixWeights;
  21407. private static _loggingLevel;
  21408. /**
  21409. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  21410. */
  21411. static ForceFullSceneLoadingForIncremental: boolean;
  21412. /**
  21413. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  21414. */
  21415. static ShowLoadingScreen: boolean;
  21416. /**
  21417. * Defines the current logging level (while loading the scene)
  21418. * @ignorenaming
  21419. */
  21420. static loggingLevel: number;
  21421. /**
  21422. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  21423. */
  21424. static CleanBoneMatrixWeights: boolean;
  21425. }
  21426. }
  21427. declare module "babylonjs/Meshes/geometry" {
  21428. import { Nullable, FloatArray, DataArray, IndicesArray } from "babylonjs/types";
  21429. import { Scene } from "babylonjs/scene";
  21430. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  21431. import { Engine } from "babylonjs/Engines/engine";
  21432. import { IGetSetVerticesData, VertexData } from "babylonjs/Meshes/mesh.vertexData";
  21433. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  21434. import { Effect } from "babylonjs/Materials/effect";
  21435. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  21436. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  21437. import { Mesh } from "babylonjs/Meshes/mesh";
  21438. /**
  21439. * Class used to store geometry data (vertex buffers + index buffer)
  21440. */
  21441. export class Geometry implements IGetSetVerticesData {
  21442. /**
  21443. * Gets or sets the ID of the geometry
  21444. */
  21445. id: string;
  21446. /**
  21447. * Gets or sets the unique ID of the geometry
  21448. */
  21449. uniqueId: number;
  21450. /**
  21451. * Gets the delay loading state of the geometry (none by default which means not delayed)
  21452. */
  21453. delayLoadState: number;
  21454. /**
  21455. * Gets the file containing the data to load when running in delay load state
  21456. */
  21457. delayLoadingFile: Nullable<string>;
  21458. /**
  21459. * Callback called when the geometry is updated
  21460. */
  21461. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  21462. private _scene;
  21463. private _engine;
  21464. private _meshes;
  21465. private _totalVertices;
  21466. /** @hidden */
  21467. _indices: IndicesArray;
  21468. /** @hidden */
  21469. _vertexBuffers: {
  21470. [key: string]: VertexBuffer;
  21471. };
  21472. private _isDisposed;
  21473. private _extend;
  21474. private _boundingBias;
  21475. /** @hidden */
  21476. _delayInfo: Array<string>;
  21477. private _indexBuffer;
  21478. private _indexBufferIsUpdatable;
  21479. /** @hidden */
  21480. _boundingInfo: Nullable<BoundingInfo>;
  21481. /** @hidden */
  21482. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  21483. /** @hidden */
  21484. _softwareSkinningFrameId: number;
  21485. private _vertexArrayObjects;
  21486. private _updatable;
  21487. /** @hidden */
  21488. _positions: Nullable<Vector3[]>;
  21489. /**
  21490. * 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
  21491. */
  21492. /**
  21493. * 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
  21494. */
  21495. boundingBias: Vector2;
  21496. /**
  21497. * Static function used to attach a new empty geometry to a mesh
  21498. * @param mesh defines the mesh to attach the geometry to
  21499. * @returns the new Geometry
  21500. */
  21501. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  21502. /**
  21503. * Creates a new geometry
  21504. * @param id defines the unique ID
  21505. * @param scene defines the hosting scene
  21506. * @param vertexData defines the VertexData used to get geometry data
  21507. * @param updatable defines if geometry must be updatable (false by default)
  21508. * @param mesh defines the mesh that will be associated with the geometry
  21509. */
  21510. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  21511. /**
  21512. * Gets the current extend of the geometry
  21513. */
  21514. readonly extend: {
  21515. minimum: Vector3;
  21516. maximum: Vector3;
  21517. };
  21518. /**
  21519. * Gets the hosting scene
  21520. * @returns the hosting Scene
  21521. */
  21522. getScene(): Scene;
  21523. /**
  21524. * Gets the hosting engine
  21525. * @returns the hosting Engine
  21526. */
  21527. getEngine(): Engine;
  21528. /**
  21529. * Defines if the geometry is ready to use
  21530. * @returns true if the geometry is ready to be used
  21531. */
  21532. isReady(): boolean;
  21533. /**
  21534. * Gets a value indicating that the geometry should not be serialized
  21535. */
  21536. readonly doNotSerialize: boolean;
  21537. /** @hidden */
  21538. _rebuild(): void;
  21539. /**
  21540. * Affects all geometry data in one call
  21541. * @param vertexData defines the geometry data
  21542. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  21543. */
  21544. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  21545. /**
  21546. * Set specific vertex data
  21547. * @param kind defines the data kind (Position, normal, etc...)
  21548. * @param data defines the vertex data to use
  21549. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  21550. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  21551. */
  21552. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  21553. /**
  21554. * Removes a specific vertex data
  21555. * @param kind defines the data kind (Position, normal, etc...)
  21556. */
  21557. removeVerticesData(kind: string): void;
  21558. /**
  21559. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  21560. * @param buffer defines the vertex buffer to use
  21561. * @param totalVertices defines the total number of vertices for position kind (could be null)
  21562. */
  21563. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  21564. /**
  21565. * Update a specific vertex buffer
  21566. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  21567. * It will do nothing if the buffer is not updatable
  21568. * @param kind defines the data kind (Position, normal, etc...)
  21569. * @param data defines the data to use
  21570. * @param offset defines the offset in the target buffer where to store the data
  21571. * @param useBytes set to true if the offset is in bytes
  21572. */
  21573. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  21574. /**
  21575. * Update a specific vertex buffer
  21576. * This function will create a new buffer if the current one is not updatable
  21577. * @param kind defines the data kind (Position, normal, etc...)
  21578. * @param data defines the data to use
  21579. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  21580. */
  21581. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  21582. private _updateBoundingInfo;
  21583. /** @hidden */
  21584. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  21585. /**
  21586. * Gets total number of vertices
  21587. * @returns the total number of vertices
  21588. */
  21589. getTotalVertices(): number;
  21590. /**
  21591. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  21592. * @param kind defines the data kind (Position, normal, etc...)
  21593. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  21594. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  21595. * @returns a float array containing vertex data
  21596. */
  21597. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  21598. /**
  21599. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  21600. * @param kind defines the data kind (Position, normal, etc...)
  21601. * @returns true if the vertex buffer with the specified kind is updatable
  21602. */
  21603. isVertexBufferUpdatable(kind: string): boolean;
  21604. /**
  21605. * Gets a specific vertex buffer
  21606. * @param kind defines the data kind (Position, normal, etc...)
  21607. * @returns a VertexBuffer
  21608. */
  21609. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  21610. /**
  21611. * Returns all vertex buffers
  21612. * @return an object holding all vertex buffers indexed by kind
  21613. */
  21614. getVertexBuffers(): Nullable<{
  21615. [key: string]: VertexBuffer;
  21616. }>;
  21617. /**
  21618. * Gets a boolean indicating if specific vertex buffer is present
  21619. * @param kind defines the data kind (Position, normal, etc...)
  21620. * @returns true if data is present
  21621. */
  21622. isVerticesDataPresent(kind: string): boolean;
  21623. /**
  21624. * Gets a list of all attached data kinds (Position, normal, etc...)
  21625. * @returns a list of string containing all kinds
  21626. */
  21627. getVerticesDataKinds(): string[];
  21628. /**
  21629. * Update index buffer
  21630. * @param indices defines the indices to store in the index buffer
  21631. * @param offset defines the offset in the target buffer where to store the data
  21632. * @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)
  21633. */
  21634. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  21635. /**
  21636. * Creates a new index buffer
  21637. * @param indices defines the indices to store in the index buffer
  21638. * @param totalVertices defines the total number of vertices (could be null)
  21639. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  21640. */
  21641. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  21642. /**
  21643. * Return the total number of indices
  21644. * @returns the total number of indices
  21645. */
  21646. getTotalIndices(): number;
  21647. /**
  21648. * Gets the index buffer array
  21649. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  21650. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  21651. * @returns the index buffer array
  21652. */
  21653. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  21654. /**
  21655. * Gets the index buffer
  21656. * @return the index buffer
  21657. */
  21658. getIndexBuffer(): Nullable<DataBuffer>;
  21659. /** @hidden */
  21660. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  21661. /**
  21662. * Release the associated resources for a specific mesh
  21663. * @param mesh defines the source mesh
  21664. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  21665. */
  21666. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  21667. /**
  21668. * Apply current geometry to a given mesh
  21669. * @param mesh defines the mesh to apply geometry to
  21670. */
  21671. applyToMesh(mesh: Mesh): void;
  21672. private _updateExtend;
  21673. private _applyToMesh;
  21674. private notifyUpdate;
  21675. /**
  21676. * Load the geometry if it was flagged as delay loaded
  21677. * @param scene defines the hosting scene
  21678. * @param onLoaded defines a callback called when the geometry is loaded
  21679. */
  21680. load(scene: Scene, onLoaded?: () => void): void;
  21681. private _queueLoad;
  21682. /**
  21683. * Invert the geometry to move from a right handed system to a left handed one.
  21684. */
  21685. toLeftHanded(): void;
  21686. /** @hidden */
  21687. _resetPointsArrayCache(): void;
  21688. /** @hidden */
  21689. _generatePointsArray(): boolean;
  21690. /**
  21691. * Gets a value indicating if the geometry is disposed
  21692. * @returns true if the geometry was disposed
  21693. */
  21694. isDisposed(): boolean;
  21695. private _disposeVertexArrayObjects;
  21696. /**
  21697. * Free all associated resources
  21698. */
  21699. dispose(): void;
  21700. /**
  21701. * Clone the current geometry into a new geometry
  21702. * @param id defines the unique ID of the new geometry
  21703. * @returns a new geometry object
  21704. */
  21705. copy(id: string): Geometry;
  21706. /**
  21707. * Serialize the current geometry info (and not the vertices data) into a JSON object
  21708. * @return a JSON representation of the current geometry data (without the vertices data)
  21709. */
  21710. serialize(): any;
  21711. private toNumberArray;
  21712. /**
  21713. * Serialize all vertices data into a JSON oject
  21714. * @returns a JSON representation of the current geometry data
  21715. */
  21716. serializeVerticeData(): any;
  21717. /**
  21718. * Extracts a clone of a mesh geometry
  21719. * @param mesh defines the source mesh
  21720. * @param id defines the unique ID of the new geometry object
  21721. * @returns the new geometry object
  21722. */
  21723. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  21724. /**
  21725. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  21726. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  21727. * Be aware Math.random() could cause collisions, but:
  21728. * "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"
  21729. * @returns a string containing a new GUID
  21730. */
  21731. static RandomId(): string;
  21732. /** @hidden */
  21733. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  21734. private static _CleanMatricesWeights;
  21735. /**
  21736. * Create a new geometry from persisted data (Using .babylon file format)
  21737. * @param parsedVertexData defines the persisted data
  21738. * @param scene defines the hosting scene
  21739. * @param rootUrl defines the root url to use to load assets (like delayed data)
  21740. * @returns the new geometry object
  21741. */
  21742. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  21743. }
  21744. }
  21745. declare module "babylonjs/Meshes/mesh.vertexData" {
  21746. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  21747. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  21748. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  21749. import { Geometry } from "babylonjs/Meshes/geometry";
  21750. import { Mesh } from "babylonjs/Meshes/mesh";
  21751. /**
  21752. * Define an interface for all classes that will get and set the data on vertices
  21753. */
  21754. export interface IGetSetVerticesData {
  21755. /**
  21756. * Gets a boolean indicating if specific vertex data is present
  21757. * @param kind defines the vertex data kind to use
  21758. * @returns true is data kind is present
  21759. */
  21760. isVerticesDataPresent(kind: string): boolean;
  21761. /**
  21762. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  21763. * @param kind defines the data kind (Position, normal, etc...)
  21764. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  21765. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  21766. * @returns a float array containing vertex data
  21767. */
  21768. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  21769. /**
  21770. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  21771. * @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.
  21772. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  21773. * @returns the indices array or an empty array if the mesh has no geometry
  21774. */
  21775. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  21776. /**
  21777. * Set specific vertex data
  21778. * @param kind defines the data kind (Position, normal, etc...)
  21779. * @param data defines the vertex data to use
  21780. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  21781. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  21782. */
  21783. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  21784. /**
  21785. * Update a specific associated vertex buffer
  21786. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  21787. * - VertexBuffer.PositionKind
  21788. * - VertexBuffer.UVKind
  21789. * - VertexBuffer.UV2Kind
  21790. * - VertexBuffer.UV3Kind
  21791. * - VertexBuffer.UV4Kind
  21792. * - VertexBuffer.UV5Kind
  21793. * - VertexBuffer.UV6Kind
  21794. * - VertexBuffer.ColorKind
  21795. * - VertexBuffer.MatricesIndicesKind
  21796. * - VertexBuffer.MatricesIndicesExtraKind
  21797. * - VertexBuffer.MatricesWeightsKind
  21798. * - VertexBuffer.MatricesWeightsExtraKind
  21799. * @param data defines the data source
  21800. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  21801. * @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)
  21802. */
  21803. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  21804. /**
  21805. * Creates a new index buffer
  21806. * @param indices defines the indices to store in the index buffer
  21807. * @param totalVertices defines the total number of vertices (could be null)
  21808. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  21809. */
  21810. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  21811. }
  21812. /**
  21813. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  21814. */
  21815. export class VertexData {
  21816. /**
  21817. * Mesh side orientation : usually the external or front surface
  21818. */
  21819. static readonly FRONTSIDE: number;
  21820. /**
  21821. * Mesh side orientation : usually the internal or back surface
  21822. */
  21823. static readonly BACKSIDE: number;
  21824. /**
  21825. * Mesh side orientation : both internal and external or front and back surfaces
  21826. */
  21827. static readonly DOUBLESIDE: number;
  21828. /**
  21829. * Mesh side orientation : by default, `FRONTSIDE`
  21830. */
  21831. static readonly DEFAULTSIDE: number;
  21832. /**
  21833. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  21834. */
  21835. positions: Nullable<FloatArray>;
  21836. /**
  21837. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  21838. */
  21839. normals: Nullable<FloatArray>;
  21840. /**
  21841. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  21842. */
  21843. tangents: Nullable<FloatArray>;
  21844. /**
  21845. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21846. */
  21847. uvs: Nullable<FloatArray>;
  21848. /**
  21849. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21850. */
  21851. uvs2: Nullable<FloatArray>;
  21852. /**
  21853. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21854. */
  21855. uvs3: Nullable<FloatArray>;
  21856. /**
  21857. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21858. */
  21859. uvs4: Nullable<FloatArray>;
  21860. /**
  21861. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21862. */
  21863. uvs5: Nullable<FloatArray>;
  21864. /**
  21865. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21866. */
  21867. uvs6: Nullable<FloatArray>;
  21868. /**
  21869. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  21870. */
  21871. colors: Nullable<FloatArray>;
  21872. /**
  21873. * 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).
  21874. */
  21875. matricesIndices: Nullable<FloatArray>;
  21876. /**
  21877. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  21878. */
  21879. matricesWeights: Nullable<FloatArray>;
  21880. /**
  21881. * An array extending the number of possible indices
  21882. */
  21883. matricesIndicesExtra: Nullable<FloatArray>;
  21884. /**
  21885. * An array extending the number of possible weights when the number of indices is extended
  21886. */
  21887. matricesWeightsExtra: Nullable<FloatArray>;
  21888. /**
  21889. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  21890. */
  21891. indices: Nullable<IndicesArray>;
  21892. /**
  21893. * Uses the passed data array to set the set the values for the specified kind of data
  21894. * @param data a linear array of floating numbers
  21895. * @param kind the type of data that is being set, eg positions, colors etc
  21896. */
  21897. set(data: FloatArray, kind: string): void;
  21898. /**
  21899. * Associates the vertexData to the passed Mesh.
  21900. * Sets it as updatable or not (default `false`)
  21901. * @param mesh the mesh the vertexData is applied to
  21902. * @param updatable when used and having the value true allows new data to update the vertexData
  21903. * @returns the VertexData
  21904. */
  21905. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  21906. /**
  21907. * Associates the vertexData to the passed Geometry.
  21908. * Sets it as updatable or not (default `false`)
  21909. * @param geometry the geometry the vertexData is applied to
  21910. * @param updatable when used and having the value true allows new data to update the vertexData
  21911. * @returns VertexData
  21912. */
  21913. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  21914. /**
  21915. * Updates the associated mesh
  21916. * @param mesh the mesh to be updated
  21917. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  21918. * @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
  21919. * @returns VertexData
  21920. */
  21921. updateMesh(mesh: Mesh): VertexData;
  21922. /**
  21923. * Updates the associated geometry
  21924. * @param geometry the geometry to be updated
  21925. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  21926. * @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
  21927. * @returns VertexData.
  21928. */
  21929. updateGeometry(geometry: Geometry): VertexData;
  21930. private _applyTo;
  21931. private _update;
  21932. /**
  21933. * Transforms each position and each normal of the vertexData according to the passed Matrix
  21934. * @param matrix the transforming matrix
  21935. * @returns the VertexData
  21936. */
  21937. transform(matrix: Matrix): VertexData;
  21938. /**
  21939. * Merges the passed VertexData into the current one
  21940. * @param other the VertexData to be merged into the current one
  21941. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  21942. * @returns the modified VertexData
  21943. */
  21944. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  21945. private _mergeElement;
  21946. private _validate;
  21947. /**
  21948. * Serializes the VertexData
  21949. * @returns a serialized object
  21950. */
  21951. serialize(): any;
  21952. /**
  21953. * Extracts the vertexData from a mesh
  21954. * @param mesh the mesh from which to extract the VertexData
  21955. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  21956. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  21957. * @returns the object VertexData associated to the passed mesh
  21958. */
  21959. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  21960. /**
  21961. * Extracts the vertexData from the geometry
  21962. * @param geometry the geometry from which to extract the VertexData
  21963. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  21964. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  21965. * @returns the object VertexData associated to the passed mesh
  21966. */
  21967. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  21968. private static _ExtractFrom;
  21969. /**
  21970. * Creates the VertexData for a Ribbon
  21971. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  21972. * * pathArray array of paths, each of which an array of successive Vector3
  21973. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  21974. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  21975. * * 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
  21976. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21977. * * 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)
  21978. * * 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)
  21979. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  21980. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  21981. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  21982. * @returns the VertexData of the ribbon
  21983. */
  21984. static CreateRibbon(options: {
  21985. pathArray: Vector3[][];
  21986. closeArray?: boolean;
  21987. closePath?: boolean;
  21988. offset?: number;
  21989. sideOrientation?: number;
  21990. frontUVs?: Vector4;
  21991. backUVs?: Vector4;
  21992. invertUV?: boolean;
  21993. uvs?: Vector2[];
  21994. colors?: Color4[];
  21995. }): VertexData;
  21996. /**
  21997. * Creates the VertexData for a box
  21998. * @param options an object used to set the following optional parameters for the box, required but can be empty
  21999. * * size sets the width, height and depth of the box to the value of size, optional default 1
  22000. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  22001. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  22002. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  22003. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  22004. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  22005. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22006. * * 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)
  22007. * * 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)
  22008. * @returns the VertexData of the box
  22009. */
  22010. static CreateBox(options: {
  22011. size?: number;
  22012. width?: number;
  22013. height?: number;
  22014. depth?: number;
  22015. faceUV?: Vector4[];
  22016. faceColors?: Color4[];
  22017. sideOrientation?: number;
  22018. frontUVs?: Vector4;
  22019. backUVs?: Vector4;
  22020. }): VertexData;
  22021. /**
  22022. * Creates the VertexData for a tiled box
  22023. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22024. * * faceTiles sets the pattern, tile size and number of tiles for a face
  22025. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  22026. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  22027. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22028. * @returns the VertexData of the box
  22029. */
  22030. static CreateTiledBox(options: {
  22031. pattern?: number;
  22032. width?: number;
  22033. height?: number;
  22034. depth?: number;
  22035. tileSize?: number;
  22036. tileWidth?: number;
  22037. tileHeight?: number;
  22038. alignHorizontal?: number;
  22039. alignVertical?: number;
  22040. faceUV?: Vector4[];
  22041. faceColors?: Color4[];
  22042. sideOrientation?: number;
  22043. }): VertexData;
  22044. /**
  22045. * Creates the VertexData for a tiled plane
  22046. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22047. * * pattern a limited pattern arrangement depending on the number
  22048. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  22049. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  22050. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  22051. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22052. * * 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)
  22053. * * 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)
  22054. * @returns the VertexData of the tiled plane
  22055. */
  22056. static CreateTiledPlane(options: {
  22057. pattern?: number;
  22058. tileSize?: number;
  22059. tileWidth?: number;
  22060. tileHeight?: number;
  22061. size?: number;
  22062. width?: number;
  22063. height?: number;
  22064. alignHorizontal?: number;
  22065. alignVertical?: number;
  22066. sideOrientation?: number;
  22067. frontUVs?: Vector4;
  22068. backUVs?: Vector4;
  22069. }): VertexData;
  22070. /**
  22071. * Creates the VertexData for an ellipsoid, defaults to a sphere
  22072. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22073. * * segments sets the number of horizontal strips optional, default 32
  22074. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  22075. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  22076. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  22077. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  22078. * * 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
  22079. * * 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
  22080. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22081. * * 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)
  22082. * * 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)
  22083. * @returns the VertexData of the ellipsoid
  22084. */
  22085. static CreateSphere(options: {
  22086. segments?: number;
  22087. diameter?: number;
  22088. diameterX?: number;
  22089. diameterY?: number;
  22090. diameterZ?: number;
  22091. arc?: number;
  22092. slice?: number;
  22093. sideOrientation?: number;
  22094. frontUVs?: Vector4;
  22095. backUVs?: Vector4;
  22096. }): VertexData;
  22097. /**
  22098. * Creates the VertexData for a cylinder, cone or prism
  22099. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22100. * * height sets the height (y direction) of the cylinder, optional, default 2
  22101. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  22102. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  22103. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  22104. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  22105. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  22106. * * 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
  22107. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  22108. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  22109. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  22110. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  22111. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22112. * * 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)
  22113. * * 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)
  22114. * @returns the VertexData of the cylinder, cone or prism
  22115. */
  22116. static CreateCylinder(options: {
  22117. height?: number;
  22118. diameterTop?: number;
  22119. diameterBottom?: number;
  22120. diameter?: number;
  22121. tessellation?: number;
  22122. subdivisions?: number;
  22123. arc?: number;
  22124. faceColors?: Color4[];
  22125. faceUV?: Vector4[];
  22126. hasRings?: boolean;
  22127. enclose?: boolean;
  22128. sideOrientation?: number;
  22129. frontUVs?: Vector4;
  22130. backUVs?: Vector4;
  22131. }): VertexData;
  22132. /**
  22133. * Creates the VertexData for a torus
  22134. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22135. * * diameter the diameter of the torus, optional default 1
  22136. * * thickness the diameter of the tube forming the torus, optional default 0.5
  22137. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  22138. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22139. * * 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)
  22140. * * 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)
  22141. * @returns the VertexData of the torus
  22142. */
  22143. static CreateTorus(options: {
  22144. diameter?: number;
  22145. thickness?: number;
  22146. tessellation?: number;
  22147. sideOrientation?: number;
  22148. frontUVs?: Vector4;
  22149. backUVs?: Vector4;
  22150. }): VertexData;
  22151. /**
  22152. * Creates the VertexData of the LineSystem
  22153. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  22154. * - lines an array of lines, each line being an array of successive Vector3
  22155. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  22156. * @returns the VertexData of the LineSystem
  22157. */
  22158. static CreateLineSystem(options: {
  22159. lines: Vector3[][];
  22160. colors?: Nullable<Color4[][]>;
  22161. }): VertexData;
  22162. /**
  22163. * Create the VertexData for a DashedLines
  22164. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  22165. * - points an array successive Vector3
  22166. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  22167. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  22168. * - dashNb the intended total number of dashes, optional, default 200
  22169. * @returns the VertexData for the DashedLines
  22170. */
  22171. static CreateDashedLines(options: {
  22172. points: Vector3[];
  22173. dashSize?: number;
  22174. gapSize?: number;
  22175. dashNb?: number;
  22176. }): VertexData;
  22177. /**
  22178. * Creates the VertexData for a Ground
  22179. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  22180. * - width the width (x direction) of the ground, optional, default 1
  22181. * - height the height (z direction) of the ground, optional, default 1
  22182. * - subdivisions the number of subdivisions per side, optional, default 1
  22183. * @returns the VertexData of the Ground
  22184. */
  22185. static CreateGround(options: {
  22186. width?: number;
  22187. height?: number;
  22188. subdivisions?: number;
  22189. subdivisionsX?: number;
  22190. subdivisionsY?: number;
  22191. }): VertexData;
  22192. /**
  22193. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  22194. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  22195. * * xmin the ground minimum X coordinate, optional, default -1
  22196. * * zmin the ground minimum Z coordinate, optional, default -1
  22197. * * xmax the ground maximum X coordinate, optional, default 1
  22198. * * zmax the ground maximum Z coordinate, optional, default 1
  22199. * * 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}
  22200. * * 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}
  22201. * @returns the VertexData of the TiledGround
  22202. */
  22203. static CreateTiledGround(options: {
  22204. xmin: number;
  22205. zmin: number;
  22206. xmax: number;
  22207. zmax: number;
  22208. subdivisions?: {
  22209. w: number;
  22210. h: number;
  22211. };
  22212. precision?: {
  22213. w: number;
  22214. h: number;
  22215. };
  22216. }): VertexData;
  22217. /**
  22218. * Creates the VertexData of the Ground designed from a heightmap
  22219. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  22220. * * width the width (x direction) of the ground
  22221. * * height the height (z direction) of the ground
  22222. * * subdivisions the number of subdivisions per side
  22223. * * minHeight the minimum altitude on the ground, optional, default 0
  22224. * * maxHeight the maximum altitude on the ground, optional default 1
  22225. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  22226. * * buffer the array holding the image color data
  22227. * * bufferWidth the width of image
  22228. * * bufferHeight the height of image
  22229. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  22230. * @returns the VertexData of the Ground designed from a heightmap
  22231. */
  22232. static CreateGroundFromHeightMap(options: {
  22233. width: number;
  22234. height: number;
  22235. subdivisions: number;
  22236. minHeight: number;
  22237. maxHeight: number;
  22238. colorFilter: Color3;
  22239. buffer: Uint8Array;
  22240. bufferWidth: number;
  22241. bufferHeight: number;
  22242. alphaFilter: number;
  22243. }): VertexData;
  22244. /**
  22245. * Creates the VertexData for a Plane
  22246. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  22247. * * size sets the width and height of the plane to the value of size, optional default 1
  22248. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  22249. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  22250. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22251. * * 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)
  22252. * * 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)
  22253. * @returns the VertexData of the box
  22254. */
  22255. static CreatePlane(options: {
  22256. size?: number;
  22257. width?: number;
  22258. height?: number;
  22259. sideOrientation?: number;
  22260. frontUVs?: Vector4;
  22261. backUVs?: Vector4;
  22262. }): VertexData;
  22263. /**
  22264. * Creates the VertexData of the Disc or regular Polygon
  22265. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  22266. * * radius the radius of the disc, optional default 0.5
  22267. * * tessellation the number of polygon sides, optional, default 64
  22268. * * 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
  22269. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22270. * * 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)
  22271. * * 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)
  22272. * @returns the VertexData of the box
  22273. */
  22274. static CreateDisc(options: {
  22275. radius?: number;
  22276. tessellation?: number;
  22277. arc?: number;
  22278. sideOrientation?: number;
  22279. frontUVs?: Vector4;
  22280. backUVs?: Vector4;
  22281. }): VertexData;
  22282. /**
  22283. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  22284. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  22285. * @param polygon a mesh built from polygonTriangulation.build()
  22286. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22287. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  22288. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  22289. * @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)
  22290. * @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)
  22291. * @returns the VertexData of the Polygon
  22292. */
  22293. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  22294. /**
  22295. * Creates the VertexData of the IcoSphere
  22296. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  22297. * * radius the radius of the IcoSphere, optional default 1
  22298. * * radiusX allows stretching in the x direction, optional, default radius
  22299. * * radiusY allows stretching in the y direction, optional, default radius
  22300. * * radiusZ allows stretching in the z direction, optional, default radius
  22301. * * flat when true creates a flat shaded mesh, optional, default true
  22302. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  22303. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22304. * * 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)
  22305. * * 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)
  22306. * @returns the VertexData of the IcoSphere
  22307. */
  22308. static CreateIcoSphere(options: {
  22309. radius?: number;
  22310. radiusX?: number;
  22311. radiusY?: number;
  22312. radiusZ?: number;
  22313. flat?: boolean;
  22314. subdivisions?: number;
  22315. sideOrientation?: number;
  22316. frontUVs?: Vector4;
  22317. backUVs?: Vector4;
  22318. }): VertexData;
  22319. /**
  22320. * Creates the VertexData for a Polyhedron
  22321. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  22322. * * type provided types are:
  22323. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  22324. * * 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)
  22325. * * size the size of the IcoSphere, optional default 1
  22326. * * sizeX allows stretching in the x direction, optional, default size
  22327. * * sizeY allows stretching in the y direction, optional, default size
  22328. * * sizeZ allows stretching in the z direction, optional, default size
  22329. * * 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
  22330. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  22331. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  22332. * * flat when true creates a flat shaded mesh, optional, default true
  22333. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  22334. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22335. * * 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)
  22336. * * 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)
  22337. * @returns the VertexData of the Polyhedron
  22338. */
  22339. static CreatePolyhedron(options: {
  22340. type?: number;
  22341. size?: number;
  22342. sizeX?: number;
  22343. sizeY?: number;
  22344. sizeZ?: number;
  22345. custom?: any;
  22346. faceUV?: Vector4[];
  22347. faceColors?: Color4[];
  22348. flat?: boolean;
  22349. sideOrientation?: number;
  22350. frontUVs?: Vector4;
  22351. backUVs?: Vector4;
  22352. }): VertexData;
  22353. /**
  22354. * Creates the VertexData for a TorusKnot
  22355. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  22356. * * radius the radius of the torus knot, optional, default 2
  22357. * * tube the thickness of the tube, optional, default 0.5
  22358. * * radialSegments the number of sides on each tube segments, optional, default 32
  22359. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  22360. * * p the number of windings around the z axis, optional, default 2
  22361. * * q the number of windings around the x axis, optional, default 3
  22362. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22363. * * 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)
  22364. * * 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)
  22365. * @returns the VertexData of the Torus Knot
  22366. */
  22367. static CreateTorusKnot(options: {
  22368. radius?: number;
  22369. tube?: number;
  22370. radialSegments?: number;
  22371. tubularSegments?: number;
  22372. p?: number;
  22373. q?: number;
  22374. sideOrientation?: number;
  22375. frontUVs?: Vector4;
  22376. backUVs?: Vector4;
  22377. }): VertexData;
  22378. /**
  22379. * Compute normals for given positions and indices
  22380. * @param positions an array of vertex positions, [...., x, y, z, ......]
  22381. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  22382. * @param normals an array of vertex normals, [...., x, y, z, ......]
  22383. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  22384. * * facetNormals : optional array of facet normals (vector3)
  22385. * * facetPositions : optional array of facet positions (vector3)
  22386. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  22387. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  22388. * * bInfo : optional bounding info, required for facetPartitioning computation
  22389. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  22390. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  22391. * * useRightHandedSystem: optional boolean to for right handed system computation
  22392. * * depthSort : optional boolean to enable the facet depth sort computation
  22393. * * distanceTo : optional Vector3 to compute the facet depth from this location
  22394. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  22395. */
  22396. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  22397. facetNormals?: any;
  22398. facetPositions?: any;
  22399. facetPartitioning?: any;
  22400. ratio?: number;
  22401. bInfo?: any;
  22402. bbSize?: Vector3;
  22403. subDiv?: any;
  22404. useRightHandedSystem?: boolean;
  22405. depthSort?: boolean;
  22406. distanceTo?: Vector3;
  22407. depthSortedFacets?: any;
  22408. }): void;
  22409. /** @hidden */
  22410. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  22411. /**
  22412. * Applies VertexData created from the imported parameters to the geometry
  22413. * @param parsedVertexData the parsed data from an imported file
  22414. * @param geometry the geometry to apply the VertexData to
  22415. */
  22416. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  22417. }
  22418. }
  22419. declare module "babylonjs/Morph/morphTarget" {
  22420. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  22421. import { Observable } from "babylonjs/Misc/observable";
  22422. import { Nullable, FloatArray } from "babylonjs/types";
  22423. import { Scene } from "babylonjs/scene";
  22424. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  22425. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  22426. /**
  22427. * Defines a target to use with MorphTargetManager
  22428. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  22429. */
  22430. export class MorphTarget implements IAnimatable {
  22431. /** defines the name of the target */
  22432. name: string;
  22433. /**
  22434. * Gets or sets the list of animations
  22435. */
  22436. animations: import("babylonjs/Animations/animation").Animation[];
  22437. private _scene;
  22438. private _positions;
  22439. private _normals;
  22440. private _tangents;
  22441. private _uvs;
  22442. private _influence;
  22443. /**
  22444. * Observable raised when the influence changes
  22445. */
  22446. onInfluenceChanged: Observable<boolean>;
  22447. /** @hidden */
  22448. _onDataLayoutChanged: Observable<void>;
  22449. /**
  22450. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  22451. */
  22452. influence: number;
  22453. /**
  22454. * Gets or sets the id of the morph Target
  22455. */
  22456. id: string;
  22457. private _animationPropertiesOverride;
  22458. /**
  22459. * Gets or sets the animation properties override
  22460. */
  22461. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  22462. /**
  22463. * Creates a new MorphTarget
  22464. * @param name defines the name of the target
  22465. * @param influence defines the influence to use
  22466. * @param scene defines the scene the morphtarget belongs to
  22467. */
  22468. constructor(
  22469. /** defines the name of the target */
  22470. name: string, influence?: number, scene?: Nullable<Scene>);
  22471. /**
  22472. * Gets a boolean defining if the target contains position data
  22473. */
  22474. readonly hasPositions: boolean;
  22475. /**
  22476. * Gets a boolean defining if the target contains normal data
  22477. */
  22478. readonly hasNormals: boolean;
  22479. /**
  22480. * Gets a boolean defining if the target contains tangent data
  22481. */
  22482. readonly hasTangents: boolean;
  22483. /**
  22484. * Gets a boolean defining if the target contains texture coordinates data
  22485. */
  22486. readonly hasUVs: boolean;
  22487. /**
  22488. * Affects position data to this target
  22489. * @param data defines the position data to use
  22490. */
  22491. setPositions(data: Nullable<FloatArray>): void;
  22492. /**
  22493. * Gets the position data stored in this target
  22494. * @returns a FloatArray containing the position data (or null if not present)
  22495. */
  22496. getPositions(): Nullable<FloatArray>;
  22497. /**
  22498. * Affects normal data to this target
  22499. * @param data defines the normal data to use
  22500. */
  22501. setNormals(data: Nullable<FloatArray>): void;
  22502. /**
  22503. * Gets the normal data stored in this target
  22504. * @returns a FloatArray containing the normal data (or null if not present)
  22505. */
  22506. getNormals(): Nullable<FloatArray>;
  22507. /**
  22508. * Affects tangent data to this target
  22509. * @param data defines the tangent data to use
  22510. */
  22511. setTangents(data: Nullable<FloatArray>): void;
  22512. /**
  22513. * Gets the tangent data stored in this target
  22514. * @returns a FloatArray containing the tangent data (or null if not present)
  22515. */
  22516. getTangents(): Nullable<FloatArray>;
  22517. /**
  22518. * Affects texture coordinates data to this target
  22519. * @param data defines the texture coordinates data to use
  22520. */
  22521. setUVs(data: Nullable<FloatArray>): void;
  22522. /**
  22523. * Gets the texture coordinates data stored in this target
  22524. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  22525. */
  22526. getUVs(): Nullable<FloatArray>;
  22527. /**
  22528. * Serializes the current target into a Serialization object
  22529. * @returns the serialized object
  22530. */
  22531. serialize(): any;
  22532. /**
  22533. * Returns the string "MorphTarget"
  22534. * @returns "MorphTarget"
  22535. */
  22536. getClassName(): string;
  22537. /**
  22538. * Creates a new target from serialized data
  22539. * @param serializationObject defines the serialized data to use
  22540. * @returns a new MorphTarget
  22541. */
  22542. static Parse(serializationObject: any): MorphTarget;
  22543. /**
  22544. * Creates a MorphTarget from mesh data
  22545. * @param mesh defines the source mesh
  22546. * @param name defines the name to use for the new target
  22547. * @param influence defines the influence to attach to the target
  22548. * @returns a new MorphTarget
  22549. */
  22550. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  22551. }
  22552. }
  22553. declare module "babylonjs/Morph/morphTargetManager" {
  22554. import { Nullable } from "babylonjs/types";
  22555. import { Scene } from "babylonjs/scene";
  22556. import { MorphTarget } from "babylonjs/Morph/morphTarget";
  22557. /**
  22558. * This class is used to deform meshes using morphing between different targets
  22559. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  22560. */
  22561. export class MorphTargetManager {
  22562. private _targets;
  22563. private _targetInfluenceChangedObservers;
  22564. private _targetDataLayoutChangedObservers;
  22565. private _activeTargets;
  22566. private _scene;
  22567. private _influences;
  22568. private _supportsNormals;
  22569. private _supportsTangents;
  22570. private _supportsUVs;
  22571. private _vertexCount;
  22572. private _uniqueId;
  22573. private _tempInfluences;
  22574. /**
  22575. * Gets or sets a boolean indicating if normals must be morphed
  22576. */
  22577. enableNormalMorphing: boolean;
  22578. /**
  22579. * Gets or sets a boolean indicating if tangents must be morphed
  22580. */
  22581. enableTangentMorphing: boolean;
  22582. /**
  22583. * Gets or sets a boolean indicating if UV must be morphed
  22584. */
  22585. enableUVMorphing: boolean;
  22586. /**
  22587. * Creates a new MorphTargetManager
  22588. * @param scene defines the current scene
  22589. */
  22590. constructor(scene?: Nullable<Scene>);
  22591. /**
  22592. * Gets the unique ID of this manager
  22593. */
  22594. readonly uniqueId: number;
  22595. /**
  22596. * Gets the number of vertices handled by this manager
  22597. */
  22598. readonly vertexCount: number;
  22599. /**
  22600. * Gets a boolean indicating if this manager supports morphing of normals
  22601. */
  22602. readonly supportsNormals: boolean;
  22603. /**
  22604. * Gets a boolean indicating if this manager supports morphing of tangents
  22605. */
  22606. readonly supportsTangents: boolean;
  22607. /**
  22608. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  22609. */
  22610. readonly supportsUVs: boolean;
  22611. /**
  22612. * Gets the number of targets stored in this manager
  22613. */
  22614. readonly numTargets: number;
  22615. /**
  22616. * Gets the number of influencers (ie. the number of targets with influences > 0)
  22617. */
  22618. readonly numInfluencers: number;
  22619. /**
  22620. * Gets the list of influences (one per target)
  22621. */
  22622. readonly influences: Float32Array;
  22623. /**
  22624. * Gets the active target at specified index. An active target is a target with an influence > 0
  22625. * @param index defines the index to check
  22626. * @returns the requested target
  22627. */
  22628. getActiveTarget(index: number): MorphTarget;
  22629. /**
  22630. * Gets the target at specified index
  22631. * @param index defines the index to check
  22632. * @returns the requested target
  22633. */
  22634. getTarget(index: number): MorphTarget;
  22635. /**
  22636. * Add a new target to this manager
  22637. * @param target defines the target to add
  22638. */
  22639. addTarget(target: MorphTarget): void;
  22640. /**
  22641. * Removes a target from the manager
  22642. * @param target defines the target to remove
  22643. */
  22644. removeTarget(target: MorphTarget): void;
  22645. /**
  22646. * Serializes the current manager into a Serialization object
  22647. * @returns the serialized object
  22648. */
  22649. serialize(): any;
  22650. private _syncActiveTargets;
  22651. /**
  22652. * Syncrhonize the targets with all the meshes using this morph target manager
  22653. */
  22654. synchronize(): void;
  22655. /**
  22656. * Creates a new MorphTargetManager from serialized data
  22657. * @param serializationObject defines the serialized data
  22658. * @param scene defines the hosting scene
  22659. * @returns the new MorphTargetManager
  22660. */
  22661. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  22662. }
  22663. }
  22664. declare module "babylonjs/Meshes/meshLODLevel" {
  22665. import { Mesh } from "babylonjs/Meshes/mesh";
  22666. import { Nullable } from "babylonjs/types";
  22667. /**
  22668. * Class used to represent a specific level of detail of a mesh
  22669. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  22670. */
  22671. export class MeshLODLevel {
  22672. /** Defines the distance where this level should star being displayed */
  22673. distance: number;
  22674. /** Defines the mesh to use to render this level */
  22675. mesh: Nullable<Mesh>;
  22676. /**
  22677. * Creates a new LOD level
  22678. * @param distance defines the distance where this level should star being displayed
  22679. * @param mesh defines the mesh to use to render this level
  22680. */
  22681. constructor(
  22682. /** Defines the distance where this level should star being displayed */
  22683. distance: number,
  22684. /** Defines the mesh to use to render this level */
  22685. mesh: Nullable<Mesh>);
  22686. }
  22687. }
  22688. declare module "babylonjs/Meshes/groundMesh" {
  22689. import { Scene } from "babylonjs/scene";
  22690. import { Vector3 } from "babylonjs/Maths/math.vector";
  22691. import { Mesh } from "babylonjs/Meshes/mesh";
  22692. /**
  22693. * Mesh representing the gorund
  22694. */
  22695. export class GroundMesh extends Mesh {
  22696. /** If octree should be generated */
  22697. generateOctree: boolean;
  22698. private _heightQuads;
  22699. /** @hidden */
  22700. _subdivisionsX: number;
  22701. /** @hidden */
  22702. _subdivisionsY: number;
  22703. /** @hidden */
  22704. _width: number;
  22705. /** @hidden */
  22706. _height: number;
  22707. /** @hidden */
  22708. _minX: number;
  22709. /** @hidden */
  22710. _maxX: number;
  22711. /** @hidden */
  22712. _minZ: number;
  22713. /** @hidden */
  22714. _maxZ: number;
  22715. constructor(name: string, scene: Scene);
  22716. /**
  22717. * "GroundMesh"
  22718. * @returns "GroundMesh"
  22719. */
  22720. getClassName(): string;
  22721. /**
  22722. * The minimum of x and y subdivisions
  22723. */
  22724. readonly subdivisions: number;
  22725. /**
  22726. * X subdivisions
  22727. */
  22728. readonly subdivisionsX: number;
  22729. /**
  22730. * Y subdivisions
  22731. */
  22732. readonly subdivisionsY: number;
  22733. /**
  22734. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  22735. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  22736. * @param chunksCount the number of subdivisions for x and y
  22737. * @param octreeBlocksSize (Default: 32)
  22738. */
  22739. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  22740. /**
  22741. * Returns a height (y) value in the Worl system :
  22742. * the ground altitude at the coordinates (x, z) expressed in the World system.
  22743. * @param x x coordinate
  22744. * @param z z coordinate
  22745. * @returns the ground y position if (x, z) are outside the ground surface.
  22746. */
  22747. getHeightAtCoordinates(x: number, z: number): number;
  22748. /**
  22749. * Returns a normalized vector (Vector3) orthogonal to the ground
  22750. * at the ground coordinates (x, z) expressed in the World system.
  22751. * @param x x coordinate
  22752. * @param z z coordinate
  22753. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  22754. */
  22755. getNormalAtCoordinates(x: number, z: number): Vector3;
  22756. /**
  22757. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  22758. * at the ground coordinates (x, z) expressed in the World system.
  22759. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  22760. * @param x x coordinate
  22761. * @param z z coordinate
  22762. * @param ref vector to store the result
  22763. * @returns the GroundMesh.
  22764. */
  22765. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  22766. /**
  22767. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  22768. * if the ground has been updated.
  22769. * This can be used in the render loop.
  22770. * @returns the GroundMesh.
  22771. */
  22772. updateCoordinateHeights(): GroundMesh;
  22773. private _getFacetAt;
  22774. private _initHeightQuads;
  22775. private _computeHeightQuads;
  22776. /**
  22777. * Serializes this ground mesh
  22778. * @param serializationObject object to write serialization to
  22779. */
  22780. serialize(serializationObject: any): void;
  22781. /**
  22782. * Parses a serialized ground mesh
  22783. * @param parsedMesh the serialized mesh
  22784. * @param scene the scene to create the ground mesh in
  22785. * @returns the created ground mesh
  22786. */
  22787. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  22788. }
  22789. }
  22790. declare module "babylonjs/Physics/physicsJoint" {
  22791. import { Vector3 } from "babylonjs/Maths/math.vector";
  22792. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  22793. /**
  22794. * Interface for Physics-Joint data
  22795. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22796. */
  22797. export interface PhysicsJointData {
  22798. /**
  22799. * The main pivot of the joint
  22800. */
  22801. mainPivot?: Vector3;
  22802. /**
  22803. * The connected pivot of the joint
  22804. */
  22805. connectedPivot?: Vector3;
  22806. /**
  22807. * The main axis of the joint
  22808. */
  22809. mainAxis?: Vector3;
  22810. /**
  22811. * The connected axis of the joint
  22812. */
  22813. connectedAxis?: Vector3;
  22814. /**
  22815. * The collision of the joint
  22816. */
  22817. collision?: boolean;
  22818. /**
  22819. * Native Oimo/Cannon/Energy data
  22820. */
  22821. nativeParams?: any;
  22822. }
  22823. /**
  22824. * This is a holder class for the physics joint created by the physics plugin
  22825. * It holds a set of functions to control the underlying joint
  22826. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22827. */
  22828. export class PhysicsJoint {
  22829. /**
  22830. * The type of the physics joint
  22831. */
  22832. type: number;
  22833. /**
  22834. * The data for the physics joint
  22835. */
  22836. jointData: PhysicsJointData;
  22837. private _physicsJoint;
  22838. protected _physicsPlugin: IPhysicsEnginePlugin;
  22839. /**
  22840. * Initializes the physics joint
  22841. * @param type The type of the physics joint
  22842. * @param jointData The data for the physics joint
  22843. */
  22844. constructor(
  22845. /**
  22846. * The type of the physics joint
  22847. */
  22848. type: number,
  22849. /**
  22850. * The data for the physics joint
  22851. */
  22852. jointData: PhysicsJointData);
  22853. /**
  22854. * Gets the physics joint
  22855. */
  22856. /**
  22857. * Sets the physics joint
  22858. */
  22859. physicsJoint: any;
  22860. /**
  22861. * Sets the physics plugin
  22862. */
  22863. physicsPlugin: IPhysicsEnginePlugin;
  22864. /**
  22865. * Execute a function that is physics-plugin specific.
  22866. * @param {Function} func the function that will be executed.
  22867. * It accepts two parameters: the physics world and the physics joint
  22868. */
  22869. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  22870. /**
  22871. * Distance-Joint type
  22872. */
  22873. static DistanceJoint: number;
  22874. /**
  22875. * Hinge-Joint type
  22876. */
  22877. static HingeJoint: number;
  22878. /**
  22879. * Ball-and-Socket joint type
  22880. */
  22881. static BallAndSocketJoint: number;
  22882. /**
  22883. * Wheel-Joint type
  22884. */
  22885. static WheelJoint: number;
  22886. /**
  22887. * Slider-Joint type
  22888. */
  22889. static SliderJoint: number;
  22890. /**
  22891. * Prismatic-Joint type
  22892. */
  22893. static PrismaticJoint: number;
  22894. /**
  22895. * Universal-Joint type
  22896. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  22897. */
  22898. static UniversalJoint: number;
  22899. /**
  22900. * Hinge-Joint 2 type
  22901. */
  22902. static Hinge2Joint: number;
  22903. /**
  22904. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  22905. */
  22906. static PointToPointJoint: number;
  22907. /**
  22908. * Spring-Joint type
  22909. */
  22910. static SpringJoint: number;
  22911. /**
  22912. * Lock-Joint type
  22913. */
  22914. static LockJoint: number;
  22915. }
  22916. /**
  22917. * A class representing a physics distance joint
  22918. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22919. */
  22920. export class DistanceJoint extends PhysicsJoint {
  22921. /**
  22922. *
  22923. * @param jointData The data for the Distance-Joint
  22924. */
  22925. constructor(jointData: DistanceJointData);
  22926. /**
  22927. * Update the predefined distance.
  22928. * @param maxDistance The maximum preferred distance
  22929. * @param minDistance The minimum preferred distance
  22930. */
  22931. updateDistance(maxDistance: number, minDistance?: number): void;
  22932. }
  22933. /**
  22934. * Represents a Motor-Enabled Joint
  22935. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22936. */
  22937. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  22938. /**
  22939. * Initializes the Motor-Enabled Joint
  22940. * @param type The type of the joint
  22941. * @param jointData The physica joint data for the joint
  22942. */
  22943. constructor(type: number, jointData: PhysicsJointData);
  22944. /**
  22945. * Set the motor values.
  22946. * Attention, this function is plugin specific. Engines won't react 100% the same.
  22947. * @param force the force to apply
  22948. * @param maxForce max force for this motor.
  22949. */
  22950. setMotor(force?: number, maxForce?: number): void;
  22951. /**
  22952. * Set the motor's limits.
  22953. * Attention, this function is plugin specific. Engines won't react 100% the same.
  22954. * @param upperLimit The upper limit of the motor
  22955. * @param lowerLimit The lower limit of the motor
  22956. */
  22957. setLimit(upperLimit: number, lowerLimit?: number): void;
  22958. }
  22959. /**
  22960. * This class represents a single physics Hinge-Joint
  22961. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22962. */
  22963. export class HingeJoint extends MotorEnabledJoint {
  22964. /**
  22965. * Initializes the Hinge-Joint
  22966. * @param jointData The joint data for the Hinge-Joint
  22967. */
  22968. constructor(jointData: PhysicsJointData);
  22969. /**
  22970. * Set the motor values.
  22971. * Attention, this function is plugin specific. Engines won't react 100% the same.
  22972. * @param {number} force the force to apply
  22973. * @param {number} maxForce max force for this motor.
  22974. */
  22975. setMotor(force?: number, maxForce?: number): void;
  22976. /**
  22977. * Set the motor's limits.
  22978. * Attention, this function is plugin specific. Engines won't react 100% the same.
  22979. * @param upperLimit The upper limit of the motor
  22980. * @param lowerLimit The lower limit of the motor
  22981. */
  22982. setLimit(upperLimit: number, lowerLimit?: number): void;
  22983. }
  22984. /**
  22985. * This class represents a dual hinge physics joint (same as wheel joint)
  22986. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22987. */
  22988. export class Hinge2Joint extends MotorEnabledJoint {
  22989. /**
  22990. * Initializes the Hinge2-Joint
  22991. * @param jointData The joint data for the Hinge2-Joint
  22992. */
  22993. constructor(jointData: PhysicsJointData);
  22994. /**
  22995. * Set the motor values.
  22996. * Attention, this function is plugin specific. Engines won't react 100% the same.
  22997. * @param {number} targetSpeed the speed the motor is to reach
  22998. * @param {number} maxForce max force for this motor.
  22999. * @param {motorIndex} the motor's index, 0 or 1.
  23000. */
  23001. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  23002. /**
  23003. * Set the motor limits.
  23004. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23005. * @param {number} upperLimit the upper limit
  23006. * @param {number} lowerLimit lower limit
  23007. * @param {motorIndex} the motor's index, 0 or 1.
  23008. */
  23009. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  23010. }
  23011. /**
  23012. * Interface for a motor enabled joint
  23013. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23014. */
  23015. export interface IMotorEnabledJoint {
  23016. /**
  23017. * Physics joint
  23018. */
  23019. physicsJoint: any;
  23020. /**
  23021. * Sets the motor of the motor-enabled joint
  23022. * @param force The force of the motor
  23023. * @param maxForce The maximum force of the motor
  23024. * @param motorIndex The index of the motor
  23025. */
  23026. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  23027. /**
  23028. * Sets the limit of the motor
  23029. * @param upperLimit The upper limit of the motor
  23030. * @param lowerLimit The lower limit of the motor
  23031. * @param motorIndex The index of the motor
  23032. */
  23033. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  23034. }
  23035. /**
  23036. * Joint data for a Distance-Joint
  23037. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23038. */
  23039. export interface DistanceJointData extends PhysicsJointData {
  23040. /**
  23041. * Max distance the 2 joint objects can be apart
  23042. */
  23043. maxDistance: number;
  23044. }
  23045. /**
  23046. * Joint data from a spring joint
  23047. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23048. */
  23049. export interface SpringJointData extends PhysicsJointData {
  23050. /**
  23051. * Length of the spring
  23052. */
  23053. length: number;
  23054. /**
  23055. * Stiffness of the spring
  23056. */
  23057. stiffness: number;
  23058. /**
  23059. * Damping of the spring
  23060. */
  23061. damping: number;
  23062. /** this callback will be called when applying the force to the impostors. */
  23063. forceApplicationCallback: () => void;
  23064. }
  23065. }
  23066. declare module "babylonjs/Physics/physicsRaycastResult" {
  23067. import { Vector3 } from "babylonjs/Maths/math.vector";
  23068. /**
  23069. * Holds the data for the raycast result
  23070. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23071. */
  23072. export class PhysicsRaycastResult {
  23073. private _hasHit;
  23074. private _hitDistance;
  23075. private _hitNormalWorld;
  23076. private _hitPointWorld;
  23077. private _rayFromWorld;
  23078. private _rayToWorld;
  23079. /**
  23080. * Gets if there was a hit
  23081. */
  23082. readonly hasHit: boolean;
  23083. /**
  23084. * Gets the distance from the hit
  23085. */
  23086. readonly hitDistance: number;
  23087. /**
  23088. * Gets the hit normal/direction in the world
  23089. */
  23090. readonly hitNormalWorld: Vector3;
  23091. /**
  23092. * Gets the hit point in the world
  23093. */
  23094. readonly hitPointWorld: Vector3;
  23095. /**
  23096. * Gets the ray "start point" of the ray in the world
  23097. */
  23098. readonly rayFromWorld: Vector3;
  23099. /**
  23100. * Gets the ray "end point" of the ray in the world
  23101. */
  23102. readonly rayToWorld: Vector3;
  23103. /**
  23104. * Sets the hit data (normal & point in world space)
  23105. * @param hitNormalWorld defines the normal in world space
  23106. * @param hitPointWorld defines the point in world space
  23107. */
  23108. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  23109. /**
  23110. * Sets the distance from the start point to the hit point
  23111. * @param distance
  23112. */
  23113. setHitDistance(distance: number): void;
  23114. /**
  23115. * Calculates the distance manually
  23116. */
  23117. calculateHitDistance(): void;
  23118. /**
  23119. * Resets all the values to default
  23120. * @param from The from point on world space
  23121. * @param to The to point on world space
  23122. */
  23123. reset(from?: Vector3, to?: Vector3): void;
  23124. }
  23125. /**
  23126. * Interface for the size containing width and height
  23127. */
  23128. interface IXYZ {
  23129. /**
  23130. * X
  23131. */
  23132. x: number;
  23133. /**
  23134. * Y
  23135. */
  23136. y: number;
  23137. /**
  23138. * Z
  23139. */
  23140. z: number;
  23141. }
  23142. }
  23143. declare module "babylonjs/Physics/IPhysicsEngine" {
  23144. import { Nullable } from "babylonjs/types";
  23145. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  23146. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  23147. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  23148. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  23149. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  23150. /**
  23151. * Interface used to describe a physics joint
  23152. */
  23153. export interface PhysicsImpostorJoint {
  23154. /** Defines the main impostor to which the joint is linked */
  23155. mainImpostor: PhysicsImpostor;
  23156. /** Defines the impostor that is connected to the main impostor using this joint */
  23157. connectedImpostor: PhysicsImpostor;
  23158. /** Defines the joint itself */
  23159. joint: PhysicsJoint;
  23160. }
  23161. /** @hidden */
  23162. export interface IPhysicsEnginePlugin {
  23163. world: any;
  23164. name: string;
  23165. setGravity(gravity: Vector3): void;
  23166. setTimeStep(timeStep: number): void;
  23167. getTimeStep(): number;
  23168. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  23169. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  23170. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  23171. generatePhysicsBody(impostor: PhysicsImpostor): void;
  23172. removePhysicsBody(impostor: PhysicsImpostor): void;
  23173. generateJoint(joint: PhysicsImpostorJoint): void;
  23174. removeJoint(joint: PhysicsImpostorJoint): void;
  23175. isSupported(): boolean;
  23176. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  23177. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  23178. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  23179. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  23180. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  23181. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  23182. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  23183. getBodyMass(impostor: PhysicsImpostor): number;
  23184. getBodyFriction(impostor: PhysicsImpostor): number;
  23185. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  23186. getBodyRestitution(impostor: PhysicsImpostor): number;
  23187. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  23188. getBodyPressure?(impostor: PhysicsImpostor): number;
  23189. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  23190. getBodyStiffness?(impostor: PhysicsImpostor): number;
  23191. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  23192. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  23193. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  23194. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  23195. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  23196. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  23197. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  23198. sleepBody(impostor: PhysicsImpostor): void;
  23199. wakeUpBody(impostor: PhysicsImpostor): void;
  23200. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  23201. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  23202. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  23203. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  23204. getRadius(impostor: PhysicsImpostor): number;
  23205. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  23206. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  23207. dispose(): void;
  23208. }
  23209. /**
  23210. * Interface used to define a physics engine
  23211. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  23212. */
  23213. export interface IPhysicsEngine {
  23214. /**
  23215. * Gets the gravity vector used by the simulation
  23216. */
  23217. gravity: Vector3;
  23218. /**
  23219. * Sets the gravity vector used by the simulation
  23220. * @param gravity defines the gravity vector to use
  23221. */
  23222. setGravity(gravity: Vector3): void;
  23223. /**
  23224. * Set the time step of the physics engine.
  23225. * Default is 1/60.
  23226. * To slow it down, enter 1/600 for example.
  23227. * To speed it up, 1/30
  23228. * @param newTimeStep the new timestep to apply to this world.
  23229. */
  23230. setTimeStep(newTimeStep: number): void;
  23231. /**
  23232. * Get the time step of the physics engine.
  23233. * @returns the current time step
  23234. */
  23235. getTimeStep(): number;
  23236. /**
  23237. * Release all resources
  23238. */
  23239. dispose(): void;
  23240. /**
  23241. * Gets the name of the current physics plugin
  23242. * @returns the name of the plugin
  23243. */
  23244. getPhysicsPluginName(): string;
  23245. /**
  23246. * Adding a new impostor for the impostor tracking.
  23247. * This will be done by the impostor itself.
  23248. * @param impostor the impostor to add
  23249. */
  23250. addImpostor(impostor: PhysicsImpostor): void;
  23251. /**
  23252. * Remove an impostor from the engine.
  23253. * This impostor and its mesh will not longer be updated by the physics engine.
  23254. * @param impostor the impostor to remove
  23255. */
  23256. removeImpostor(impostor: PhysicsImpostor): void;
  23257. /**
  23258. * Add a joint to the physics engine
  23259. * @param mainImpostor defines the main impostor to which the joint is added.
  23260. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  23261. * @param joint defines the joint that will connect both impostors.
  23262. */
  23263. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  23264. /**
  23265. * Removes a joint from the simulation
  23266. * @param mainImpostor defines the impostor used with the joint
  23267. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  23268. * @param joint defines the joint to remove
  23269. */
  23270. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  23271. /**
  23272. * Gets the current plugin used to run the simulation
  23273. * @returns current plugin
  23274. */
  23275. getPhysicsPlugin(): IPhysicsEnginePlugin;
  23276. /**
  23277. * Gets the list of physic impostors
  23278. * @returns an array of PhysicsImpostor
  23279. */
  23280. getImpostors(): Array<PhysicsImpostor>;
  23281. /**
  23282. * Gets the impostor for a physics enabled object
  23283. * @param object defines the object impersonated by the impostor
  23284. * @returns the PhysicsImpostor or null if not found
  23285. */
  23286. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  23287. /**
  23288. * Gets the impostor for a physics body object
  23289. * @param body defines physics body used by the impostor
  23290. * @returns the PhysicsImpostor or null if not found
  23291. */
  23292. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  23293. /**
  23294. * Does a raycast in the physics world
  23295. * @param from when should the ray start?
  23296. * @param to when should the ray end?
  23297. * @returns PhysicsRaycastResult
  23298. */
  23299. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  23300. /**
  23301. * Called by the scene. No need to call it.
  23302. * @param delta defines the timespam between frames
  23303. */
  23304. _step(delta: number): void;
  23305. }
  23306. }
  23307. declare module "babylonjs/Physics/physicsImpostor" {
  23308. import { Nullable, IndicesArray } from "babylonjs/types";
  23309. import { Vector3, Matrix, Quaternion } from "babylonjs/Maths/math.vector";
  23310. import { TransformNode } from "babylonjs/Meshes/transformNode";
  23311. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  23312. import { Scene } from "babylonjs/scene";
  23313. import { Bone } from "babylonjs/Bones/bone";
  23314. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  23315. import { PhysicsJoint, PhysicsJointData } from "babylonjs/Physics/physicsJoint";
  23316. import { Space } from "babylonjs/Maths/math.axis";
  23317. /**
  23318. * The interface for the physics imposter parameters
  23319. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23320. */
  23321. export interface PhysicsImpostorParameters {
  23322. /**
  23323. * The mass of the physics imposter
  23324. */
  23325. mass: number;
  23326. /**
  23327. * The friction of the physics imposter
  23328. */
  23329. friction?: number;
  23330. /**
  23331. * The coefficient of restitution of the physics imposter
  23332. */
  23333. restitution?: number;
  23334. /**
  23335. * The native options of the physics imposter
  23336. */
  23337. nativeOptions?: any;
  23338. /**
  23339. * Specifies if the parent should be ignored
  23340. */
  23341. ignoreParent?: boolean;
  23342. /**
  23343. * Specifies if bi-directional transformations should be disabled
  23344. */
  23345. disableBidirectionalTransformation?: boolean;
  23346. /**
  23347. * The pressure inside the physics imposter, soft object only
  23348. */
  23349. pressure?: number;
  23350. /**
  23351. * The stiffness the physics imposter, soft object only
  23352. */
  23353. stiffness?: number;
  23354. /**
  23355. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  23356. */
  23357. velocityIterations?: number;
  23358. /**
  23359. * The number of iterations used in maintaining consistent vertex positions, soft object only
  23360. */
  23361. positionIterations?: number;
  23362. /**
  23363. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  23364. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  23365. * Add to fix multiple points
  23366. */
  23367. fixedPoints?: number;
  23368. /**
  23369. * The collision margin around a soft object
  23370. */
  23371. margin?: number;
  23372. /**
  23373. * The collision margin around a soft object
  23374. */
  23375. damping?: number;
  23376. /**
  23377. * The path for a rope based on an extrusion
  23378. */
  23379. path?: any;
  23380. /**
  23381. * The shape of an extrusion used for a rope based on an extrusion
  23382. */
  23383. shape?: any;
  23384. }
  23385. /**
  23386. * Interface for a physics-enabled object
  23387. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23388. */
  23389. export interface IPhysicsEnabledObject {
  23390. /**
  23391. * The position of the physics-enabled object
  23392. */
  23393. position: Vector3;
  23394. /**
  23395. * The rotation of the physics-enabled object
  23396. */
  23397. rotationQuaternion: Nullable<Quaternion>;
  23398. /**
  23399. * The scale of the physics-enabled object
  23400. */
  23401. scaling: Vector3;
  23402. /**
  23403. * The rotation of the physics-enabled object
  23404. */
  23405. rotation?: Vector3;
  23406. /**
  23407. * The parent of the physics-enabled object
  23408. */
  23409. parent?: any;
  23410. /**
  23411. * The bounding info of the physics-enabled object
  23412. * @returns The bounding info of the physics-enabled object
  23413. */
  23414. getBoundingInfo(): BoundingInfo;
  23415. /**
  23416. * Computes the world matrix
  23417. * @param force Specifies if the world matrix should be computed by force
  23418. * @returns A world matrix
  23419. */
  23420. computeWorldMatrix(force: boolean): Matrix;
  23421. /**
  23422. * Gets the world matrix
  23423. * @returns A world matrix
  23424. */
  23425. getWorldMatrix?(): Matrix;
  23426. /**
  23427. * Gets the child meshes
  23428. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  23429. * @returns An array of abstract meshes
  23430. */
  23431. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  23432. /**
  23433. * Gets the vertex data
  23434. * @param kind The type of vertex data
  23435. * @returns A nullable array of numbers, or a float32 array
  23436. */
  23437. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  23438. /**
  23439. * Gets the indices from the mesh
  23440. * @returns A nullable array of index arrays
  23441. */
  23442. getIndices?(): Nullable<IndicesArray>;
  23443. /**
  23444. * Gets the scene from the mesh
  23445. * @returns the indices array or null
  23446. */
  23447. getScene?(): Scene;
  23448. /**
  23449. * Gets the absolute position from the mesh
  23450. * @returns the absolute position
  23451. */
  23452. getAbsolutePosition(): Vector3;
  23453. /**
  23454. * Gets the absolute pivot point from the mesh
  23455. * @returns the absolute pivot point
  23456. */
  23457. getAbsolutePivotPoint(): Vector3;
  23458. /**
  23459. * Rotates the mesh
  23460. * @param axis The axis of rotation
  23461. * @param amount The amount of rotation
  23462. * @param space The space of the rotation
  23463. * @returns The rotation transform node
  23464. */
  23465. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  23466. /**
  23467. * Translates the mesh
  23468. * @param axis The axis of translation
  23469. * @param distance The distance of translation
  23470. * @param space The space of the translation
  23471. * @returns The transform node
  23472. */
  23473. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  23474. /**
  23475. * Sets the absolute position of the mesh
  23476. * @param absolutePosition The absolute position of the mesh
  23477. * @returns The transform node
  23478. */
  23479. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  23480. /**
  23481. * Gets the class name of the mesh
  23482. * @returns The class name
  23483. */
  23484. getClassName(): string;
  23485. }
  23486. /**
  23487. * Represents a physics imposter
  23488. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23489. */
  23490. export class PhysicsImpostor {
  23491. /**
  23492. * The physics-enabled object used as the physics imposter
  23493. */
  23494. object: IPhysicsEnabledObject;
  23495. /**
  23496. * The type of the physics imposter
  23497. */
  23498. type: number;
  23499. private _options;
  23500. private _scene?;
  23501. /**
  23502. * The default object size of the imposter
  23503. */
  23504. static DEFAULT_OBJECT_SIZE: Vector3;
  23505. /**
  23506. * The identity quaternion of the imposter
  23507. */
  23508. static IDENTITY_QUATERNION: Quaternion;
  23509. /** @hidden */
  23510. _pluginData: any;
  23511. private _physicsEngine;
  23512. private _physicsBody;
  23513. private _bodyUpdateRequired;
  23514. private _onBeforePhysicsStepCallbacks;
  23515. private _onAfterPhysicsStepCallbacks;
  23516. /** @hidden */
  23517. _onPhysicsCollideCallbacks: Array<{
  23518. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  23519. otherImpostors: Array<PhysicsImpostor>;
  23520. }>;
  23521. private _deltaPosition;
  23522. private _deltaRotation;
  23523. private _deltaRotationConjugated;
  23524. /** @hidden */
  23525. _isFromLine: boolean;
  23526. private _parent;
  23527. private _isDisposed;
  23528. private static _tmpVecs;
  23529. private static _tmpQuat;
  23530. /**
  23531. * Specifies if the physics imposter is disposed
  23532. */
  23533. readonly isDisposed: boolean;
  23534. /**
  23535. * Gets the mass of the physics imposter
  23536. */
  23537. mass: number;
  23538. /**
  23539. * Gets the coefficient of friction
  23540. */
  23541. /**
  23542. * Sets the coefficient of friction
  23543. */
  23544. friction: number;
  23545. /**
  23546. * Gets the coefficient of restitution
  23547. */
  23548. /**
  23549. * Sets the coefficient of restitution
  23550. */
  23551. restitution: number;
  23552. /**
  23553. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  23554. */
  23555. /**
  23556. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  23557. */
  23558. pressure: number;
  23559. /**
  23560. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  23561. */
  23562. /**
  23563. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  23564. */
  23565. stiffness: number;
  23566. /**
  23567. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  23568. */
  23569. /**
  23570. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  23571. */
  23572. velocityIterations: number;
  23573. /**
  23574. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  23575. */
  23576. /**
  23577. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  23578. */
  23579. positionIterations: number;
  23580. /**
  23581. * The unique id of the physics imposter
  23582. * set by the physics engine when adding this impostor to the array
  23583. */
  23584. uniqueId: number;
  23585. /**
  23586. * @hidden
  23587. */
  23588. soft: boolean;
  23589. /**
  23590. * @hidden
  23591. */
  23592. segments: number;
  23593. private _joints;
  23594. /**
  23595. * Initializes the physics imposter
  23596. * @param object The physics-enabled object used as the physics imposter
  23597. * @param type The type of the physics imposter
  23598. * @param _options The options for the physics imposter
  23599. * @param _scene The Babylon scene
  23600. */
  23601. constructor(
  23602. /**
  23603. * The physics-enabled object used as the physics imposter
  23604. */
  23605. object: IPhysicsEnabledObject,
  23606. /**
  23607. * The type of the physics imposter
  23608. */
  23609. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  23610. /**
  23611. * This function will completly initialize this impostor.
  23612. * It will create a new body - but only if this mesh has no parent.
  23613. * If it has, this impostor will not be used other than to define the impostor
  23614. * of the child mesh.
  23615. * @hidden
  23616. */
  23617. _init(): void;
  23618. private _getPhysicsParent;
  23619. /**
  23620. * Should a new body be generated.
  23621. * @returns boolean specifying if body initialization is required
  23622. */
  23623. isBodyInitRequired(): boolean;
  23624. /**
  23625. * Sets the updated scaling
  23626. * @param updated Specifies if the scaling is updated
  23627. */
  23628. setScalingUpdated(): void;
  23629. /**
  23630. * Force a regeneration of this or the parent's impostor's body.
  23631. * Use under cautious - This will remove all joints already implemented.
  23632. */
  23633. forceUpdate(): void;
  23634. /**
  23635. * Gets the body that holds this impostor. Either its own, or its parent.
  23636. */
  23637. /**
  23638. * Set the physics body. Used mainly by the physics engine/plugin
  23639. */
  23640. physicsBody: any;
  23641. /**
  23642. * Get the parent of the physics imposter
  23643. * @returns Physics imposter or null
  23644. */
  23645. /**
  23646. * Sets the parent of the physics imposter
  23647. */
  23648. parent: Nullable<PhysicsImpostor>;
  23649. /**
  23650. * Resets the update flags
  23651. */
  23652. resetUpdateFlags(): void;
  23653. /**
  23654. * Gets the object extend size
  23655. * @returns the object extend size
  23656. */
  23657. getObjectExtendSize(): Vector3;
  23658. /**
  23659. * Gets the object center
  23660. * @returns The object center
  23661. */
  23662. getObjectCenter(): Vector3;
  23663. /**
  23664. * Get a specific parametes from the options parameter
  23665. * @param paramName The object parameter name
  23666. * @returns The object parameter
  23667. */
  23668. getParam(paramName: string): any;
  23669. /**
  23670. * Sets a specific parameter in the options given to the physics plugin
  23671. * @param paramName The parameter name
  23672. * @param value The value of the parameter
  23673. */
  23674. setParam(paramName: string, value: number): void;
  23675. /**
  23676. * Specifically change the body's mass option. Won't recreate the physics body object
  23677. * @param mass The mass of the physics imposter
  23678. */
  23679. setMass(mass: number): void;
  23680. /**
  23681. * Gets the linear velocity
  23682. * @returns linear velocity or null
  23683. */
  23684. getLinearVelocity(): Nullable<Vector3>;
  23685. /**
  23686. * Sets the linear velocity
  23687. * @param velocity linear velocity or null
  23688. */
  23689. setLinearVelocity(velocity: Nullable<Vector3>): void;
  23690. /**
  23691. * Gets the angular velocity
  23692. * @returns angular velocity or null
  23693. */
  23694. getAngularVelocity(): Nullable<Vector3>;
  23695. /**
  23696. * Sets the angular velocity
  23697. * @param velocity The velocity or null
  23698. */
  23699. setAngularVelocity(velocity: Nullable<Vector3>): void;
  23700. /**
  23701. * Execute a function with the physics plugin native code
  23702. * Provide a function the will have two variables - the world object and the physics body object
  23703. * @param func The function to execute with the physics plugin native code
  23704. */
  23705. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  23706. /**
  23707. * Register a function that will be executed before the physics world is stepping forward
  23708. * @param func The function to execute before the physics world is stepped forward
  23709. */
  23710. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  23711. /**
  23712. * Unregister a function that will be executed before the physics world is stepping forward
  23713. * @param func The function to execute before the physics world is stepped forward
  23714. */
  23715. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  23716. /**
  23717. * Register a function that will be executed after the physics step
  23718. * @param func The function to execute after physics step
  23719. */
  23720. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  23721. /**
  23722. * Unregisters a function that will be executed after the physics step
  23723. * @param func The function to execute after physics step
  23724. */
  23725. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  23726. /**
  23727. * register a function that will be executed when this impostor collides against a different body
  23728. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  23729. * @param func Callback that is executed on collision
  23730. */
  23731. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  23732. /**
  23733. * Unregisters the physics imposter on contact
  23734. * @param collideAgainst The physics object to collide against
  23735. * @param func Callback to execute on collision
  23736. */
  23737. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  23738. private _tmpQuat;
  23739. private _tmpQuat2;
  23740. /**
  23741. * Get the parent rotation
  23742. * @returns The parent rotation
  23743. */
  23744. getParentsRotation(): Quaternion;
  23745. /**
  23746. * this function is executed by the physics engine.
  23747. */
  23748. beforeStep: () => void;
  23749. /**
  23750. * this function is executed by the physics engine
  23751. */
  23752. afterStep: () => void;
  23753. /**
  23754. * Legacy collision detection event support
  23755. */
  23756. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  23757. /**
  23758. * event and body object due to cannon's event-based architecture.
  23759. */
  23760. onCollide: (e: {
  23761. body: any;
  23762. }) => void;
  23763. /**
  23764. * Apply a force
  23765. * @param force The force to apply
  23766. * @param contactPoint The contact point for the force
  23767. * @returns The physics imposter
  23768. */
  23769. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  23770. /**
  23771. * Apply an impulse
  23772. * @param force The impulse force
  23773. * @param contactPoint The contact point for the impulse force
  23774. * @returns The physics imposter
  23775. */
  23776. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  23777. /**
  23778. * A help function to create a joint
  23779. * @param otherImpostor A physics imposter used to create a joint
  23780. * @param jointType The type of joint
  23781. * @param jointData The data for the joint
  23782. * @returns The physics imposter
  23783. */
  23784. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  23785. /**
  23786. * Add a joint to this impostor with a different impostor
  23787. * @param otherImpostor A physics imposter used to add a joint
  23788. * @param joint The joint to add
  23789. * @returns The physics imposter
  23790. */
  23791. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  23792. /**
  23793. * Add an anchor to a cloth impostor
  23794. * @param otherImpostor rigid impostor to anchor to
  23795. * @param width ratio across width from 0 to 1
  23796. * @param height ratio up height from 0 to 1
  23797. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  23798. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  23799. * @returns impostor the soft imposter
  23800. */
  23801. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  23802. /**
  23803. * Add a hook to a rope impostor
  23804. * @param otherImpostor rigid impostor to anchor to
  23805. * @param length ratio across rope from 0 to 1
  23806. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  23807. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  23808. * @returns impostor the rope imposter
  23809. */
  23810. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  23811. /**
  23812. * Will keep this body still, in a sleep mode.
  23813. * @returns the physics imposter
  23814. */
  23815. sleep(): PhysicsImpostor;
  23816. /**
  23817. * Wake the body up.
  23818. * @returns The physics imposter
  23819. */
  23820. wakeUp(): PhysicsImpostor;
  23821. /**
  23822. * Clones the physics imposter
  23823. * @param newObject The physics imposter clones to this physics-enabled object
  23824. * @returns A nullable physics imposter
  23825. */
  23826. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  23827. /**
  23828. * Disposes the physics imposter
  23829. */
  23830. dispose(): void;
  23831. /**
  23832. * Sets the delta position
  23833. * @param position The delta position amount
  23834. */
  23835. setDeltaPosition(position: Vector3): void;
  23836. /**
  23837. * Sets the delta rotation
  23838. * @param rotation The delta rotation amount
  23839. */
  23840. setDeltaRotation(rotation: Quaternion): void;
  23841. /**
  23842. * Gets the box size of the physics imposter and stores the result in the input parameter
  23843. * @param result Stores the box size
  23844. * @returns The physics imposter
  23845. */
  23846. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  23847. /**
  23848. * Gets the radius of the physics imposter
  23849. * @returns Radius of the physics imposter
  23850. */
  23851. getRadius(): number;
  23852. /**
  23853. * Sync a bone with this impostor
  23854. * @param bone The bone to sync to the impostor.
  23855. * @param boneMesh The mesh that the bone is influencing.
  23856. * @param jointPivot The pivot of the joint / bone in local space.
  23857. * @param distToJoint Optional distance from the impostor to the joint.
  23858. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  23859. */
  23860. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  23861. /**
  23862. * Sync impostor to a bone
  23863. * @param bone The bone that the impostor will be synced to.
  23864. * @param boneMesh The mesh that the bone is influencing.
  23865. * @param jointPivot The pivot of the joint / bone in local space.
  23866. * @param distToJoint Optional distance from the impostor to the joint.
  23867. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  23868. * @param boneAxis Optional vector3 axis the bone is aligned with
  23869. */
  23870. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  23871. /**
  23872. * No-Imposter type
  23873. */
  23874. static NoImpostor: number;
  23875. /**
  23876. * Sphere-Imposter type
  23877. */
  23878. static SphereImpostor: number;
  23879. /**
  23880. * Box-Imposter type
  23881. */
  23882. static BoxImpostor: number;
  23883. /**
  23884. * Plane-Imposter type
  23885. */
  23886. static PlaneImpostor: number;
  23887. /**
  23888. * Mesh-imposter type
  23889. */
  23890. static MeshImpostor: number;
  23891. /**
  23892. * Capsule-Impostor type (Ammo.js plugin only)
  23893. */
  23894. static CapsuleImpostor: number;
  23895. /**
  23896. * Cylinder-Imposter type
  23897. */
  23898. static CylinderImpostor: number;
  23899. /**
  23900. * Particle-Imposter type
  23901. */
  23902. static ParticleImpostor: number;
  23903. /**
  23904. * Heightmap-Imposter type
  23905. */
  23906. static HeightmapImpostor: number;
  23907. /**
  23908. * ConvexHull-Impostor type (Ammo.js plugin only)
  23909. */
  23910. static ConvexHullImpostor: number;
  23911. /**
  23912. * Rope-Imposter type
  23913. */
  23914. static RopeImpostor: number;
  23915. /**
  23916. * Cloth-Imposter type
  23917. */
  23918. static ClothImpostor: number;
  23919. /**
  23920. * Softbody-Imposter type
  23921. */
  23922. static SoftbodyImpostor: number;
  23923. }
  23924. }
  23925. declare module "babylonjs/Meshes/mesh" {
  23926. import { Observable } from "babylonjs/Misc/observable";
  23927. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  23928. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  23929. import { Camera } from "babylonjs/Cameras/camera";
  23930. import { Scene } from "babylonjs/scene";
  23931. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  23932. import { Color4 } from "babylonjs/Maths/math.color";
  23933. import { Engine } from "babylonjs/Engines/engine";
  23934. import { Node } from "babylonjs/node";
  23935. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  23936. import { IGetSetVerticesData } from "babylonjs/Meshes/mesh.vertexData";
  23937. import { Buffer } from "babylonjs/Meshes/buffer";
  23938. import { Geometry } from "babylonjs/Meshes/geometry";
  23939. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  23940. import { SubMesh } from "babylonjs/Meshes/subMesh";
  23941. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  23942. import { Effect } from "babylonjs/Materials/effect";
  23943. import { Material } from "babylonjs/Materials/material";
  23944. import { Skeleton } from "babylonjs/Bones/skeleton";
  23945. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  23946. import { MeshLODLevel } from "babylonjs/Meshes/meshLODLevel";
  23947. import { Path3D } from "babylonjs/Maths/math.path";
  23948. import { Plane } from "babylonjs/Maths/math.plane";
  23949. import { TransformNode } from "babylonjs/Meshes/transformNode";
  23950. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  23951. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  23952. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  23953. import { IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  23954. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  23955. /**
  23956. * @hidden
  23957. **/
  23958. export class _CreationDataStorage {
  23959. closePath?: boolean;
  23960. closeArray?: boolean;
  23961. idx: number[];
  23962. dashSize: number;
  23963. gapSize: number;
  23964. path3D: Path3D;
  23965. pathArray: Vector3[][];
  23966. arc: number;
  23967. radius: number;
  23968. cap: number;
  23969. tessellation: number;
  23970. }
  23971. /**
  23972. * @hidden
  23973. **/
  23974. class _InstanceDataStorage {
  23975. visibleInstances: any;
  23976. batchCache: _InstancesBatch;
  23977. instancesBufferSize: number;
  23978. instancesBuffer: Nullable<Buffer>;
  23979. instancesData: Float32Array;
  23980. overridenInstanceCount: number;
  23981. isFrozen: boolean;
  23982. previousBatch: Nullable<_InstancesBatch>;
  23983. hardwareInstancedRendering: boolean;
  23984. sideOrientation: number;
  23985. }
  23986. /**
  23987. * @hidden
  23988. **/
  23989. export class _InstancesBatch {
  23990. mustReturn: boolean;
  23991. visibleInstances: Nullable<import("babylonjs/Meshes/instancedMesh").InstancedMesh[]>[];
  23992. renderSelf: boolean[];
  23993. hardwareInstancedRendering: boolean[];
  23994. }
  23995. /**
  23996. * Class used to represent renderable models
  23997. */
  23998. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  23999. /**
  24000. * Mesh side orientation : usually the external or front surface
  24001. */
  24002. static readonly FRONTSIDE: number;
  24003. /**
  24004. * Mesh side orientation : usually the internal or back surface
  24005. */
  24006. static readonly BACKSIDE: number;
  24007. /**
  24008. * Mesh side orientation : both internal and external or front and back surfaces
  24009. */
  24010. static readonly DOUBLESIDE: number;
  24011. /**
  24012. * Mesh side orientation : by default, `FRONTSIDE`
  24013. */
  24014. static readonly DEFAULTSIDE: number;
  24015. /**
  24016. * Mesh cap setting : no cap
  24017. */
  24018. static readonly NO_CAP: number;
  24019. /**
  24020. * Mesh cap setting : one cap at the beginning of the mesh
  24021. */
  24022. static readonly CAP_START: number;
  24023. /**
  24024. * Mesh cap setting : one cap at the end of the mesh
  24025. */
  24026. static readonly CAP_END: number;
  24027. /**
  24028. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  24029. */
  24030. static readonly CAP_ALL: number;
  24031. /**
  24032. * Mesh pattern setting : no flip or rotate
  24033. */
  24034. static readonly NO_FLIP: number;
  24035. /**
  24036. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  24037. */
  24038. static readonly FLIP_TILE: number;
  24039. /**
  24040. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  24041. */
  24042. static readonly ROTATE_TILE: number;
  24043. /**
  24044. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  24045. */
  24046. static readonly FLIP_ROW: number;
  24047. /**
  24048. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  24049. */
  24050. static readonly ROTATE_ROW: number;
  24051. /**
  24052. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  24053. */
  24054. static readonly FLIP_N_ROTATE_TILE: number;
  24055. /**
  24056. * Mesh pattern setting : rotate pattern and rotate
  24057. */
  24058. static readonly FLIP_N_ROTATE_ROW: number;
  24059. /**
  24060. * Mesh tile positioning : part tiles same on left/right or top/bottom
  24061. */
  24062. static readonly CENTER: number;
  24063. /**
  24064. * Mesh tile positioning : part tiles on left
  24065. */
  24066. static readonly LEFT: number;
  24067. /**
  24068. * Mesh tile positioning : part tiles on right
  24069. */
  24070. static readonly RIGHT: number;
  24071. /**
  24072. * Mesh tile positioning : part tiles on top
  24073. */
  24074. static readonly TOP: number;
  24075. /**
  24076. * Mesh tile positioning : part tiles on bottom
  24077. */
  24078. static readonly BOTTOM: number;
  24079. /**
  24080. * Gets the default side orientation.
  24081. * @param orientation the orientation to value to attempt to get
  24082. * @returns the default orientation
  24083. * @hidden
  24084. */
  24085. static _GetDefaultSideOrientation(orientation?: number): number;
  24086. private _internalMeshDataInfo;
  24087. /**
  24088. * An event triggered before rendering the mesh
  24089. */
  24090. readonly onBeforeRenderObservable: Observable<Mesh>;
  24091. /**
  24092. * An event triggered before binding the mesh
  24093. */
  24094. readonly onBeforeBindObservable: Observable<Mesh>;
  24095. /**
  24096. * An event triggered after rendering the mesh
  24097. */
  24098. readonly onAfterRenderObservable: Observable<Mesh>;
  24099. /**
  24100. * An event triggered before drawing the mesh
  24101. */
  24102. readonly onBeforeDrawObservable: Observable<Mesh>;
  24103. private _onBeforeDrawObserver;
  24104. /**
  24105. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  24106. */
  24107. onBeforeDraw: () => void;
  24108. readonly hasInstances: boolean;
  24109. /**
  24110. * Gets the delay loading state of the mesh (when delay loading is turned on)
  24111. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  24112. */
  24113. delayLoadState: number;
  24114. /**
  24115. * Gets the list of instances created from this mesh
  24116. * it is not supposed to be modified manually.
  24117. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  24118. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  24119. */
  24120. instances: import("babylonjs/Meshes/instancedMesh").InstancedMesh[];
  24121. /**
  24122. * Gets the file containing delay loading data for this mesh
  24123. */
  24124. delayLoadingFile: string;
  24125. /** @hidden */
  24126. _binaryInfo: any;
  24127. /**
  24128. * User defined function used to change how LOD level selection is done
  24129. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  24130. */
  24131. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  24132. /**
  24133. * Gets or sets the morph target manager
  24134. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  24135. */
  24136. morphTargetManager: Nullable<MorphTargetManager>;
  24137. /** @hidden */
  24138. _creationDataStorage: Nullable<_CreationDataStorage>;
  24139. /** @hidden */
  24140. _geometry: Nullable<Geometry>;
  24141. /** @hidden */
  24142. _delayInfo: Array<string>;
  24143. /** @hidden */
  24144. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  24145. /** @hidden */
  24146. _instanceDataStorage: _InstanceDataStorage;
  24147. private _effectiveMaterial;
  24148. /** @hidden */
  24149. _shouldGenerateFlatShading: boolean;
  24150. /** @hidden */
  24151. _originalBuilderSideOrientation: number;
  24152. /**
  24153. * Use this property to change the original side orientation defined at construction time
  24154. */
  24155. overrideMaterialSideOrientation: Nullable<number>;
  24156. /**
  24157. * Gets the source mesh (the one used to clone this one from)
  24158. */
  24159. readonly source: Nullable<Mesh>;
  24160. /**
  24161. * Gets or sets a boolean indicating that this mesh does not use index buffer
  24162. */
  24163. isUnIndexed: boolean;
  24164. /**
  24165. * @constructor
  24166. * @param name The value used by scene.getMeshByName() to do a lookup.
  24167. * @param scene The scene to add this mesh to.
  24168. * @param parent The parent of this mesh, if it has one
  24169. * @param source An optional Mesh from which geometry is shared, cloned.
  24170. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  24171. * When false, achieved by calling a clone(), also passing False.
  24172. * This will make creation of children, recursive.
  24173. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  24174. */
  24175. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  24176. instantiateHierarychy(newParent?: Nullable<TransformNode>): Nullable<TransformNode>;
  24177. /**
  24178. * Gets the class name
  24179. * @returns the string "Mesh".
  24180. */
  24181. getClassName(): string;
  24182. /** @hidden */
  24183. readonly _isMesh: boolean;
  24184. /**
  24185. * Returns a description of this mesh
  24186. * @param fullDetails define if full details about this mesh must be used
  24187. * @returns a descriptive string representing this mesh
  24188. */
  24189. toString(fullDetails?: boolean): string;
  24190. /** @hidden */
  24191. _unBindEffect(): void;
  24192. /**
  24193. * Gets a boolean indicating if this mesh has LOD
  24194. */
  24195. readonly hasLODLevels: boolean;
  24196. /**
  24197. * Gets the list of MeshLODLevel associated with the current mesh
  24198. * @returns an array of MeshLODLevel
  24199. */
  24200. getLODLevels(): MeshLODLevel[];
  24201. private _sortLODLevels;
  24202. /**
  24203. * Add a mesh as LOD level triggered at the given distance.
  24204. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24205. * @param distance The distance from the center of the object to show this level
  24206. * @param mesh The mesh to be added as LOD level (can be null)
  24207. * @return This mesh (for chaining)
  24208. */
  24209. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  24210. /**
  24211. * Returns the LOD level mesh at the passed distance or null if not found.
  24212. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24213. * @param distance The distance from the center of the object to show this level
  24214. * @returns a Mesh or `null`
  24215. */
  24216. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  24217. /**
  24218. * Remove a mesh from the LOD array
  24219. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24220. * @param mesh defines the mesh to be removed
  24221. * @return This mesh (for chaining)
  24222. */
  24223. removeLODLevel(mesh: Mesh): Mesh;
  24224. /**
  24225. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  24226. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24227. * @param camera defines the camera to use to compute distance
  24228. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  24229. * @return This mesh (for chaining)
  24230. */
  24231. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  24232. /**
  24233. * Gets the mesh internal Geometry object
  24234. */
  24235. readonly geometry: Nullable<Geometry>;
  24236. /**
  24237. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  24238. * @returns the total number of vertices
  24239. */
  24240. getTotalVertices(): number;
  24241. /**
  24242. * Returns the content of an associated vertex buffer
  24243. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  24244. * - VertexBuffer.PositionKind
  24245. * - VertexBuffer.UVKind
  24246. * - VertexBuffer.UV2Kind
  24247. * - VertexBuffer.UV3Kind
  24248. * - VertexBuffer.UV4Kind
  24249. * - VertexBuffer.UV5Kind
  24250. * - VertexBuffer.UV6Kind
  24251. * - VertexBuffer.ColorKind
  24252. * - VertexBuffer.MatricesIndicesKind
  24253. * - VertexBuffer.MatricesIndicesExtraKind
  24254. * - VertexBuffer.MatricesWeightsKind
  24255. * - VertexBuffer.MatricesWeightsExtraKind
  24256. * @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
  24257. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  24258. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  24259. */
  24260. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  24261. /**
  24262. * Returns the mesh VertexBuffer object from the requested `kind`
  24263. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  24264. * - VertexBuffer.PositionKind
  24265. * - VertexBuffer.NormalKind
  24266. * - VertexBuffer.UVKind
  24267. * - VertexBuffer.UV2Kind
  24268. * - VertexBuffer.UV3Kind
  24269. * - VertexBuffer.UV4Kind
  24270. * - VertexBuffer.UV5Kind
  24271. * - VertexBuffer.UV6Kind
  24272. * - VertexBuffer.ColorKind
  24273. * - VertexBuffer.MatricesIndicesKind
  24274. * - VertexBuffer.MatricesIndicesExtraKind
  24275. * - VertexBuffer.MatricesWeightsKind
  24276. * - VertexBuffer.MatricesWeightsExtraKind
  24277. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  24278. */
  24279. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  24280. /**
  24281. * Tests if a specific vertex buffer is associated with this mesh
  24282. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  24283. * - VertexBuffer.PositionKind
  24284. * - VertexBuffer.NormalKind
  24285. * - VertexBuffer.UVKind
  24286. * - VertexBuffer.UV2Kind
  24287. * - VertexBuffer.UV3Kind
  24288. * - VertexBuffer.UV4Kind
  24289. * - VertexBuffer.UV5Kind
  24290. * - VertexBuffer.UV6Kind
  24291. * - VertexBuffer.ColorKind
  24292. * - VertexBuffer.MatricesIndicesKind
  24293. * - VertexBuffer.MatricesIndicesExtraKind
  24294. * - VertexBuffer.MatricesWeightsKind
  24295. * - VertexBuffer.MatricesWeightsExtraKind
  24296. * @returns a boolean
  24297. */
  24298. isVerticesDataPresent(kind: string): boolean;
  24299. /**
  24300. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  24301. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  24302. * - VertexBuffer.PositionKind
  24303. * - VertexBuffer.UVKind
  24304. * - VertexBuffer.UV2Kind
  24305. * - VertexBuffer.UV3Kind
  24306. * - VertexBuffer.UV4Kind
  24307. * - VertexBuffer.UV5Kind
  24308. * - VertexBuffer.UV6Kind
  24309. * - VertexBuffer.ColorKind
  24310. * - VertexBuffer.MatricesIndicesKind
  24311. * - VertexBuffer.MatricesIndicesExtraKind
  24312. * - VertexBuffer.MatricesWeightsKind
  24313. * - VertexBuffer.MatricesWeightsExtraKind
  24314. * @returns a boolean
  24315. */
  24316. isVertexBufferUpdatable(kind: string): boolean;
  24317. /**
  24318. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  24319. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  24320. * - VertexBuffer.PositionKind
  24321. * - VertexBuffer.NormalKind
  24322. * - VertexBuffer.UVKind
  24323. * - VertexBuffer.UV2Kind
  24324. * - VertexBuffer.UV3Kind
  24325. * - VertexBuffer.UV4Kind
  24326. * - VertexBuffer.UV5Kind
  24327. * - VertexBuffer.UV6Kind
  24328. * - VertexBuffer.ColorKind
  24329. * - VertexBuffer.MatricesIndicesKind
  24330. * - VertexBuffer.MatricesIndicesExtraKind
  24331. * - VertexBuffer.MatricesWeightsKind
  24332. * - VertexBuffer.MatricesWeightsExtraKind
  24333. * @returns an array of strings
  24334. */
  24335. getVerticesDataKinds(): string[];
  24336. /**
  24337. * Returns a positive integer : the total number of indices in this mesh geometry.
  24338. * @returns the numner of indices or zero if the mesh has no geometry.
  24339. */
  24340. getTotalIndices(): number;
  24341. /**
  24342. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  24343. * @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.
  24344. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  24345. * @returns the indices array or an empty array if the mesh has no geometry
  24346. */
  24347. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  24348. readonly isBlocked: boolean;
  24349. /**
  24350. * Determine if the current mesh is ready to be rendered
  24351. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  24352. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  24353. * @returns true if all associated assets are ready (material, textures, shaders)
  24354. */
  24355. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  24356. /**
  24357. * 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.
  24358. */
  24359. readonly areNormalsFrozen: boolean;
  24360. /**
  24361. * 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.
  24362. * @returns the current mesh
  24363. */
  24364. freezeNormals(): Mesh;
  24365. /**
  24366. * 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
  24367. * @returns the current mesh
  24368. */
  24369. unfreezeNormals(): Mesh;
  24370. /**
  24371. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  24372. */
  24373. overridenInstanceCount: number;
  24374. /** @hidden */
  24375. _preActivate(): Mesh;
  24376. /** @hidden */
  24377. _preActivateForIntermediateRendering(renderId: number): Mesh;
  24378. /** @hidden */
  24379. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  24380. /**
  24381. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  24382. * This means the mesh underlying bounding box and sphere are recomputed.
  24383. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  24384. * @returns the current mesh
  24385. */
  24386. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  24387. /** @hidden */
  24388. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  24389. /**
  24390. * This function will subdivide the mesh into multiple submeshes
  24391. * @param count defines the expected number of submeshes
  24392. */
  24393. subdivide(count: number): void;
  24394. /**
  24395. * Copy a FloatArray into a specific associated vertex buffer
  24396. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  24397. * - VertexBuffer.PositionKind
  24398. * - VertexBuffer.UVKind
  24399. * - VertexBuffer.UV2Kind
  24400. * - VertexBuffer.UV3Kind
  24401. * - VertexBuffer.UV4Kind
  24402. * - VertexBuffer.UV5Kind
  24403. * - VertexBuffer.UV6Kind
  24404. * - VertexBuffer.ColorKind
  24405. * - VertexBuffer.MatricesIndicesKind
  24406. * - VertexBuffer.MatricesIndicesExtraKind
  24407. * - VertexBuffer.MatricesWeightsKind
  24408. * - VertexBuffer.MatricesWeightsExtraKind
  24409. * @param data defines the data source
  24410. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  24411. * @param stride defines the data stride size (can be null)
  24412. * @returns the current mesh
  24413. */
  24414. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  24415. /**
  24416. * Flags an associated vertex buffer as updatable
  24417. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  24418. * - VertexBuffer.PositionKind
  24419. * - VertexBuffer.UVKind
  24420. * - VertexBuffer.UV2Kind
  24421. * - VertexBuffer.UV3Kind
  24422. * - VertexBuffer.UV4Kind
  24423. * - VertexBuffer.UV5Kind
  24424. * - VertexBuffer.UV6Kind
  24425. * - VertexBuffer.ColorKind
  24426. * - VertexBuffer.MatricesIndicesKind
  24427. * - VertexBuffer.MatricesIndicesExtraKind
  24428. * - VertexBuffer.MatricesWeightsKind
  24429. * - VertexBuffer.MatricesWeightsExtraKind
  24430. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  24431. */
  24432. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  24433. /**
  24434. * Sets the mesh global Vertex Buffer
  24435. * @param buffer defines the buffer to use
  24436. * @returns the current mesh
  24437. */
  24438. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  24439. /**
  24440. * Update a specific associated vertex buffer
  24441. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  24442. * - VertexBuffer.PositionKind
  24443. * - VertexBuffer.UVKind
  24444. * - VertexBuffer.UV2Kind
  24445. * - VertexBuffer.UV3Kind
  24446. * - VertexBuffer.UV4Kind
  24447. * - VertexBuffer.UV5Kind
  24448. * - VertexBuffer.UV6Kind
  24449. * - VertexBuffer.ColorKind
  24450. * - VertexBuffer.MatricesIndicesKind
  24451. * - VertexBuffer.MatricesIndicesExtraKind
  24452. * - VertexBuffer.MatricesWeightsKind
  24453. * - VertexBuffer.MatricesWeightsExtraKind
  24454. * @param data defines the data source
  24455. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  24456. * @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)
  24457. * @returns the current mesh
  24458. */
  24459. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  24460. /**
  24461. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  24462. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  24463. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  24464. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  24465. * @returns the current mesh
  24466. */
  24467. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  24468. /**
  24469. * Creates a un-shared specific occurence of the geometry for the mesh.
  24470. * @returns the current mesh
  24471. */
  24472. makeGeometryUnique(): Mesh;
  24473. /**
  24474. * Set the index buffer of this mesh
  24475. * @param indices defines the source data
  24476. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  24477. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  24478. * @returns the current mesh
  24479. */
  24480. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  24481. /**
  24482. * Update the current index buffer
  24483. * @param indices defines the source data
  24484. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  24485. * @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)
  24486. * @returns the current mesh
  24487. */
  24488. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  24489. /**
  24490. * Invert the geometry to move from a right handed system to a left handed one.
  24491. * @returns the current mesh
  24492. */
  24493. toLeftHanded(): Mesh;
  24494. /** @hidden */
  24495. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  24496. /** @hidden */
  24497. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  24498. /**
  24499. * Registers for this mesh a javascript function called just before the rendering process
  24500. * @param func defines the function to call before rendering this mesh
  24501. * @returns the current mesh
  24502. */
  24503. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  24504. /**
  24505. * Disposes a previously registered javascript function called before the rendering
  24506. * @param func defines the function to remove
  24507. * @returns the current mesh
  24508. */
  24509. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  24510. /**
  24511. * Registers for this mesh a javascript function called just after the rendering is complete
  24512. * @param func defines the function to call after rendering this mesh
  24513. * @returns the current mesh
  24514. */
  24515. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  24516. /**
  24517. * Disposes a previously registered javascript function called after the rendering.
  24518. * @param func defines the function to remove
  24519. * @returns the current mesh
  24520. */
  24521. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  24522. /** @hidden */
  24523. _getInstancesRenderList(subMeshId: number): _InstancesBatch;
  24524. /** @hidden */
  24525. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  24526. /** @hidden */
  24527. _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  24528. /** @hidden */
  24529. _rebuild(): void;
  24530. /** @hidden */
  24531. _freeze(): void;
  24532. /** @hidden */
  24533. _unFreeze(): void;
  24534. /**
  24535. * 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
  24536. * @param subMesh defines the subMesh to render
  24537. * @param enableAlphaMode defines if alpha mode can be changed
  24538. * @returns the current mesh
  24539. */
  24540. render(subMesh: SubMesh, enableAlphaMode: boolean): Mesh;
  24541. private _onBeforeDraw;
  24542. /**
  24543. * Renormalize the mesh and patch it up if there are no weights
  24544. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  24545. * However in the case of zero weights then we set just a single influence to 1.
  24546. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  24547. */
  24548. cleanMatrixWeights(): void;
  24549. private normalizeSkinFourWeights;
  24550. private normalizeSkinWeightsAndExtra;
  24551. /**
  24552. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  24553. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  24554. * the user know there was an issue with importing the mesh
  24555. * @returns a validation object with skinned, valid and report string
  24556. */
  24557. validateSkinning(): {
  24558. skinned: boolean;
  24559. valid: boolean;
  24560. report: string;
  24561. };
  24562. /** @hidden */
  24563. _checkDelayState(): Mesh;
  24564. private _queueLoad;
  24565. /**
  24566. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  24567. * A mesh is in the frustum if its bounding box intersects the frustum
  24568. * @param frustumPlanes defines the frustum to test
  24569. * @returns true if the mesh is in the frustum planes
  24570. */
  24571. isInFrustum(frustumPlanes: Plane[]): boolean;
  24572. /**
  24573. * Sets the mesh material by the material or multiMaterial `id` property
  24574. * @param id is a string identifying the material or the multiMaterial
  24575. * @returns the current mesh
  24576. */
  24577. setMaterialByID(id: string): Mesh;
  24578. /**
  24579. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  24580. * @returns an array of IAnimatable
  24581. */
  24582. getAnimatables(): IAnimatable[];
  24583. /**
  24584. * Modifies the mesh geometry according to the passed transformation matrix.
  24585. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  24586. * The mesh normals are modified using the same transformation.
  24587. * Note that, under the hood, this method sets a new VertexBuffer each call.
  24588. * @param transform defines the transform matrix to use
  24589. * @see http://doc.babylonjs.com/resources/baking_transformations
  24590. * @returns the current mesh
  24591. */
  24592. bakeTransformIntoVertices(transform: Matrix): Mesh;
  24593. /**
  24594. * Modifies the mesh geometry according to its own current World Matrix.
  24595. * The mesh World Matrix is then reset.
  24596. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  24597. * Note that, under the hood, this method sets a new VertexBuffer each call.
  24598. * @see http://doc.babylonjs.com/resources/baking_transformations
  24599. * @returns the current mesh
  24600. */
  24601. bakeCurrentTransformIntoVertices(): Mesh;
  24602. /** @hidden */
  24603. readonly _positions: Nullable<Vector3[]>;
  24604. /** @hidden */
  24605. _resetPointsArrayCache(): Mesh;
  24606. /** @hidden */
  24607. _generatePointsArray(): boolean;
  24608. /**
  24609. * Returns a new Mesh object generated from the current mesh properties.
  24610. * This method must not get confused with createInstance()
  24611. * @param name is a string, the name given to the new mesh
  24612. * @param newParent can be any Node object (default `null`)
  24613. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  24614. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  24615. * @returns a new mesh
  24616. */
  24617. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Nullable<AbstractMesh>;
  24618. /**
  24619. * Releases resources associated with this mesh.
  24620. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  24621. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  24622. */
  24623. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  24624. /**
  24625. * Modifies the mesh geometry according to a displacement map.
  24626. * 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.
  24627. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  24628. * @param url is a string, the URL from the image file is to be downloaded.
  24629. * @param minHeight is the lower limit of the displacement.
  24630. * @param maxHeight is the upper limit of the displacement.
  24631. * @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.
  24632. * @param uvOffset is an optional vector2 used to offset UV.
  24633. * @param uvScale is an optional vector2 used to scale UV.
  24634. * @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.
  24635. * @returns the Mesh.
  24636. */
  24637. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  24638. /**
  24639. * Modifies the mesh geometry according to a displacementMap buffer.
  24640. * 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.
  24641. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  24642. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  24643. * @param heightMapWidth is the width of the buffer image.
  24644. * @param heightMapHeight is the height of the buffer image.
  24645. * @param minHeight is the lower limit of the displacement.
  24646. * @param maxHeight is the upper limit of the displacement.
  24647. * @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.
  24648. * @param uvOffset is an optional vector2 used to offset UV.
  24649. * @param uvScale is an optional vector2 used to scale UV.
  24650. * @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.
  24651. * @returns the Mesh.
  24652. */
  24653. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  24654. /**
  24655. * Modify the mesh to get a flat shading rendering.
  24656. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  24657. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  24658. * @returns current mesh
  24659. */
  24660. convertToFlatShadedMesh(): Mesh;
  24661. /**
  24662. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  24663. * In other words, more vertices, no more indices and a single bigger VBO.
  24664. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  24665. * @returns current mesh
  24666. */
  24667. convertToUnIndexedMesh(): Mesh;
  24668. /**
  24669. * Inverses facet orientations.
  24670. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  24671. * @param flipNormals will also inverts the normals
  24672. * @returns current mesh
  24673. */
  24674. flipFaces(flipNormals?: boolean): Mesh;
  24675. /**
  24676. * Increase the number of facets and hence vertices in a mesh
  24677. * Vertex normals are interpolated from existing vertex normals
  24678. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  24679. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  24680. */
  24681. increaseVertices(numberPerEdge: number): void;
  24682. /**
  24683. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  24684. * This will undo any application of covertToFlatShadedMesh
  24685. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  24686. */
  24687. forceSharedVertices(): void;
  24688. /** @hidden */
  24689. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  24690. /** @hidden */
  24691. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  24692. /**
  24693. * Creates a new InstancedMesh object from the mesh model.
  24694. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  24695. * @param name defines the name of the new instance
  24696. * @returns a new InstancedMesh
  24697. */
  24698. createInstance(name: string): InstancedMesh;
  24699. /**
  24700. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  24701. * After this call, all the mesh instances have the same submeshes than the current mesh.
  24702. * @returns the current mesh
  24703. */
  24704. synchronizeInstances(): Mesh;
  24705. /**
  24706. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  24707. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  24708. * This should be used together with the simplification to avoid disappearing triangles.
  24709. * @param successCallback an optional success callback to be called after the optimization finished.
  24710. * @returns the current mesh
  24711. */
  24712. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  24713. /**
  24714. * Serialize current mesh
  24715. * @param serializationObject defines the object which will receive the serialization data
  24716. */
  24717. serialize(serializationObject: any): void;
  24718. /** @hidden */
  24719. _syncGeometryWithMorphTargetManager(): void;
  24720. /** @hidden */
  24721. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  24722. /**
  24723. * Returns a new Mesh object parsed from the source provided.
  24724. * @param parsedMesh is the source
  24725. * @param scene defines the hosting scene
  24726. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  24727. * @returns a new Mesh
  24728. */
  24729. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  24730. /**
  24731. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  24732. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  24733. * @param name defines the name of the mesh to create
  24734. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  24735. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  24736. * @param closePath creates a seam between the first and the last points of each path of the path array
  24737. * @param offset is taken in account only if the `pathArray` is containing a single path
  24738. * @param scene defines the hosting scene
  24739. * @param updatable defines if the mesh must be flagged as updatable
  24740. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24741. * @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)
  24742. * @returns a new Mesh
  24743. */
  24744. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  24745. /**
  24746. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  24747. * @param name defines the name of the mesh to create
  24748. * @param radius sets the radius size (float) of the polygon (default 0.5)
  24749. * @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
  24750. * @param scene defines the hosting scene
  24751. * @param updatable defines if the mesh must be flagged as updatable
  24752. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24753. * @returns a new Mesh
  24754. */
  24755. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  24756. /**
  24757. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  24758. * @param name defines the name of the mesh to create
  24759. * @param size sets the size (float) of each box side (default 1)
  24760. * @param scene defines the hosting scene
  24761. * @param updatable defines if the mesh must be flagged as updatable
  24762. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24763. * @returns a new Mesh
  24764. */
  24765. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  24766. /**
  24767. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  24768. * @param name defines the name of the mesh to create
  24769. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  24770. * @param diameter sets the diameter size (float) of the sphere (default 1)
  24771. * @param scene defines the hosting scene
  24772. * @param updatable defines if the mesh must be flagged as updatable
  24773. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24774. * @returns a new Mesh
  24775. */
  24776. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  24777. /**
  24778. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  24779. * @param name defines the name of the mesh to create
  24780. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  24781. * @param diameter sets the diameter size (float) of the sphere (default 1)
  24782. * @param scene defines the hosting scene
  24783. * @returns a new Mesh
  24784. */
  24785. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  24786. /**
  24787. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  24788. * @param name defines the name of the mesh to create
  24789. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  24790. * @param diameterTop set the top cap diameter (floats, default 1)
  24791. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  24792. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  24793. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  24794. * @param scene defines the hosting scene
  24795. * @param updatable defines if the mesh must be flagged as updatable
  24796. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24797. * @returns a new Mesh
  24798. */
  24799. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  24800. /**
  24801. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  24802. * @param name defines the name of the mesh to create
  24803. * @param diameter sets the diameter size (float) of the torus (default 1)
  24804. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  24805. * @param tessellation sets the number of torus sides (postive integer, default 16)
  24806. * @param scene defines the hosting scene
  24807. * @param updatable defines if the mesh must be flagged as updatable
  24808. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24809. * @returns a new Mesh
  24810. */
  24811. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  24812. /**
  24813. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  24814. * @param name defines the name of the mesh to create
  24815. * @param radius sets the global radius size (float) of the torus knot (default 2)
  24816. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  24817. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  24818. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  24819. * @param p the number of windings on X axis (positive integers, default 2)
  24820. * @param q the number of windings on Y axis (positive integers, default 3)
  24821. * @param scene defines the hosting scene
  24822. * @param updatable defines if the mesh must be flagged as updatable
  24823. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24824. * @returns a new Mesh
  24825. */
  24826. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  24827. /**
  24828. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  24829. * @param name defines the name of the mesh to create
  24830. * @param points is an array successive Vector3
  24831. * @param scene defines the hosting scene
  24832. * @param updatable defines if the mesh must be flagged as updatable
  24833. * @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).
  24834. * @returns a new Mesh
  24835. */
  24836. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  24837. /**
  24838. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  24839. * @param name defines the name of the mesh to create
  24840. * @param points is an array successive Vector3
  24841. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  24842. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  24843. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  24844. * @param scene defines the hosting scene
  24845. * @param updatable defines if the mesh must be flagged as updatable
  24846. * @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)
  24847. * @returns a new Mesh
  24848. */
  24849. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  24850. /**
  24851. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  24852. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  24853. * 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.
  24854. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  24855. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  24856. * Remember you can only change the shape positions, not their number when updating a polygon.
  24857. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  24858. * @param name defines the name of the mesh to create
  24859. * @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
  24860. * @param scene defines the hosting scene
  24861. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  24862. * @param updatable defines if the mesh must be flagged as updatable
  24863. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24864. * @param earcutInjection can be used to inject your own earcut reference
  24865. * @returns a new Mesh
  24866. */
  24867. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  24868. /**
  24869. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  24870. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  24871. * @param name defines the name of the mesh to create
  24872. * @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
  24873. * @param depth defines the height of extrusion
  24874. * @param scene defines the hosting scene
  24875. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  24876. * @param updatable defines if the mesh must be flagged as updatable
  24877. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24878. * @param earcutInjection can be used to inject your own earcut reference
  24879. * @returns a new Mesh
  24880. */
  24881. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  24882. /**
  24883. * Creates an extruded shape mesh.
  24884. * 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
  24885. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  24886. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  24887. * @param name defines the name of the mesh to create
  24888. * @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
  24889. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  24890. * @param scale is the value to scale the shape
  24891. * @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
  24892. * @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
  24893. * @param scene defines the hosting scene
  24894. * @param updatable defines if the mesh must be flagged as updatable
  24895. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24896. * @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)
  24897. * @returns a new Mesh
  24898. */
  24899. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  24900. /**
  24901. * Creates an custom extruded shape mesh.
  24902. * The custom extrusion is a parametric shape.
  24903. * It has no predefined shape. Its final shape will depend on the input parameters.
  24904. * Please consider using the same method from the MeshBuilder class instead
  24905. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  24906. * @param name defines the name of the mesh to create
  24907. * @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
  24908. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  24909. * @param scaleFunction is a custom Javascript function called on each path point
  24910. * @param rotationFunction is a custom Javascript function called on each path point
  24911. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  24912. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  24913. * @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
  24914. * @param scene defines the hosting scene
  24915. * @param updatable defines if the mesh must be flagged as updatable
  24916. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24917. * @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)
  24918. * @returns a new Mesh
  24919. */
  24920. 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;
  24921. /**
  24922. * Creates lathe mesh.
  24923. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  24924. * Please consider using the same method from the MeshBuilder class instead
  24925. * @param name defines the name of the mesh to create
  24926. * @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
  24927. * @param radius is the radius value of the lathe
  24928. * @param tessellation is the side number of the lathe.
  24929. * @param scene defines the hosting scene
  24930. * @param updatable defines if the mesh must be flagged as updatable
  24931. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24932. * @returns a new Mesh
  24933. */
  24934. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  24935. /**
  24936. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  24937. * @param name defines the name of the mesh to create
  24938. * @param size sets the size (float) of both sides of the plane at once (default 1)
  24939. * @param scene defines the hosting scene
  24940. * @param updatable defines if the mesh must be flagged as updatable
  24941. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24942. * @returns a new Mesh
  24943. */
  24944. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  24945. /**
  24946. * Creates a ground mesh.
  24947. * Please consider using the same method from the MeshBuilder class instead
  24948. * @param name defines the name of the mesh to create
  24949. * @param width set the width of the ground
  24950. * @param height set the height of the ground
  24951. * @param subdivisions sets the number of subdivisions per side
  24952. * @param scene defines the hosting scene
  24953. * @param updatable defines if the mesh must be flagged as updatable
  24954. * @returns a new Mesh
  24955. */
  24956. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  24957. /**
  24958. * Creates a tiled ground mesh.
  24959. * Please consider using the same method from the MeshBuilder class instead
  24960. * @param name defines the name of the mesh to create
  24961. * @param xmin set the ground minimum X coordinate
  24962. * @param zmin set the ground minimum Y coordinate
  24963. * @param xmax set the ground maximum X coordinate
  24964. * @param zmax set the ground maximum Z coordinate
  24965. * @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
  24966. * @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
  24967. * @param scene defines the hosting scene
  24968. * @param updatable defines if the mesh must be flagged as updatable
  24969. * @returns a new Mesh
  24970. */
  24971. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  24972. w: number;
  24973. h: number;
  24974. }, precision: {
  24975. w: number;
  24976. h: number;
  24977. }, scene: Scene, updatable?: boolean): Mesh;
  24978. /**
  24979. * Creates a ground mesh from a height map.
  24980. * Please consider using the same method from the MeshBuilder class instead
  24981. * @see http://doc.babylonjs.com/babylon101/height_map
  24982. * @param name defines the name of the mesh to create
  24983. * @param url sets the URL of the height map image resource
  24984. * @param width set the ground width size
  24985. * @param height set the ground height size
  24986. * @param subdivisions sets the number of subdivision per side
  24987. * @param minHeight is the minimum altitude on the ground
  24988. * @param maxHeight is the maximum altitude on the ground
  24989. * @param scene defines the hosting scene
  24990. * @param updatable defines if the mesh must be flagged as updatable
  24991. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  24992. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  24993. * @returns a new Mesh
  24994. */
  24995. 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;
  24996. /**
  24997. * Creates a tube mesh.
  24998. * The tube is a parametric shape.
  24999. * It has no predefined shape. Its final shape will depend on the input parameters.
  25000. * Please consider using the same method from the MeshBuilder class instead
  25001. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  25002. * @param name defines the name of the mesh to create
  25003. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  25004. * @param radius sets the tube radius size
  25005. * @param tessellation is the number of sides on the tubular surface
  25006. * @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
  25007. * @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
  25008. * @param scene defines the hosting scene
  25009. * @param updatable defines if the mesh must be flagged as updatable
  25010. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25011. * @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)
  25012. * @returns a new Mesh
  25013. */
  25014. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  25015. (i: number, distance: number): number;
  25016. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  25017. /**
  25018. * Creates a polyhedron mesh.
  25019. * Please consider using the same method from the MeshBuilder class instead.
  25020. * * 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
  25021. * * The parameter `size` (positive float, default 1) sets the polygon size
  25022. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  25023. * * 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`
  25024. * * 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
  25025. * * 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)`)
  25026. * * 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
  25027. * * 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
  25028. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25029. * * If you create a double-sided mesh, you can choose what parts of 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
  25030. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  25031. * @param name defines the name of the mesh to create
  25032. * @param options defines the options used to create the mesh
  25033. * @param scene defines the hosting scene
  25034. * @returns a new Mesh
  25035. */
  25036. static CreatePolyhedron(name: string, options: {
  25037. type?: number;
  25038. size?: number;
  25039. sizeX?: number;
  25040. sizeY?: number;
  25041. sizeZ?: number;
  25042. custom?: any;
  25043. faceUV?: Vector4[];
  25044. faceColors?: Color4[];
  25045. updatable?: boolean;
  25046. sideOrientation?: number;
  25047. }, scene: Scene): Mesh;
  25048. /**
  25049. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  25050. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  25051. * * 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`)
  25052. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  25053. * * 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
  25054. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25055. * * If you create a double-sided mesh, you can choose what parts of 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
  25056. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  25057. * @param name defines the name of the mesh
  25058. * @param options defines the options used to create the mesh
  25059. * @param scene defines the hosting scene
  25060. * @returns a new Mesh
  25061. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  25062. */
  25063. static CreateIcoSphere(name: string, options: {
  25064. radius?: number;
  25065. flat?: boolean;
  25066. subdivisions?: number;
  25067. sideOrientation?: number;
  25068. updatable?: boolean;
  25069. }, scene: Scene): Mesh;
  25070. /**
  25071. * Creates a decal mesh.
  25072. * Please consider using the same method from the MeshBuilder class instead.
  25073. * A decal is a mesh usually applied as a model onto the surface of another mesh
  25074. * @param name defines the name of the mesh
  25075. * @param sourceMesh defines the mesh receiving the decal
  25076. * @param position sets the position of the decal in world coordinates
  25077. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  25078. * @param size sets the decal scaling
  25079. * @param angle sets the angle to rotate the decal
  25080. * @returns a new Mesh
  25081. */
  25082. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  25083. /**
  25084. * Prepare internal position array for software CPU skinning
  25085. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  25086. */
  25087. setPositionsForCPUSkinning(): Float32Array;
  25088. /**
  25089. * Prepare internal normal array for software CPU skinning
  25090. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  25091. */
  25092. setNormalsForCPUSkinning(): Float32Array;
  25093. /**
  25094. * Updates the vertex buffer by applying transformation from the bones
  25095. * @param skeleton defines the skeleton to apply to current mesh
  25096. * @returns the current mesh
  25097. */
  25098. applySkeleton(skeleton: Skeleton): Mesh;
  25099. /**
  25100. * 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
  25101. * @param meshes defines the list of meshes to scan
  25102. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  25103. */
  25104. static MinMax(meshes: AbstractMesh[]): {
  25105. min: Vector3;
  25106. max: Vector3;
  25107. };
  25108. /**
  25109. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  25110. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  25111. * @returns a vector3
  25112. */
  25113. static Center(meshesOrMinMaxVector: {
  25114. min: Vector3;
  25115. max: Vector3;
  25116. } | AbstractMesh[]): Vector3;
  25117. /**
  25118. * Merge the array of meshes into a single mesh for performance reasons.
  25119. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  25120. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  25121. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  25122. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  25123. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  25124. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  25125. * @returns a new mesh
  25126. */
  25127. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  25128. /** @hidden */
  25129. addInstance(instance: InstancedMesh): void;
  25130. /** @hidden */
  25131. removeInstance(instance: InstancedMesh): void;
  25132. }
  25133. }
  25134. declare module "babylonjs/Cameras/camera" {
  25135. import { SmartArray } from "babylonjs/Misc/smartArray";
  25136. import { Observable } from "babylonjs/Misc/observable";
  25137. import { Nullable } from "babylonjs/types";
  25138. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  25139. import { Scene } from "babylonjs/scene";
  25140. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  25141. import { Node } from "babylonjs/node";
  25142. import { Mesh } from "babylonjs/Meshes/mesh";
  25143. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  25144. import { ICullable } from "babylonjs/Culling/boundingInfo";
  25145. import { Viewport } from "babylonjs/Maths/math.viewport";
  25146. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  25147. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  25148. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  25149. import { Ray } from "babylonjs/Culling/ray";
  25150. /**
  25151. * This is the base class of all the camera used in the application.
  25152. * @see http://doc.babylonjs.com/features/cameras
  25153. */
  25154. export class Camera extends Node {
  25155. /** @hidden */
  25156. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  25157. /**
  25158. * This is the default projection mode used by the cameras.
  25159. * It helps recreating a feeling of perspective and better appreciate depth.
  25160. * This is the best way to simulate real life cameras.
  25161. */
  25162. static readonly PERSPECTIVE_CAMERA: number;
  25163. /**
  25164. * This helps creating camera with an orthographic mode.
  25165. * 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.
  25166. */
  25167. static readonly ORTHOGRAPHIC_CAMERA: number;
  25168. /**
  25169. * This is the default FOV mode for perspective cameras.
  25170. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  25171. */
  25172. static readonly FOVMODE_VERTICAL_FIXED: number;
  25173. /**
  25174. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  25175. */
  25176. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  25177. /**
  25178. * This specifies ther is no need for a camera rig.
  25179. * Basically only one eye is rendered corresponding to the camera.
  25180. */
  25181. static readonly RIG_MODE_NONE: number;
  25182. /**
  25183. * Simulates a camera Rig with one blue eye and one red eye.
  25184. * This can be use with 3d blue and red glasses.
  25185. */
  25186. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  25187. /**
  25188. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  25189. */
  25190. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  25191. /**
  25192. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  25193. */
  25194. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  25195. /**
  25196. * Defines that both eyes of the camera will be rendered over under each other.
  25197. */
  25198. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  25199. /**
  25200. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  25201. */
  25202. static readonly RIG_MODE_VR: number;
  25203. /**
  25204. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  25205. */
  25206. static readonly RIG_MODE_WEBVR: number;
  25207. /**
  25208. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  25209. */
  25210. static readonly RIG_MODE_CUSTOM: number;
  25211. /**
  25212. * Defines if by default attaching controls should prevent the default javascript event to continue.
  25213. */
  25214. static ForceAttachControlToAlwaysPreventDefault: boolean;
  25215. /**
  25216. * Define the input manager associated with the camera.
  25217. */
  25218. inputs: CameraInputsManager<Camera>;
  25219. /** @hidden */
  25220. _position: Vector3;
  25221. /**
  25222. * Define the current local position of the camera in the scene
  25223. */
  25224. position: Vector3;
  25225. /**
  25226. * The vector the camera should consider as up.
  25227. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  25228. */
  25229. upVector: Vector3;
  25230. /**
  25231. * Define the current limit on the left side for an orthographic camera
  25232. * In scene unit
  25233. */
  25234. orthoLeft: Nullable<number>;
  25235. /**
  25236. * Define the current limit on the right side for an orthographic camera
  25237. * In scene unit
  25238. */
  25239. orthoRight: Nullable<number>;
  25240. /**
  25241. * Define the current limit on the bottom side for an orthographic camera
  25242. * In scene unit
  25243. */
  25244. orthoBottom: Nullable<number>;
  25245. /**
  25246. * Define the current limit on the top side for an orthographic camera
  25247. * In scene unit
  25248. */
  25249. orthoTop: Nullable<number>;
  25250. /**
  25251. * Field Of View is set in Radians. (default is 0.8)
  25252. */
  25253. fov: number;
  25254. /**
  25255. * Define the minimum distance the camera can see from.
  25256. * This is important to note that the depth buffer are not infinite and the closer it starts
  25257. * the more your scene might encounter depth fighting issue.
  25258. */
  25259. minZ: number;
  25260. /**
  25261. * Define the maximum distance the camera can see to.
  25262. * This is important to note that the depth buffer are not infinite and the further it end
  25263. * the more your scene might encounter depth fighting issue.
  25264. */
  25265. maxZ: number;
  25266. /**
  25267. * Define the default inertia of the camera.
  25268. * This helps giving a smooth feeling to the camera movement.
  25269. */
  25270. inertia: number;
  25271. /**
  25272. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  25273. */
  25274. mode: number;
  25275. /**
  25276. * Define wether the camera is intermediate.
  25277. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  25278. */
  25279. isIntermediate: boolean;
  25280. /**
  25281. * Define the viewport of the camera.
  25282. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  25283. */
  25284. viewport: Viewport;
  25285. /**
  25286. * Restricts the camera to viewing objects with the same layerMask.
  25287. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  25288. */
  25289. layerMask: number;
  25290. /**
  25291. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  25292. */
  25293. fovMode: number;
  25294. /**
  25295. * Rig mode of the camera.
  25296. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  25297. * This is normally controlled byt the camera themselves as internal use.
  25298. */
  25299. cameraRigMode: number;
  25300. /**
  25301. * Defines the distance between both "eyes" in case of a RIG
  25302. */
  25303. interaxialDistance: number;
  25304. /**
  25305. * Defines if stereoscopic rendering is done side by side or over under.
  25306. */
  25307. isStereoscopicSideBySide: boolean;
  25308. /**
  25309. * 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
  25310. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  25311. * else in the scene. (Eg. security camera)
  25312. *
  25313. * 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)
  25314. */
  25315. customRenderTargets: import("babylonjs/Materials/Textures/renderTargetTexture").RenderTargetTexture[];
  25316. /**
  25317. * When set, the camera will render to this render target instead of the default canvas
  25318. *
  25319. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  25320. */
  25321. outputRenderTarget: Nullable<RenderTargetTexture>;
  25322. /**
  25323. * Observable triggered when the camera view matrix has changed.
  25324. */
  25325. onViewMatrixChangedObservable: Observable<Camera>;
  25326. /**
  25327. * Observable triggered when the camera Projection matrix has changed.
  25328. */
  25329. onProjectionMatrixChangedObservable: Observable<Camera>;
  25330. /**
  25331. * Observable triggered when the inputs have been processed.
  25332. */
  25333. onAfterCheckInputsObservable: Observable<Camera>;
  25334. /**
  25335. * Observable triggered when reset has been called and applied to the camera.
  25336. */
  25337. onRestoreStateObservable: Observable<Camera>;
  25338. /** @hidden */
  25339. _cameraRigParams: any;
  25340. /** @hidden */
  25341. _rigCameras: Camera[];
  25342. /** @hidden */
  25343. _rigPostProcess: Nullable<PostProcess>;
  25344. protected _webvrViewMatrix: Matrix;
  25345. /** @hidden */
  25346. _skipRendering: boolean;
  25347. /** @hidden */
  25348. _projectionMatrix: Matrix;
  25349. /** @hidden */
  25350. _postProcesses: Nullable<import("babylonjs/PostProcesses/postProcess").PostProcess>[];
  25351. /** @hidden */
  25352. _activeMeshes: SmartArray<AbstractMesh>;
  25353. protected _globalPosition: Vector3;
  25354. /** @hidden */
  25355. _computedViewMatrix: Matrix;
  25356. private _doNotComputeProjectionMatrix;
  25357. private _transformMatrix;
  25358. private _frustumPlanes;
  25359. private _refreshFrustumPlanes;
  25360. private _storedFov;
  25361. private _stateStored;
  25362. /**
  25363. * Instantiates a new camera object.
  25364. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  25365. * @see http://doc.babylonjs.com/features/cameras
  25366. * @param name Defines the name of the camera in the scene
  25367. * @param position Defines the position of the camera
  25368. * @param scene Defines the scene the camera belongs too
  25369. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  25370. */
  25371. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  25372. /**
  25373. * Store current camera state (fov, position, etc..)
  25374. * @returns the camera
  25375. */
  25376. storeState(): Camera;
  25377. /**
  25378. * Restores the camera state values if it has been stored. You must call storeState() first
  25379. */
  25380. protected _restoreStateValues(): boolean;
  25381. /**
  25382. * Restored camera state. You must call storeState() first.
  25383. * @returns true if restored and false otherwise
  25384. */
  25385. restoreState(): boolean;
  25386. /**
  25387. * Gets the class name of the camera.
  25388. * @returns the class name
  25389. */
  25390. getClassName(): string;
  25391. /** @hidden */
  25392. readonly _isCamera: boolean;
  25393. /**
  25394. * Gets a string representation of the camera useful for debug purpose.
  25395. * @param fullDetails Defines that a more verboe level of logging is required
  25396. * @returns the string representation
  25397. */
  25398. toString(fullDetails?: boolean): string;
  25399. /**
  25400. * Gets the current world space position of the camera.
  25401. */
  25402. readonly globalPosition: Vector3;
  25403. /**
  25404. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  25405. * @returns the active meshe list
  25406. */
  25407. getActiveMeshes(): SmartArray<AbstractMesh>;
  25408. /**
  25409. * Check wether a mesh is part of the current active mesh list of the camera
  25410. * @param mesh Defines the mesh to check
  25411. * @returns true if active, false otherwise
  25412. */
  25413. isActiveMesh(mesh: Mesh): boolean;
  25414. /**
  25415. * Is this camera ready to be used/rendered
  25416. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  25417. * @return true if the camera is ready
  25418. */
  25419. isReady(completeCheck?: boolean): boolean;
  25420. /** @hidden */
  25421. _initCache(): void;
  25422. /** @hidden */
  25423. _updateCache(ignoreParentClass?: boolean): void;
  25424. /** @hidden */
  25425. _isSynchronized(): boolean;
  25426. /** @hidden */
  25427. _isSynchronizedViewMatrix(): boolean;
  25428. /** @hidden */
  25429. _isSynchronizedProjectionMatrix(): boolean;
  25430. /**
  25431. * Attach the input controls to a specific dom element to get the input from.
  25432. * @param element Defines the element the controls should be listened from
  25433. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  25434. */
  25435. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  25436. /**
  25437. * Detach the current controls from the specified dom element.
  25438. * @param element Defines the element to stop listening the inputs from
  25439. */
  25440. detachControl(element: HTMLElement): void;
  25441. /**
  25442. * Update the camera state according to the different inputs gathered during the frame.
  25443. */
  25444. update(): void;
  25445. /** @hidden */
  25446. _checkInputs(): void;
  25447. /** @hidden */
  25448. readonly rigCameras: Camera[];
  25449. /**
  25450. * Gets the post process used by the rig cameras
  25451. */
  25452. readonly rigPostProcess: Nullable<PostProcess>;
  25453. /**
  25454. * Internal, gets the first post proces.
  25455. * @returns the first post process to be run on this camera.
  25456. */
  25457. _getFirstPostProcess(): Nullable<PostProcess>;
  25458. private _cascadePostProcessesToRigCams;
  25459. /**
  25460. * Attach a post process to the camera.
  25461. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  25462. * @param postProcess The post process to attach to the camera
  25463. * @param insertAt The position of the post process in case several of them are in use in the scene
  25464. * @returns the position the post process has been inserted at
  25465. */
  25466. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  25467. /**
  25468. * Detach a post process to the camera.
  25469. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  25470. * @param postProcess The post process to detach from the camera
  25471. */
  25472. detachPostProcess(postProcess: PostProcess): void;
  25473. /**
  25474. * Gets the current world matrix of the camera
  25475. */
  25476. getWorldMatrix(): Matrix;
  25477. /** @hidden */
  25478. _getViewMatrix(): Matrix;
  25479. /**
  25480. * Gets the current view matrix of the camera.
  25481. * @param force forces the camera to recompute the matrix without looking at the cached state
  25482. * @returns the view matrix
  25483. */
  25484. getViewMatrix(force?: boolean): Matrix;
  25485. /**
  25486. * Freeze the projection matrix.
  25487. * It will prevent the cache check of the camera projection compute and can speed up perf
  25488. * if no parameter of the camera are meant to change
  25489. * @param projection Defines manually a projection if necessary
  25490. */
  25491. freezeProjectionMatrix(projection?: Matrix): void;
  25492. /**
  25493. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  25494. */
  25495. unfreezeProjectionMatrix(): void;
  25496. /**
  25497. * Gets the current projection matrix of the camera.
  25498. * @param force forces the camera to recompute the matrix without looking at the cached state
  25499. * @returns the projection matrix
  25500. */
  25501. getProjectionMatrix(force?: boolean): Matrix;
  25502. /**
  25503. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  25504. * @returns a Matrix
  25505. */
  25506. getTransformationMatrix(): Matrix;
  25507. private _updateFrustumPlanes;
  25508. /**
  25509. * Checks if a cullable object (mesh...) is in the camera frustum
  25510. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  25511. * @param target The object to check
  25512. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  25513. * @returns true if the object is in frustum otherwise false
  25514. */
  25515. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  25516. /**
  25517. * Checks if a cullable object (mesh...) is in the camera frustum
  25518. * Unlike isInFrustum this cheks the full bounding box
  25519. * @param target The object to check
  25520. * @returns true if the object is in frustum otherwise false
  25521. */
  25522. isCompletelyInFrustum(target: ICullable): boolean;
  25523. /**
  25524. * Gets a ray in the forward direction from the camera.
  25525. * @param length Defines the length of the ray to create
  25526. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  25527. * @param origin Defines the start point of the ray which defaults to the camera position
  25528. * @returns the forward ray
  25529. */
  25530. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  25531. /**
  25532. * Releases resources associated with this node.
  25533. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  25534. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  25535. */
  25536. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  25537. /** @hidden */
  25538. _isLeftCamera: boolean;
  25539. /**
  25540. * Gets the left camera of a rig setup in case of Rigged Camera
  25541. */
  25542. readonly isLeftCamera: boolean;
  25543. /** @hidden */
  25544. _isRightCamera: boolean;
  25545. /**
  25546. * Gets the right camera of a rig setup in case of Rigged Camera
  25547. */
  25548. readonly isRightCamera: boolean;
  25549. /**
  25550. * Gets the left camera of a rig setup in case of Rigged Camera
  25551. */
  25552. readonly leftCamera: Nullable<FreeCamera>;
  25553. /**
  25554. * Gets the right camera of a rig setup in case of Rigged Camera
  25555. */
  25556. readonly rightCamera: Nullable<FreeCamera>;
  25557. /**
  25558. * Gets the left camera target of a rig setup in case of Rigged Camera
  25559. * @returns the target position
  25560. */
  25561. getLeftTarget(): Nullable<Vector3>;
  25562. /**
  25563. * Gets the right camera target of a rig setup in case of Rigged Camera
  25564. * @returns the target position
  25565. */
  25566. getRightTarget(): Nullable<Vector3>;
  25567. /**
  25568. * @hidden
  25569. */
  25570. setCameraRigMode(mode: number, rigParams: any): void;
  25571. /** @hidden */
  25572. static _setStereoscopicRigMode(camera: Camera): void;
  25573. /** @hidden */
  25574. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  25575. /** @hidden */
  25576. static _setVRRigMode(camera: Camera, rigParams: any): void;
  25577. /** @hidden */
  25578. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  25579. /** @hidden */
  25580. _getVRProjectionMatrix(): Matrix;
  25581. protected _updateCameraRotationMatrix(): void;
  25582. protected _updateWebVRCameraRotationMatrix(): void;
  25583. /**
  25584. * This function MUST be overwritten by the different WebVR cameras available.
  25585. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  25586. * @hidden
  25587. */
  25588. _getWebVRProjectionMatrix(): Matrix;
  25589. /**
  25590. * This function MUST be overwritten by the different WebVR cameras available.
  25591. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  25592. * @hidden
  25593. */
  25594. _getWebVRViewMatrix(): Matrix;
  25595. /** @hidden */
  25596. setCameraRigParameter(name: string, value: any): void;
  25597. /**
  25598. * needs to be overridden by children so sub has required properties to be copied
  25599. * @hidden
  25600. */
  25601. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  25602. /**
  25603. * May need to be overridden by children
  25604. * @hidden
  25605. */
  25606. _updateRigCameras(): void;
  25607. /** @hidden */
  25608. _setupInputs(): void;
  25609. /**
  25610. * Serialiaze the camera setup to a json represention
  25611. * @returns the JSON representation
  25612. */
  25613. serialize(): any;
  25614. /**
  25615. * Clones the current camera.
  25616. * @param name The cloned camera name
  25617. * @returns the cloned camera
  25618. */
  25619. clone(name: string): Camera;
  25620. /**
  25621. * Gets the direction of the camera relative to a given local axis.
  25622. * @param localAxis Defines the reference axis to provide a relative direction.
  25623. * @return the direction
  25624. */
  25625. getDirection(localAxis: Vector3): Vector3;
  25626. /**
  25627. * Gets the direction of the camera relative to a given local axis into a passed vector.
  25628. * @param localAxis Defines the reference axis to provide a relative direction.
  25629. * @param result Defines the vector to store the result in
  25630. */
  25631. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  25632. /**
  25633. * Gets a camera constructor for a given camera type
  25634. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  25635. * @param name The name of the camera the result will be able to instantiate
  25636. * @param scene The scene the result will construct the camera in
  25637. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  25638. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  25639. * @returns a factory method to construc the camera
  25640. */
  25641. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  25642. /**
  25643. * Compute the world matrix of the camera.
  25644. * @returns the camera workd matrix
  25645. */
  25646. computeWorldMatrix(): Matrix;
  25647. /**
  25648. * Parse a JSON and creates the camera from the parsed information
  25649. * @param parsedCamera The JSON to parse
  25650. * @param scene The scene to instantiate the camera in
  25651. * @returns the newly constructed camera
  25652. */
  25653. static Parse(parsedCamera: any, scene: Scene): Camera;
  25654. }
  25655. }
  25656. declare module "babylonjs/Meshes/Builders/discBuilder" {
  25657. import { Nullable } from "babylonjs/types";
  25658. import { Scene } from "babylonjs/scene";
  25659. import { Vector4 } from "babylonjs/Maths/math.vector";
  25660. import { Mesh } from "babylonjs/Meshes/mesh";
  25661. /**
  25662. * Class containing static functions to help procedurally build meshes
  25663. */
  25664. export class DiscBuilder {
  25665. /**
  25666. * Creates a plane polygonal mesh. By default, this is a disc
  25667. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  25668. * * 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
  25669. * * 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
  25670. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  25671. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  25672. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  25673. * @param name defines the name of the mesh
  25674. * @param options defines the options used to create the mesh
  25675. * @param scene defines the hosting scene
  25676. * @returns the plane polygonal mesh
  25677. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  25678. */
  25679. static CreateDisc(name: string, options: {
  25680. radius?: number;
  25681. tessellation?: number;
  25682. arc?: number;
  25683. updatable?: boolean;
  25684. sideOrientation?: number;
  25685. frontUVs?: Vector4;
  25686. backUVs?: Vector4;
  25687. }, scene?: Nullable<Scene>): Mesh;
  25688. }
  25689. }
  25690. declare module "babylonjs/Particles/solidParticleSystem" {
  25691. import { Vector3 } from "babylonjs/Maths/math.vector";
  25692. import { Mesh } from "babylonjs/Meshes/mesh";
  25693. import { Scene, IDisposable } from "babylonjs/scene";
  25694. import { DepthSortedParticle, SolidParticle } from "babylonjs/Particles/solidParticle";
  25695. /**
  25696. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  25697. *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.
  25698. * The SPS is also a particle system. It provides some methods to manage the particles.
  25699. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  25700. *
  25701. * Full documentation here : http://doc.babylonjs.com/how_to/Solid_Particle_System
  25702. */
  25703. export class SolidParticleSystem implements IDisposable {
  25704. /**
  25705. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  25706. * Example : var p = SPS.particles[i];
  25707. */
  25708. particles: SolidParticle[];
  25709. /**
  25710. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  25711. */
  25712. nbParticles: number;
  25713. /**
  25714. * If the particles must ever face the camera (default false). Useful for planar particles.
  25715. */
  25716. billboard: boolean;
  25717. /**
  25718. * Recompute normals when adding a shape
  25719. */
  25720. recomputeNormals: boolean;
  25721. /**
  25722. * This a counter ofr your own usage. It's not set by any SPS functions.
  25723. */
  25724. counter: number;
  25725. /**
  25726. * The SPS name. This name is also given to the underlying mesh.
  25727. */
  25728. name: string;
  25729. /**
  25730. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  25731. */
  25732. mesh: Mesh;
  25733. /**
  25734. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  25735. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  25736. */
  25737. vars: any;
  25738. /**
  25739. * This array is populated when the SPS is set as 'pickable'.
  25740. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  25741. * Each element of this array is an object `{idx: int, faceId: int}`.
  25742. * `idx` is the picked particle index in the `SPS.particles` array
  25743. * `faceId` is the picked face index counted within this particle.
  25744. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  25745. */
  25746. pickedParticles: {
  25747. idx: number;
  25748. faceId: number;
  25749. }[];
  25750. /**
  25751. * This array is populated when `enableDepthSort` is set to true.
  25752. * Each element of this array is an instance of the class DepthSortedParticle.
  25753. */
  25754. depthSortedParticles: DepthSortedParticle[];
  25755. /**
  25756. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  25757. * @hidden
  25758. */
  25759. _bSphereOnly: boolean;
  25760. /**
  25761. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  25762. * @hidden
  25763. */
  25764. _bSphereRadiusFactor: number;
  25765. private _scene;
  25766. private _positions;
  25767. private _indices;
  25768. private _normals;
  25769. private _colors;
  25770. private _uvs;
  25771. private _indices32;
  25772. private _positions32;
  25773. private _normals32;
  25774. private _fixedNormal32;
  25775. private _colors32;
  25776. private _uvs32;
  25777. private _index;
  25778. private _updatable;
  25779. private _pickable;
  25780. private _isVisibilityBoxLocked;
  25781. private _alwaysVisible;
  25782. private _depthSort;
  25783. private _shapeCounter;
  25784. private _copy;
  25785. private _color;
  25786. private _computeParticleColor;
  25787. private _computeParticleTexture;
  25788. private _computeParticleRotation;
  25789. private _computeParticleVertex;
  25790. private _computeBoundingBox;
  25791. private _depthSortParticles;
  25792. private _camera;
  25793. private _mustUnrotateFixedNormals;
  25794. private _particlesIntersect;
  25795. private _needs32Bits;
  25796. /**
  25797. * Creates a SPS (Solid Particle System) object.
  25798. * @param name (String) is the SPS name, this will be the underlying mesh name.
  25799. * @param scene (Scene) is the scene in which the SPS is added.
  25800. * @param options defines the options of the sps e.g.
  25801. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  25802. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  25803. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  25804. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  25805. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  25806. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  25807. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  25808. */
  25809. constructor(name: string, scene: Scene, options?: {
  25810. updatable?: boolean;
  25811. isPickable?: boolean;
  25812. enableDepthSort?: boolean;
  25813. particleIntersection?: boolean;
  25814. boundingSphereOnly?: boolean;
  25815. bSphereRadiusFactor?: number;
  25816. });
  25817. /**
  25818. * Builds the SPS underlying mesh. Returns a standard Mesh.
  25819. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  25820. * @returns the created mesh
  25821. */
  25822. buildMesh(): Mesh;
  25823. /**
  25824. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  25825. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  25826. * Thus the particles generated from `digest()` have their property `position` set yet.
  25827. * @param mesh ( Mesh ) is the mesh to be digested
  25828. * @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
  25829. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  25830. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  25831. * @returns the current SPS
  25832. */
  25833. digest(mesh: Mesh, options?: {
  25834. facetNb?: number;
  25835. number?: number;
  25836. delta?: number;
  25837. }): SolidParticleSystem;
  25838. private _unrotateFixedNormals;
  25839. private _resetCopy;
  25840. private _meshBuilder;
  25841. private _posToShape;
  25842. private _uvsToShapeUV;
  25843. private _addParticle;
  25844. /**
  25845. * Adds some particles to the SPS from the model shape. Returns the shape id.
  25846. * Please read the doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  25847. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  25848. * @param nb (positive integer) the number of particles to be created from this model
  25849. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  25850. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  25851. * @returns the number of shapes in the system
  25852. */
  25853. addShape(mesh: Mesh, nb: number, options?: {
  25854. positionFunction?: any;
  25855. vertexFunction?: any;
  25856. }): number;
  25857. private _rebuildParticle;
  25858. /**
  25859. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  25860. * @returns the SPS.
  25861. */
  25862. rebuildMesh(): SolidParticleSystem;
  25863. /**
  25864. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  25865. * This method calls `updateParticle()` for each particle of the SPS.
  25866. * For an animated SPS, it is usually called within the render loop.
  25867. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  25868. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  25869. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  25870. * @returns the SPS.
  25871. */
  25872. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  25873. /**
  25874. * Disposes the SPS.
  25875. */
  25876. dispose(): void;
  25877. /**
  25878. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  25879. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  25880. * @returns the SPS.
  25881. */
  25882. refreshVisibleSize(): SolidParticleSystem;
  25883. /**
  25884. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  25885. * @param size the size (float) of the visibility box
  25886. * note : this doesn't lock the SPS mesh bounding box.
  25887. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  25888. */
  25889. setVisibilityBox(size: number): void;
  25890. /**
  25891. * Gets whether the SPS as always visible or not
  25892. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  25893. */
  25894. /**
  25895. * Sets the SPS as always visible or not
  25896. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  25897. */
  25898. isAlwaysVisible: boolean;
  25899. /**
  25900. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  25901. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  25902. */
  25903. /**
  25904. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  25905. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  25906. */
  25907. isVisibilityBoxLocked: boolean;
  25908. /**
  25909. * Tells to `setParticles()` to compute the particle rotations or not.
  25910. * Default value : true. The SPS is faster when it's set to false.
  25911. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  25912. */
  25913. /**
  25914. * Gets if `setParticles()` computes the particle rotations or not.
  25915. * Default value : true. The SPS is faster when it's set to false.
  25916. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  25917. */
  25918. computeParticleRotation: boolean;
  25919. /**
  25920. * Tells to `setParticles()` to compute the particle colors or not.
  25921. * Default value : true. The SPS is faster when it's set to false.
  25922. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  25923. */
  25924. /**
  25925. * Gets if `setParticles()` computes the particle colors or not.
  25926. * Default value : true. The SPS is faster when it's set to false.
  25927. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  25928. */
  25929. computeParticleColor: boolean;
  25930. /**
  25931. * Gets if `setParticles()` computes the particle textures or not.
  25932. * Default value : true. The SPS is faster when it's set to false.
  25933. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  25934. */
  25935. computeParticleTexture: boolean;
  25936. /**
  25937. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  25938. * Default value : false. The SPS is faster when it's set to false.
  25939. * Note : the particle custom vertex positions aren't stored values.
  25940. */
  25941. /**
  25942. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  25943. * Default value : false. The SPS is faster when it's set to false.
  25944. * Note : the particle custom vertex positions aren't stored values.
  25945. */
  25946. computeParticleVertex: boolean;
  25947. /**
  25948. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  25949. */
  25950. /**
  25951. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  25952. */
  25953. computeBoundingBox: boolean;
  25954. /**
  25955. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  25956. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  25957. * Default : `true`
  25958. */
  25959. /**
  25960. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  25961. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  25962. * Default : `true`
  25963. */
  25964. depthSortParticles: boolean;
  25965. /**
  25966. * This function does nothing. It may be overwritten to set all the particle first values.
  25967. * The SPS doesn't call this function, you may have to call it by your own.
  25968. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  25969. */
  25970. initParticles(): void;
  25971. /**
  25972. * This function does nothing. It may be overwritten to recycle a particle.
  25973. * The SPS doesn't call this function, you may have to call it by your own.
  25974. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  25975. * @param particle The particle to recycle
  25976. * @returns the recycled particle
  25977. */
  25978. recycleParticle(particle: SolidParticle): SolidParticle;
  25979. /**
  25980. * Updates a particle : this function should be overwritten by the user.
  25981. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  25982. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  25983. * @example : just set a particle position or velocity and recycle conditions
  25984. * @param particle The particle to update
  25985. * @returns the updated particle
  25986. */
  25987. updateParticle(particle: SolidParticle): SolidParticle;
  25988. /**
  25989. * Updates a vertex of a particle : it can be overwritten by the user.
  25990. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  25991. * @param particle the current particle
  25992. * @param vertex the current index of the current particle
  25993. * @param pt the index of the current vertex in the particle shape
  25994. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  25995. * @example : just set a vertex particle position
  25996. * @returns the updated vertex
  25997. */
  25998. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  25999. /**
  26000. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  26001. * This does nothing and may be overwritten by the user.
  26002. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  26003. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  26004. * @param update the boolean update value actually passed to setParticles()
  26005. */
  26006. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  26007. /**
  26008. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  26009. * This will be passed three parameters.
  26010. * This does nothing and may be overwritten by the user.
  26011. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  26012. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  26013. * @param update the boolean update value actually passed to setParticles()
  26014. */
  26015. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  26016. }
  26017. }
  26018. declare module "babylonjs/Particles/solidParticle" {
  26019. import { Nullable } from "babylonjs/types";
  26020. import { Vector3, Matrix, Quaternion, Vector4 } from "babylonjs/Maths/math.vector";
  26021. import { Color4 } from "babylonjs/Maths/math.color";
  26022. import { Mesh } from "babylonjs/Meshes/mesh";
  26023. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  26024. import { SolidParticleSystem } from "babylonjs/Particles/solidParticleSystem";
  26025. import { Plane } from "babylonjs/Maths/math.plane";
  26026. /**
  26027. * Represents one particle of a solid particle system.
  26028. */
  26029. export class SolidParticle {
  26030. /**
  26031. * particle global index
  26032. */
  26033. idx: number;
  26034. /**
  26035. * The color of the particle
  26036. */
  26037. color: Nullable<Color4>;
  26038. /**
  26039. * The world space position of the particle.
  26040. */
  26041. position: Vector3;
  26042. /**
  26043. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  26044. */
  26045. rotation: Vector3;
  26046. /**
  26047. * The world space rotation quaternion of the particle.
  26048. */
  26049. rotationQuaternion: Nullable<Quaternion>;
  26050. /**
  26051. * The scaling of the particle.
  26052. */
  26053. scaling: Vector3;
  26054. /**
  26055. * The uvs of the particle.
  26056. */
  26057. uvs: Vector4;
  26058. /**
  26059. * The current speed of the particle.
  26060. */
  26061. velocity: Vector3;
  26062. /**
  26063. * The pivot point in the particle local space.
  26064. */
  26065. pivot: Vector3;
  26066. /**
  26067. * Must the particle be translated from its pivot point in its local space ?
  26068. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  26069. * Default : false
  26070. */
  26071. translateFromPivot: boolean;
  26072. /**
  26073. * Is the particle active or not ?
  26074. */
  26075. alive: boolean;
  26076. /**
  26077. * Is the particle visible or not ?
  26078. */
  26079. isVisible: boolean;
  26080. /**
  26081. * Index of this particle in the global "positions" array (Internal use)
  26082. * @hidden
  26083. */
  26084. _pos: number;
  26085. /**
  26086. * @hidden Index of this particle in the global "indices" array (Internal use)
  26087. */
  26088. _ind: number;
  26089. /**
  26090. * @hidden ModelShape of this particle (Internal use)
  26091. */
  26092. _model: ModelShape;
  26093. /**
  26094. * ModelShape id of this particle
  26095. */
  26096. shapeId: number;
  26097. /**
  26098. * Index of the particle in its shape id
  26099. */
  26100. idxInShape: number;
  26101. /**
  26102. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  26103. */
  26104. _modelBoundingInfo: BoundingInfo;
  26105. /**
  26106. * @hidden Particle BoundingInfo object (Internal use)
  26107. */
  26108. _boundingInfo: BoundingInfo;
  26109. /**
  26110. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  26111. */
  26112. _sps: SolidParticleSystem;
  26113. /**
  26114. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  26115. */
  26116. _stillInvisible: boolean;
  26117. /**
  26118. * @hidden Last computed particle rotation matrix
  26119. */
  26120. _rotationMatrix: number[];
  26121. /**
  26122. * Parent particle Id, if any.
  26123. * Default null.
  26124. */
  26125. parentId: Nullable<number>;
  26126. /**
  26127. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  26128. * The possible values are :
  26129. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  26130. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  26131. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  26132. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  26133. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  26134. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  26135. * */
  26136. cullingStrategy: number;
  26137. /**
  26138. * @hidden Internal global position in the SPS.
  26139. */
  26140. _globalPosition: Vector3;
  26141. /**
  26142. * Creates a Solid Particle object.
  26143. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  26144. * @param particleIndex (integer) is the particle index in the Solid Particle System pool. It's also the particle identifier.
  26145. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  26146. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  26147. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  26148. * @param shapeId (integer) is the model shape identifier in the SPS.
  26149. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  26150. * @param sps defines the sps it is associated to
  26151. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  26152. */
  26153. constructor(particleIndex: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>);
  26154. /**
  26155. * Legacy support, changed scale to scaling
  26156. */
  26157. /**
  26158. * Legacy support, changed scale to scaling
  26159. */
  26160. scale: Vector3;
  26161. /**
  26162. * Legacy support, changed quaternion to rotationQuaternion
  26163. */
  26164. /**
  26165. * Legacy support, changed quaternion to rotationQuaternion
  26166. */
  26167. quaternion: Nullable<Quaternion>;
  26168. /**
  26169. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  26170. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  26171. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  26172. * @returns true if it intersects
  26173. */
  26174. intersectsMesh(target: Mesh | SolidParticle): boolean;
  26175. /**
  26176. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  26177. * A particle is in the frustum if its bounding box intersects the frustum
  26178. * @param frustumPlanes defines the frustum to test
  26179. * @returns true if the particle is in the frustum planes
  26180. */
  26181. isInFrustum(frustumPlanes: Plane[]): boolean;
  26182. /**
  26183. * get the rotation matrix of the particle
  26184. * @hidden
  26185. */
  26186. getRotationMatrix(m: Matrix): void;
  26187. }
  26188. /**
  26189. * Represents the shape of the model used by one particle of a solid particle system.
  26190. * SPS internal tool, don't use it manually.
  26191. */
  26192. export class ModelShape {
  26193. /**
  26194. * The shape id
  26195. * @hidden
  26196. */
  26197. shapeID: number;
  26198. /**
  26199. * flat array of model positions (internal use)
  26200. * @hidden
  26201. */
  26202. _shape: Vector3[];
  26203. /**
  26204. * flat array of model UVs (internal use)
  26205. * @hidden
  26206. */
  26207. _shapeUV: number[];
  26208. /**
  26209. * length of the shape in the model indices array (internal use)
  26210. * @hidden
  26211. */
  26212. _indicesLength: number;
  26213. /**
  26214. * Custom position function (internal use)
  26215. * @hidden
  26216. */
  26217. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  26218. /**
  26219. * Custom vertex function (internal use)
  26220. * @hidden
  26221. */
  26222. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  26223. /**
  26224. * 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.
  26225. * SPS internal tool, don't use it manually.
  26226. * @hidden
  26227. */
  26228. constructor(id: number, shape: Vector3[], indicesLength: number, shapeUV: number[], posFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>, vtxFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>);
  26229. }
  26230. /**
  26231. * Represents a Depth Sorted Particle in the solid particle system.
  26232. */
  26233. export class DepthSortedParticle {
  26234. /**
  26235. * Index of the particle in the "indices" array
  26236. */
  26237. ind: number;
  26238. /**
  26239. * Length of the particle shape in the "indices" array
  26240. */
  26241. indicesLength: number;
  26242. /**
  26243. * Squared distance from the particle to the camera
  26244. */
  26245. sqDistance: number;
  26246. }
  26247. }
  26248. declare module "babylonjs/Collisions/meshCollisionData" {
  26249. import { Collider } from "babylonjs/Collisions/collider";
  26250. import { Vector3 } from "babylonjs/Maths/math.vector";
  26251. import { Nullable } from "babylonjs/types";
  26252. import { Observer } from "babylonjs/Misc/observable";
  26253. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  26254. /**
  26255. * @hidden
  26256. */
  26257. export class _MeshCollisionData {
  26258. _checkCollisions: boolean;
  26259. _collisionMask: number;
  26260. _collisionGroup: number;
  26261. _collider: Nullable<Collider>;
  26262. _oldPositionForCollisions: Vector3;
  26263. _diffPositionForCollisions: Vector3;
  26264. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  26265. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  26266. }
  26267. }
  26268. declare module "babylonjs/Meshes/abstractMesh" {
  26269. import { Observable } from "babylonjs/Misc/observable";
  26270. import { Nullable, FloatArray, IndicesArray, DeepImmutable } from "babylonjs/types";
  26271. import { Camera } from "babylonjs/Cameras/camera";
  26272. import { Scene, IDisposable } from "babylonjs/scene";
  26273. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  26274. import { Node } from "babylonjs/node";
  26275. import { IGetSetVerticesData } from "babylonjs/Meshes/mesh.vertexData";
  26276. import { TransformNode } from "babylonjs/Meshes/transformNode";
  26277. import { SubMesh } from "babylonjs/Meshes/subMesh";
  26278. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  26279. import { ICullable, BoundingInfo } from "babylonjs/Culling/boundingInfo";
  26280. import { Material } from "babylonjs/Materials/material";
  26281. import { Light } from "babylonjs/Lights/light";
  26282. import { Skeleton } from "babylonjs/Bones/skeleton";
  26283. import { IEdgesRenderer } from "babylonjs/Rendering/edgesRenderer";
  26284. import { SolidParticle } from "babylonjs/Particles/solidParticle";
  26285. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  26286. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  26287. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  26288. import { Plane } from "babylonjs/Maths/math.plane";
  26289. import { Ray } from "babylonjs/Culling/ray";
  26290. import { Collider } from "babylonjs/Collisions/collider";
  26291. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  26292. import { RenderingGroup } from "babylonjs/Rendering/renderingGroup";
  26293. /** @hidden */
  26294. class _FacetDataStorage {
  26295. facetPositions: Vector3[];
  26296. facetNormals: Vector3[];
  26297. facetPartitioning: number[][];
  26298. facetNb: number;
  26299. partitioningSubdivisions: number;
  26300. partitioningBBoxRatio: number;
  26301. facetDataEnabled: boolean;
  26302. facetParameters: any;
  26303. bbSize: Vector3;
  26304. subDiv: {
  26305. max: number;
  26306. X: number;
  26307. Y: number;
  26308. Z: number;
  26309. };
  26310. facetDepthSort: boolean;
  26311. facetDepthSortEnabled: boolean;
  26312. depthSortedIndices: IndicesArray;
  26313. depthSortedFacets: {
  26314. ind: number;
  26315. sqDistance: number;
  26316. }[];
  26317. facetDepthSortFunction: (f1: {
  26318. ind: number;
  26319. sqDistance: number;
  26320. }, f2: {
  26321. ind: number;
  26322. sqDistance: number;
  26323. }) => number;
  26324. facetDepthSortFrom: Vector3;
  26325. facetDepthSortOrigin: Vector3;
  26326. invertedMatrix: Matrix;
  26327. }
  26328. /**
  26329. * @hidden
  26330. **/
  26331. class _InternalAbstractMeshDataInfo {
  26332. _hasVertexAlpha: boolean;
  26333. _useVertexColors: boolean;
  26334. _numBoneInfluencers: number;
  26335. _applyFog: boolean;
  26336. _receiveShadows: boolean;
  26337. _facetData: _FacetDataStorage;
  26338. _visibility: number;
  26339. _skeleton: Nullable<Skeleton>;
  26340. _layerMask: number;
  26341. _computeBonesUsingShaders: boolean;
  26342. _isActive: boolean;
  26343. _onlyForInstances: boolean;
  26344. _isActiveIntermediate: boolean;
  26345. _onlyForInstancesIntermediate: boolean;
  26346. }
  26347. /**
  26348. * Class used to store all common mesh properties
  26349. */
  26350. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  26351. /** No occlusion */
  26352. static OCCLUSION_TYPE_NONE: number;
  26353. /** Occlusion set to optimisitic */
  26354. static OCCLUSION_TYPE_OPTIMISTIC: number;
  26355. /** Occlusion set to strict */
  26356. static OCCLUSION_TYPE_STRICT: number;
  26357. /** Use an accurante occlusion algorithm */
  26358. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  26359. /** Use a conservative occlusion algorithm */
  26360. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  26361. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  26362. * Test order :
  26363. * Is the bounding sphere outside the frustum ?
  26364. * If not, are the bounding box vertices outside the frustum ?
  26365. * It not, then the cullable object is in the frustum.
  26366. */
  26367. static readonly CULLINGSTRATEGY_STANDARD: number;
  26368. /** Culling strategy : Bounding Sphere Only.
  26369. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  26370. * It's also less accurate than the standard because some not visible objects can still be selected.
  26371. * Test : is the bounding sphere outside the frustum ?
  26372. * If not, then the cullable object is in the frustum.
  26373. */
  26374. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  26375. /** Culling strategy : Optimistic Inclusion.
  26376. * This in an inclusion test first, then the standard exclusion test.
  26377. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  26378. * 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.
  26379. * Anyway, it's as accurate as the standard strategy.
  26380. * Test :
  26381. * Is the cullable object bounding sphere center in the frustum ?
  26382. * If not, apply the default culling strategy.
  26383. */
  26384. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  26385. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  26386. * This in an inclusion test first, then the bounding sphere only exclusion test.
  26387. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  26388. * 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.
  26389. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  26390. * Test :
  26391. * Is the cullable object bounding sphere center in the frustum ?
  26392. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  26393. */
  26394. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  26395. /**
  26396. * No billboard
  26397. */
  26398. static readonly BILLBOARDMODE_NONE: number;
  26399. /** Billboard on X axis */
  26400. static readonly BILLBOARDMODE_X: number;
  26401. /** Billboard on Y axis */
  26402. static readonly BILLBOARDMODE_Y: number;
  26403. /** Billboard on Z axis */
  26404. static readonly BILLBOARDMODE_Z: number;
  26405. /** Billboard on all axes */
  26406. static readonly BILLBOARDMODE_ALL: number;
  26407. /** Billboard on using position instead of orientation */
  26408. static readonly BILLBOARDMODE_USE_POSITION: number;
  26409. /** @hidden */
  26410. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  26411. /**
  26412. * The culling strategy to use to check whether the mesh must be rendered or not.
  26413. * This value can be changed at any time and will be used on the next render mesh selection.
  26414. * The possible values are :
  26415. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  26416. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  26417. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  26418. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  26419. * Please read each static variable documentation to get details about the culling process.
  26420. * */
  26421. cullingStrategy: number;
  26422. /**
  26423. * Gets the number of facets in the mesh
  26424. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  26425. */
  26426. readonly facetNb: number;
  26427. /**
  26428. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  26429. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  26430. */
  26431. partitioningSubdivisions: number;
  26432. /**
  26433. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  26434. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  26435. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  26436. */
  26437. partitioningBBoxRatio: number;
  26438. /**
  26439. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  26440. * Works only for updatable meshes.
  26441. * Doesn't work with multi-materials
  26442. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  26443. */
  26444. mustDepthSortFacets: boolean;
  26445. /**
  26446. * The location (Vector3) where the facet depth sort must be computed from.
  26447. * By default, the active camera position.
  26448. * Used only when facet depth sort is enabled
  26449. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  26450. */
  26451. facetDepthSortFrom: Vector3;
  26452. /**
  26453. * gets a boolean indicating if facetData is enabled
  26454. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  26455. */
  26456. readonly isFacetDataEnabled: boolean;
  26457. /** @hidden */
  26458. _updateNonUniformScalingState(value: boolean): boolean;
  26459. /**
  26460. * An event triggered when this mesh collides with another one
  26461. */
  26462. onCollideObservable: Observable<AbstractMesh>;
  26463. /** Set a function to call when this mesh collides with another one */
  26464. onCollide: () => void;
  26465. /**
  26466. * An event triggered when the collision's position changes
  26467. */
  26468. onCollisionPositionChangeObservable: Observable<Vector3>;
  26469. /** Set a function to call when the collision's position changes */
  26470. onCollisionPositionChange: () => void;
  26471. /**
  26472. * An event triggered when material is changed
  26473. */
  26474. onMaterialChangedObservable: Observable<AbstractMesh>;
  26475. /**
  26476. * Gets or sets the orientation for POV movement & rotation
  26477. */
  26478. definedFacingForward: boolean;
  26479. /** @hidden */
  26480. _occlusionQuery: Nullable<WebGLQuery>;
  26481. /** @hidden */
  26482. _renderingGroup: Nullable<RenderingGroup>;
  26483. /**
  26484. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  26485. */
  26486. /**
  26487. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  26488. */
  26489. visibility: number;
  26490. /** Gets or sets the alpha index used to sort transparent meshes
  26491. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  26492. */
  26493. alphaIndex: number;
  26494. /**
  26495. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  26496. */
  26497. isVisible: boolean;
  26498. /**
  26499. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  26500. */
  26501. isPickable: boolean;
  26502. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  26503. showSubMeshesBoundingBox: boolean;
  26504. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  26505. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  26506. */
  26507. isBlocker: boolean;
  26508. /**
  26509. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  26510. */
  26511. enablePointerMoveEvents: boolean;
  26512. /**
  26513. * Specifies the rendering group id for this mesh (0 by default)
  26514. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  26515. */
  26516. renderingGroupId: number;
  26517. private _material;
  26518. /** Gets or sets current material */
  26519. material: Nullable<Material>;
  26520. /**
  26521. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  26522. * @see http://doc.babylonjs.com/babylon101/shadows
  26523. */
  26524. receiveShadows: boolean;
  26525. /** Defines color to use when rendering outline */
  26526. outlineColor: Color3;
  26527. /** Define width to use when rendering outline */
  26528. outlineWidth: number;
  26529. /** Defines color to use when rendering overlay */
  26530. overlayColor: Color3;
  26531. /** Defines alpha to use when rendering overlay */
  26532. overlayAlpha: number;
  26533. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  26534. hasVertexAlpha: boolean;
  26535. /** 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) */
  26536. useVertexColors: boolean;
  26537. /**
  26538. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  26539. */
  26540. computeBonesUsingShaders: boolean;
  26541. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  26542. numBoneInfluencers: number;
  26543. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  26544. applyFog: boolean;
  26545. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  26546. useOctreeForRenderingSelection: boolean;
  26547. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  26548. useOctreeForPicking: boolean;
  26549. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  26550. useOctreeForCollisions: boolean;
  26551. /**
  26552. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  26553. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  26554. */
  26555. layerMask: number;
  26556. /**
  26557. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  26558. */
  26559. alwaysSelectAsActiveMesh: boolean;
  26560. /**
  26561. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  26562. */
  26563. doNotSyncBoundingInfo: boolean;
  26564. /**
  26565. * Gets or sets the current action manager
  26566. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  26567. */
  26568. actionManager: Nullable<AbstractActionManager>;
  26569. private _meshCollisionData;
  26570. /**
  26571. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  26572. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  26573. */
  26574. ellipsoid: Vector3;
  26575. /**
  26576. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  26577. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  26578. */
  26579. ellipsoidOffset: Vector3;
  26580. /**
  26581. * Gets or sets a collision mask used to mask collisions (default is -1).
  26582. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  26583. */
  26584. collisionMask: number;
  26585. /**
  26586. * Gets or sets the current collision group mask (-1 by default).
  26587. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  26588. */
  26589. collisionGroup: number;
  26590. /**
  26591. * Defines edge width used when edgesRenderer is enabled
  26592. * @see https://www.babylonjs-playground.com/#10OJSG#13
  26593. */
  26594. edgesWidth: number;
  26595. /**
  26596. * Defines edge color used when edgesRenderer is enabled
  26597. * @see https://www.babylonjs-playground.com/#10OJSG#13
  26598. */
  26599. edgesColor: Color4;
  26600. /** @hidden */
  26601. _edgesRenderer: Nullable<IEdgesRenderer>;
  26602. /** @hidden */
  26603. _masterMesh: Nullable<AbstractMesh>;
  26604. /** @hidden */
  26605. _boundingInfo: Nullable<BoundingInfo>;
  26606. /** @hidden */
  26607. _renderId: number;
  26608. /**
  26609. * Gets or sets the list of subMeshes
  26610. * @see http://doc.babylonjs.com/how_to/multi_materials
  26611. */
  26612. subMeshes: SubMesh[];
  26613. /** @hidden */
  26614. _intersectionsInProgress: AbstractMesh[];
  26615. /** @hidden */
  26616. _unIndexed: boolean;
  26617. /** @hidden */
  26618. _lightSources: Light[];
  26619. /** Gets the list of lights affecting that mesh */
  26620. readonly lightSources: Light[];
  26621. /** @hidden */
  26622. readonly _positions: Nullable<Vector3[]>;
  26623. /** @hidden */
  26624. _waitingData: {
  26625. lods: Nullable<any>;
  26626. actions: Nullable<any>;
  26627. freezeWorldMatrix: Nullable<boolean>;
  26628. };
  26629. /** @hidden */
  26630. _bonesTransformMatrices: Nullable<Float32Array>;
  26631. /** @hidden */
  26632. _transformMatrixTexture: Nullable<RawTexture>;
  26633. /**
  26634. * Gets or sets a skeleton to apply skining transformations
  26635. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  26636. */
  26637. skeleton: Nullable<Skeleton>;
  26638. /**
  26639. * An event triggered when the mesh is rebuilt.
  26640. */
  26641. onRebuildObservable: Observable<AbstractMesh>;
  26642. /**
  26643. * Creates a new AbstractMesh
  26644. * @param name defines the name of the mesh
  26645. * @param scene defines the hosting scene
  26646. */
  26647. constructor(name: string, scene?: Nullable<Scene>);
  26648. /**
  26649. * Returns the string "AbstractMesh"
  26650. * @returns "AbstractMesh"
  26651. */
  26652. getClassName(): string;
  26653. /**
  26654. * Gets a string representation of the current mesh
  26655. * @param fullDetails defines a boolean indicating if full details must be included
  26656. * @returns a string representation of the current mesh
  26657. */
  26658. toString(fullDetails?: boolean): string;
  26659. /**
  26660. * @hidden
  26661. */
  26662. protected _getEffectiveParent(): Nullable<Node>;
  26663. /** @hidden */
  26664. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  26665. /** @hidden */
  26666. _rebuild(): void;
  26667. /** @hidden */
  26668. _resyncLightSources(): void;
  26669. /** @hidden */
  26670. _resyncLighSource(light: Light): void;
  26671. /** @hidden */
  26672. _unBindEffect(): void;
  26673. /** @hidden */
  26674. _removeLightSource(light: Light, dispose: boolean): void;
  26675. private _markSubMeshesAsDirty;
  26676. /** @hidden */
  26677. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  26678. /** @hidden */
  26679. _markSubMeshesAsAttributesDirty(): void;
  26680. /** @hidden */
  26681. _markSubMeshesAsMiscDirty(): void;
  26682. /**
  26683. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  26684. */
  26685. scaling: Vector3;
  26686. /**
  26687. * Returns true if the mesh is blocked. Implemented by child classes
  26688. */
  26689. readonly isBlocked: boolean;
  26690. /**
  26691. * Returns the mesh itself by default. Implemented by child classes
  26692. * @param camera defines the camera to use to pick the right LOD level
  26693. * @returns the currentAbstractMesh
  26694. */
  26695. getLOD(camera: Camera): Nullable<AbstractMesh>;
  26696. /**
  26697. * Returns 0 by default. Implemented by child classes
  26698. * @returns an integer
  26699. */
  26700. getTotalVertices(): number;
  26701. /**
  26702. * Returns a positive integer : the total number of indices in this mesh geometry.
  26703. * @returns the numner of indices or zero if the mesh has no geometry.
  26704. */
  26705. getTotalIndices(): number;
  26706. /**
  26707. * Returns null by default. Implemented by child classes
  26708. * @returns null
  26709. */
  26710. getIndices(): Nullable<IndicesArray>;
  26711. /**
  26712. * Returns the array of the requested vertex data kind. Implemented by child classes
  26713. * @param kind defines the vertex data kind to use
  26714. * @returns null
  26715. */
  26716. getVerticesData(kind: string): Nullable<FloatArray>;
  26717. /**
  26718. * Sets the vertex data of the mesh geometry for the requested `kind`.
  26719. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  26720. * Note that a new underlying VertexBuffer object is created each call.
  26721. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  26722. * @param kind defines vertex data kind:
  26723. * * VertexBuffer.PositionKind
  26724. * * VertexBuffer.UVKind
  26725. * * VertexBuffer.UV2Kind
  26726. * * VertexBuffer.UV3Kind
  26727. * * VertexBuffer.UV4Kind
  26728. * * VertexBuffer.UV5Kind
  26729. * * VertexBuffer.UV6Kind
  26730. * * VertexBuffer.ColorKind
  26731. * * VertexBuffer.MatricesIndicesKind
  26732. * * VertexBuffer.MatricesIndicesExtraKind
  26733. * * VertexBuffer.MatricesWeightsKind
  26734. * * VertexBuffer.MatricesWeightsExtraKind
  26735. * @param data defines the data source
  26736. * @param updatable defines if the data must be flagged as updatable (or static)
  26737. * @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
  26738. * @returns the current mesh
  26739. */
  26740. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  26741. /**
  26742. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  26743. * If the mesh has no geometry, it is simply returned as it is.
  26744. * @param kind defines vertex data kind:
  26745. * * VertexBuffer.PositionKind
  26746. * * VertexBuffer.UVKind
  26747. * * VertexBuffer.UV2Kind
  26748. * * VertexBuffer.UV3Kind
  26749. * * VertexBuffer.UV4Kind
  26750. * * VertexBuffer.UV5Kind
  26751. * * VertexBuffer.UV6Kind
  26752. * * VertexBuffer.ColorKind
  26753. * * VertexBuffer.MatricesIndicesKind
  26754. * * VertexBuffer.MatricesIndicesExtraKind
  26755. * * VertexBuffer.MatricesWeightsKind
  26756. * * VertexBuffer.MatricesWeightsExtraKind
  26757. * @param data defines the data source
  26758. * @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
  26759. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  26760. * @returns the current mesh
  26761. */
  26762. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  26763. /**
  26764. * Sets the mesh indices,
  26765. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  26766. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  26767. * @param totalVertices Defines the total number of vertices
  26768. * @returns the current mesh
  26769. */
  26770. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  26771. /**
  26772. * Gets a boolean indicating if specific vertex data is present
  26773. * @param kind defines the vertex data kind to use
  26774. * @returns true is data kind is present
  26775. */
  26776. isVerticesDataPresent(kind: string): boolean;
  26777. /**
  26778. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  26779. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  26780. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  26781. * @returns a BoundingInfo
  26782. */
  26783. getBoundingInfo(): BoundingInfo;
  26784. /**
  26785. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  26786. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  26787. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  26788. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  26789. * @returns the current mesh
  26790. */
  26791. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  26792. /**
  26793. * Overwrite the current bounding info
  26794. * @param boundingInfo defines the new bounding info
  26795. * @returns the current mesh
  26796. */
  26797. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  26798. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  26799. readonly useBones: boolean;
  26800. /** @hidden */
  26801. _preActivate(): void;
  26802. /** @hidden */
  26803. _preActivateForIntermediateRendering(renderId: number): void;
  26804. /** @hidden */
  26805. _activate(renderId: number, intermediateRendering: boolean): boolean;
  26806. /** @hidden */
  26807. _postActivate(): void;
  26808. /** @hidden */
  26809. _freeze(): void;
  26810. /** @hidden */
  26811. _unFreeze(): void;
  26812. /**
  26813. * Gets the current world matrix
  26814. * @returns a Matrix
  26815. */
  26816. getWorldMatrix(): Matrix;
  26817. /** @hidden */
  26818. _getWorldMatrixDeterminant(): number;
  26819. /**
  26820. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  26821. */
  26822. readonly isAnInstance: boolean;
  26823. /**
  26824. * Gets a boolean indicating if this mesh has instances
  26825. */
  26826. readonly hasInstances: boolean;
  26827. /**
  26828. * Perform relative position change from the point of view of behind the front of the mesh.
  26829. * This is performed taking into account the meshes current rotation, so you do not have to care.
  26830. * Supports definition of mesh facing forward or backward
  26831. * @param amountRight defines the distance on the right axis
  26832. * @param amountUp defines the distance on the up axis
  26833. * @param amountForward defines the distance on the forward axis
  26834. * @returns the current mesh
  26835. */
  26836. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  26837. /**
  26838. * Calculate relative position change from the point of view of behind the front of the mesh.
  26839. * This is performed taking into account the meshes current rotation, so you do not have to care.
  26840. * Supports definition of mesh facing forward or backward
  26841. * @param amountRight defines the distance on the right axis
  26842. * @param amountUp defines the distance on the up axis
  26843. * @param amountForward defines the distance on the forward axis
  26844. * @returns the new displacement vector
  26845. */
  26846. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  26847. /**
  26848. * Perform relative rotation change from the point of view of behind the front of the mesh.
  26849. * Supports definition of mesh facing forward or backward
  26850. * @param flipBack defines the flip
  26851. * @param twirlClockwise defines the twirl
  26852. * @param tiltRight defines the tilt
  26853. * @returns the current mesh
  26854. */
  26855. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  26856. /**
  26857. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  26858. * Supports definition of mesh facing forward or backward.
  26859. * @param flipBack defines the flip
  26860. * @param twirlClockwise defines the twirl
  26861. * @param tiltRight defines the tilt
  26862. * @returns the new rotation vector
  26863. */
  26864. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  26865. /**
  26866. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  26867. * This means the mesh underlying bounding box and sphere are recomputed.
  26868. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  26869. * @returns the current mesh
  26870. */
  26871. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  26872. /** @hidden */
  26873. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  26874. /** @hidden */
  26875. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  26876. /** @hidden */
  26877. _updateBoundingInfo(): AbstractMesh;
  26878. /** @hidden */
  26879. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  26880. /** @hidden */
  26881. protected _afterComputeWorldMatrix(): void;
  26882. /** @hidden */
  26883. readonly _effectiveMesh: AbstractMesh;
  26884. /**
  26885. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  26886. * A mesh is in the frustum if its bounding box intersects the frustum
  26887. * @param frustumPlanes defines the frustum to test
  26888. * @returns true if the mesh is in the frustum planes
  26889. */
  26890. isInFrustum(frustumPlanes: Plane[]): boolean;
  26891. /**
  26892. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  26893. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  26894. * @param frustumPlanes defines the frustum to test
  26895. * @returns true if the mesh is completely in the frustum planes
  26896. */
  26897. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  26898. /**
  26899. * True if the mesh intersects another mesh or a SolidParticle object
  26900. * @param mesh defines a target mesh or SolidParticle to test
  26901. * @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)
  26902. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  26903. * @returns true if there is an intersection
  26904. */
  26905. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  26906. /**
  26907. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  26908. * @param point defines the point to test
  26909. * @returns true if there is an intersection
  26910. */
  26911. intersectsPoint(point: Vector3): boolean;
  26912. /**
  26913. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  26914. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  26915. */
  26916. checkCollisions: boolean;
  26917. /**
  26918. * Gets Collider object used to compute collisions (not physics)
  26919. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  26920. */
  26921. readonly collider: Nullable<Collider>;
  26922. /**
  26923. * Move the mesh using collision engine
  26924. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  26925. * @param displacement defines the requested displacement vector
  26926. * @returns the current mesh
  26927. */
  26928. moveWithCollisions(displacement: Vector3): AbstractMesh;
  26929. private _onCollisionPositionChange;
  26930. /** @hidden */
  26931. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  26932. /** @hidden */
  26933. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  26934. /** @hidden */
  26935. _checkCollision(collider: Collider): AbstractMesh;
  26936. /** @hidden */
  26937. _generatePointsArray(): boolean;
  26938. /**
  26939. * Checks if the passed Ray intersects with the mesh
  26940. * @param ray defines the ray to use
  26941. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  26942. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  26943. * @returns the picking info
  26944. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  26945. */
  26946. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): PickingInfo;
  26947. /**
  26948. * Clones the current mesh
  26949. * @param name defines the mesh name
  26950. * @param newParent defines the new mesh parent
  26951. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  26952. * @returns the new mesh
  26953. */
  26954. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  26955. /**
  26956. * Disposes all the submeshes of the current meshnp
  26957. * @returns the current mesh
  26958. */
  26959. releaseSubMeshes(): AbstractMesh;
  26960. /**
  26961. * Releases resources associated with this abstract mesh.
  26962. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  26963. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  26964. */
  26965. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  26966. /**
  26967. * Adds the passed mesh as a child to the current mesh
  26968. * @param mesh defines the child mesh
  26969. * @returns the current mesh
  26970. */
  26971. addChild(mesh: AbstractMesh): AbstractMesh;
  26972. /**
  26973. * Removes the passed mesh from the current mesh children list
  26974. * @param mesh defines the child mesh
  26975. * @returns the current mesh
  26976. */
  26977. removeChild(mesh: AbstractMesh): AbstractMesh;
  26978. /** @hidden */
  26979. private _initFacetData;
  26980. /**
  26981. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  26982. * This method can be called within the render loop.
  26983. * 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
  26984. * @returns the current mesh
  26985. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26986. */
  26987. updateFacetData(): AbstractMesh;
  26988. /**
  26989. * Returns the facetLocalNormals array.
  26990. * The normals are expressed in the mesh local spac
  26991. * @returns an array of Vector3
  26992. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26993. */
  26994. getFacetLocalNormals(): Vector3[];
  26995. /**
  26996. * Returns the facetLocalPositions array.
  26997. * The facet positions are expressed in the mesh local space
  26998. * @returns an array of Vector3
  26999. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27000. */
  27001. getFacetLocalPositions(): Vector3[];
  27002. /**
  27003. * Returns the facetLocalPartioning array
  27004. * @returns an array of array of numbers
  27005. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27006. */
  27007. getFacetLocalPartitioning(): number[][];
  27008. /**
  27009. * Returns the i-th facet position in the world system.
  27010. * This method allocates a new Vector3 per call
  27011. * @param i defines the facet index
  27012. * @returns a new Vector3
  27013. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27014. */
  27015. getFacetPosition(i: number): Vector3;
  27016. /**
  27017. * Sets the reference Vector3 with the i-th facet position in the world system
  27018. * @param i defines the facet index
  27019. * @param ref defines the target vector
  27020. * @returns the current mesh
  27021. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27022. */
  27023. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  27024. /**
  27025. * Returns the i-th facet normal in the world system.
  27026. * This method allocates a new Vector3 per call
  27027. * @param i defines the facet index
  27028. * @returns a new Vector3
  27029. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27030. */
  27031. getFacetNormal(i: number): Vector3;
  27032. /**
  27033. * Sets the reference Vector3 with the i-th facet normal in the world system
  27034. * @param i defines the facet index
  27035. * @param ref defines the target vector
  27036. * @returns the current mesh
  27037. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27038. */
  27039. getFacetNormalToRef(i: number, ref: Vector3): this;
  27040. /**
  27041. * 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)
  27042. * @param x defines x coordinate
  27043. * @param y defines y coordinate
  27044. * @param z defines z coordinate
  27045. * @returns the array of facet indexes
  27046. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27047. */
  27048. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  27049. /**
  27050. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  27051. * @param projected sets as the (x,y,z) world projection on the facet
  27052. * @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
  27053. * @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
  27054. * @param x defines x coordinate
  27055. * @param y defines y coordinate
  27056. * @param z defines z coordinate
  27057. * @returns the face index if found (or null instead)
  27058. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27059. */
  27060. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  27061. /**
  27062. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  27063. * @param projected sets as the (x,y,z) local projection on the facet
  27064. * @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
  27065. * @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
  27066. * @param x defines x coordinate
  27067. * @param y defines y coordinate
  27068. * @param z defines z coordinate
  27069. * @returns the face index if found (or null instead)
  27070. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27071. */
  27072. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  27073. /**
  27074. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  27075. * @returns the parameters
  27076. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27077. */
  27078. getFacetDataParameters(): any;
  27079. /**
  27080. * Disables the feature FacetData and frees the related memory
  27081. * @returns the current mesh
  27082. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27083. */
  27084. disableFacetData(): AbstractMesh;
  27085. /**
  27086. * Updates the AbstractMesh indices array
  27087. * @param indices defines the data source
  27088. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  27089. * @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)
  27090. * @returns the current mesh
  27091. */
  27092. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  27093. /**
  27094. * Creates new normals data for the mesh
  27095. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  27096. * @returns the current mesh
  27097. */
  27098. createNormals(updatable: boolean): AbstractMesh;
  27099. /**
  27100. * Align the mesh with a normal
  27101. * @param normal defines the normal to use
  27102. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  27103. * @returns the current mesh
  27104. */
  27105. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  27106. /** @hidden */
  27107. _checkOcclusionQuery(): boolean;
  27108. /**
  27109. * Disables the mesh edge rendering mode
  27110. * @returns the currentAbstractMesh
  27111. */
  27112. disableEdgesRendering(): AbstractMesh;
  27113. /**
  27114. * Enables the edge rendering mode on the mesh.
  27115. * This mode makes the mesh edges visible
  27116. * @param epsilon defines the maximal distance between two angles to detect a face
  27117. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  27118. * @returns the currentAbstractMesh
  27119. * @see https://www.babylonjs-playground.com/#19O9TU#0
  27120. */
  27121. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  27122. }
  27123. }
  27124. declare module "babylonjs/Actions/actionEvent" {
  27125. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  27126. import { Nullable } from "babylonjs/types";
  27127. import { Sprite } from "babylonjs/Sprites/sprite";
  27128. import { Scene } from "babylonjs/scene";
  27129. import { Vector2 } from "babylonjs/Maths/math.vector";
  27130. /**
  27131. * Interface used to define ActionEvent
  27132. */
  27133. export interface IActionEvent {
  27134. /** The mesh or sprite that triggered the action */
  27135. source: any;
  27136. /** The X mouse cursor position at the time of the event */
  27137. pointerX: number;
  27138. /** The Y mouse cursor position at the time of the event */
  27139. pointerY: number;
  27140. /** The mesh that is currently pointed at (can be null) */
  27141. meshUnderPointer: Nullable<AbstractMesh>;
  27142. /** the original (browser) event that triggered the ActionEvent */
  27143. sourceEvent?: any;
  27144. /** additional data for the event */
  27145. additionalData?: any;
  27146. }
  27147. /**
  27148. * ActionEvent is the event being sent when an action is triggered.
  27149. */
  27150. export class ActionEvent implements IActionEvent {
  27151. /** The mesh or sprite that triggered the action */
  27152. source: any;
  27153. /** The X mouse cursor position at the time of the event */
  27154. pointerX: number;
  27155. /** The Y mouse cursor position at the time of the event */
  27156. pointerY: number;
  27157. /** The mesh that is currently pointed at (can be null) */
  27158. meshUnderPointer: Nullable<AbstractMesh>;
  27159. /** the original (browser) event that triggered the ActionEvent */
  27160. sourceEvent?: any;
  27161. /** additional data for the event */
  27162. additionalData?: any;
  27163. /**
  27164. * Creates a new ActionEvent
  27165. * @param source The mesh or sprite that triggered the action
  27166. * @param pointerX The X mouse cursor position at the time of the event
  27167. * @param pointerY The Y mouse cursor position at the time of the event
  27168. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  27169. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  27170. * @param additionalData additional data for the event
  27171. */
  27172. constructor(
  27173. /** The mesh or sprite that triggered the action */
  27174. source: any,
  27175. /** The X mouse cursor position at the time of the event */
  27176. pointerX: number,
  27177. /** The Y mouse cursor position at the time of the event */
  27178. pointerY: number,
  27179. /** The mesh that is currently pointed at (can be null) */
  27180. meshUnderPointer: Nullable<AbstractMesh>,
  27181. /** the original (browser) event that triggered the ActionEvent */
  27182. sourceEvent?: any,
  27183. /** additional data for the event */
  27184. additionalData?: any);
  27185. /**
  27186. * Helper function to auto-create an ActionEvent from a source mesh.
  27187. * @param source The source mesh that triggered the event
  27188. * @param evt The original (browser) event
  27189. * @param additionalData additional data for the event
  27190. * @returns the new ActionEvent
  27191. */
  27192. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  27193. /**
  27194. * Helper function to auto-create an ActionEvent from a source sprite
  27195. * @param source The source sprite that triggered the event
  27196. * @param scene Scene associated with the sprite
  27197. * @param evt The original (browser) event
  27198. * @param additionalData additional data for the event
  27199. * @returns the new ActionEvent
  27200. */
  27201. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  27202. /**
  27203. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  27204. * @param scene the scene where the event occurred
  27205. * @param evt The original (browser) event
  27206. * @returns the new ActionEvent
  27207. */
  27208. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  27209. /**
  27210. * Helper function to auto-create an ActionEvent from a primitive
  27211. * @param prim defines the target primitive
  27212. * @param pointerPos defines the pointer position
  27213. * @param evt The original (browser) event
  27214. * @param additionalData additional data for the event
  27215. * @returns the new ActionEvent
  27216. */
  27217. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  27218. }
  27219. }
  27220. declare module "babylonjs/Actions/abstractActionManager" {
  27221. import { IDisposable } from "babylonjs/scene";
  27222. import { IActionEvent } from "babylonjs/Actions/actionEvent";
  27223. import { IAction } from "babylonjs/Actions/action";
  27224. import { Nullable } from "babylonjs/types";
  27225. /**
  27226. * Abstract class used to decouple action Manager from scene and meshes.
  27227. * Do not instantiate.
  27228. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  27229. */
  27230. export abstract class AbstractActionManager implements IDisposable {
  27231. /** Gets the list of active triggers */
  27232. static Triggers: {
  27233. [key: string]: number;
  27234. };
  27235. /** Gets the cursor to use when hovering items */
  27236. hoverCursor: string;
  27237. /** Gets the list of actions */
  27238. actions: IAction[];
  27239. /**
  27240. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  27241. */
  27242. isRecursive: boolean;
  27243. /**
  27244. * Releases all associated resources
  27245. */
  27246. abstract dispose(): void;
  27247. /**
  27248. * Does this action manager has pointer triggers
  27249. */
  27250. abstract readonly hasPointerTriggers: boolean;
  27251. /**
  27252. * Does this action manager has pick triggers
  27253. */
  27254. abstract readonly hasPickTriggers: boolean;
  27255. /**
  27256. * Process a specific trigger
  27257. * @param trigger defines the trigger to process
  27258. * @param evt defines the event details to be processed
  27259. */
  27260. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  27261. /**
  27262. * Does this action manager handles actions of any of the given triggers
  27263. * @param triggers defines the triggers to be tested
  27264. * @return a boolean indicating whether one (or more) of the triggers is handled
  27265. */
  27266. abstract hasSpecificTriggers(triggers: number[]): boolean;
  27267. /**
  27268. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  27269. * speed.
  27270. * @param triggerA defines the trigger to be tested
  27271. * @param triggerB defines the trigger to be tested
  27272. * @return a boolean indicating whether one (or more) of the triggers is handled
  27273. */
  27274. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  27275. /**
  27276. * Does this action manager handles actions of a given trigger
  27277. * @param trigger defines the trigger to be tested
  27278. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  27279. * @return whether the trigger is handled
  27280. */
  27281. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  27282. /**
  27283. * Serialize this manager to a JSON object
  27284. * @param name defines the property name to store this manager
  27285. * @returns a JSON representation of this manager
  27286. */
  27287. abstract serialize(name: string): any;
  27288. /**
  27289. * Registers an action to this action manager
  27290. * @param action defines the action to be registered
  27291. * @return the action amended (prepared) after registration
  27292. */
  27293. abstract registerAction(action: IAction): Nullable<IAction>;
  27294. /**
  27295. * Unregisters an action to this action manager
  27296. * @param action defines the action to be unregistered
  27297. * @return a boolean indicating whether the action has been unregistered
  27298. */
  27299. abstract unregisterAction(action: IAction): Boolean;
  27300. /**
  27301. * Does exist one action manager with at least one trigger
  27302. **/
  27303. static readonly HasTriggers: boolean;
  27304. /**
  27305. * Does exist one action manager with at least one pick trigger
  27306. **/
  27307. static readonly HasPickTriggers: boolean;
  27308. /**
  27309. * Does exist one action manager that handles actions of a given trigger
  27310. * @param trigger defines the trigger to be tested
  27311. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  27312. **/
  27313. static HasSpecificTrigger(trigger: number): boolean;
  27314. }
  27315. }
  27316. declare module "babylonjs/node" {
  27317. import { Scene } from "babylonjs/scene";
  27318. import { Nullable } from "babylonjs/types";
  27319. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  27320. import { Engine } from "babylonjs/Engines/engine";
  27321. import { IBehaviorAware, Behavior } from "babylonjs/Behaviors/behavior";
  27322. import { Observable } from "babylonjs/Misc/observable";
  27323. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  27324. import { IInspectable } from "babylonjs/Misc/iInspectable";
  27325. import { Animatable } from "babylonjs/Animations/animatable";
  27326. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  27327. import { Animation } from "babylonjs/Animations/animation";
  27328. import { AnimationRange } from "babylonjs/Animations/animationRange";
  27329. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  27330. /**
  27331. * Defines how a node can be built from a string name.
  27332. */
  27333. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  27334. /**
  27335. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  27336. */
  27337. export class Node implements IBehaviorAware<Node> {
  27338. /** @hidden */
  27339. static _AnimationRangeFactory: (name: string, from: number, to: number) => import("babylonjs/Animations/animationRange").AnimationRange;
  27340. private static _NodeConstructors;
  27341. /**
  27342. * Add a new node constructor
  27343. * @param type defines the type name of the node to construct
  27344. * @param constructorFunc defines the constructor function
  27345. */
  27346. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  27347. /**
  27348. * Returns a node constructor based on type name
  27349. * @param type defines the type name
  27350. * @param name defines the new node name
  27351. * @param scene defines the hosting scene
  27352. * @param options defines optional options to transmit to constructors
  27353. * @returns the new constructor or null
  27354. */
  27355. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  27356. /**
  27357. * Gets or sets the name of the node
  27358. */
  27359. name: string;
  27360. /**
  27361. * Gets or sets the id of the node
  27362. */
  27363. id: string;
  27364. /**
  27365. * Gets or sets the unique id of the node
  27366. */
  27367. uniqueId: number;
  27368. /**
  27369. * Gets or sets a string used to store user defined state for the node
  27370. */
  27371. state: string;
  27372. /**
  27373. * Gets or sets an object used to store user defined information for the node
  27374. */
  27375. metadata: any;
  27376. /**
  27377. * For internal use only. Please do not use.
  27378. */
  27379. reservedDataStore: any;
  27380. /**
  27381. * List of inspectable custom properties (used by the Inspector)
  27382. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  27383. */
  27384. inspectableCustomProperties: IInspectable[];
  27385. /**
  27386. * Gets or sets a boolean used to define if the node must be serialized
  27387. */
  27388. doNotSerialize: boolean;
  27389. /** @hidden */
  27390. _isDisposed: boolean;
  27391. /**
  27392. * Gets a list of Animations associated with the node
  27393. */
  27394. animations: import("babylonjs/Animations/animation").Animation[];
  27395. protected _ranges: {
  27396. [name: string]: Nullable<AnimationRange>;
  27397. };
  27398. /**
  27399. * Callback raised when the node is ready to be used
  27400. */
  27401. onReady: Nullable<(node: Node) => void>;
  27402. private _isEnabled;
  27403. private _isParentEnabled;
  27404. private _isReady;
  27405. /** @hidden */
  27406. _currentRenderId: number;
  27407. private _parentUpdateId;
  27408. /** @hidden */
  27409. _childUpdateId: number;
  27410. /** @hidden */
  27411. _waitingParentId: Nullable<string>;
  27412. /** @hidden */
  27413. _scene: Scene;
  27414. /** @hidden */
  27415. _cache: any;
  27416. private _parentNode;
  27417. private _children;
  27418. /** @hidden */
  27419. _worldMatrix: Matrix;
  27420. /** @hidden */
  27421. _worldMatrixDeterminant: number;
  27422. /** @hidden */
  27423. _worldMatrixDeterminantIsDirty: boolean;
  27424. /** @hidden */
  27425. private _sceneRootNodesIndex;
  27426. /**
  27427. * Gets a boolean indicating if the node has been disposed
  27428. * @returns true if the node was disposed
  27429. */
  27430. isDisposed(): boolean;
  27431. /**
  27432. * Gets or sets the parent of the node (without keeping the current position in the scene)
  27433. * @see https://doc.babylonjs.com/how_to/parenting
  27434. */
  27435. parent: Nullable<Node>;
  27436. private addToSceneRootNodes;
  27437. private removeFromSceneRootNodes;
  27438. private _animationPropertiesOverride;
  27439. /**
  27440. * Gets or sets the animation properties override
  27441. */
  27442. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  27443. /**
  27444. * Gets a string idenfifying the name of the class
  27445. * @returns "Node" string
  27446. */
  27447. getClassName(): string;
  27448. /** @hidden */
  27449. readonly _isNode: boolean;
  27450. /**
  27451. * An event triggered when the mesh is disposed
  27452. */
  27453. onDisposeObservable: Observable<Node>;
  27454. private _onDisposeObserver;
  27455. /**
  27456. * Sets a callback that will be raised when the node will be disposed
  27457. */
  27458. onDispose: () => void;
  27459. /**
  27460. * Creates a new Node
  27461. * @param name the name and id to be given to this node
  27462. * @param scene the scene this node will be added to
  27463. * @param addToRootNodes the node will be added to scene.rootNodes
  27464. */
  27465. constructor(name: string, scene?: Nullable<Scene>, addToRootNodes?: boolean);
  27466. /**
  27467. * Gets the scene of the node
  27468. * @returns a scene
  27469. */
  27470. getScene(): Scene;
  27471. /**
  27472. * Gets the engine of the node
  27473. * @returns a Engine
  27474. */
  27475. getEngine(): Engine;
  27476. private _behaviors;
  27477. /**
  27478. * Attach a behavior to the node
  27479. * @see http://doc.babylonjs.com/features/behaviour
  27480. * @param behavior defines the behavior to attach
  27481. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  27482. * @returns the current Node
  27483. */
  27484. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  27485. /**
  27486. * Remove an attached behavior
  27487. * @see http://doc.babylonjs.com/features/behaviour
  27488. * @param behavior defines the behavior to attach
  27489. * @returns the current Node
  27490. */
  27491. removeBehavior(behavior: Behavior<Node>): Node;
  27492. /**
  27493. * Gets the list of attached behaviors
  27494. * @see http://doc.babylonjs.com/features/behaviour
  27495. */
  27496. readonly behaviors: Behavior<Node>[];
  27497. /**
  27498. * Gets an attached behavior by name
  27499. * @param name defines the name of the behavior to look for
  27500. * @see http://doc.babylonjs.com/features/behaviour
  27501. * @returns null if behavior was not found else the requested behavior
  27502. */
  27503. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  27504. /**
  27505. * Returns the latest update of the World matrix
  27506. * @returns a Matrix
  27507. */
  27508. getWorldMatrix(): Matrix;
  27509. /** @hidden */
  27510. _getWorldMatrixDeterminant(): number;
  27511. /**
  27512. * Returns directly the latest state of the mesh World matrix.
  27513. * A Matrix is returned.
  27514. */
  27515. readonly worldMatrixFromCache: Matrix;
  27516. /** @hidden */
  27517. _initCache(): void;
  27518. /** @hidden */
  27519. updateCache(force?: boolean): void;
  27520. /** @hidden */
  27521. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  27522. /** @hidden */
  27523. _updateCache(ignoreParentClass?: boolean): void;
  27524. /** @hidden */
  27525. _isSynchronized(): boolean;
  27526. /** @hidden */
  27527. _markSyncedWithParent(): void;
  27528. /** @hidden */
  27529. isSynchronizedWithParent(): boolean;
  27530. /** @hidden */
  27531. isSynchronized(): boolean;
  27532. /**
  27533. * Is this node ready to be used/rendered
  27534. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  27535. * @return true if the node is ready
  27536. */
  27537. isReady(completeCheck?: boolean): boolean;
  27538. /**
  27539. * Is this node enabled?
  27540. * 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
  27541. * @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
  27542. * @return whether this node (and its parent) is enabled
  27543. */
  27544. isEnabled(checkAncestors?: boolean): boolean;
  27545. /** @hidden */
  27546. protected _syncParentEnabledState(): void;
  27547. /**
  27548. * Set the enabled state of this node
  27549. * @param value defines the new enabled state
  27550. */
  27551. setEnabled(value: boolean): void;
  27552. /**
  27553. * Is this node a descendant of the given node?
  27554. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  27555. * @param ancestor defines the parent node to inspect
  27556. * @returns a boolean indicating if this node is a descendant of the given node
  27557. */
  27558. isDescendantOf(ancestor: Node): boolean;
  27559. /** @hidden */
  27560. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  27561. /**
  27562. * Will return all nodes that have this node as ascendant
  27563. * @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
  27564. * @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
  27565. * @return all children nodes of all types
  27566. */
  27567. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  27568. /**
  27569. * Get all child-meshes of this node
  27570. * @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)
  27571. * @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
  27572. * @returns an array of AbstractMesh
  27573. */
  27574. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  27575. /**
  27576. * Get all direct children of this node
  27577. * @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
  27578. * @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)
  27579. * @returns an array of Node
  27580. */
  27581. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  27582. /** @hidden */
  27583. _setReady(state: boolean): void;
  27584. /**
  27585. * Get an animation by name
  27586. * @param name defines the name of the animation to look for
  27587. * @returns null if not found else the requested animation
  27588. */
  27589. getAnimationByName(name: string): Nullable<Animation>;
  27590. /**
  27591. * Creates an animation range for this node
  27592. * @param name defines the name of the range
  27593. * @param from defines the starting key
  27594. * @param to defines the end key
  27595. */
  27596. createAnimationRange(name: string, from: number, to: number): void;
  27597. /**
  27598. * Delete a specific animation range
  27599. * @param name defines the name of the range to delete
  27600. * @param deleteFrames defines if animation frames from the range must be deleted as well
  27601. */
  27602. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  27603. /**
  27604. * Get an animation range by name
  27605. * @param name defines the name of the animation range to look for
  27606. * @returns null if not found else the requested animation range
  27607. */
  27608. getAnimationRange(name: string): Nullable<AnimationRange>;
  27609. /**
  27610. * Gets the list of all animation ranges defined on this node
  27611. * @returns an array
  27612. */
  27613. getAnimationRanges(): Nullable<AnimationRange>[];
  27614. /**
  27615. * Will start the animation sequence
  27616. * @param name defines the range frames for animation sequence
  27617. * @param loop defines if the animation should loop (false by default)
  27618. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  27619. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  27620. * @returns the object created for this animation. If range does not exist, it will return null
  27621. */
  27622. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  27623. /**
  27624. * Serialize animation ranges into a JSON compatible object
  27625. * @returns serialization object
  27626. */
  27627. serializeAnimationRanges(): any;
  27628. /**
  27629. * Computes the world matrix of the node
  27630. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  27631. * @returns the world matrix
  27632. */
  27633. computeWorldMatrix(force?: boolean): Matrix;
  27634. /**
  27635. * Releases resources associated with this node.
  27636. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  27637. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  27638. */
  27639. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  27640. /**
  27641. * Parse animation range data from a serialization object and store them into a given node
  27642. * @param node defines where to store the animation ranges
  27643. * @param parsedNode defines the serialization object to read data from
  27644. * @param scene defines the hosting scene
  27645. */
  27646. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  27647. /**
  27648. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  27649. * @param includeDescendants Include bounding info from descendants as well (true by default)
  27650. * @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
  27651. * @returns the new bounding vectors
  27652. */
  27653. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  27654. min: Vector3;
  27655. max: Vector3;
  27656. };
  27657. }
  27658. }
  27659. declare module "babylonjs/Animations/animation" {
  27660. import { IEasingFunction, EasingFunction } from "babylonjs/Animations/easing";
  27661. import { Vector3, Quaternion, Vector2, Matrix } from "babylonjs/Maths/math.vector";
  27662. import { Color3 } from "babylonjs/Maths/math.color";
  27663. import { Nullable } from "babylonjs/types";
  27664. import { Scene } from "babylonjs/scene";
  27665. import { IAnimationKey } from "babylonjs/Animations/animationKey";
  27666. import { AnimationRange } from "babylonjs/Animations/animationRange";
  27667. import { AnimationEvent } from "babylonjs/Animations/animationEvent";
  27668. import { Node } from "babylonjs/node";
  27669. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  27670. import { Size } from "babylonjs/Maths/math.size";
  27671. import { Animatable } from "babylonjs/Animations/animatable";
  27672. import { RuntimeAnimation } from "babylonjs/Animations/runtimeAnimation";
  27673. /**
  27674. * @hidden
  27675. */
  27676. export class _IAnimationState {
  27677. key: number;
  27678. repeatCount: number;
  27679. workValue?: any;
  27680. loopMode?: number;
  27681. offsetValue?: any;
  27682. highLimitValue?: any;
  27683. }
  27684. /**
  27685. * Class used to store any kind of animation
  27686. */
  27687. export class Animation {
  27688. /**Name of the animation */
  27689. name: string;
  27690. /**Property to animate */
  27691. targetProperty: string;
  27692. /**The frames per second of the animation */
  27693. framePerSecond: number;
  27694. /**The data type of the animation */
  27695. dataType: number;
  27696. /**The loop mode of the animation */
  27697. loopMode?: number | undefined;
  27698. /**Specifies if blending should be enabled */
  27699. enableBlending?: boolean | undefined;
  27700. /**
  27701. * Use matrix interpolation instead of using direct key value when animating matrices
  27702. */
  27703. static AllowMatricesInterpolation: boolean;
  27704. /**
  27705. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  27706. */
  27707. static AllowMatrixDecomposeForInterpolation: boolean;
  27708. /**
  27709. * Stores the key frames of the animation
  27710. */
  27711. private _keys;
  27712. /**
  27713. * Stores the easing function of the animation
  27714. */
  27715. private _easingFunction;
  27716. /**
  27717. * @hidden Internal use only
  27718. */
  27719. _runtimeAnimations: import("babylonjs/Animations/runtimeAnimation").RuntimeAnimation[];
  27720. /**
  27721. * The set of event that will be linked to this animation
  27722. */
  27723. private _events;
  27724. /**
  27725. * Stores an array of target property paths
  27726. */
  27727. targetPropertyPath: string[];
  27728. /**
  27729. * Stores the blending speed of the animation
  27730. */
  27731. blendingSpeed: number;
  27732. /**
  27733. * Stores the animation ranges for the animation
  27734. */
  27735. private _ranges;
  27736. /**
  27737. * @hidden Internal use
  27738. */
  27739. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  27740. /**
  27741. * Sets up an animation
  27742. * @param property The property to animate
  27743. * @param animationType The animation type to apply
  27744. * @param framePerSecond The frames per second of the animation
  27745. * @param easingFunction The easing function used in the animation
  27746. * @returns The created animation
  27747. */
  27748. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  27749. /**
  27750. * Create and start an animation on a node
  27751. * @param name defines the name of the global animation that will be run on all nodes
  27752. * @param node defines the root node where the animation will take place
  27753. * @param targetProperty defines property to animate
  27754. * @param framePerSecond defines the number of frame per second yo use
  27755. * @param totalFrame defines the number of frames in total
  27756. * @param from defines the initial value
  27757. * @param to defines the final value
  27758. * @param loopMode defines which loop mode you want to use (off by default)
  27759. * @param easingFunction defines the easing function to use (linear by default)
  27760. * @param onAnimationEnd defines the callback to call when animation end
  27761. * @returns the animatable created for this animation
  27762. */
  27763. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  27764. /**
  27765. * Create and start an animation on a node and its descendants
  27766. * @param name defines the name of the global animation that will be run on all nodes
  27767. * @param node defines the root node where the animation will take place
  27768. * @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
  27769. * @param targetProperty defines property to animate
  27770. * @param framePerSecond defines the number of frame per second to use
  27771. * @param totalFrame defines the number of frames in total
  27772. * @param from defines the initial value
  27773. * @param to defines the final value
  27774. * @param loopMode defines which loop mode you want to use (off by default)
  27775. * @param easingFunction defines the easing function to use (linear by default)
  27776. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  27777. * @returns the list of animatables created for all nodes
  27778. * @example https://www.babylonjs-playground.com/#MH0VLI
  27779. */
  27780. 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[]>;
  27781. /**
  27782. * Creates a new animation, merges it with the existing animations and starts it
  27783. * @param name Name of the animation
  27784. * @param node Node which contains the scene that begins the animations
  27785. * @param targetProperty Specifies which property to animate
  27786. * @param framePerSecond The frames per second of the animation
  27787. * @param totalFrame The total number of frames
  27788. * @param from The frame at the beginning of the animation
  27789. * @param to The frame at the end of the animation
  27790. * @param loopMode Specifies the loop mode of the animation
  27791. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  27792. * @param onAnimationEnd Callback to run once the animation is complete
  27793. * @returns Nullable animation
  27794. */
  27795. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  27796. /**
  27797. * Transition property of an host to the target Value
  27798. * @param property The property to transition
  27799. * @param targetValue The target Value of the property
  27800. * @param host The object where the property to animate belongs
  27801. * @param scene Scene used to run the animation
  27802. * @param frameRate Framerate (in frame/s) to use
  27803. * @param transition The transition type we want to use
  27804. * @param duration The duration of the animation, in milliseconds
  27805. * @param onAnimationEnd Callback trigger at the end of the animation
  27806. * @returns Nullable animation
  27807. */
  27808. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  27809. /**
  27810. * Return the array of runtime animations currently using this animation
  27811. */
  27812. readonly runtimeAnimations: RuntimeAnimation[];
  27813. /**
  27814. * Specifies if any of the runtime animations are currently running
  27815. */
  27816. readonly hasRunningRuntimeAnimations: boolean;
  27817. /**
  27818. * Initializes the animation
  27819. * @param name Name of the animation
  27820. * @param targetProperty Property to animate
  27821. * @param framePerSecond The frames per second of the animation
  27822. * @param dataType The data type of the animation
  27823. * @param loopMode The loop mode of the animation
  27824. * @param enableBlending Specifies if blending should be enabled
  27825. */
  27826. constructor(
  27827. /**Name of the animation */
  27828. name: string,
  27829. /**Property to animate */
  27830. targetProperty: string,
  27831. /**The frames per second of the animation */
  27832. framePerSecond: number,
  27833. /**The data type of the animation */
  27834. dataType: number,
  27835. /**The loop mode of the animation */
  27836. loopMode?: number | undefined,
  27837. /**Specifies if blending should be enabled */
  27838. enableBlending?: boolean | undefined);
  27839. /**
  27840. * Converts the animation to a string
  27841. * @param fullDetails support for multiple levels of logging within scene loading
  27842. * @returns String form of the animation
  27843. */
  27844. toString(fullDetails?: boolean): string;
  27845. /**
  27846. * Add an event to this animation
  27847. * @param event Event to add
  27848. */
  27849. addEvent(event: AnimationEvent): void;
  27850. /**
  27851. * Remove all events found at the given frame
  27852. * @param frame The frame to remove events from
  27853. */
  27854. removeEvents(frame: number): void;
  27855. /**
  27856. * Retrieves all the events from the animation
  27857. * @returns Events from the animation
  27858. */
  27859. getEvents(): AnimationEvent[];
  27860. /**
  27861. * Creates an animation range
  27862. * @param name Name of the animation range
  27863. * @param from Starting frame of the animation range
  27864. * @param to Ending frame of the animation
  27865. */
  27866. createRange(name: string, from: number, to: number): void;
  27867. /**
  27868. * Deletes an animation range by name
  27869. * @param name Name of the animation range to delete
  27870. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  27871. */
  27872. deleteRange(name: string, deleteFrames?: boolean): void;
  27873. /**
  27874. * Gets the animation range by name, or null if not defined
  27875. * @param name Name of the animation range
  27876. * @returns Nullable animation range
  27877. */
  27878. getRange(name: string): Nullable<AnimationRange>;
  27879. /**
  27880. * Gets the key frames from the animation
  27881. * @returns The key frames of the animation
  27882. */
  27883. getKeys(): Array<IAnimationKey>;
  27884. /**
  27885. * Gets the highest frame rate of the animation
  27886. * @returns Highest frame rate of the animation
  27887. */
  27888. getHighestFrame(): number;
  27889. /**
  27890. * Gets the easing function of the animation
  27891. * @returns Easing function of the animation
  27892. */
  27893. getEasingFunction(): IEasingFunction;
  27894. /**
  27895. * Sets the easing function of the animation
  27896. * @param easingFunction A custom mathematical formula for animation
  27897. */
  27898. setEasingFunction(easingFunction: EasingFunction): void;
  27899. /**
  27900. * Interpolates a scalar linearly
  27901. * @param startValue Start value of the animation curve
  27902. * @param endValue End value of the animation curve
  27903. * @param gradient Scalar amount to interpolate
  27904. * @returns Interpolated scalar value
  27905. */
  27906. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  27907. /**
  27908. * Interpolates a scalar cubically
  27909. * @param startValue Start value of the animation curve
  27910. * @param outTangent End tangent of the animation
  27911. * @param endValue End value of the animation curve
  27912. * @param inTangent Start tangent of the animation curve
  27913. * @param gradient Scalar amount to interpolate
  27914. * @returns Interpolated scalar value
  27915. */
  27916. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  27917. /**
  27918. * Interpolates a quaternion using a spherical linear interpolation
  27919. * @param startValue Start value of the animation curve
  27920. * @param endValue End value of the animation curve
  27921. * @param gradient Scalar amount to interpolate
  27922. * @returns Interpolated quaternion value
  27923. */
  27924. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  27925. /**
  27926. * Interpolates a quaternion cubically
  27927. * @param startValue Start value of the animation curve
  27928. * @param outTangent End tangent of the animation curve
  27929. * @param endValue End value of the animation curve
  27930. * @param inTangent Start tangent of the animation curve
  27931. * @param gradient Scalar amount to interpolate
  27932. * @returns Interpolated quaternion value
  27933. */
  27934. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  27935. /**
  27936. * Interpolates a Vector3 linearl
  27937. * @param startValue Start value of the animation curve
  27938. * @param endValue End value of the animation curve
  27939. * @param gradient Scalar amount to interpolate
  27940. * @returns Interpolated scalar value
  27941. */
  27942. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  27943. /**
  27944. * Interpolates a Vector3 cubically
  27945. * @param startValue Start value of the animation curve
  27946. * @param outTangent End tangent of the animation
  27947. * @param endValue End value of the animation curve
  27948. * @param inTangent Start tangent of the animation curve
  27949. * @param gradient Scalar amount to interpolate
  27950. * @returns InterpolatedVector3 value
  27951. */
  27952. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  27953. /**
  27954. * Interpolates a Vector2 linearly
  27955. * @param startValue Start value of the animation curve
  27956. * @param endValue End value of the animation curve
  27957. * @param gradient Scalar amount to interpolate
  27958. * @returns Interpolated Vector2 value
  27959. */
  27960. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  27961. /**
  27962. * Interpolates a Vector2 cubically
  27963. * @param startValue Start value of the animation curve
  27964. * @param outTangent End tangent of the animation
  27965. * @param endValue End value of the animation curve
  27966. * @param inTangent Start tangent of the animation curve
  27967. * @param gradient Scalar amount to interpolate
  27968. * @returns Interpolated Vector2 value
  27969. */
  27970. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  27971. /**
  27972. * Interpolates a size linearly
  27973. * @param startValue Start value of the animation curve
  27974. * @param endValue End value of the animation curve
  27975. * @param gradient Scalar amount to interpolate
  27976. * @returns Interpolated Size value
  27977. */
  27978. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  27979. /**
  27980. * Interpolates a Color3 linearly
  27981. * @param startValue Start value of the animation curve
  27982. * @param endValue End value of the animation curve
  27983. * @param gradient Scalar amount to interpolate
  27984. * @returns Interpolated Color3 value
  27985. */
  27986. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  27987. /**
  27988. * @hidden Internal use only
  27989. */
  27990. _getKeyValue(value: any): any;
  27991. /**
  27992. * @hidden Internal use only
  27993. */
  27994. _interpolate(currentFrame: number, state: _IAnimationState): any;
  27995. /**
  27996. * Defines the function to use to interpolate matrices
  27997. * @param startValue defines the start matrix
  27998. * @param endValue defines the end matrix
  27999. * @param gradient defines the gradient between both matrices
  28000. * @param result defines an optional target matrix where to store the interpolation
  28001. * @returns the interpolated matrix
  28002. */
  28003. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  28004. /**
  28005. * Makes a copy of the animation
  28006. * @returns Cloned animation
  28007. */
  28008. clone(): Animation;
  28009. /**
  28010. * Sets the key frames of the animation
  28011. * @param values The animation key frames to set
  28012. */
  28013. setKeys(values: Array<IAnimationKey>): void;
  28014. /**
  28015. * Serializes the animation to an object
  28016. * @returns Serialized object
  28017. */
  28018. serialize(): any;
  28019. /**
  28020. * Float animation type
  28021. */
  28022. private static _ANIMATIONTYPE_FLOAT;
  28023. /**
  28024. * Vector3 animation type
  28025. */
  28026. private static _ANIMATIONTYPE_VECTOR3;
  28027. /**
  28028. * Quaternion animation type
  28029. */
  28030. private static _ANIMATIONTYPE_QUATERNION;
  28031. /**
  28032. * Matrix animation type
  28033. */
  28034. private static _ANIMATIONTYPE_MATRIX;
  28035. /**
  28036. * Color3 animation type
  28037. */
  28038. private static _ANIMATIONTYPE_COLOR3;
  28039. /**
  28040. * Vector2 animation type
  28041. */
  28042. private static _ANIMATIONTYPE_VECTOR2;
  28043. /**
  28044. * Size animation type
  28045. */
  28046. private static _ANIMATIONTYPE_SIZE;
  28047. /**
  28048. * Relative Loop Mode
  28049. */
  28050. private static _ANIMATIONLOOPMODE_RELATIVE;
  28051. /**
  28052. * Cycle Loop Mode
  28053. */
  28054. private static _ANIMATIONLOOPMODE_CYCLE;
  28055. /**
  28056. * Constant Loop Mode
  28057. */
  28058. private static _ANIMATIONLOOPMODE_CONSTANT;
  28059. /**
  28060. * Get the float animation type
  28061. */
  28062. static readonly ANIMATIONTYPE_FLOAT: number;
  28063. /**
  28064. * Get the Vector3 animation type
  28065. */
  28066. static readonly ANIMATIONTYPE_VECTOR3: number;
  28067. /**
  28068. * Get the Vector2 animation type
  28069. */
  28070. static readonly ANIMATIONTYPE_VECTOR2: number;
  28071. /**
  28072. * Get the Size animation type
  28073. */
  28074. static readonly ANIMATIONTYPE_SIZE: number;
  28075. /**
  28076. * Get the Quaternion animation type
  28077. */
  28078. static readonly ANIMATIONTYPE_QUATERNION: number;
  28079. /**
  28080. * Get the Matrix animation type
  28081. */
  28082. static readonly ANIMATIONTYPE_MATRIX: number;
  28083. /**
  28084. * Get the Color3 animation type
  28085. */
  28086. static readonly ANIMATIONTYPE_COLOR3: number;
  28087. /**
  28088. * Get the Relative Loop Mode
  28089. */
  28090. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  28091. /**
  28092. * Get the Cycle Loop Mode
  28093. */
  28094. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  28095. /**
  28096. * Get the Constant Loop Mode
  28097. */
  28098. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  28099. /** @hidden */
  28100. static _UniversalLerp(left: any, right: any, amount: number): any;
  28101. /**
  28102. * Parses an animation object and creates an animation
  28103. * @param parsedAnimation Parsed animation object
  28104. * @returns Animation object
  28105. */
  28106. static Parse(parsedAnimation: any): Animation;
  28107. /**
  28108. * Appends the serialized animations from the source animations
  28109. * @param source Source containing the animations
  28110. * @param destination Target to store the animations
  28111. */
  28112. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  28113. }
  28114. }
  28115. declare module "babylonjs/Animations/animatable.interface" {
  28116. import { Nullable } from "babylonjs/types";
  28117. import { Animation } from "babylonjs/Animations/animation";
  28118. /**
  28119. * Interface containing an array of animations
  28120. */
  28121. export interface IAnimatable {
  28122. /**
  28123. * Array of animations
  28124. */
  28125. animations: Nullable<Array<Animation>>;
  28126. }
  28127. }
  28128. declare module "babylonjs/Materials/fresnelParameters" {
  28129. import { Color3 } from "babylonjs/Maths/math.color";
  28130. /**
  28131. * This represents all the required information to add a fresnel effect on a material:
  28132. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  28133. */
  28134. export class FresnelParameters {
  28135. private _isEnabled;
  28136. /**
  28137. * Define if the fresnel effect is enable or not.
  28138. */
  28139. isEnabled: boolean;
  28140. /**
  28141. * Define the color used on edges (grazing angle)
  28142. */
  28143. leftColor: Color3;
  28144. /**
  28145. * Define the color used on center
  28146. */
  28147. rightColor: Color3;
  28148. /**
  28149. * Define bias applied to computed fresnel term
  28150. */
  28151. bias: number;
  28152. /**
  28153. * Defined the power exponent applied to fresnel term
  28154. */
  28155. power: number;
  28156. /**
  28157. * Clones the current fresnel and its valuues
  28158. * @returns a clone fresnel configuration
  28159. */
  28160. clone(): FresnelParameters;
  28161. /**
  28162. * Serializes the current fresnel parameters to a JSON representation.
  28163. * @return the JSON serialization
  28164. */
  28165. serialize(): any;
  28166. /**
  28167. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  28168. * @param parsedFresnelParameters Define the JSON representation
  28169. * @returns the parsed parameters
  28170. */
  28171. static Parse(parsedFresnelParameters: any): FresnelParameters;
  28172. }
  28173. }
  28174. declare module "babylonjs/Misc/decorators" {
  28175. import { Nullable } from "babylonjs/types";
  28176. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  28177. import { Scene } from "babylonjs/scene";
  28178. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  28179. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28180. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28181. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28182. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28183. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28184. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28185. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28186. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28187. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28188. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28189. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28190. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28191. /**
  28192. * Decorator used to define property that can be serialized as reference to a camera
  28193. * @param sourceName defines the name of the property to decorate
  28194. */
  28195. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28196. /**
  28197. * Class used to help serialization objects
  28198. */
  28199. export class SerializationHelper {
  28200. /** @hidden */
  28201. static _ImageProcessingConfigurationParser: (sourceProperty: any) => import("babylonjs/Materials/imageProcessingConfiguration").ImageProcessingConfiguration;
  28202. /** @hidden */
  28203. static _FresnelParametersParser: (sourceProperty: any) => import("babylonjs/Materials/fresnelParameters").FresnelParameters;
  28204. /** @hidden */
  28205. static _ColorCurvesParser: (sourceProperty: any) => import("babylonjs/Materials/colorCurves").ColorCurves;
  28206. /** @hidden */
  28207. static _TextureParser: (sourceProperty: any, scene: import("babylonjs/scene").Scene, rootUrl: string) => Nullable<import("babylonjs/Materials/Textures/baseTexture").BaseTexture>;
  28208. /**
  28209. * Appends the serialized animations from the source animations
  28210. * @param source Source containing the animations
  28211. * @param destination Target to store the animations
  28212. */
  28213. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  28214. /**
  28215. * Static function used to serialized a specific entity
  28216. * @param entity defines the entity to serialize
  28217. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  28218. * @returns a JSON compatible object representing the serialization of the entity
  28219. */
  28220. static Serialize<T>(entity: T, serializationObject?: any): any;
  28221. /**
  28222. * Creates a new entity from a serialization data object
  28223. * @param creationFunction defines a function used to instanciated the new entity
  28224. * @param source defines the source serialization data
  28225. * @param scene defines the hosting scene
  28226. * @param rootUrl defines the root url for resources
  28227. * @returns a new entity
  28228. */
  28229. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  28230. /**
  28231. * Clones an object
  28232. * @param creationFunction defines the function used to instanciate the new object
  28233. * @param source defines the source object
  28234. * @returns the cloned object
  28235. */
  28236. static Clone<T>(creationFunction: () => T, source: T): T;
  28237. /**
  28238. * Instanciates a new object based on a source one (some data will be shared between both object)
  28239. * @param creationFunction defines the function used to instanciate the new object
  28240. * @param source defines the source object
  28241. * @returns the new object
  28242. */
  28243. static Instanciate<T>(creationFunction: () => T, source: T): T;
  28244. }
  28245. }
  28246. declare module "babylonjs/Misc/HighDynamicRange/panoramaToCubemap" {
  28247. import { Nullable } from "babylonjs/types";
  28248. /**
  28249. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  28250. */
  28251. export interface CubeMapInfo {
  28252. /**
  28253. * The pixel array for the front face.
  28254. * This is stored in format, left to right, up to down format.
  28255. */
  28256. front: Nullable<ArrayBufferView>;
  28257. /**
  28258. * The pixel array for the back face.
  28259. * This is stored in format, left to right, up to down format.
  28260. */
  28261. back: Nullable<ArrayBufferView>;
  28262. /**
  28263. * The pixel array for the left face.
  28264. * This is stored in format, left to right, up to down format.
  28265. */
  28266. left: Nullable<ArrayBufferView>;
  28267. /**
  28268. * The pixel array for the right face.
  28269. * This is stored in format, left to right, up to down format.
  28270. */
  28271. right: Nullable<ArrayBufferView>;
  28272. /**
  28273. * The pixel array for the up face.
  28274. * This is stored in format, left to right, up to down format.
  28275. */
  28276. up: Nullable<ArrayBufferView>;
  28277. /**
  28278. * The pixel array for the down face.
  28279. * This is stored in format, left to right, up to down format.
  28280. */
  28281. down: Nullable<ArrayBufferView>;
  28282. /**
  28283. * The size of the cubemap stored.
  28284. *
  28285. * Each faces will be size * size pixels.
  28286. */
  28287. size: number;
  28288. /**
  28289. * The format of the texture.
  28290. *
  28291. * RGBA, RGB.
  28292. */
  28293. format: number;
  28294. /**
  28295. * The type of the texture data.
  28296. *
  28297. * UNSIGNED_INT, FLOAT.
  28298. */
  28299. type: number;
  28300. /**
  28301. * Specifies whether the texture is in gamma space.
  28302. */
  28303. gammaSpace: boolean;
  28304. }
  28305. /**
  28306. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  28307. */
  28308. export class PanoramaToCubeMapTools {
  28309. private static FACE_FRONT;
  28310. private static FACE_BACK;
  28311. private static FACE_RIGHT;
  28312. private static FACE_LEFT;
  28313. private static FACE_DOWN;
  28314. private static FACE_UP;
  28315. /**
  28316. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  28317. *
  28318. * @param float32Array The source data.
  28319. * @param inputWidth The width of the input panorama.
  28320. * @param inputHeight The height of the input panorama.
  28321. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  28322. * @return The cubemap data
  28323. */
  28324. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  28325. private static CreateCubemapTexture;
  28326. private static CalcProjectionSpherical;
  28327. }
  28328. }
  28329. declare module "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial" {
  28330. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  28331. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  28332. import { Nullable } from "babylonjs/types";
  28333. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  28334. /**
  28335. * Helper class dealing with the extraction of spherical polynomial dataArray
  28336. * from a cube map.
  28337. */
  28338. export class CubeMapToSphericalPolynomialTools {
  28339. private static FileFaces;
  28340. /**
  28341. * Converts a texture to the according Spherical Polynomial data.
  28342. * This extracts the first 3 orders only as they are the only one used in the lighting.
  28343. *
  28344. * @param texture The texture to extract the information from.
  28345. * @return The Spherical Polynomial data.
  28346. */
  28347. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  28348. /**
  28349. * Converts a cubemap to the according Spherical Polynomial data.
  28350. * This extracts the first 3 orders only as they are the only one used in the lighting.
  28351. *
  28352. * @param cubeInfo The Cube map to extract the information from.
  28353. * @return The Spherical Polynomial data.
  28354. */
  28355. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  28356. }
  28357. }
  28358. declare module "babylonjs/Misc/guid" {
  28359. /**
  28360. * Class used to manipulate GUIDs
  28361. */
  28362. export class GUID {
  28363. /**
  28364. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  28365. * Be aware Math.random() could cause collisions, but:
  28366. * "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"
  28367. * @returns a pseudo random id
  28368. */
  28369. static RandomId(): string;
  28370. }
  28371. }
  28372. declare module "babylonjs/Materials/Textures/baseTexture" {
  28373. import { Observable } from "babylonjs/Misc/observable";
  28374. import { Nullable } from "babylonjs/types";
  28375. import { Scene } from "babylonjs/scene";
  28376. import { Matrix } from "babylonjs/Maths/math.vector";
  28377. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  28378. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  28379. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  28380. import { ISize } from "babylonjs/Maths/math.size";
  28381. /**
  28382. * Base class of all the textures in babylon.
  28383. * It groups all the common properties the materials, post process, lights... might need
  28384. * in order to make a correct use of the texture.
  28385. */
  28386. export class BaseTexture implements IAnimatable {
  28387. /**
  28388. * Default anisotropic filtering level for the application.
  28389. * It is set to 4 as a good tradeoff between perf and quality.
  28390. */
  28391. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  28392. /**
  28393. * Gets or sets the unique id of the texture
  28394. */
  28395. uniqueId: number;
  28396. /**
  28397. * Define the name of the texture.
  28398. */
  28399. name: string;
  28400. /**
  28401. * Gets or sets an object used to store user defined information.
  28402. */
  28403. metadata: any;
  28404. /**
  28405. * For internal use only. Please do not use.
  28406. */
  28407. reservedDataStore: any;
  28408. private _hasAlpha;
  28409. /**
  28410. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  28411. */
  28412. hasAlpha: boolean;
  28413. /**
  28414. * Defines if the alpha value should be determined via the rgb values.
  28415. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  28416. */
  28417. getAlphaFromRGB: boolean;
  28418. /**
  28419. * Intensity or strength of the texture.
  28420. * It is commonly used by materials to fine tune the intensity of the texture
  28421. */
  28422. level: number;
  28423. /**
  28424. * Define the UV chanel to use starting from 0 and defaulting to 0.
  28425. * This is part of the texture as textures usually maps to one uv set.
  28426. */
  28427. coordinatesIndex: number;
  28428. private _coordinatesMode;
  28429. /**
  28430. * How a texture is mapped.
  28431. *
  28432. * | Value | Type | Description |
  28433. * | ----- | ----------------------------------- | ----------- |
  28434. * | 0 | EXPLICIT_MODE | |
  28435. * | 1 | SPHERICAL_MODE | |
  28436. * | 2 | PLANAR_MODE | |
  28437. * | 3 | CUBIC_MODE | |
  28438. * | 4 | PROJECTION_MODE | |
  28439. * | 5 | SKYBOX_MODE | |
  28440. * | 6 | INVCUBIC_MODE | |
  28441. * | 7 | EQUIRECTANGULAR_MODE | |
  28442. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  28443. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  28444. */
  28445. coordinatesMode: number;
  28446. /**
  28447. * | Value | Type | Description |
  28448. * | ----- | ------------------ | ----------- |
  28449. * | 0 | CLAMP_ADDRESSMODE | |
  28450. * | 1 | WRAP_ADDRESSMODE | |
  28451. * | 2 | MIRROR_ADDRESSMODE | |
  28452. */
  28453. wrapU: number;
  28454. /**
  28455. * | Value | Type | Description |
  28456. * | ----- | ------------------ | ----------- |
  28457. * | 0 | CLAMP_ADDRESSMODE | |
  28458. * | 1 | WRAP_ADDRESSMODE | |
  28459. * | 2 | MIRROR_ADDRESSMODE | |
  28460. */
  28461. wrapV: number;
  28462. /**
  28463. * | Value | Type | Description |
  28464. * | ----- | ------------------ | ----------- |
  28465. * | 0 | CLAMP_ADDRESSMODE | |
  28466. * | 1 | WRAP_ADDRESSMODE | |
  28467. * | 2 | MIRROR_ADDRESSMODE | |
  28468. */
  28469. wrapR: number;
  28470. /**
  28471. * With compliant hardware and browser (supporting anisotropic filtering)
  28472. * this defines the level of anisotropic filtering in the texture.
  28473. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  28474. */
  28475. anisotropicFilteringLevel: number;
  28476. /**
  28477. * Define if the texture is a cube texture or if false a 2d texture.
  28478. */
  28479. isCube: boolean;
  28480. /**
  28481. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  28482. */
  28483. is3D: boolean;
  28484. /**
  28485. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  28486. * HDR texture are usually stored in linear space.
  28487. * This only impacts the PBR and Background materials
  28488. */
  28489. gammaSpace: boolean;
  28490. /**
  28491. * Gets whether or not the texture contains RGBD data.
  28492. */
  28493. readonly isRGBD: boolean;
  28494. /**
  28495. * Is Z inverted in the texture (useful in a cube texture).
  28496. */
  28497. invertZ: boolean;
  28498. /**
  28499. * Are mip maps generated for this texture or not.
  28500. */
  28501. readonly noMipmap: boolean;
  28502. /**
  28503. * @hidden
  28504. */
  28505. lodLevelInAlpha: boolean;
  28506. /**
  28507. * With prefiltered texture, defined the offset used during the prefiltering steps.
  28508. */
  28509. lodGenerationOffset: number;
  28510. /**
  28511. * With prefiltered texture, defined the scale used during the prefiltering steps.
  28512. */
  28513. lodGenerationScale: number;
  28514. /**
  28515. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  28516. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  28517. * average roughness values.
  28518. */
  28519. linearSpecularLOD: boolean;
  28520. /**
  28521. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  28522. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  28523. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  28524. */
  28525. irradianceTexture: Nullable<BaseTexture>;
  28526. /**
  28527. * Define if the texture is a render target.
  28528. */
  28529. isRenderTarget: boolean;
  28530. /**
  28531. * Define the unique id of the texture in the scene.
  28532. */
  28533. readonly uid: string;
  28534. /**
  28535. * Return a string representation of the texture.
  28536. * @returns the texture as a string
  28537. */
  28538. toString(): string;
  28539. /**
  28540. * Get the class name of the texture.
  28541. * @returns "BaseTexture"
  28542. */
  28543. getClassName(): string;
  28544. /**
  28545. * Define the list of animation attached to the texture.
  28546. */
  28547. animations: import("babylonjs/Animations/animation").Animation[];
  28548. /**
  28549. * An event triggered when the texture is disposed.
  28550. */
  28551. onDisposeObservable: Observable<BaseTexture>;
  28552. private _onDisposeObserver;
  28553. /**
  28554. * Callback triggered when the texture has been disposed.
  28555. * Kept for back compatibility, you can use the onDisposeObservable instead.
  28556. */
  28557. onDispose: () => void;
  28558. /**
  28559. * Define the current state of the loading sequence when in delayed load mode.
  28560. */
  28561. delayLoadState: number;
  28562. private _scene;
  28563. /** @hidden */
  28564. _texture: Nullable<InternalTexture>;
  28565. private _uid;
  28566. /**
  28567. * Define if the texture is preventinga material to render or not.
  28568. * If not and the texture is not ready, the engine will use a default black texture instead.
  28569. */
  28570. readonly isBlocking: boolean;
  28571. /**
  28572. * Instantiates a new BaseTexture.
  28573. * Base class of all the textures in babylon.
  28574. * It groups all the common properties the materials, post process, lights... might need
  28575. * in order to make a correct use of the texture.
  28576. * @param scene Define the scene the texture blongs to
  28577. */
  28578. constructor(scene: Nullable<Scene>);
  28579. /**
  28580. * Get the scene the texture belongs to.
  28581. * @returns the scene or null if undefined
  28582. */
  28583. getScene(): Nullable<Scene>;
  28584. /**
  28585. * Get the texture transform matrix used to offset tile the texture for istance.
  28586. * @returns the transformation matrix
  28587. */
  28588. getTextureMatrix(): Matrix;
  28589. /**
  28590. * Get the texture reflection matrix used to rotate/transform the reflection.
  28591. * @returns the reflection matrix
  28592. */
  28593. getReflectionTextureMatrix(): Matrix;
  28594. /**
  28595. * Get the underlying lower level texture from Babylon.
  28596. * @returns the insternal texture
  28597. */
  28598. getInternalTexture(): Nullable<InternalTexture>;
  28599. /**
  28600. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  28601. * @returns true if ready or not blocking
  28602. */
  28603. isReadyOrNotBlocking(): boolean;
  28604. /**
  28605. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  28606. * @returns true if fully ready
  28607. */
  28608. isReady(): boolean;
  28609. private _cachedSize;
  28610. /**
  28611. * Get the size of the texture.
  28612. * @returns the texture size.
  28613. */
  28614. getSize(): ISize;
  28615. /**
  28616. * Get the base size of the texture.
  28617. * It can be different from the size if the texture has been resized for POT for instance
  28618. * @returns the base size
  28619. */
  28620. getBaseSize(): ISize;
  28621. /**
  28622. * Update the sampling mode of the texture.
  28623. * Default is Trilinear mode.
  28624. *
  28625. * | Value | Type | Description |
  28626. * | ----- | ------------------ | ----------- |
  28627. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  28628. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  28629. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  28630. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  28631. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  28632. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  28633. * | 7 | NEAREST_LINEAR | |
  28634. * | 8 | NEAREST_NEAREST | |
  28635. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  28636. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  28637. * | 11 | LINEAR_LINEAR | |
  28638. * | 12 | LINEAR_NEAREST | |
  28639. *
  28640. * > _mag_: magnification filter (close to the viewer)
  28641. * > _min_: minification filter (far from the viewer)
  28642. * > _mip_: filter used between mip map levels
  28643. *@param samplingMode Define the new sampling mode of the texture
  28644. */
  28645. updateSamplingMode(samplingMode: number): void;
  28646. /**
  28647. * Scales the texture if is `canRescale()`
  28648. * @param ratio the resize factor we want to use to rescale
  28649. */
  28650. scale(ratio: number): void;
  28651. /**
  28652. * Get if the texture can rescale.
  28653. */
  28654. readonly canRescale: boolean;
  28655. /** @hidden */
  28656. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  28657. /** @hidden */
  28658. _rebuild(): void;
  28659. /**
  28660. * Triggers the load sequence in delayed load mode.
  28661. */
  28662. delayLoad(): void;
  28663. /**
  28664. * Clones the texture.
  28665. * @returns the cloned texture
  28666. */
  28667. clone(): Nullable<BaseTexture>;
  28668. /**
  28669. * Get the texture underlying type (INT, FLOAT...)
  28670. */
  28671. readonly textureType: number;
  28672. /**
  28673. * Get the texture underlying format (RGB, RGBA...)
  28674. */
  28675. readonly textureFormat: number;
  28676. /**
  28677. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  28678. * This will returns an RGBA array buffer containing either in values (0-255) or
  28679. * float values (0-1) depending of the underlying buffer type.
  28680. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  28681. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  28682. * @param buffer defines a user defined buffer to fill with data (can be null)
  28683. * @returns The Array buffer containing the pixels data.
  28684. */
  28685. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  28686. /**
  28687. * Release and destroy the underlying lower level texture aka internalTexture.
  28688. */
  28689. releaseInternalTexture(): void;
  28690. /**
  28691. * Get the polynomial representation of the texture data.
  28692. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  28693. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  28694. */
  28695. sphericalPolynomial: Nullable<SphericalPolynomial>;
  28696. /** @hidden */
  28697. readonly _lodTextureHigh: Nullable<BaseTexture>;
  28698. /** @hidden */
  28699. readonly _lodTextureMid: Nullable<BaseTexture>;
  28700. /** @hidden */
  28701. readonly _lodTextureLow: Nullable<BaseTexture>;
  28702. /**
  28703. * Dispose the texture and release its associated resources.
  28704. */
  28705. dispose(): void;
  28706. /**
  28707. * Serialize the texture into a JSON representation that can be parsed later on.
  28708. * @returns the JSON representation of the texture
  28709. */
  28710. serialize(): any;
  28711. /**
  28712. * Helper function to be called back once a list of texture contains only ready textures.
  28713. * @param textures Define the list of textures to wait for
  28714. * @param callback Define the callback triggered once the entire list will be ready
  28715. */
  28716. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  28717. }
  28718. }
  28719. declare module "babylonjs/Materials/Textures/internalTexture" {
  28720. import { Observable } from "babylonjs/Misc/observable";
  28721. import { Nullable, int } from "babylonjs/types";
  28722. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  28723. import { Engine } from "babylonjs/Engines/engine";
  28724. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  28725. /**
  28726. * Class used to store data associated with WebGL texture data for the engine
  28727. * This class should not be used directly
  28728. */
  28729. export class InternalTexture {
  28730. /** @hidden */
  28731. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  28732. /**
  28733. * The source of the texture data is unknown
  28734. */
  28735. static DATASOURCE_UNKNOWN: number;
  28736. /**
  28737. * Texture data comes from an URL
  28738. */
  28739. static DATASOURCE_URL: number;
  28740. /**
  28741. * Texture data is only used for temporary storage
  28742. */
  28743. static DATASOURCE_TEMP: number;
  28744. /**
  28745. * Texture data comes from raw data (ArrayBuffer)
  28746. */
  28747. static DATASOURCE_RAW: number;
  28748. /**
  28749. * Texture content is dynamic (video or dynamic texture)
  28750. */
  28751. static DATASOURCE_DYNAMIC: number;
  28752. /**
  28753. * Texture content is generated by rendering to it
  28754. */
  28755. static DATASOURCE_RENDERTARGET: number;
  28756. /**
  28757. * Texture content is part of a multi render target process
  28758. */
  28759. static DATASOURCE_MULTIRENDERTARGET: number;
  28760. /**
  28761. * Texture data comes from a cube data file
  28762. */
  28763. static DATASOURCE_CUBE: number;
  28764. /**
  28765. * Texture data comes from a raw cube data
  28766. */
  28767. static DATASOURCE_CUBERAW: number;
  28768. /**
  28769. * Texture data come from a prefiltered cube data file
  28770. */
  28771. static DATASOURCE_CUBEPREFILTERED: number;
  28772. /**
  28773. * Texture content is raw 3D data
  28774. */
  28775. static DATASOURCE_RAW3D: number;
  28776. /**
  28777. * Texture content is a depth texture
  28778. */
  28779. static DATASOURCE_DEPTHTEXTURE: number;
  28780. /**
  28781. * Texture data comes from a raw cube data encoded with RGBD
  28782. */
  28783. static DATASOURCE_CUBERAW_RGBD: number;
  28784. /**
  28785. * Defines if the texture is ready
  28786. */
  28787. isReady: boolean;
  28788. /**
  28789. * Defines if the texture is a cube texture
  28790. */
  28791. isCube: boolean;
  28792. /**
  28793. * Defines if the texture contains 3D data
  28794. */
  28795. is3D: boolean;
  28796. /**
  28797. * Defines if the texture contains multiview data
  28798. */
  28799. isMultiview: boolean;
  28800. /**
  28801. * Gets the URL used to load this texture
  28802. */
  28803. url: string;
  28804. /**
  28805. * Gets the sampling mode of the texture
  28806. */
  28807. samplingMode: number;
  28808. /**
  28809. * Gets a boolean indicating if the texture needs mipmaps generation
  28810. */
  28811. generateMipMaps: boolean;
  28812. /**
  28813. * Gets the number of samples used by the texture (WebGL2+ only)
  28814. */
  28815. samples: number;
  28816. /**
  28817. * Gets the type of the texture (int, float...)
  28818. */
  28819. type: number;
  28820. /**
  28821. * Gets the format of the texture (RGB, RGBA...)
  28822. */
  28823. format: number;
  28824. /**
  28825. * Observable called when the texture is loaded
  28826. */
  28827. onLoadedObservable: Observable<InternalTexture>;
  28828. /**
  28829. * Gets the width of the texture
  28830. */
  28831. width: number;
  28832. /**
  28833. * Gets the height of the texture
  28834. */
  28835. height: number;
  28836. /**
  28837. * Gets the depth of the texture
  28838. */
  28839. depth: number;
  28840. /**
  28841. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  28842. */
  28843. baseWidth: number;
  28844. /**
  28845. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  28846. */
  28847. baseHeight: number;
  28848. /**
  28849. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  28850. */
  28851. baseDepth: number;
  28852. /**
  28853. * Gets a boolean indicating if the texture is inverted on Y axis
  28854. */
  28855. invertY: boolean;
  28856. /** @hidden */
  28857. _invertVScale: boolean;
  28858. /** @hidden */
  28859. _associatedChannel: number;
  28860. /** @hidden */
  28861. _dataSource: number;
  28862. /** @hidden */
  28863. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>;
  28864. /** @hidden */
  28865. _bufferView: Nullable<ArrayBufferView>;
  28866. /** @hidden */
  28867. _bufferViewArray: Nullable<ArrayBufferView[]>;
  28868. /** @hidden */
  28869. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  28870. /** @hidden */
  28871. _size: number;
  28872. /** @hidden */
  28873. _extension: string;
  28874. /** @hidden */
  28875. _files: Nullable<string[]>;
  28876. /** @hidden */
  28877. _workingCanvas: Nullable<HTMLCanvasElement>;
  28878. /** @hidden */
  28879. _workingContext: Nullable<CanvasRenderingContext2D>;
  28880. /** @hidden */
  28881. _framebuffer: Nullable<WebGLFramebuffer>;
  28882. /** @hidden */
  28883. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  28884. /** @hidden */
  28885. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  28886. /** @hidden */
  28887. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  28888. /** @hidden */
  28889. _attachments: Nullable<number[]>;
  28890. /** @hidden */
  28891. _cachedCoordinatesMode: Nullable<number>;
  28892. /** @hidden */
  28893. _cachedWrapU: Nullable<number>;
  28894. /** @hidden */
  28895. _cachedWrapV: Nullable<number>;
  28896. /** @hidden */
  28897. _cachedWrapR: Nullable<number>;
  28898. /** @hidden */
  28899. _cachedAnisotropicFilteringLevel: Nullable<number>;
  28900. /** @hidden */
  28901. _isDisabled: boolean;
  28902. /** @hidden */
  28903. _compression: Nullable<string>;
  28904. /** @hidden */
  28905. _generateStencilBuffer: boolean;
  28906. /** @hidden */
  28907. _generateDepthBuffer: boolean;
  28908. /** @hidden */
  28909. _comparisonFunction: number;
  28910. /** @hidden */
  28911. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  28912. /** @hidden */
  28913. _lodGenerationScale: number;
  28914. /** @hidden */
  28915. _lodGenerationOffset: number;
  28916. /** @hidden */
  28917. _colorTextureArray: Nullable<WebGLTexture>;
  28918. /** @hidden */
  28919. _depthStencilTextureArray: Nullable<WebGLTexture>;
  28920. /** @hidden */
  28921. _lodTextureHigh: Nullable<BaseTexture>;
  28922. /** @hidden */
  28923. _lodTextureMid: Nullable<BaseTexture>;
  28924. /** @hidden */
  28925. _lodTextureLow: Nullable<BaseTexture>;
  28926. /** @hidden */
  28927. _isRGBD: boolean;
  28928. /** @hidden */
  28929. _linearSpecularLOD: boolean;
  28930. /** @hidden */
  28931. _irradianceTexture: Nullable<BaseTexture>;
  28932. /** @hidden */
  28933. _webGLTexture: Nullable<WebGLTexture>;
  28934. /** @hidden */
  28935. _references: number;
  28936. private _engine;
  28937. /**
  28938. * Gets the Engine the texture belongs to.
  28939. * @returns The babylon engine
  28940. */
  28941. getEngine(): Engine;
  28942. /**
  28943. * Gets the data source type of the texture (can be one of the InternalTexture.DATASOURCE_XXXX)
  28944. */
  28945. readonly dataSource: number;
  28946. /**
  28947. * Creates a new InternalTexture
  28948. * @param engine defines the engine to use
  28949. * @param dataSource defines the type of data that will be used
  28950. * @param delayAllocation if the texture allocation should be delayed (default: false)
  28951. */
  28952. constructor(engine: Engine, dataSource: number, delayAllocation?: boolean);
  28953. /**
  28954. * Increments the number of references (ie. the number of Texture that point to it)
  28955. */
  28956. incrementReferences(): void;
  28957. /**
  28958. * Change the size of the texture (not the size of the content)
  28959. * @param width defines the new width
  28960. * @param height defines the new height
  28961. * @param depth defines the new depth (1 by default)
  28962. */
  28963. updateSize(width: int, height: int, depth?: int): void;
  28964. /** @hidden */
  28965. _rebuild(): void;
  28966. /** @hidden */
  28967. _swapAndDie(target: InternalTexture): void;
  28968. /**
  28969. * Dispose the current allocated resources
  28970. */
  28971. dispose(): void;
  28972. }
  28973. }
  28974. declare module "babylonjs/Materials/effect" {
  28975. import { Observable } from "babylonjs/Misc/observable";
  28976. import { Nullable } from "babylonjs/types";
  28977. import { IDisposable } from "babylonjs/scene";
  28978. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  28979. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  28980. import { IMatrixLike, IVector2Like, IVector3Like, IVector4Like, IColor3Like, IColor4Like } from "babylonjs/Maths/math.like";
  28981. import { Engine } from "babylonjs/Engines/engine";
  28982. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  28983. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  28984. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  28985. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  28986. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  28987. /**
  28988. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  28989. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  28990. */
  28991. export class EffectFallbacks {
  28992. private _defines;
  28993. private _currentRank;
  28994. private _maxRank;
  28995. private _mesh;
  28996. /**
  28997. * Removes the fallback from the bound mesh.
  28998. */
  28999. unBindMesh(): void;
  29000. /**
  29001. * Adds a fallback on the specified property.
  29002. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  29003. * @param define The name of the define in the shader
  29004. */
  29005. addFallback(rank: number, define: string): void;
  29006. /**
  29007. * Sets the mesh to use CPU skinning when needing to fallback.
  29008. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  29009. * @param mesh The mesh to use the fallbacks.
  29010. */
  29011. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  29012. /**
  29013. * Checks to see if more fallbacks are still availible.
  29014. */
  29015. readonly hasMoreFallbacks: boolean;
  29016. /**
  29017. * Removes the defines that should be removed when falling back.
  29018. * @param currentDefines defines the current define statements for the shader.
  29019. * @param effect defines the current effect we try to compile
  29020. * @returns The resulting defines with defines of the current rank removed.
  29021. */
  29022. reduce(currentDefines: string, effect: Effect): string;
  29023. }
  29024. /**
  29025. * Options to be used when creating an effect.
  29026. */
  29027. export class EffectCreationOptions {
  29028. /**
  29029. * Atrributes that will be used in the shader.
  29030. */
  29031. attributes: string[];
  29032. /**
  29033. * Uniform varible names that will be set in the shader.
  29034. */
  29035. uniformsNames: string[];
  29036. /**
  29037. * Uniform buffer varible names that will be set in the shader.
  29038. */
  29039. uniformBuffersNames: string[];
  29040. /**
  29041. * Sampler texture variable names that will be set in the shader.
  29042. */
  29043. samplers: string[];
  29044. /**
  29045. * Define statements that will be set in the shader.
  29046. */
  29047. defines: any;
  29048. /**
  29049. * Possible fallbacks for this effect to improve performance when needed.
  29050. */
  29051. fallbacks: Nullable<EffectFallbacks>;
  29052. /**
  29053. * Callback that will be called when the shader is compiled.
  29054. */
  29055. onCompiled: Nullable<(effect: Effect) => void>;
  29056. /**
  29057. * Callback that will be called if an error occurs during shader compilation.
  29058. */
  29059. onError: Nullable<(effect: Effect, errors: string) => void>;
  29060. /**
  29061. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  29062. */
  29063. indexParameters: any;
  29064. /**
  29065. * Max number of lights that can be used in the shader.
  29066. */
  29067. maxSimultaneousLights: number;
  29068. /**
  29069. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  29070. */
  29071. transformFeedbackVaryings: Nullable<string[]>;
  29072. }
  29073. /**
  29074. * Effect containing vertex and fragment shader that can be executed on an object.
  29075. */
  29076. export class Effect implements IDisposable {
  29077. /**
  29078. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  29079. */
  29080. static ShadersRepository: string;
  29081. /**
  29082. * Name of the effect.
  29083. */
  29084. name: any;
  29085. /**
  29086. * String container all the define statements that should be set on the shader.
  29087. */
  29088. defines: string;
  29089. /**
  29090. * Callback that will be called when the shader is compiled.
  29091. */
  29092. onCompiled: Nullable<(effect: Effect) => void>;
  29093. /**
  29094. * Callback that will be called if an error occurs during shader compilation.
  29095. */
  29096. onError: Nullable<(effect: Effect, errors: string) => void>;
  29097. /**
  29098. * Callback that will be called when effect is bound.
  29099. */
  29100. onBind: Nullable<(effect: Effect) => void>;
  29101. /**
  29102. * Unique ID of the effect.
  29103. */
  29104. uniqueId: number;
  29105. /**
  29106. * Observable that will be called when the shader is compiled.
  29107. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  29108. */
  29109. onCompileObservable: Observable<Effect>;
  29110. /**
  29111. * Observable that will be called if an error occurs during shader compilation.
  29112. */
  29113. onErrorObservable: Observable<Effect>;
  29114. /** @hidden */
  29115. _onBindObservable: Nullable<Observable<Effect>>;
  29116. /**
  29117. * Observable that will be called when effect is bound.
  29118. */
  29119. readonly onBindObservable: Observable<Effect>;
  29120. /** @hidden */
  29121. _bonesComputationForcedToCPU: boolean;
  29122. private static _uniqueIdSeed;
  29123. private _engine;
  29124. private _uniformBuffersNames;
  29125. private _uniformsNames;
  29126. private _samplerList;
  29127. private _samplers;
  29128. private _isReady;
  29129. private _compilationError;
  29130. private _attributesNames;
  29131. private _attributes;
  29132. private _uniforms;
  29133. /**
  29134. * Key for the effect.
  29135. * @hidden
  29136. */
  29137. _key: string;
  29138. private _indexParameters;
  29139. private _fallbacks;
  29140. private _vertexSourceCode;
  29141. private _fragmentSourceCode;
  29142. private _vertexSourceCodeOverride;
  29143. private _fragmentSourceCodeOverride;
  29144. private _transformFeedbackVaryings;
  29145. /**
  29146. * Compiled shader to webGL program.
  29147. * @hidden
  29148. */
  29149. _pipelineContext: Nullable<IPipelineContext>;
  29150. private _valueCache;
  29151. private static _baseCache;
  29152. /**
  29153. * Instantiates an effect.
  29154. * An effect can be used to create/manage/execute vertex and fragment shaders.
  29155. * @param baseName Name of the effect.
  29156. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  29157. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  29158. * @param samplers List of sampler variables that will be passed to the shader.
  29159. * @param engine Engine to be used to render the effect
  29160. * @param defines Define statements to be added to the shader.
  29161. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  29162. * @param onCompiled Callback that will be called when the shader is compiled.
  29163. * @param onError Callback that will be called if an error occurs during shader compilation.
  29164. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  29165. */
  29166. constructor(baseName: any, attributesNamesOrOptions: string[] | EffectCreationOptions, uniformsNamesOrEngine: string[] | Engine, samplers?: Nullable<string[]>, engine?: Engine, defines?: Nullable<string>, fallbacks?: Nullable<EffectFallbacks>, onCompiled?: Nullable<(effect: Effect) => void>, onError?: Nullable<(effect: Effect, errors: string) => void>, indexParameters?: any);
  29167. private _useFinalCode;
  29168. /**
  29169. * Unique key for this effect
  29170. */
  29171. readonly key: string;
  29172. /**
  29173. * If the effect has been compiled and prepared.
  29174. * @returns if the effect is compiled and prepared.
  29175. */
  29176. isReady(): boolean;
  29177. private _isReadyInternal;
  29178. /**
  29179. * The engine the effect was initialized with.
  29180. * @returns the engine.
  29181. */
  29182. getEngine(): Engine;
  29183. /**
  29184. * The pipeline context for this effect
  29185. * @returns the associated pipeline context
  29186. */
  29187. getPipelineContext(): Nullable<IPipelineContext>;
  29188. /**
  29189. * The set of names of attribute variables for the shader.
  29190. * @returns An array of attribute names.
  29191. */
  29192. getAttributesNames(): string[];
  29193. /**
  29194. * Returns the attribute at the given index.
  29195. * @param index The index of the attribute.
  29196. * @returns The location of the attribute.
  29197. */
  29198. getAttributeLocation(index: number): number;
  29199. /**
  29200. * Returns the attribute based on the name of the variable.
  29201. * @param name of the attribute to look up.
  29202. * @returns the attribute location.
  29203. */
  29204. getAttributeLocationByName(name: string): number;
  29205. /**
  29206. * The number of attributes.
  29207. * @returns the numnber of attributes.
  29208. */
  29209. getAttributesCount(): number;
  29210. /**
  29211. * Gets the index of a uniform variable.
  29212. * @param uniformName of the uniform to look up.
  29213. * @returns the index.
  29214. */
  29215. getUniformIndex(uniformName: string): number;
  29216. /**
  29217. * Returns the attribute based on the name of the variable.
  29218. * @param uniformName of the uniform to look up.
  29219. * @returns the location of the uniform.
  29220. */
  29221. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  29222. /**
  29223. * Returns an array of sampler variable names
  29224. * @returns The array of sampler variable neames.
  29225. */
  29226. getSamplers(): string[];
  29227. /**
  29228. * The error from the last compilation.
  29229. * @returns the error string.
  29230. */
  29231. getCompilationError(): string;
  29232. /**
  29233. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  29234. * @param func The callback to be used.
  29235. */
  29236. executeWhenCompiled(func: (effect: Effect) => void): void;
  29237. private _checkIsReady;
  29238. /** @hidden */
  29239. _loadVertexShader(vertex: any, callback: (data: any) => void): void;
  29240. /** @hidden */
  29241. _loadFragmentShader(fragment: any, callback: (data: any) => void): void;
  29242. /** @hidden */
  29243. _dumpShadersSource(vertexCode: string, fragmentCode: string, defines: string): void;
  29244. /**
  29245. * Recompiles the webGL program
  29246. * @param vertexSourceCode The source code for the vertex shader.
  29247. * @param fragmentSourceCode The source code for the fragment shader.
  29248. * @param onCompiled Callback called when completed.
  29249. * @param onError Callback called on error.
  29250. * @hidden
  29251. */
  29252. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  29253. /**
  29254. * Prepares the effect
  29255. * @hidden
  29256. */
  29257. _prepareEffect(): void;
  29258. private _processCompilationErrors;
  29259. /**
  29260. * Checks if the effect is supported. (Must be called after compilation)
  29261. */
  29262. readonly isSupported: boolean;
  29263. /**
  29264. * Binds a texture to the engine to be used as output of the shader.
  29265. * @param channel Name of the output variable.
  29266. * @param texture Texture to bind.
  29267. * @hidden
  29268. */
  29269. _bindTexture(channel: string, texture: InternalTexture): void;
  29270. /**
  29271. * Sets a texture on the engine to be used in the shader.
  29272. * @param channel Name of the sampler variable.
  29273. * @param texture Texture to set.
  29274. */
  29275. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  29276. /**
  29277. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  29278. * @param channel Name of the sampler variable.
  29279. * @param texture Texture to set.
  29280. */
  29281. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  29282. /**
  29283. * Sets an array of textures on the engine to be used in the shader.
  29284. * @param channel Name of the variable.
  29285. * @param textures Textures to set.
  29286. */
  29287. setTextureArray(channel: string, textures: BaseTexture[]): void;
  29288. /**
  29289. * 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)
  29290. * @param channel Name of the sampler variable.
  29291. * @param postProcess Post process to get the input texture from.
  29292. */
  29293. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  29294. /**
  29295. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  29296. * 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)
  29297. * @param channel Name of the sampler variable.
  29298. * @param postProcess Post process to get the output texture from.
  29299. */
  29300. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  29301. /** @hidden */
  29302. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  29303. /** @hidden */
  29304. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  29305. /** @hidden */
  29306. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  29307. /** @hidden */
  29308. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  29309. /**
  29310. * Binds a buffer to a uniform.
  29311. * @param buffer Buffer to bind.
  29312. * @param name Name of the uniform variable to bind to.
  29313. */
  29314. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  29315. /**
  29316. * Binds block to a uniform.
  29317. * @param blockName Name of the block to bind.
  29318. * @param index Index to bind.
  29319. */
  29320. bindUniformBlock(blockName: string, index: number): void;
  29321. /**
  29322. * Sets an interger value on a uniform variable.
  29323. * @param uniformName Name of the variable.
  29324. * @param value Value to be set.
  29325. * @returns this effect.
  29326. */
  29327. setInt(uniformName: string, value: number): Effect;
  29328. /**
  29329. * Sets an int array on a uniform variable.
  29330. * @param uniformName Name of the variable.
  29331. * @param array array to be set.
  29332. * @returns this effect.
  29333. */
  29334. setIntArray(uniformName: string, array: Int32Array): Effect;
  29335. /**
  29336. * 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)
  29337. * @param uniformName Name of the variable.
  29338. * @param array array to be set.
  29339. * @returns this effect.
  29340. */
  29341. setIntArray2(uniformName: string, array: Int32Array): Effect;
  29342. /**
  29343. * 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)
  29344. * @param uniformName Name of the variable.
  29345. * @param array array to be set.
  29346. * @returns this effect.
  29347. */
  29348. setIntArray3(uniformName: string, array: Int32Array): Effect;
  29349. /**
  29350. * 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)
  29351. * @param uniformName Name of the variable.
  29352. * @param array array to be set.
  29353. * @returns this effect.
  29354. */
  29355. setIntArray4(uniformName: string, array: Int32Array): Effect;
  29356. /**
  29357. * Sets an float array on a uniform variable.
  29358. * @param uniformName Name of the variable.
  29359. * @param array array to be set.
  29360. * @returns this effect.
  29361. */
  29362. setFloatArray(uniformName: string, array: Float32Array): Effect;
  29363. /**
  29364. * 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)
  29365. * @param uniformName Name of the variable.
  29366. * @param array array to be set.
  29367. * @returns this effect.
  29368. */
  29369. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  29370. /**
  29371. * 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)
  29372. * @param uniformName Name of the variable.
  29373. * @param array array to be set.
  29374. * @returns this effect.
  29375. */
  29376. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  29377. /**
  29378. * 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)
  29379. * @param uniformName Name of the variable.
  29380. * @param array array to be set.
  29381. * @returns this effect.
  29382. */
  29383. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  29384. /**
  29385. * Sets an array on a uniform variable.
  29386. * @param uniformName Name of the variable.
  29387. * @param array array to be set.
  29388. * @returns this effect.
  29389. */
  29390. setArray(uniformName: string, array: number[]): Effect;
  29391. /**
  29392. * 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)
  29393. * @param uniformName Name of the variable.
  29394. * @param array array to be set.
  29395. * @returns this effect.
  29396. */
  29397. setArray2(uniformName: string, array: number[]): Effect;
  29398. /**
  29399. * 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)
  29400. * @param uniformName Name of the variable.
  29401. * @param array array to be set.
  29402. * @returns this effect.
  29403. */
  29404. setArray3(uniformName: string, array: number[]): Effect;
  29405. /**
  29406. * 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)
  29407. * @param uniformName Name of the variable.
  29408. * @param array array to be set.
  29409. * @returns this effect.
  29410. */
  29411. setArray4(uniformName: string, array: number[]): Effect;
  29412. /**
  29413. * Sets matrices on a uniform variable.
  29414. * @param uniformName Name of the variable.
  29415. * @param matrices matrices to be set.
  29416. * @returns this effect.
  29417. */
  29418. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  29419. /**
  29420. * Sets matrix on a uniform variable.
  29421. * @param uniformName Name of the variable.
  29422. * @param matrix matrix to be set.
  29423. * @returns this effect.
  29424. */
  29425. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  29426. /**
  29427. * 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)
  29428. * @param uniformName Name of the variable.
  29429. * @param matrix matrix to be set.
  29430. * @returns this effect.
  29431. */
  29432. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  29433. /**
  29434. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  29435. * @param uniformName Name of the variable.
  29436. * @param matrix matrix to be set.
  29437. * @returns this effect.
  29438. */
  29439. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  29440. /**
  29441. * Sets a float on a uniform variable.
  29442. * @param uniformName Name of the variable.
  29443. * @param value value to be set.
  29444. * @returns this effect.
  29445. */
  29446. setFloat(uniformName: string, value: number): Effect;
  29447. /**
  29448. * Sets a boolean on a uniform variable.
  29449. * @param uniformName Name of the variable.
  29450. * @param bool value to be set.
  29451. * @returns this effect.
  29452. */
  29453. setBool(uniformName: string, bool: boolean): Effect;
  29454. /**
  29455. * Sets a Vector2 on a uniform variable.
  29456. * @param uniformName Name of the variable.
  29457. * @param vector2 vector2 to be set.
  29458. * @returns this effect.
  29459. */
  29460. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  29461. /**
  29462. * Sets a float2 on a uniform variable.
  29463. * @param uniformName Name of the variable.
  29464. * @param x First float in float2.
  29465. * @param y Second float in float2.
  29466. * @returns this effect.
  29467. */
  29468. setFloat2(uniformName: string, x: number, y: number): Effect;
  29469. /**
  29470. * Sets a Vector3 on a uniform variable.
  29471. * @param uniformName Name of the variable.
  29472. * @param vector3 Value to be set.
  29473. * @returns this effect.
  29474. */
  29475. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  29476. /**
  29477. * Sets a float3 on a uniform variable.
  29478. * @param uniformName Name of the variable.
  29479. * @param x First float in float3.
  29480. * @param y Second float in float3.
  29481. * @param z Third float in float3.
  29482. * @returns this effect.
  29483. */
  29484. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  29485. /**
  29486. * Sets a Vector4 on a uniform variable.
  29487. * @param uniformName Name of the variable.
  29488. * @param vector4 Value to be set.
  29489. * @returns this effect.
  29490. */
  29491. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  29492. /**
  29493. * Sets a float4 on a uniform variable.
  29494. * @param uniformName Name of the variable.
  29495. * @param x First float in float4.
  29496. * @param y Second float in float4.
  29497. * @param z Third float in float4.
  29498. * @param w Fourth float in float4.
  29499. * @returns this effect.
  29500. */
  29501. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  29502. /**
  29503. * Sets a Color3 on a uniform variable.
  29504. * @param uniformName Name of the variable.
  29505. * @param color3 Value to be set.
  29506. * @returns this effect.
  29507. */
  29508. setColor3(uniformName: string, color3: IColor3Like): Effect;
  29509. /**
  29510. * Sets a Color4 on a uniform variable.
  29511. * @param uniformName Name of the variable.
  29512. * @param color3 Value to be set.
  29513. * @param alpha Alpha value to be set.
  29514. * @returns this effect.
  29515. */
  29516. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  29517. /**
  29518. * Sets a Color4 on a uniform variable
  29519. * @param uniformName defines the name of the variable
  29520. * @param color4 defines the value to be set
  29521. * @returns this effect.
  29522. */
  29523. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  29524. /** Release all associated resources */
  29525. dispose(): void;
  29526. /**
  29527. * This function will add a new shader to the shader store
  29528. * @param name the name of the shader
  29529. * @param pixelShader optional pixel shader content
  29530. * @param vertexShader optional vertex shader content
  29531. */
  29532. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  29533. /**
  29534. * Store of each shader (The can be looked up using effect.key)
  29535. */
  29536. static ShadersStore: {
  29537. [key: string]: string;
  29538. };
  29539. /**
  29540. * Store of each included file for a shader (The can be looked up using effect.key)
  29541. */
  29542. static IncludesShadersStore: {
  29543. [key: string]: string;
  29544. };
  29545. /**
  29546. * Resets the cache of effects.
  29547. */
  29548. static ResetCache(): void;
  29549. }
  29550. }
  29551. declare module "babylonjs/Materials/uniformBuffer" {
  29552. import { Nullable, FloatArray } from "babylonjs/types";
  29553. import { Matrix, Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  29554. import { Engine } from "babylonjs/Engines/engine";
  29555. import { Effect } from "babylonjs/Materials/effect";
  29556. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  29557. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  29558. import { Color3 } from "babylonjs/Maths/math.color";
  29559. /**
  29560. * Uniform buffer objects.
  29561. *
  29562. * Handles blocks of uniform on the GPU.
  29563. *
  29564. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  29565. *
  29566. * For more information, please refer to :
  29567. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  29568. */
  29569. export class UniformBuffer {
  29570. private _engine;
  29571. private _buffer;
  29572. private _data;
  29573. private _bufferData;
  29574. private _dynamic?;
  29575. private _uniformLocations;
  29576. private _uniformSizes;
  29577. private _uniformLocationPointer;
  29578. private _needSync;
  29579. private _noUBO;
  29580. private _currentEffect;
  29581. private static _MAX_UNIFORM_SIZE;
  29582. private static _tempBuffer;
  29583. /**
  29584. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  29585. * This is dynamic to allow compat with webgl 1 and 2.
  29586. * You will need to pass the name of the uniform as well as the value.
  29587. */
  29588. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  29589. /**
  29590. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  29591. * This is dynamic to allow compat with webgl 1 and 2.
  29592. * You will need to pass the name of the uniform as well as the value.
  29593. */
  29594. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  29595. /**
  29596. * Lambda to Update a single float in a uniform buffer.
  29597. * This is dynamic to allow compat with webgl 1 and 2.
  29598. * You will need to pass the name of the uniform as well as the value.
  29599. */
  29600. updateFloat: (name: string, x: number) => void;
  29601. /**
  29602. * Lambda to Update a vec2 of float in a uniform buffer.
  29603. * This is dynamic to allow compat with webgl 1 and 2.
  29604. * You will need to pass the name of the uniform as well as the value.
  29605. */
  29606. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  29607. /**
  29608. * Lambda to Update a vec3 of float in a uniform buffer.
  29609. * This is dynamic to allow compat with webgl 1 and 2.
  29610. * You will need to pass the name of the uniform as well as the value.
  29611. */
  29612. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  29613. /**
  29614. * Lambda to Update a vec4 of float in a uniform buffer.
  29615. * This is dynamic to allow compat with webgl 1 and 2.
  29616. * You will need to pass the name of the uniform as well as the value.
  29617. */
  29618. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  29619. /**
  29620. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  29621. * This is dynamic to allow compat with webgl 1 and 2.
  29622. * You will need to pass the name of the uniform as well as the value.
  29623. */
  29624. updateMatrix: (name: string, mat: Matrix) => void;
  29625. /**
  29626. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  29627. * This is dynamic to allow compat with webgl 1 and 2.
  29628. * You will need to pass the name of the uniform as well as the value.
  29629. */
  29630. updateVector3: (name: string, vector: Vector3) => void;
  29631. /**
  29632. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  29633. * This is dynamic to allow compat with webgl 1 and 2.
  29634. * You will need to pass the name of the uniform as well as the value.
  29635. */
  29636. updateVector4: (name: string, vector: Vector4) => void;
  29637. /**
  29638. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  29639. * This is dynamic to allow compat with webgl 1 and 2.
  29640. * You will need to pass the name of the uniform as well as the value.
  29641. */
  29642. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  29643. /**
  29644. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  29645. * This is dynamic to allow compat with webgl 1 and 2.
  29646. * You will need to pass the name of the uniform as well as the value.
  29647. */
  29648. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  29649. /**
  29650. * Instantiates a new Uniform buffer objects.
  29651. *
  29652. * Handles blocks of uniform on the GPU.
  29653. *
  29654. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  29655. *
  29656. * For more information, please refer to :
  29657. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  29658. * @param engine Define the engine the buffer is associated with
  29659. * @param data Define the data contained in the buffer
  29660. * @param dynamic Define if the buffer is updatable
  29661. */
  29662. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  29663. /**
  29664. * Indicates if the buffer is using the WebGL2 UBO implementation,
  29665. * or just falling back on setUniformXXX calls.
  29666. */
  29667. readonly useUbo: boolean;
  29668. /**
  29669. * Indicates if the WebGL underlying uniform buffer is in sync
  29670. * with the javascript cache data.
  29671. */
  29672. readonly isSync: boolean;
  29673. /**
  29674. * Indicates if the WebGL underlying uniform buffer is dynamic.
  29675. * Also, a dynamic UniformBuffer will disable cache verification and always
  29676. * update the underlying WebGL uniform buffer to the GPU.
  29677. * @returns if Dynamic, otherwise false
  29678. */
  29679. isDynamic(): boolean;
  29680. /**
  29681. * The data cache on JS side.
  29682. * @returns the underlying data as a float array
  29683. */
  29684. getData(): Float32Array;
  29685. /**
  29686. * The underlying WebGL Uniform buffer.
  29687. * @returns the webgl buffer
  29688. */
  29689. getBuffer(): Nullable<DataBuffer>;
  29690. /**
  29691. * std140 layout specifies how to align data within an UBO structure.
  29692. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  29693. * for specs.
  29694. */
  29695. private _fillAlignment;
  29696. /**
  29697. * Adds an uniform in the buffer.
  29698. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  29699. * for the layout to be correct !
  29700. * @param name Name of the uniform, as used in the uniform block in the shader.
  29701. * @param size Data size, or data directly.
  29702. */
  29703. addUniform(name: string, size: number | number[]): void;
  29704. /**
  29705. * Adds a Matrix 4x4 to the uniform buffer.
  29706. * @param name Name of the uniform, as used in the uniform block in the shader.
  29707. * @param mat A 4x4 matrix.
  29708. */
  29709. addMatrix(name: string, mat: Matrix): void;
  29710. /**
  29711. * Adds a vec2 to the uniform buffer.
  29712. * @param name Name of the uniform, as used in the uniform block in the shader.
  29713. * @param x Define the x component value of the vec2
  29714. * @param y Define the y component value of the vec2
  29715. */
  29716. addFloat2(name: string, x: number, y: number): void;
  29717. /**
  29718. * Adds a vec3 to the uniform buffer.
  29719. * @param name Name of the uniform, as used in the uniform block in the shader.
  29720. * @param x Define the x component value of the vec3
  29721. * @param y Define the y component value of the vec3
  29722. * @param z Define the z component value of the vec3
  29723. */
  29724. addFloat3(name: string, x: number, y: number, z: number): void;
  29725. /**
  29726. * Adds a vec3 to the uniform buffer.
  29727. * @param name Name of the uniform, as used in the uniform block in the shader.
  29728. * @param color Define the vec3 from a Color
  29729. */
  29730. addColor3(name: string, color: Color3): void;
  29731. /**
  29732. * Adds a vec4 to the uniform buffer.
  29733. * @param name Name of the uniform, as used in the uniform block in the shader.
  29734. * @param color Define the rgb components from a Color
  29735. * @param alpha Define the a component of the vec4
  29736. */
  29737. addColor4(name: string, color: Color3, alpha: number): void;
  29738. /**
  29739. * Adds a vec3 to the uniform buffer.
  29740. * @param name Name of the uniform, as used in the uniform block in the shader.
  29741. * @param vector Define the vec3 components from a Vector
  29742. */
  29743. addVector3(name: string, vector: Vector3): void;
  29744. /**
  29745. * Adds a Matrix 3x3 to the uniform buffer.
  29746. * @param name Name of the uniform, as used in the uniform block in the shader.
  29747. */
  29748. addMatrix3x3(name: string): void;
  29749. /**
  29750. * Adds a Matrix 2x2 to the uniform buffer.
  29751. * @param name Name of the uniform, as used in the uniform block in the shader.
  29752. */
  29753. addMatrix2x2(name: string): void;
  29754. /**
  29755. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  29756. */
  29757. create(): void;
  29758. /** @hidden */
  29759. _rebuild(): void;
  29760. /**
  29761. * Updates the WebGL Uniform Buffer on the GPU.
  29762. * If the `dynamic` flag is set to true, no cache comparison is done.
  29763. * Otherwise, the buffer will be updated only if the cache differs.
  29764. */
  29765. update(): void;
  29766. /**
  29767. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  29768. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  29769. * @param data Define the flattened data
  29770. * @param size Define the size of the data.
  29771. */
  29772. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  29773. private _valueCache;
  29774. private _cacheMatrix;
  29775. private _updateMatrix3x3ForUniform;
  29776. private _updateMatrix3x3ForEffect;
  29777. private _updateMatrix2x2ForEffect;
  29778. private _updateMatrix2x2ForUniform;
  29779. private _updateFloatForEffect;
  29780. private _updateFloatForUniform;
  29781. private _updateFloat2ForEffect;
  29782. private _updateFloat2ForUniform;
  29783. private _updateFloat3ForEffect;
  29784. private _updateFloat3ForUniform;
  29785. private _updateFloat4ForEffect;
  29786. private _updateFloat4ForUniform;
  29787. private _updateMatrixForEffect;
  29788. private _updateMatrixForUniform;
  29789. private _updateVector3ForEffect;
  29790. private _updateVector3ForUniform;
  29791. private _updateVector4ForEffect;
  29792. private _updateVector4ForUniform;
  29793. private _updateColor3ForEffect;
  29794. private _updateColor3ForUniform;
  29795. private _updateColor4ForEffect;
  29796. private _updateColor4ForUniform;
  29797. /**
  29798. * Sets a sampler uniform on the effect.
  29799. * @param name Define the name of the sampler.
  29800. * @param texture Define the texture to set in the sampler
  29801. */
  29802. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  29803. /**
  29804. * Directly updates the value of the uniform in the cache AND on the GPU.
  29805. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  29806. * @param data Define the flattened data
  29807. */
  29808. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  29809. /**
  29810. * Binds this uniform buffer to an effect.
  29811. * @param effect Define the effect to bind the buffer to
  29812. * @param name Name of the uniform block in the shader.
  29813. */
  29814. bindToEffect(effect: Effect, name: string): void;
  29815. /**
  29816. * Disposes the uniform buffer.
  29817. */
  29818. dispose(): void;
  29819. }
  29820. }
  29821. declare module "babylonjs/Audio/analyser" {
  29822. import { Scene } from "babylonjs/scene";
  29823. /**
  29824. * Class used to work with sound analyzer using fast fourier transform (FFT)
  29825. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  29826. */
  29827. export class Analyser {
  29828. /**
  29829. * Gets or sets the smoothing
  29830. * @ignorenaming
  29831. */
  29832. SMOOTHING: number;
  29833. /**
  29834. * Gets or sets the FFT table size
  29835. * @ignorenaming
  29836. */
  29837. FFT_SIZE: number;
  29838. /**
  29839. * Gets or sets the bar graph amplitude
  29840. * @ignorenaming
  29841. */
  29842. BARGRAPHAMPLITUDE: number;
  29843. /**
  29844. * Gets or sets the position of the debug canvas
  29845. * @ignorenaming
  29846. */
  29847. DEBUGCANVASPOS: {
  29848. x: number;
  29849. y: number;
  29850. };
  29851. /**
  29852. * Gets or sets the debug canvas size
  29853. * @ignorenaming
  29854. */
  29855. DEBUGCANVASSIZE: {
  29856. width: number;
  29857. height: number;
  29858. };
  29859. private _byteFreqs;
  29860. private _byteTime;
  29861. private _floatFreqs;
  29862. private _webAudioAnalyser;
  29863. private _debugCanvas;
  29864. private _debugCanvasContext;
  29865. private _scene;
  29866. private _registerFunc;
  29867. private _audioEngine;
  29868. /**
  29869. * Creates a new analyser
  29870. * @param scene defines hosting scene
  29871. */
  29872. constructor(scene: Scene);
  29873. /**
  29874. * Get the number of data values you will have to play with for the visualization
  29875. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  29876. * @returns a number
  29877. */
  29878. getFrequencyBinCount(): number;
  29879. /**
  29880. * Gets the current frequency data as a byte array
  29881. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  29882. * @returns a Uint8Array
  29883. */
  29884. getByteFrequencyData(): Uint8Array;
  29885. /**
  29886. * Gets the current waveform as a byte array
  29887. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  29888. * @returns a Uint8Array
  29889. */
  29890. getByteTimeDomainData(): Uint8Array;
  29891. /**
  29892. * Gets the current frequency data as a float array
  29893. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  29894. * @returns a Float32Array
  29895. */
  29896. getFloatFrequencyData(): Float32Array;
  29897. /**
  29898. * Renders the debug canvas
  29899. */
  29900. drawDebugCanvas(): void;
  29901. /**
  29902. * Stops rendering the debug canvas and removes it
  29903. */
  29904. stopDebugCanvas(): void;
  29905. /**
  29906. * Connects two audio nodes
  29907. * @param inputAudioNode defines first node to connect
  29908. * @param outputAudioNode defines second node to connect
  29909. */
  29910. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  29911. /**
  29912. * Releases all associated resources
  29913. */
  29914. dispose(): void;
  29915. }
  29916. }
  29917. declare module "babylonjs/Audio/audioEngine" {
  29918. import { IDisposable } from "babylonjs/scene";
  29919. import { Analyser } from "babylonjs/Audio/analyser";
  29920. import { Nullable } from "babylonjs/types";
  29921. import { Observable } from "babylonjs/Misc/observable";
  29922. /**
  29923. * This represents an audio engine and it is responsible
  29924. * to play, synchronize and analyse sounds throughout the application.
  29925. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  29926. */
  29927. export interface IAudioEngine extends IDisposable {
  29928. /**
  29929. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  29930. */
  29931. readonly canUseWebAudio: boolean;
  29932. /**
  29933. * Gets the current AudioContext if available.
  29934. */
  29935. readonly audioContext: Nullable<AudioContext>;
  29936. /**
  29937. * The master gain node defines the global audio volume of your audio engine.
  29938. */
  29939. readonly masterGain: GainNode;
  29940. /**
  29941. * Gets whether or not mp3 are supported by your browser.
  29942. */
  29943. readonly isMP3supported: boolean;
  29944. /**
  29945. * Gets whether or not ogg are supported by your browser.
  29946. */
  29947. readonly isOGGsupported: boolean;
  29948. /**
  29949. * Defines if Babylon should emit a warning if WebAudio is not supported.
  29950. * @ignoreNaming
  29951. */
  29952. WarnedWebAudioUnsupported: boolean;
  29953. /**
  29954. * Defines if the audio engine relies on a custom unlocked button.
  29955. * In this case, the embedded button will not be displayed.
  29956. */
  29957. useCustomUnlockedButton: boolean;
  29958. /**
  29959. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  29960. */
  29961. readonly unlocked: boolean;
  29962. /**
  29963. * Event raised when audio has been unlocked on the browser.
  29964. */
  29965. onAudioUnlockedObservable: Observable<AudioEngine>;
  29966. /**
  29967. * Event raised when audio has been locked on the browser.
  29968. */
  29969. onAudioLockedObservable: Observable<AudioEngine>;
  29970. /**
  29971. * Flags the audio engine in Locked state.
  29972. * This happens due to new browser policies preventing audio to autoplay.
  29973. */
  29974. lock(): void;
  29975. /**
  29976. * Unlocks the audio engine once a user action has been done on the dom.
  29977. * This is helpful to resume play once browser policies have been satisfied.
  29978. */
  29979. unlock(): void;
  29980. }
  29981. /**
  29982. * This represents the default audio engine used in babylon.
  29983. * It is responsible to play, synchronize and analyse sounds throughout the application.
  29984. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  29985. */
  29986. export class AudioEngine implements IAudioEngine {
  29987. private _audioContext;
  29988. private _audioContextInitialized;
  29989. private _muteButton;
  29990. private _hostElement;
  29991. /**
  29992. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  29993. */
  29994. canUseWebAudio: boolean;
  29995. /**
  29996. * The master gain node defines the global audio volume of your audio engine.
  29997. */
  29998. masterGain: GainNode;
  29999. /**
  30000. * Defines if Babylon should emit a warning if WebAudio is not supported.
  30001. * @ignoreNaming
  30002. */
  30003. WarnedWebAudioUnsupported: boolean;
  30004. /**
  30005. * Gets whether or not mp3 are supported by your browser.
  30006. */
  30007. isMP3supported: boolean;
  30008. /**
  30009. * Gets whether or not ogg are supported by your browser.
  30010. */
  30011. isOGGsupported: boolean;
  30012. /**
  30013. * Gets whether audio has been unlocked on the device.
  30014. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  30015. * a user interaction has happened.
  30016. */
  30017. unlocked: boolean;
  30018. /**
  30019. * Defines if the audio engine relies on a custom unlocked button.
  30020. * In this case, the embedded button will not be displayed.
  30021. */
  30022. useCustomUnlockedButton: boolean;
  30023. /**
  30024. * Event raised when audio has been unlocked on the browser.
  30025. */
  30026. onAudioUnlockedObservable: Observable<AudioEngine>;
  30027. /**
  30028. * Event raised when audio has been locked on the browser.
  30029. */
  30030. onAudioLockedObservable: Observable<AudioEngine>;
  30031. /**
  30032. * Gets the current AudioContext if available.
  30033. */
  30034. readonly audioContext: Nullable<AudioContext>;
  30035. private _connectedAnalyser;
  30036. /**
  30037. * Instantiates a new audio engine.
  30038. *
  30039. * There should be only one per page as some browsers restrict the number
  30040. * of audio contexts you can create.
  30041. * @param hostElement defines the host element where to display the mute icon if necessary
  30042. */
  30043. constructor(hostElement?: Nullable<HTMLElement>);
  30044. /**
  30045. * Flags the audio engine in Locked state.
  30046. * This happens due to new browser policies preventing audio to autoplay.
  30047. */
  30048. lock(): void;
  30049. /**
  30050. * Unlocks the audio engine once a user action has been done on the dom.
  30051. * This is helpful to resume play once browser policies have been satisfied.
  30052. */
  30053. unlock(): void;
  30054. private _resumeAudioContext;
  30055. private _initializeAudioContext;
  30056. private _tryToRun;
  30057. private _triggerRunningState;
  30058. private _triggerSuspendedState;
  30059. private _displayMuteButton;
  30060. private _moveButtonToTopLeft;
  30061. private _onResize;
  30062. private _hideMuteButton;
  30063. /**
  30064. * Destroy and release the resources associated with the audio ccontext.
  30065. */
  30066. dispose(): void;
  30067. /**
  30068. * Gets the global volume sets on the master gain.
  30069. * @returns the global volume if set or -1 otherwise
  30070. */
  30071. getGlobalVolume(): number;
  30072. /**
  30073. * Sets the global volume of your experience (sets on the master gain).
  30074. * @param newVolume Defines the new global volume of the application
  30075. */
  30076. setGlobalVolume(newVolume: number): void;
  30077. /**
  30078. * Connect the audio engine to an audio analyser allowing some amazing
  30079. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  30080. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  30081. * @param analyser The analyser to connect to the engine
  30082. */
  30083. connectToAnalyser(analyser: Analyser): void;
  30084. }
  30085. }
  30086. declare module "babylonjs/Loading/loadingScreen" {
  30087. /**
  30088. * Interface used to present a loading screen while loading a scene
  30089. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  30090. */
  30091. export interface ILoadingScreen {
  30092. /**
  30093. * Function called to display the loading screen
  30094. */
  30095. displayLoadingUI: () => void;
  30096. /**
  30097. * Function called to hide the loading screen
  30098. */
  30099. hideLoadingUI: () => void;
  30100. /**
  30101. * Gets or sets the color to use for the background
  30102. */
  30103. loadingUIBackgroundColor: string;
  30104. /**
  30105. * Gets or sets the text to display while loading
  30106. */
  30107. loadingUIText: string;
  30108. }
  30109. /**
  30110. * Class used for the default loading screen
  30111. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  30112. */
  30113. export class DefaultLoadingScreen implements ILoadingScreen {
  30114. private _renderingCanvas;
  30115. private _loadingText;
  30116. private _loadingDivBackgroundColor;
  30117. private _loadingDiv;
  30118. private _loadingTextDiv;
  30119. /** Gets or sets the logo url to use for the default loading screen */
  30120. static DefaultLogoUrl: string;
  30121. /** Gets or sets the spinner url to use for the default loading screen */
  30122. static DefaultSpinnerUrl: string;
  30123. /**
  30124. * Creates a new default loading screen
  30125. * @param _renderingCanvas defines the canvas used to render the scene
  30126. * @param _loadingText defines the default text to display
  30127. * @param _loadingDivBackgroundColor defines the default background color
  30128. */
  30129. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  30130. /**
  30131. * Function called to display the loading screen
  30132. */
  30133. displayLoadingUI(): void;
  30134. /**
  30135. * Function called to hide the loading screen
  30136. */
  30137. hideLoadingUI(): void;
  30138. /**
  30139. * Gets or sets the text to display while loading
  30140. */
  30141. loadingUIText: string;
  30142. /**
  30143. * Gets or sets the color to use for the background
  30144. */
  30145. loadingUIBackgroundColor: string;
  30146. private _resizeLoadingUI;
  30147. }
  30148. }
  30149. declare module "babylonjs/Engines/WebGL/webGLPipelineContext" {
  30150. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  30151. import { Engine } from "babylonjs/Engines/engine";
  30152. import { Nullable } from "babylonjs/types";
  30153. /** @hidden */
  30154. export class WebGLPipelineContext implements IPipelineContext {
  30155. engine: Engine;
  30156. program: Nullable<WebGLProgram>;
  30157. context?: WebGLRenderingContext;
  30158. vertexShader?: WebGLShader;
  30159. fragmentShader?: WebGLShader;
  30160. isParallelCompiled: boolean;
  30161. onCompiled?: () => void;
  30162. transformFeedback?: WebGLTransformFeedback | null;
  30163. readonly isAsync: boolean;
  30164. readonly isReady: boolean;
  30165. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  30166. }
  30167. }
  30168. declare module "babylonjs/Meshes/WebGL/webGLDataBuffer" {
  30169. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  30170. /** @hidden */
  30171. export class WebGLDataBuffer extends DataBuffer {
  30172. private _buffer;
  30173. constructor(resource: WebGLBuffer);
  30174. readonly underlyingResource: any;
  30175. }
  30176. }
  30177. declare module "babylonjs/Engines/WebGL/webGL2ShaderProcessors" {
  30178. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  30179. /** @hidden */
  30180. export class WebGL2ShaderProcessor implements IShaderProcessor {
  30181. attributeProcessor(attribute: string): string;
  30182. varyingProcessor(varying: string, isFragment: boolean): string;
  30183. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  30184. }
  30185. }
  30186. declare module "babylonjs/Misc/perfCounter" {
  30187. /**
  30188. * This class is used to track a performance counter which is number based.
  30189. * The user has access to many properties which give statistics of different nature.
  30190. *
  30191. * The implementer can track two kinds of Performance Counter: time and count.
  30192. * 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.
  30193. * 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.
  30194. */
  30195. export class PerfCounter {
  30196. /**
  30197. * Gets or sets a global boolean to turn on and off all the counters
  30198. */
  30199. static Enabled: boolean;
  30200. /**
  30201. * Returns the smallest value ever
  30202. */
  30203. readonly min: number;
  30204. /**
  30205. * Returns the biggest value ever
  30206. */
  30207. readonly max: number;
  30208. /**
  30209. * Returns the average value since the performance counter is running
  30210. */
  30211. readonly average: number;
  30212. /**
  30213. * Returns the average value of the last second the counter was monitored
  30214. */
  30215. readonly lastSecAverage: number;
  30216. /**
  30217. * Returns the current value
  30218. */
  30219. readonly current: number;
  30220. /**
  30221. * Gets the accumulated total
  30222. */
  30223. readonly total: number;
  30224. /**
  30225. * Gets the total value count
  30226. */
  30227. readonly count: number;
  30228. /**
  30229. * Creates a new counter
  30230. */
  30231. constructor();
  30232. /**
  30233. * Call this method to start monitoring a new frame.
  30234. * 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.
  30235. */
  30236. fetchNewFrame(): void;
  30237. /**
  30238. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  30239. * @param newCount the count value to add to the monitored count
  30240. * @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.
  30241. */
  30242. addCount(newCount: number, fetchResult: boolean): void;
  30243. /**
  30244. * Start monitoring this performance counter
  30245. */
  30246. beginMonitoring(): void;
  30247. /**
  30248. * Compute the time lapsed since the previous beginMonitoring() call.
  30249. * @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
  30250. */
  30251. endMonitoring(newFrame?: boolean): void;
  30252. private _fetchResult;
  30253. private _startMonitoringTime;
  30254. private _min;
  30255. private _max;
  30256. private _average;
  30257. private _current;
  30258. private _totalValueCount;
  30259. private _totalAccumulated;
  30260. private _lastSecAverage;
  30261. private _lastSecAccumulated;
  30262. private _lastSecTime;
  30263. private _lastSecValueCount;
  30264. }
  30265. }
  30266. declare module "babylonjs/Misc/customAnimationFrameRequester" {
  30267. /**
  30268. * Interface for any object that can request an animation frame
  30269. */
  30270. export interface ICustomAnimationFrameRequester {
  30271. /**
  30272. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  30273. */
  30274. renderFunction?: Function;
  30275. /**
  30276. * Called to request the next frame to render to
  30277. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  30278. */
  30279. requestAnimationFrame: Function;
  30280. /**
  30281. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  30282. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  30283. */
  30284. requestID?: number;
  30285. }
  30286. }
  30287. declare module "babylonjs/Materials/Textures/videoTexture" {
  30288. import { Observable } from "babylonjs/Misc/observable";
  30289. import { Nullable } from "babylonjs/types";
  30290. import { Scene } from "babylonjs/scene";
  30291. import { Texture } from "babylonjs/Materials/Textures/texture";
  30292. /**
  30293. * Settings for finer control over video usage
  30294. */
  30295. export interface VideoTextureSettings {
  30296. /**
  30297. * Applies `autoplay` to video, if specified
  30298. */
  30299. autoPlay?: boolean;
  30300. /**
  30301. * Applies `loop` to video, if specified
  30302. */
  30303. loop?: boolean;
  30304. /**
  30305. * Automatically updates internal texture from video at every frame in the render loop
  30306. */
  30307. autoUpdateTexture: boolean;
  30308. /**
  30309. * Image src displayed during the video loading or until the user interacts with the video.
  30310. */
  30311. poster?: string;
  30312. }
  30313. /**
  30314. * If you want to display a video in your scene, this is the special texture for that.
  30315. * This special texture works similar to other textures, with the exception of a few parameters.
  30316. * @see https://doc.babylonjs.com/how_to/video_texture
  30317. */
  30318. export class VideoTexture extends Texture {
  30319. /**
  30320. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  30321. */
  30322. readonly autoUpdateTexture: boolean;
  30323. /**
  30324. * The video instance used by the texture internally
  30325. */
  30326. readonly video: HTMLVideoElement;
  30327. private _onUserActionRequestedObservable;
  30328. /**
  30329. * Event triggerd when a dom action is required by the user to play the video.
  30330. * This happens due to recent changes in browser policies preventing video to auto start.
  30331. */
  30332. readonly onUserActionRequestedObservable: Observable<Texture>;
  30333. private _generateMipMaps;
  30334. private _engine;
  30335. private _stillImageCaptured;
  30336. private _displayingPosterTexture;
  30337. private _settings;
  30338. private _createInternalTextureOnEvent;
  30339. private _frameId;
  30340. /**
  30341. * Creates a video texture.
  30342. * If you want to display a video in your scene, this is the special texture for that.
  30343. * This special texture works similar to other textures, with the exception of a few parameters.
  30344. * @see https://doc.babylonjs.com/how_to/video_texture
  30345. * @param name optional name, will detect from video source, if not defined
  30346. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  30347. * @param scene is obviously the current scene.
  30348. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  30349. * @param invertY is false by default but can be used to invert video on Y axis
  30350. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  30351. * @param settings allows finer control over video usage
  30352. */
  30353. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  30354. private _getName;
  30355. private _getVideo;
  30356. private _createInternalTexture;
  30357. private reset;
  30358. /**
  30359. * @hidden Internal method to initiate `update`.
  30360. */
  30361. _rebuild(): void;
  30362. /**
  30363. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  30364. */
  30365. update(): void;
  30366. /**
  30367. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  30368. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  30369. */
  30370. updateTexture(isVisible: boolean): void;
  30371. protected _updateInternalTexture: () => void;
  30372. /**
  30373. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  30374. * @param url New url.
  30375. */
  30376. updateURL(url: string): void;
  30377. /**
  30378. * Dispose the texture and release its associated resources.
  30379. */
  30380. dispose(): void;
  30381. /**
  30382. * Creates a video texture straight from a stream.
  30383. * @param scene Define the scene the texture should be created in
  30384. * @param stream Define the stream the texture should be created from
  30385. * @returns The created video texture as a promise
  30386. */
  30387. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  30388. /**
  30389. * Creates a video texture straight from your WebCam video feed.
  30390. * @param scene Define the scene the texture should be created in
  30391. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  30392. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  30393. * @returns The created video texture as a promise
  30394. */
  30395. static CreateFromWebCamAsync(scene: Scene, constraints: {
  30396. minWidth: number;
  30397. maxWidth: number;
  30398. minHeight: number;
  30399. maxHeight: number;
  30400. deviceId: string;
  30401. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  30402. /**
  30403. * Creates a video texture straight from your WebCam video feed.
  30404. * @param scene Define the scene the texture should be created in
  30405. * @param onReady Define a callback to triggered once the texture will be ready
  30406. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  30407. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  30408. */
  30409. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  30410. minWidth: number;
  30411. maxWidth: number;
  30412. minHeight: number;
  30413. maxHeight: number;
  30414. deviceId: string;
  30415. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  30416. }
  30417. }
  30418. declare module "babylonjs/Engines/engine" {
  30419. import { Observable } from "babylonjs/Misc/observable";
  30420. import { PerformanceMonitor } from "babylonjs/Misc/performanceMonitor";
  30421. import { Nullable, FloatArray, DataArray, IndicesArray } from "babylonjs/types";
  30422. import { Scene } from "babylonjs/scene";
  30423. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  30424. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  30425. import { Effect, EffectCreationOptions, EffectFallbacks } from "babylonjs/Materials/effect";
  30426. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  30427. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  30428. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  30429. import { IAudioEngine } from "babylonjs/Audio/audioEngine";
  30430. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  30431. import { ILoadingScreen } from "babylonjs/Loading/loadingScreen";
  30432. import { _DepthCullingState, _StencilState, _AlphaState } from "babylonjs/States/index";
  30433. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  30434. import { WebRequest } from "babylonjs/Misc/webRequest";
  30435. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  30436. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  30437. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  30438. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  30439. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  30440. import { ICustomAnimationFrameRequester } from "babylonjs/Misc/customAnimationFrameRequester";
  30441. import { IViewportLike, IColor4Like } from "babylonjs/Maths/math.like";
  30442. import { Material } from "babylonjs/Materials/material";
  30443. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  30444. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  30445. /**
  30446. * Defines the interface used by objects containing a viewport (like a camera)
  30447. */
  30448. interface IViewportOwnerLike {
  30449. /**
  30450. * Gets or sets the viewport
  30451. */
  30452. viewport: IViewportLike;
  30453. }
  30454. /**
  30455. * Interface for attribute information associated with buffer instanciation
  30456. */
  30457. export class InstancingAttributeInfo {
  30458. /**
  30459. * Index/offset of the attribute in the vertex shader
  30460. */
  30461. index: number;
  30462. /**
  30463. * size of the attribute, 1, 2, 3 or 4
  30464. */
  30465. attributeSize: number;
  30466. /**
  30467. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  30468. * default is FLOAT
  30469. */
  30470. attribyteType: number;
  30471. /**
  30472. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  30473. */
  30474. normalized: boolean;
  30475. /**
  30476. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  30477. */
  30478. offset: number;
  30479. /**
  30480. * Name of the GLSL attribute, for debugging purpose only
  30481. */
  30482. attributeName: string;
  30483. }
  30484. /**
  30485. * Define options used to create a depth texture
  30486. */
  30487. export class DepthTextureCreationOptions {
  30488. /** Specifies whether or not a stencil should be allocated in the texture */
  30489. generateStencil?: boolean;
  30490. /** Specifies whether or not bilinear filtering is enable on the texture */
  30491. bilinearFiltering?: boolean;
  30492. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  30493. comparisonFunction?: number;
  30494. /** Specifies if the created texture is a cube texture */
  30495. isCube?: boolean;
  30496. }
  30497. /**
  30498. * Class used to describe the capabilities of the engine relatively to the current browser
  30499. */
  30500. export class EngineCapabilities {
  30501. /** Maximum textures units per fragment shader */
  30502. maxTexturesImageUnits: number;
  30503. /** Maximum texture units per vertex shader */
  30504. maxVertexTextureImageUnits: number;
  30505. /** Maximum textures units in the entire pipeline */
  30506. maxCombinedTexturesImageUnits: number;
  30507. /** Maximum texture size */
  30508. maxTextureSize: number;
  30509. /** Maximum cube texture size */
  30510. maxCubemapTextureSize: number;
  30511. /** Maximum render texture size */
  30512. maxRenderTextureSize: number;
  30513. /** Maximum number of vertex attributes */
  30514. maxVertexAttribs: number;
  30515. /** Maximum number of varyings */
  30516. maxVaryingVectors: number;
  30517. /** Maximum number of uniforms per vertex shader */
  30518. maxVertexUniformVectors: number;
  30519. /** Maximum number of uniforms per fragment shader */
  30520. maxFragmentUniformVectors: number;
  30521. /** Defines if standard derivates (dx/dy) are supported */
  30522. standardDerivatives: boolean;
  30523. /** Defines if s3tc texture compression is supported */
  30524. s3tc: Nullable<WEBGL_compressed_texture_s3tc>;
  30525. /** Defines if pvrtc texture compression is supported */
  30526. pvrtc: any;
  30527. /** Defines if etc1 texture compression is supported */
  30528. etc1: any;
  30529. /** Defines if etc2 texture compression is supported */
  30530. etc2: any;
  30531. /** Defines if astc texture compression is supported */
  30532. astc: any;
  30533. /** Defines if float textures are supported */
  30534. textureFloat: boolean;
  30535. /** Defines if vertex array objects are supported */
  30536. vertexArrayObject: boolean;
  30537. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  30538. textureAnisotropicFilterExtension: Nullable<EXT_texture_filter_anisotropic>;
  30539. /** Gets the maximum level of anisotropy supported */
  30540. maxAnisotropy: number;
  30541. /** Defines if instancing is supported */
  30542. instancedArrays: boolean;
  30543. /** Defines if 32 bits indices are supported */
  30544. uintIndices: boolean;
  30545. /** Defines if high precision shaders are supported */
  30546. highPrecisionShaderSupported: boolean;
  30547. /** Defines if depth reading in the fragment shader is supported */
  30548. fragmentDepthSupported: boolean;
  30549. /** Defines if float texture linear filtering is supported*/
  30550. textureFloatLinearFiltering: boolean;
  30551. /** Defines if rendering to float textures is supported */
  30552. textureFloatRender: boolean;
  30553. /** Defines if half float textures are supported*/
  30554. textureHalfFloat: boolean;
  30555. /** Defines if half float texture linear filtering is supported*/
  30556. textureHalfFloatLinearFiltering: boolean;
  30557. /** Defines if rendering to half float textures is supported */
  30558. textureHalfFloatRender: boolean;
  30559. /** Defines if textureLOD shader command is supported */
  30560. textureLOD: boolean;
  30561. /** Defines if draw buffers extension is supported */
  30562. drawBuffersExtension: boolean;
  30563. /** Defines if depth textures are supported */
  30564. depthTextureExtension: boolean;
  30565. /** Defines if float color buffer are supported */
  30566. colorBufferFloat: boolean;
  30567. /** Gets disjoint timer query extension (null if not supported) */
  30568. timerQuery: EXT_disjoint_timer_query;
  30569. /** Defines if timestamp can be used with timer query */
  30570. canUseTimestampForTimerQuery: boolean;
  30571. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  30572. multiview: any;
  30573. /** Function used to let the system compiles shaders in background */
  30574. parallelShaderCompile: {
  30575. COMPLETION_STATUS_KHR: number;
  30576. };
  30577. /** Max number of texture samples for MSAA */
  30578. maxMSAASamples: number;
  30579. }
  30580. /** Interface defining initialization parameters for Engine class */
  30581. export interface EngineOptions extends WebGLContextAttributes {
  30582. /**
  30583. * Defines if the engine should no exceed a specified device ratio
  30584. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  30585. */
  30586. limitDeviceRatio?: number;
  30587. /**
  30588. * Defines if webvr should be enabled automatically
  30589. * @see http://doc.babylonjs.com/how_to/webvr_camera
  30590. */
  30591. autoEnableWebVR?: boolean;
  30592. /**
  30593. * Defines if webgl2 should be turned off even if supported
  30594. * @see http://doc.babylonjs.com/features/webgl2
  30595. */
  30596. disableWebGL2Support?: boolean;
  30597. /**
  30598. * Defines if webaudio should be initialized as well
  30599. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  30600. */
  30601. audioEngine?: boolean;
  30602. /**
  30603. * Defines if animations should run using a deterministic lock step
  30604. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  30605. */
  30606. deterministicLockstep?: boolean;
  30607. /** Defines the maximum steps to use with deterministic lock step mode */
  30608. lockstepMaxSteps?: number;
  30609. /**
  30610. * Defines that engine should ignore context lost events
  30611. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  30612. */
  30613. doNotHandleContextLost?: boolean;
  30614. /**
  30615. * Defines that engine should ignore modifying touch action attribute and style
  30616. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  30617. */
  30618. doNotHandleTouchAction?: boolean;
  30619. /**
  30620. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  30621. */
  30622. useHighPrecisionFloats?: boolean;
  30623. }
  30624. /**
  30625. * Defines the interface used by display changed events
  30626. */
  30627. export interface IDisplayChangedEventArgs {
  30628. /** Gets the vrDisplay object (if any) */
  30629. vrDisplay: Nullable<any>;
  30630. /** Gets a boolean indicating if webVR is supported */
  30631. vrSupported: boolean;
  30632. }
  30633. /**
  30634. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  30635. */
  30636. export class Engine {
  30637. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  30638. static ExceptionList: ({
  30639. key: string;
  30640. capture: string;
  30641. captureConstraint: number;
  30642. targets: string[];
  30643. } | {
  30644. key: string;
  30645. capture: null;
  30646. captureConstraint: null;
  30647. targets: string[];
  30648. })[];
  30649. /** Gets the list of created engines */
  30650. static readonly Instances: Engine[];
  30651. /**
  30652. * Gets the latest created engine
  30653. */
  30654. static readonly LastCreatedEngine: Nullable<Engine>;
  30655. /**
  30656. * Gets the latest created scene
  30657. */
  30658. static readonly LastCreatedScene: Nullable<Scene>;
  30659. /**
  30660. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  30661. * @param flag defines which part of the materials must be marked as dirty
  30662. * @param predicate defines a predicate used to filter which materials should be affected
  30663. */
  30664. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  30665. /** @hidden */
  30666. static _TextureLoaders: IInternalTextureLoader[];
  30667. /** Defines that alpha blending is disabled */
  30668. static readonly ALPHA_DISABLE: number;
  30669. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  30670. static readonly ALPHA_ADD: number;
  30671. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  30672. static readonly ALPHA_COMBINE: number;
  30673. /** Defines that alpha blending to DEST - SRC * DEST */
  30674. static readonly ALPHA_SUBTRACT: number;
  30675. /** Defines that alpha blending to SRC * DEST */
  30676. static readonly ALPHA_MULTIPLY: number;
  30677. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  30678. static readonly ALPHA_MAXIMIZED: number;
  30679. /** Defines that alpha blending to SRC + DEST */
  30680. static readonly ALPHA_ONEONE: number;
  30681. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  30682. static readonly ALPHA_PREMULTIPLIED: number;
  30683. /**
  30684. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  30685. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  30686. */
  30687. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  30688. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  30689. static readonly ALPHA_INTERPOLATE: number;
  30690. /**
  30691. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  30692. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  30693. */
  30694. static readonly ALPHA_SCREENMODE: number;
  30695. /** Defines that the ressource is not delayed*/
  30696. static readonly DELAYLOADSTATE_NONE: number;
  30697. /** Defines that the ressource was successfully delay loaded */
  30698. static readonly DELAYLOADSTATE_LOADED: number;
  30699. /** Defines that the ressource is currently delay loading */
  30700. static readonly DELAYLOADSTATE_LOADING: number;
  30701. /** Defines that the ressource is delayed and has not started loading */
  30702. static readonly DELAYLOADSTATE_NOTLOADED: number;
  30703. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  30704. static readonly NEVER: number;
  30705. /** 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 */
  30706. static readonly ALWAYS: number;
  30707. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  30708. static readonly LESS: number;
  30709. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  30710. static readonly EQUAL: number;
  30711. /** 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 */
  30712. static readonly LEQUAL: number;
  30713. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  30714. static readonly GREATER: number;
  30715. /** 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 */
  30716. static readonly GEQUAL: number;
  30717. /** 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 */
  30718. static readonly NOTEQUAL: number;
  30719. /** Passed to stencilOperation to specify that stencil value must be kept */
  30720. static readonly KEEP: number;
  30721. /** Passed to stencilOperation to specify that stencil value must be replaced */
  30722. static readonly REPLACE: number;
  30723. /** Passed to stencilOperation to specify that stencil value must be incremented */
  30724. static readonly INCR: number;
  30725. /** Passed to stencilOperation to specify that stencil value must be decremented */
  30726. static readonly DECR: number;
  30727. /** Passed to stencilOperation to specify that stencil value must be inverted */
  30728. static readonly INVERT: number;
  30729. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  30730. static readonly INCR_WRAP: number;
  30731. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  30732. static readonly DECR_WRAP: number;
  30733. /** Texture is not repeating outside of 0..1 UVs */
  30734. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  30735. /** Texture is repeating outside of 0..1 UVs */
  30736. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  30737. /** Texture is repeating and mirrored */
  30738. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  30739. /** ALPHA */
  30740. static readonly TEXTUREFORMAT_ALPHA: number;
  30741. /** LUMINANCE */
  30742. static readonly TEXTUREFORMAT_LUMINANCE: number;
  30743. /** LUMINANCE_ALPHA */
  30744. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  30745. /** RGB */
  30746. static readonly TEXTUREFORMAT_RGB: number;
  30747. /** RGBA */
  30748. static readonly TEXTUREFORMAT_RGBA: number;
  30749. /** RED */
  30750. static readonly TEXTUREFORMAT_RED: number;
  30751. /** RED (2nd reference) */
  30752. static readonly TEXTUREFORMAT_R: number;
  30753. /** RG */
  30754. static readonly TEXTUREFORMAT_RG: number;
  30755. /** RED_INTEGER */
  30756. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  30757. /** RED_INTEGER (2nd reference) */
  30758. static readonly TEXTUREFORMAT_R_INTEGER: number;
  30759. /** RG_INTEGER */
  30760. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  30761. /** RGB_INTEGER */
  30762. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  30763. /** RGBA_INTEGER */
  30764. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  30765. /** UNSIGNED_BYTE */
  30766. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  30767. /** UNSIGNED_BYTE (2nd reference) */
  30768. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  30769. /** FLOAT */
  30770. static readonly TEXTURETYPE_FLOAT: number;
  30771. /** HALF_FLOAT */
  30772. static readonly TEXTURETYPE_HALF_FLOAT: number;
  30773. /** BYTE */
  30774. static readonly TEXTURETYPE_BYTE: number;
  30775. /** SHORT */
  30776. static readonly TEXTURETYPE_SHORT: number;
  30777. /** UNSIGNED_SHORT */
  30778. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  30779. /** INT */
  30780. static readonly TEXTURETYPE_INT: number;
  30781. /** UNSIGNED_INT */
  30782. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  30783. /** UNSIGNED_SHORT_4_4_4_4 */
  30784. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  30785. /** UNSIGNED_SHORT_5_5_5_1 */
  30786. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  30787. /** UNSIGNED_SHORT_5_6_5 */
  30788. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  30789. /** UNSIGNED_INT_2_10_10_10_REV */
  30790. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  30791. /** UNSIGNED_INT_24_8 */
  30792. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  30793. /** UNSIGNED_INT_10F_11F_11F_REV */
  30794. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  30795. /** UNSIGNED_INT_5_9_9_9_REV */
  30796. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  30797. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  30798. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  30799. /** nearest is mag = nearest and min = nearest and mip = linear */
  30800. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  30801. /** Bilinear is mag = linear and min = linear and mip = nearest */
  30802. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  30803. /** Trilinear is mag = linear and min = linear and mip = linear */
  30804. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  30805. /** nearest is mag = nearest and min = nearest and mip = linear */
  30806. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  30807. /** Bilinear is mag = linear and min = linear and mip = nearest */
  30808. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  30809. /** Trilinear is mag = linear and min = linear and mip = linear */
  30810. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  30811. /** mag = nearest and min = nearest and mip = nearest */
  30812. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  30813. /** mag = nearest and min = linear and mip = nearest */
  30814. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  30815. /** mag = nearest and min = linear and mip = linear */
  30816. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  30817. /** mag = nearest and min = linear and mip = none */
  30818. static readonly TEXTURE_NEAREST_LINEAR: number;
  30819. /** mag = nearest and min = nearest and mip = none */
  30820. static readonly TEXTURE_NEAREST_NEAREST: number;
  30821. /** mag = linear and min = nearest and mip = nearest */
  30822. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  30823. /** mag = linear and min = nearest and mip = linear */
  30824. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  30825. /** mag = linear and min = linear and mip = none */
  30826. static readonly TEXTURE_LINEAR_LINEAR: number;
  30827. /** mag = linear and min = nearest and mip = none */
  30828. static readonly TEXTURE_LINEAR_NEAREST: number;
  30829. /** Explicit coordinates mode */
  30830. static readonly TEXTURE_EXPLICIT_MODE: number;
  30831. /** Spherical coordinates mode */
  30832. static readonly TEXTURE_SPHERICAL_MODE: number;
  30833. /** Planar coordinates mode */
  30834. static readonly TEXTURE_PLANAR_MODE: number;
  30835. /** Cubic coordinates mode */
  30836. static readonly TEXTURE_CUBIC_MODE: number;
  30837. /** Projection coordinates mode */
  30838. static readonly TEXTURE_PROJECTION_MODE: number;
  30839. /** Skybox coordinates mode */
  30840. static readonly TEXTURE_SKYBOX_MODE: number;
  30841. /** Inverse Cubic coordinates mode */
  30842. static readonly TEXTURE_INVCUBIC_MODE: number;
  30843. /** Equirectangular coordinates mode */
  30844. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  30845. /** Equirectangular Fixed coordinates mode */
  30846. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  30847. /** Equirectangular Fixed Mirrored coordinates mode */
  30848. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  30849. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  30850. static readonly SCALEMODE_FLOOR: number;
  30851. /** Defines that texture rescaling will look for the nearest power of 2 size */
  30852. static readonly SCALEMODE_NEAREST: number;
  30853. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  30854. static readonly SCALEMODE_CEILING: number;
  30855. /**
  30856. * Returns the current npm package of the sdk
  30857. */
  30858. static readonly NpmPackage: string;
  30859. /**
  30860. * Returns the current version of the framework
  30861. */
  30862. static readonly Version: string;
  30863. /**
  30864. * Returns a string describing the current engine
  30865. */
  30866. readonly description: string;
  30867. /**
  30868. * Gets or sets the epsilon value used by collision engine
  30869. */
  30870. static CollisionsEpsilon: number;
  30871. /**
  30872. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  30873. */
  30874. static ShadersRepository: string;
  30875. /**
  30876. * Method called to create the default loading screen.
  30877. * This can be overriden in your own app.
  30878. * @param canvas The rendering canvas element
  30879. * @returns The loading screen
  30880. */
  30881. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  30882. /**
  30883. * Method called to create the default rescale post process on each engine.
  30884. */
  30885. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  30886. /** @hidden */
  30887. _shaderProcessor: IShaderProcessor;
  30888. /**
  30889. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  30890. */
  30891. forcePOTTextures: boolean;
  30892. /**
  30893. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  30894. */
  30895. isFullscreen: boolean;
  30896. /**
  30897. * Gets a boolean indicating if the pointer is currently locked
  30898. */
  30899. isPointerLock: boolean;
  30900. /**
  30901. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  30902. */
  30903. cullBackFaces: boolean;
  30904. /**
  30905. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  30906. */
  30907. renderEvenInBackground: boolean;
  30908. /**
  30909. * Gets or sets a boolean indicating that cache can be kept between frames
  30910. */
  30911. preventCacheWipeBetweenFrames: boolean;
  30912. /**
  30913. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  30914. **/
  30915. enableOfflineSupport: boolean;
  30916. /**
  30917. * 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)
  30918. **/
  30919. disableManifestCheck: boolean;
  30920. /**
  30921. * Gets the list of created scenes
  30922. */
  30923. scenes: Scene[];
  30924. /**
  30925. * Event raised when a new scene is created
  30926. */
  30927. onNewSceneAddedObservable: Observable<Scene>;
  30928. /**
  30929. * Gets the list of created postprocesses
  30930. */
  30931. postProcesses: import("babylonjs/PostProcesses/postProcess").PostProcess[];
  30932. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  30933. validateShaderPrograms: boolean;
  30934. /**
  30935. * Observable event triggered each time the rendering canvas is resized
  30936. */
  30937. onResizeObservable: Observable<Engine>;
  30938. /**
  30939. * Observable event triggered each time the canvas loses focus
  30940. */
  30941. onCanvasBlurObservable: Observable<Engine>;
  30942. /**
  30943. * Observable event triggered each time the canvas gains focus
  30944. */
  30945. onCanvasFocusObservable: Observable<Engine>;
  30946. /**
  30947. * Observable event triggered each time the canvas receives pointerout event
  30948. */
  30949. onCanvasPointerOutObservable: Observable<PointerEvent>;
  30950. /**
  30951. * Observable event triggered before each texture is initialized
  30952. */
  30953. onBeforeTextureInitObservable: Observable<import("babylonjs/Materials/Textures/texture").Texture>;
  30954. /**
  30955. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  30956. */
  30957. disableUniformBuffers: boolean;
  30958. /** @hidden */
  30959. _uniformBuffers: UniformBuffer[];
  30960. /**
  30961. * Gets a boolean indicating that the engine supports uniform buffers
  30962. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  30963. */
  30964. readonly supportsUniformBuffers: boolean;
  30965. /**
  30966. * Observable raised when the engine begins a new frame
  30967. */
  30968. onBeginFrameObservable: Observable<Engine>;
  30969. /**
  30970. * If set, will be used to request the next animation frame for the render loop
  30971. */
  30972. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  30973. /**
  30974. * Observable raised when the engine ends the current frame
  30975. */
  30976. onEndFrameObservable: Observable<Engine>;
  30977. /**
  30978. * Observable raised when the engine is about to compile a shader
  30979. */
  30980. onBeforeShaderCompilationObservable: Observable<Engine>;
  30981. /**
  30982. * Observable raised when the engine has jsut compiled a shader
  30983. */
  30984. onAfterShaderCompilationObservable: Observable<Engine>;
  30985. /** @hidden */
  30986. _gl: WebGLRenderingContext;
  30987. private _renderingCanvas;
  30988. private _windowIsBackground;
  30989. protected _webGLVersion: number;
  30990. protected _highPrecisionShadersAllowed: boolean;
  30991. /** @hidden */
  30992. readonly _shouldUseHighPrecisionShader: boolean;
  30993. /**
  30994. * Gets a boolean indicating that only power of 2 textures are supported
  30995. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  30996. */
  30997. readonly needPOTTextures: boolean;
  30998. /** @hidden */
  30999. _badOS: boolean;
  31000. /** @hidden */
  31001. _badDesktopOS: boolean;
  31002. /**
  31003. * Gets the audio engine
  31004. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  31005. * @ignorenaming
  31006. */
  31007. static audioEngine: IAudioEngine;
  31008. /**
  31009. * Default AudioEngine factory responsible of creating the Audio Engine.
  31010. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  31011. */
  31012. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  31013. /**
  31014. * Default offline support factory responsible of creating a tool used to store data locally.
  31015. * By default, this will create a Database object if the workload has been embedded.
  31016. */
  31017. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  31018. private _onFocus;
  31019. private _onBlur;
  31020. private _onCanvasPointerOut;
  31021. private _onCanvasBlur;
  31022. private _onCanvasFocus;
  31023. private _onFullscreenChange;
  31024. private _onPointerLockChange;
  31025. private _hardwareScalingLevel;
  31026. /** @hidden */
  31027. _caps: EngineCapabilities;
  31028. private _pointerLockRequested;
  31029. private _isStencilEnable;
  31030. protected _colorWrite: boolean;
  31031. private _loadingScreen;
  31032. /** @hidden */
  31033. _drawCalls: PerfCounter;
  31034. private _glVersion;
  31035. private _glRenderer;
  31036. private _glVendor;
  31037. private _videoTextureSupported;
  31038. private _renderingQueueLaunched;
  31039. private _activeRenderLoops;
  31040. private _deterministicLockstep;
  31041. private _lockstepMaxSteps;
  31042. /**
  31043. * Observable signaled when a context lost event is raised
  31044. */
  31045. onContextLostObservable: Observable<Engine>;
  31046. /**
  31047. * Observable signaled when a context restored event is raised
  31048. */
  31049. onContextRestoredObservable: Observable<Engine>;
  31050. private _onContextLost;
  31051. private _onContextRestored;
  31052. private _contextWasLost;
  31053. /** @hidden */
  31054. _doNotHandleContextLost: boolean;
  31055. /**
  31056. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  31057. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  31058. */
  31059. doNotHandleContextLost: boolean;
  31060. private _performanceMonitor;
  31061. private _fps;
  31062. private _deltaTime;
  31063. /**
  31064. * Turn this value on if you want to pause FPS computation when in background
  31065. */
  31066. disablePerformanceMonitorInBackground: boolean;
  31067. /**
  31068. * Gets the performance monitor attached to this engine
  31069. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  31070. */
  31071. readonly performanceMonitor: PerformanceMonitor;
  31072. /**
  31073. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  31074. */
  31075. disableVertexArrayObjects: boolean;
  31076. /** @hidden */
  31077. protected _depthCullingState: _DepthCullingState;
  31078. /** @hidden */
  31079. protected _stencilState: _StencilState;
  31080. /** @hidden */
  31081. protected _alphaState: _AlphaState;
  31082. /** @hidden */
  31083. protected _alphaMode: number;
  31084. /** @hidden */
  31085. _internalTexturesCache: InternalTexture[];
  31086. /** @hidden */
  31087. protected _activeChannel: number;
  31088. private _currentTextureChannel;
  31089. /** @hidden */
  31090. protected _boundTexturesCache: {
  31091. [key: string]: Nullable<InternalTexture>;
  31092. };
  31093. /** @hidden */
  31094. protected _currentEffect: Nullable<Effect>;
  31095. /** @hidden */
  31096. protected _currentProgram: Nullable<WebGLProgram>;
  31097. private _compiledEffects;
  31098. private _vertexAttribArraysEnabled;
  31099. /** @hidden */
  31100. protected _cachedViewport: Nullable<IViewportLike>;
  31101. private _cachedVertexArrayObject;
  31102. /** @hidden */
  31103. protected _cachedVertexBuffers: any;
  31104. /** @hidden */
  31105. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  31106. /** @hidden */
  31107. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  31108. /** @hidden */
  31109. _currentRenderTarget: Nullable<InternalTexture>;
  31110. private _uintIndicesCurrentlySet;
  31111. private _currentBoundBuffer;
  31112. /** @hidden */
  31113. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  31114. private _currentBufferPointers;
  31115. private _currentInstanceLocations;
  31116. private _currentInstanceBuffers;
  31117. private _textureUnits;
  31118. /** @hidden */
  31119. _workingCanvas: Nullable<HTMLCanvasElement>;
  31120. /** @hidden */
  31121. _workingContext: Nullable<CanvasRenderingContext2D>;
  31122. private _rescalePostProcess;
  31123. private _dummyFramebuffer;
  31124. private _externalData;
  31125. /** @hidden */
  31126. _bindedRenderFunction: any;
  31127. private _vaoRecordInProgress;
  31128. private _mustWipeVertexAttributes;
  31129. private _emptyTexture;
  31130. private _emptyCubeTexture;
  31131. private _emptyTexture3D;
  31132. /** @hidden */
  31133. _frameHandler: number;
  31134. private _nextFreeTextureSlots;
  31135. private _maxSimultaneousTextures;
  31136. private _activeRequests;
  31137. private _texturesSupported;
  31138. /** @hidden */
  31139. _textureFormatInUse: Nullable<string>;
  31140. /**
  31141. * Gets the list of texture formats supported
  31142. */
  31143. readonly texturesSupported: Array<string>;
  31144. /**
  31145. * Gets the list of texture formats in use
  31146. */
  31147. readonly textureFormatInUse: Nullable<string>;
  31148. /**
  31149. * Gets the current viewport
  31150. */
  31151. readonly currentViewport: Nullable<IViewportLike>;
  31152. /**
  31153. * Gets the default empty texture
  31154. */
  31155. readonly emptyTexture: InternalTexture;
  31156. /**
  31157. * Gets the default empty 3D texture
  31158. */
  31159. readonly emptyTexture3D: InternalTexture;
  31160. /**
  31161. * Gets the default empty cube texture
  31162. */
  31163. readonly emptyCubeTexture: InternalTexture;
  31164. /**
  31165. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  31166. */
  31167. readonly premultipliedAlpha: boolean;
  31168. /**
  31169. * Creates a new engine
  31170. * @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
  31171. * @param antialias defines enable antialiasing (default: false)
  31172. * @param options defines further options to be sent to the getContext() function
  31173. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  31174. */
  31175. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  31176. /**
  31177. * Initializes a webVR display and starts listening to display change events
  31178. * The onVRDisplayChangedObservable will be notified upon these changes
  31179. * @returns The onVRDisplayChangedObservable
  31180. */
  31181. initWebVR(): Observable<IDisplayChangedEventArgs>;
  31182. /** @hidden */
  31183. _prepareVRComponent(): void;
  31184. /** @hidden */
  31185. _connectVREvents(canvas: HTMLCanvasElement, document: any): void;
  31186. /** @hidden */
  31187. _submitVRFrame(): void;
  31188. /**
  31189. * Call this function to leave webVR mode
  31190. * Will do nothing if webVR is not supported or if there is no webVR device
  31191. * @see http://doc.babylonjs.com/how_to/webvr_camera
  31192. */
  31193. disableVR(): void;
  31194. /**
  31195. * Gets a boolean indicating that the system is in VR mode and is presenting
  31196. * @returns true if VR mode is engaged
  31197. */
  31198. isVRPresenting(): boolean;
  31199. /** @hidden */
  31200. _requestVRFrame(): void;
  31201. private _disableTouchAction;
  31202. private _rebuildInternalTextures;
  31203. private _rebuildEffects;
  31204. /**
  31205. * Gets a boolean indicating if all created effects are ready
  31206. * @returns true if all effects are ready
  31207. */
  31208. areAllEffectsReady(): boolean;
  31209. private _rebuildBuffers;
  31210. private _initGLContext;
  31211. /**
  31212. * Gets version of the current webGL context
  31213. */
  31214. readonly webGLVersion: number;
  31215. /**
  31216. * Gets a string idenfifying the name of the class
  31217. * @returns "Engine" string
  31218. */
  31219. getClassName(): string;
  31220. /**
  31221. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  31222. */
  31223. readonly isStencilEnable: boolean;
  31224. /** @hidden */
  31225. _prepareWorkingCanvas(): void;
  31226. /**
  31227. * Reset the texture cache to empty state
  31228. */
  31229. resetTextureCache(): void;
  31230. /**
  31231. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  31232. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  31233. * @returns true if engine is in deterministic lock step mode
  31234. */
  31235. isDeterministicLockStep(): boolean;
  31236. /**
  31237. * Gets the max steps when engine is running in deterministic lock step
  31238. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  31239. * @returns the max steps
  31240. */
  31241. getLockstepMaxSteps(): number;
  31242. /**
  31243. * Gets an object containing information about the current webGL context
  31244. * @returns an object containing the vender, the renderer and the version of the current webGL context
  31245. */
  31246. getGlInfo(): {
  31247. vendor: string;
  31248. renderer: string;
  31249. version: string;
  31250. };
  31251. /**
  31252. * Gets current aspect ratio
  31253. * @param viewportOwner defines the camera to use to get the aspect ratio
  31254. * @param useScreen defines if screen size must be used (or the current render target if any)
  31255. * @returns a number defining the aspect ratio
  31256. */
  31257. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  31258. /**
  31259. * Gets current screen aspect ratio
  31260. * @returns a number defining the aspect ratio
  31261. */
  31262. getScreenAspectRatio(): number;
  31263. /**
  31264. * Gets the current render width
  31265. * @param useScreen defines if screen size must be used (or the current render target if any)
  31266. * @returns a number defining the current render width
  31267. */
  31268. getRenderWidth(useScreen?: boolean): number;
  31269. /**
  31270. * Gets the current render height
  31271. * @param useScreen defines if screen size must be used (or the current render target if any)
  31272. * @returns a number defining the current render height
  31273. */
  31274. getRenderHeight(useScreen?: boolean): number;
  31275. /**
  31276. * Gets the HTML canvas attached with the current webGL context
  31277. * @returns a HTML canvas
  31278. */
  31279. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  31280. /**
  31281. * Gets host window
  31282. * @returns the host window object
  31283. */
  31284. getHostWindow(): Window;
  31285. /**
  31286. * Gets host document
  31287. * @returns the host document object
  31288. */
  31289. getHostDocument(): Document;
  31290. /**
  31291. * Gets the client rect of the HTML canvas attached with the current webGL context
  31292. * @returns a client rectanglee
  31293. */
  31294. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  31295. /**
  31296. * Defines the hardware scaling level.
  31297. * By default the hardware scaling level is computed from the window device ratio.
  31298. * 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.
  31299. * @param level defines the level to use
  31300. */
  31301. setHardwareScalingLevel(level: number): void;
  31302. /**
  31303. * Gets the current hardware scaling level.
  31304. * By default the hardware scaling level is computed from the window device ratio.
  31305. * 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.
  31306. * @returns a number indicating the current hardware scaling level
  31307. */
  31308. getHardwareScalingLevel(): number;
  31309. /**
  31310. * Gets the list of loaded textures
  31311. * @returns an array containing all loaded textures
  31312. */
  31313. getLoadedTexturesCache(): InternalTexture[];
  31314. /**
  31315. * Gets the object containing all engine capabilities
  31316. * @returns the EngineCapabilities object
  31317. */
  31318. getCaps(): EngineCapabilities;
  31319. /**
  31320. * Gets the current depth function
  31321. * @returns a number defining the depth function
  31322. */
  31323. getDepthFunction(): Nullable<number>;
  31324. /**
  31325. * Sets the current depth function
  31326. * @param depthFunc defines the function to use
  31327. */
  31328. setDepthFunction(depthFunc: number): void;
  31329. /**
  31330. * Sets the current depth function to GREATER
  31331. */
  31332. setDepthFunctionToGreater(): void;
  31333. /**
  31334. * Sets the current depth function to GEQUAL
  31335. */
  31336. setDepthFunctionToGreaterOrEqual(): void;
  31337. /**
  31338. * Sets the current depth function to LESS
  31339. */
  31340. setDepthFunctionToLess(): void;
  31341. private _cachedStencilBuffer;
  31342. private _cachedStencilFunction;
  31343. private _cachedStencilMask;
  31344. private _cachedStencilOperationPass;
  31345. private _cachedStencilOperationFail;
  31346. private _cachedStencilOperationDepthFail;
  31347. private _cachedStencilReference;
  31348. /**
  31349. * Caches the the state of the stencil buffer
  31350. */
  31351. cacheStencilState(): void;
  31352. /**
  31353. * Restores the state of the stencil buffer
  31354. */
  31355. restoreStencilState(): void;
  31356. /**
  31357. * Sets the current depth function to LEQUAL
  31358. */
  31359. setDepthFunctionToLessOrEqual(): void;
  31360. /**
  31361. * Gets a boolean indicating if stencil buffer is enabled
  31362. * @returns the current stencil buffer state
  31363. */
  31364. getStencilBuffer(): boolean;
  31365. /**
  31366. * Enable or disable the stencil buffer
  31367. * @param enable defines if the stencil buffer must be enabled or disabled
  31368. */
  31369. setStencilBuffer(enable: boolean): void;
  31370. /**
  31371. * Gets the current stencil mask
  31372. * @returns a number defining the new stencil mask to use
  31373. */
  31374. getStencilMask(): number;
  31375. /**
  31376. * Sets the current stencil mask
  31377. * @param mask defines the new stencil mask to use
  31378. */
  31379. setStencilMask(mask: number): void;
  31380. /**
  31381. * Gets the current stencil function
  31382. * @returns a number defining the stencil function to use
  31383. */
  31384. getStencilFunction(): number;
  31385. /**
  31386. * Gets the current stencil reference value
  31387. * @returns a number defining the stencil reference value to use
  31388. */
  31389. getStencilFunctionReference(): number;
  31390. /**
  31391. * Gets the current stencil mask
  31392. * @returns a number defining the stencil mask to use
  31393. */
  31394. getStencilFunctionMask(): number;
  31395. /**
  31396. * Sets the current stencil function
  31397. * @param stencilFunc defines the new stencil function to use
  31398. */
  31399. setStencilFunction(stencilFunc: number): void;
  31400. /**
  31401. * Sets the current stencil reference
  31402. * @param reference defines the new stencil reference to use
  31403. */
  31404. setStencilFunctionReference(reference: number): void;
  31405. /**
  31406. * Sets the current stencil mask
  31407. * @param mask defines the new stencil mask to use
  31408. */
  31409. setStencilFunctionMask(mask: number): void;
  31410. /**
  31411. * Gets the current stencil operation when stencil fails
  31412. * @returns a number defining stencil operation to use when stencil fails
  31413. */
  31414. getStencilOperationFail(): number;
  31415. /**
  31416. * Gets the current stencil operation when depth fails
  31417. * @returns a number defining stencil operation to use when depth fails
  31418. */
  31419. getStencilOperationDepthFail(): number;
  31420. /**
  31421. * Gets the current stencil operation when stencil passes
  31422. * @returns a number defining stencil operation to use when stencil passes
  31423. */
  31424. getStencilOperationPass(): number;
  31425. /**
  31426. * Sets the stencil operation to use when stencil fails
  31427. * @param operation defines the stencil operation to use when stencil fails
  31428. */
  31429. setStencilOperationFail(operation: number): void;
  31430. /**
  31431. * Sets the stencil operation to use when depth fails
  31432. * @param operation defines the stencil operation to use when depth fails
  31433. */
  31434. setStencilOperationDepthFail(operation: number): void;
  31435. /**
  31436. * Sets the stencil operation to use when stencil passes
  31437. * @param operation defines the stencil operation to use when stencil passes
  31438. */
  31439. setStencilOperationPass(operation: number): void;
  31440. /**
  31441. * Sets a boolean indicating if the dithering state is enabled or disabled
  31442. * @param value defines the dithering state
  31443. */
  31444. setDitheringState(value: boolean): void;
  31445. /**
  31446. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  31447. * @param value defines the rasterizer state
  31448. */
  31449. setRasterizerState(value: boolean): void;
  31450. /**
  31451. * stop executing a render loop function and remove it from the execution array
  31452. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  31453. */
  31454. stopRenderLoop(renderFunction?: () => void): void;
  31455. /** @hidden */
  31456. _renderLoop(): void;
  31457. /**
  31458. * Can be used to override the current requestAnimationFrame requester.
  31459. * @hidden
  31460. */
  31461. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  31462. /**
  31463. * Register and execute a render loop. The engine can have more than one render function
  31464. * @param renderFunction defines the function to continuously execute
  31465. */
  31466. runRenderLoop(renderFunction: () => void): void;
  31467. /**
  31468. * Toggle full screen mode
  31469. * @param requestPointerLock defines if a pointer lock should be requested from the user
  31470. */
  31471. switchFullscreen(requestPointerLock: boolean): void;
  31472. /**
  31473. * Enters full screen mode
  31474. * @param requestPointerLock defines if a pointer lock should be requested from the user
  31475. */
  31476. enterFullscreen(requestPointerLock: boolean): void;
  31477. /**
  31478. * Exits full screen mode
  31479. */
  31480. exitFullscreen(): void;
  31481. /**
  31482. * Enters Pointerlock mode
  31483. */
  31484. enterPointerlock(): void;
  31485. /**
  31486. * Exits Pointerlock mode
  31487. */
  31488. exitPointerlock(): void;
  31489. /**
  31490. * Clear the current render buffer or the current render target (if any is set up)
  31491. * @param color defines the color to use
  31492. * @param backBuffer defines if the back buffer must be cleared
  31493. * @param depth defines if the depth buffer must be cleared
  31494. * @param stencil defines if the stencil buffer must be cleared
  31495. */
  31496. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  31497. /**
  31498. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  31499. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  31500. * @param y defines the y-coordinate of the corner of the clear rectangle
  31501. * @param width defines the width of the clear rectangle
  31502. * @param height defines the height of the clear rectangle
  31503. * @param clearColor defines the clear color
  31504. */
  31505. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  31506. /**
  31507. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  31508. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  31509. * @param y defines the y-coordinate of the corner of the clear rectangle
  31510. * @param width defines the width of the clear rectangle
  31511. * @param height defines the height of the clear rectangle
  31512. */
  31513. enableScissor(x: number, y: number, width: number, height: number): void;
  31514. /**
  31515. * Disable previously set scissor test rectangle
  31516. */
  31517. disableScissor(): void;
  31518. private _viewportCached;
  31519. /** @hidden */
  31520. _viewport(x: number, y: number, width: number, height: number): void;
  31521. /**
  31522. * Set the WebGL's viewport
  31523. * @param viewport defines the viewport element to be used
  31524. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  31525. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  31526. */
  31527. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  31528. /**
  31529. * Directly set the WebGL Viewport
  31530. * @param x defines the x coordinate of the viewport (in screen space)
  31531. * @param y defines the y coordinate of the viewport (in screen space)
  31532. * @param width defines the width of the viewport (in screen space)
  31533. * @param height defines the height of the viewport (in screen space)
  31534. * @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
  31535. */
  31536. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  31537. /**
  31538. * Begin a new frame
  31539. */
  31540. beginFrame(): void;
  31541. /**
  31542. * Enf the current frame
  31543. */
  31544. endFrame(): void;
  31545. /**
  31546. * Resize the view according to the canvas' size
  31547. */
  31548. resize(): void;
  31549. /**
  31550. * Force a specific size of the canvas
  31551. * @param width defines the new canvas' width
  31552. * @param height defines the new canvas' height
  31553. */
  31554. setSize(width: number, height: number): void;
  31555. /**
  31556. * Binds the frame buffer to the specified texture.
  31557. * @param texture The texture to render to or null for the default canvas
  31558. * @param faceIndex The face of the texture to render to in case of cube texture
  31559. * @param requiredWidth The width of the target to render to
  31560. * @param requiredHeight The height of the target to render to
  31561. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  31562. * @param depthStencilTexture The depth stencil texture to use to render
  31563. * @param lodLevel defines le lod level to bind to the frame buffer
  31564. */
  31565. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, depthStencilTexture?: InternalTexture, lodLevel?: number): void;
  31566. /** @hidden */
  31567. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  31568. /**
  31569. * Unbind the current render target texture from the webGL context
  31570. * @param texture defines the render target texture to unbind
  31571. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  31572. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  31573. */
  31574. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  31575. /**
  31576. * Force the mipmap generation for the given render target texture
  31577. * @param texture defines the render target texture to use
  31578. */
  31579. generateMipMapsForCubemap(texture: InternalTexture): void;
  31580. /**
  31581. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  31582. */
  31583. flushFramebuffer(): void;
  31584. /**
  31585. * Unbind the current render target and bind the default framebuffer
  31586. */
  31587. restoreDefaultFramebuffer(): void;
  31588. /**
  31589. * Create an uniform buffer
  31590. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  31591. * @param elements defines the content of the uniform buffer
  31592. * @returns the webGL uniform buffer
  31593. */
  31594. createUniformBuffer(elements: FloatArray): DataBuffer;
  31595. /**
  31596. * Create a dynamic uniform buffer
  31597. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  31598. * @param elements defines the content of the uniform buffer
  31599. * @returns the webGL uniform buffer
  31600. */
  31601. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  31602. /**
  31603. * Update an existing uniform buffer
  31604. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  31605. * @param uniformBuffer defines the target uniform buffer
  31606. * @param elements defines the content to update
  31607. * @param offset defines the offset in the uniform buffer where update should start
  31608. * @param count defines the size of the data to update
  31609. */
  31610. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  31611. private _resetVertexBufferBinding;
  31612. /**
  31613. * Creates a vertex buffer
  31614. * @param data the data for the vertex buffer
  31615. * @returns the new WebGL static buffer
  31616. */
  31617. createVertexBuffer(data: DataArray): DataBuffer;
  31618. /**
  31619. * Creates a dynamic vertex buffer
  31620. * @param data the data for the dynamic vertex buffer
  31621. * @returns the new WebGL dynamic buffer
  31622. */
  31623. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  31624. /**
  31625. * Update a dynamic index buffer
  31626. * @param indexBuffer defines the target index buffer
  31627. * @param indices defines the data to update
  31628. * @param offset defines the offset in the target index buffer where update should start
  31629. */
  31630. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  31631. /**
  31632. * Updates a dynamic vertex buffer.
  31633. * @param vertexBuffer the vertex buffer to update
  31634. * @param data the data used to update the vertex buffer
  31635. * @param byteOffset the byte offset of the data
  31636. * @param byteLength the byte length of the data
  31637. */
  31638. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  31639. private _resetIndexBufferBinding;
  31640. /**
  31641. * Creates a new index buffer
  31642. * @param indices defines the content of the index buffer
  31643. * @param updatable defines if the index buffer must be updatable
  31644. * @returns a new webGL buffer
  31645. */
  31646. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  31647. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  31648. /**
  31649. * Bind a webGL buffer to the webGL context
  31650. * @param buffer defines the buffer to bind
  31651. */
  31652. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  31653. /**
  31654. * Bind an uniform buffer to the current webGL context
  31655. * @param buffer defines the buffer to bind
  31656. */
  31657. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  31658. /**
  31659. * Bind a buffer to the current webGL context at a given location
  31660. * @param buffer defines the buffer to bind
  31661. * @param location defines the index where to bind the buffer
  31662. */
  31663. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  31664. /**
  31665. * Bind a specific block at a given index in a specific shader program
  31666. * @param pipelineContext defines the pipeline context to use
  31667. * @param blockName defines the block name
  31668. * @param index defines the index where to bind the block
  31669. */
  31670. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  31671. private bindIndexBuffer;
  31672. private bindBuffer;
  31673. /**
  31674. * update the bound buffer with the given data
  31675. * @param data defines the data to update
  31676. */
  31677. updateArrayBuffer(data: Float32Array): void;
  31678. private _vertexAttribPointer;
  31679. private _bindIndexBufferWithCache;
  31680. private _bindVertexBuffersAttributes;
  31681. /**
  31682. * Records a vertex array object
  31683. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  31684. * @param vertexBuffers defines the list of vertex buffers to store
  31685. * @param indexBuffer defines the index buffer to store
  31686. * @param effect defines the effect to store
  31687. * @returns the new vertex array object
  31688. */
  31689. recordVertexArrayObject(vertexBuffers: {
  31690. [key: string]: VertexBuffer;
  31691. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  31692. /**
  31693. * Bind a specific vertex array object
  31694. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  31695. * @param vertexArrayObject defines the vertex array object to bind
  31696. * @param indexBuffer defines the index buffer to bind
  31697. */
  31698. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  31699. /**
  31700. * Bind webGl buffers directly to the webGL context
  31701. * @param vertexBuffer defines the vertex buffer to bind
  31702. * @param indexBuffer defines the index buffer to bind
  31703. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  31704. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  31705. * @param effect defines the effect associated with the vertex buffer
  31706. */
  31707. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  31708. private _unbindVertexArrayObject;
  31709. /**
  31710. * Bind a list of vertex buffers to the webGL context
  31711. * @param vertexBuffers defines the list of vertex buffers to bind
  31712. * @param indexBuffer defines the index buffer to bind
  31713. * @param effect defines the effect associated with the vertex buffers
  31714. */
  31715. bindBuffers(vertexBuffers: {
  31716. [key: string]: Nullable<VertexBuffer>;
  31717. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  31718. /**
  31719. * Unbind all instance attributes
  31720. */
  31721. unbindInstanceAttributes(): void;
  31722. /**
  31723. * Release and free the memory of a vertex array object
  31724. * @param vao defines the vertex array object to delete
  31725. */
  31726. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  31727. /** @hidden */
  31728. _releaseBuffer(buffer: DataBuffer): boolean;
  31729. protected _deleteBuffer(buffer: DataBuffer): void;
  31730. /**
  31731. * Creates a webGL buffer to use with instanciation
  31732. * @param capacity defines the size of the buffer
  31733. * @returns the webGL buffer
  31734. */
  31735. createInstancesBuffer(capacity: number): DataBuffer;
  31736. /**
  31737. * Delete a webGL buffer used with instanciation
  31738. * @param buffer defines the webGL buffer to delete
  31739. */
  31740. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  31741. /**
  31742. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  31743. * @param instancesBuffer defines the webGL buffer to update and bind
  31744. * @param data defines the data to store in the buffer
  31745. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  31746. */
  31747. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  31748. /**
  31749. * Apply all cached states (depth, culling, stencil and alpha)
  31750. */
  31751. applyStates(): void;
  31752. /**
  31753. * Send a draw order
  31754. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  31755. * @param indexStart defines the starting index
  31756. * @param indexCount defines the number of index to draw
  31757. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  31758. */
  31759. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  31760. /**
  31761. * Draw a list of points
  31762. * @param verticesStart defines the index of first vertex to draw
  31763. * @param verticesCount defines the count of vertices to draw
  31764. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  31765. */
  31766. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  31767. /**
  31768. * Draw a list of unindexed primitives
  31769. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  31770. * @param verticesStart defines the index of first vertex to draw
  31771. * @param verticesCount defines the count of vertices to draw
  31772. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  31773. */
  31774. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  31775. /**
  31776. * Draw a list of indexed primitives
  31777. * @param fillMode defines the primitive to use
  31778. * @param indexStart defines the starting index
  31779. * @param indexCount defines the number of index to draw
  31780. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  31781. */
  31782. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  31783. /**
  31784. * Draw a list of unindexed primitives
  31785. * @param fillMode defines the primitive to use
  31786. * @param verticesStart defines the index of first vertex to draw
  31787. * @param verticesCount defines the count of vertices to draw
  31788. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  31789. */
  31790. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  31791. private _drawMode;
  31792. /** @hidden */
  31793. _releaseEffect(effect: Effect): void;
  31794. /** @hidden */
  31795. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  31796. /**
  31797. * Create a new effect (used to store vertex/fragment shaders)
  31798. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  31799. * @param attributesNamesOrOptions defines either a list of attribute names or an EffectCreationOptions object
  31800. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  31801. * @param samplers defines an array of string used to represent textures
  31802. * @param defines defines the string containing the defines to use to compile the shaders
  31803. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  31804. * @param onCompiled defines a function to call when the effect creation is successful
  31805. * @param onError defines a function to call when the effect creation has failed
  31806. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  31807. * @returns the new Effect
  31808. */
  31809. createEffect(baseName: any, attributesNamesOrOptions: string[] | EffectCreationOptions, uniformsNamesOrEngine: string[] | Engine, samplers?: string[], defines?: string, fallbacks?: EffectFallbacks, onCompiled?: Nullable<(effect: Effect) => void>, onError?: Nullable<(effect: Effect, errors: string) => void>, indexParameters?: any): Effect;
  31810. protected static _concatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  31811. private _compileShader;
  31812. private _compileRawShader;
  31813. /**
  31814. * Directly creates a webGL program
  31815. * @param pipelineContext defines the pipeline context to attach to
  31816. * @param vertexCode defines the vertex shader code to use
  31817. * @param fragmentCode defines the fragment shader code to use
  31818. * @param context defines the webGL context to use (if not set, the current one will be used)
  31819. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  31820. * @returns the new webGL program
  31821. */
  31822. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  31823. /**
  31824. * Creates a webGL program
  31825. * @param pipelineContext defines the pipeline context to attach to
  31826. * @param vertexCode defines the vertex shader code to use
  31827. * @param fragmentCode defines the fragment shader code to use
  31828. * @param defines defines the string containing the defines to use to compile the shaders
  31829. * @param context defines the webGL context to use (if not set, the current one will be used)
  31830. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  31831. * @returns the new webGL program
  31832. */
  31833. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  31834. /**
  31835. * Creates a new pipeline context
  31836. * @returns the new pipeline
  31837. */
  31838. createPipelineContext(): IPipelineContext;
  31839. private _createShaderProgram;
  31840. private _finalizePipelineContext;
  31841. /** @hidden */
  31842. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  31843. /** @hidden */
  31844. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  31845. /** @hidden */
  31846. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  31847. /**
  31848. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  31849. * @param pipelineContext defines the pipeline context to use
  31850. * @param uniformsNames defines the list of uniform names
  31851. * @returns an array of webGL uniform locations
  31852. */
  31853. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  31854. /**
  31855. * Gets the lsit of active attributes for a given webGL program
  31856. * @param pipelineContext defines the pipeline context to use
  31857. * @param attributesNames defines the list of attribute names to get
  31858. * @returns an array of indices indicating the offset of each attribute
  31859. */
  31860. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  31861. /**
  31862. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  31863. * @param effect defines the effect to activate
  31864. */
  31865. enableEffect(effect: Nullable<Effect>): void;
  31866. /**
  31867. * Set the value of an uniform to an array of int32
  31868. * @param uniform defines the webGL uniform location where to store the value
  31869. * @param array defines the array of int32 to store
  31870. */
  31871. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  31872. /**
  31873. * Set the value of an uniform to an array of int32 (stored as vec2)
  31874. * @param uniform defines the webGL uniform location where to store the value
  31875. * @param array defines the array of int32 to store
  31876. */
  31877. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  31878. /**
  31879. * Set the value of an uniform to an array of int32 (stored as vec3)
  31880. * @param uniform defines the webGL uniform location where to store the value
  31881. * @param array defines the array of int32 to store
  31882. */
  31883. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  31884. /**
  31885. * Set the value of an uniform to an array of int32 (stored as vec4)
  31886. * @param uniform defines the webGL uniform location where to store the value
  31887. * @param array defines the array of int32 to store
  31888. */
  31889. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  31890. /**
  31891. * Set the value of an uniform to an array of float32
  31892. * @param uniform defines the webGL uniform location where to store the value
  31893. * @param array defines the array of float32 to store
  31894. */
  31895. setFloatArray(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  31896. /**
  31897. * Set the value of an uniform to an array of float32 (stored as vec2)
  31898. * @param uniform defines the webGL uniform location where to store the value
  31899. * @param array defines the array of float32 to store
  31900. */
  31901. setFloatArray2(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  31902. /**
  31903. * Set the value of an uniform to an array of float32 (stored as vec3)
  31904. * @param uniform defines the webGL uniform location where to store the value
  31905. * @param array defines the array of float32 to store
  31906. */
  31907. setFloatArray3(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  31908. /**
  31909. * Set the value of an uniform to an array of float32 (stored as vec4)
  31910. * @param uniform defines the webGL uniform location where to store the value
  31911. * @param array defines the array of float32 to store
  31912. */
  31913. setFloatArray4(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  31914. /**
  31915. * Set the value of an uniform to an array of number
  31916. * @param uniform defines the webGL uniform location where to store the value
  31917. * @param array defines the array of number to store
  31918. */
  31919. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  31920. /**
  31921. * Set the value of an uniform to an array of number (stored as vec2)
  31922. * @param uniform defines the webGL uniform location where to store the value
  31923. * @param array defines the array of number to store
  31924. */
  31925. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  31926. /**
  31927. * Set the value of an uniform to an array of number (stored as vec3)
  31928. * @param uniform defines the webGL uniform location where to store the value
  31929. * @param array defines the array of number to store
  31930. */
  31931. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  31932. /**
  31933. * Set the value of an uniform to an array of number (stored as vec4)
  31934. * @param uniform defines the webGL uniform location where to store the value
  31935. * @param array defines the array of number to store
  31936. */
  31937. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  31938. /**
  31939. * Set the value of an uniform to an array of float32 (stored as matrices)
  31940. * @param uniform defines the webGL uniform location where to store the value
  31941. * @param matrices defines the array of float32 to store
  31942. */
  31943. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  31944. /**
  31945. * Set the value of an uniform to a matrix (3x3)
  31946. * @param uniform defines the webGL uniform location where to store the value
  31947. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  31948. */
  31949. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  31950. /**
  31951. * Set the value of an uniform to a matrix (2x2)
  31952. * @param uniform defines the webGL uniform location where to store the value
  31953. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  31954. */
  31955. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  31956. /**
  31957. * Set the value of an uniform to a number (int)
  31958. * @param uniform defines the webGL uniform location where to store the value
  31959. * @param value defines the int number to store
  31960. */
  31961. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  31962. /**
  31963. * Set the value of an uniform to a number (float)
  31964. * @param uniform defines the webGL uniform location where to store the value
  31965. * @param value defines the float number to store
  31966. */
  31967. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  31968. /**
  31969. * Set the value of an uniform to a vec2
  31970. * @param uniform defines the webGL uniform location where to store the value
  31971. * @param x defines the 1st component of the value
  31972. * @param y defines the 2nd component of the value
  31973. */
  31974. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  31975. /**
  31976. * Set the value of an uniform to a vec3
  31977. * @param uniform defines the webGL uniform location where to store the value
  31978. * @param x defines the 1st component of the value
  31979. * @param y defines the 2nd component of the value
  31980. * @param z defines the 3rd component of the value
  31981. */
  31982. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  31983. /**
  31984. * Set the value of an uniform to a boolean
  31985. * @param uniform defines the webGL uniform location where to store the value
  31986. * @param bool defines the boolean to store
  31987. */
  31988. setBool(uniform: Nullable<WebGLUniformLocation>, bool: number): void;
  31989. /**
  31990. * Set the value of an uniform to a vec4
  31991. * @param uniform defines the webGL uniform location where to store the value
  31992. * @param x defines the 1st component of the value
  31993. * @param y defines the 2nd component of the value
  31994. * @param z defines the 3rd component of the value
  31995. * @param w defines the 4th component of the value
  31996. */
  31997. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  31998. /**
  31999. * Sets a Color4 on a uniform variable
  32000. * @param uniform defines the uniform location
  32001. * @param color4 defines the value to be set
  32002. */
  32003. setDirectColor4(uniform: Nullable<WebGLUniformLocation>, color4: IColor4Like): void;
  32004. /**
  32005. * Set various states to the webGL context
  32006. * @param culling defines backface culling state
  32007. * @param zOffset defines the value to apply to zOffset (0 by default)
  32008. * @param force defines if states must be applied even if cache is up to date
  32009. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  32010. */
  32011. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  32012. /**
  32013. * Set the z offset to apply to current rendering
  32014. * @param value defines the offset to apply
  32015. */
  32016. setZOffset(value: number): void;
  32017. /**
  32018. * Gets the current value of the zOffset
  32019. * @returns the current zOffset state
  32020. */
  32021. getZOffset(): number;
  32022. /**
  32023. * Enable or disable depth buffering
  32024. * @param enable defines the state to set
  32025. */
  32026. setDepthBuffer(enable: boolean): void;
  32027. /**
  32028. * Gets a boolean indicating if depth writing is enabled
  32029. * @returns the current depth writing state
  32030. */
  32031. getDepthWrite(): boolean;
  32032. /**
  32033. * Enable or disable depth writing
  32034. * @param enable defines the state to set
  32035. */
  32036. setDepthWrite(enable: boolean): void;
  32037. /**
  32038. * Enable or disable color writing
  32039. * @param enable defines the state to set
  32040. */
  32041. setColorWrite(enable: boolean): void;
  32042. /**
  32043. * Gets a boolean indicating if color writing is enabled
  32044. * @returns the current color writing state
  32045. */
  32046. getColorWrite(): boolean;
  32047. /**
  32048. * Sets alpha constants used by some alpha blending modes
  32049. * @param r defines the red component
  32050. * @param g defines the green component
  32051. * @param b defines the blue component
  32052. * @param a defines the alpha component
  32053. */
  32054. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  32055. /**
  32056. * Sets the current alpha mode
  32057. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  32058. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  32059. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  32060. */
  32061. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  32062. /**
  32063. * Gets the current alpha mode
  32064. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  32065. * @returns the current alpha mode
  32066. */
  32067. getAlphaMode(): number;
  32068. /**
  32069. * Clears the list of texture accessible through engine.
  32070. * This can help preventing texture load conflict due to name collision.
  32071. */
  32072. clearInternalTexturesCache(): void;
  32073. /**
  32074. * Force the entire cache to be cleared
  32075. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  32076. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  32077. */
  32078. wipeCaches(bruteForce?: boolean): void;
  32079. /**
  32080. * Set the compressed texture format to use, based on the formats you have, and the formats
  32081. * supported by the hardware / browser.
  32082. *
  32083. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  32084. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  32085. * to API arguments needed to compressed textures. This puts the burden on the container
  32086. * generator to house the arcane code for determining these for current & future formats.
  32087. *
  32088. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  32089. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  32090. *
  32091. * Note: The result of this call is not taken into account when a texture is base64.
  32092. *
  32093. * @param formatsAvailable defines the list of those format families you have created
  32094. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  32095. *
  32096. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  32097. * @returns The extension selected.
  32098. */
  32099. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  32100. /** @hidden */
  32101. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  32102. min: number;
  32103. mag: number;
  32104. };
  32105. /** @hidden */
  32106. _createTexture(): WebGLTexture;
  32107. /**
  32108. * Usually called from Texture.ts.
  32109. * Passed information to create a WebGLTexture
  32110. * @param urlArg defines a value which contains one of the following:
  32111. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  32112. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  32113. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  32114. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  32115. * @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)
  32116. * @param scene needed for loading to the correct scene
  32117. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  32118. * @param onLoad optional callback to be called upon successful completion
  32119. * @param onError optional callback to be called upon failure
  32120. * @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
  32121. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  32122. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  32123. * @param forcedExtension defines the extension to use to pick the right loader
  32124. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  32125. * @returns a InternalTexture for assignment back into BABYLON.Texture
  32126. */
  32127. 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 | ArrayBufferView | HTMLImageElement | Blob>, fallback?: Nullable<InternalTexture>, format?: Nullable<number>, forcedExtension?: Nullable<string>, excludeLoaders?: Array<IInternalTextureLoader>): InternalTexture;
  32128. /**
  32129. * @hidden
  32130. * Rescales a texture
  32131. * @param source input texutre
  32132. * @param destination destination texture
  32133. * @param scene scene to use to render the resize
  32134. * @param internalFormat format to use when resizing
  32135. * @param onComplete callback to be called when resize has completed
  32136. */
  32137. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<Scene>, internalFormat: number, onComplete: () => void): void;
  32138. private _unpackFlipYCached;
  32139. /**
  32140. * In case you are sharing the context with other applications, it might
  32141. * be interested to not cache the unpack flip y state to ensure a consistent
  32142. * value would be set.
  32143. */
  32144. enableUnpackFlipYCached: boolean;
  32145. /** @hidden */
  32146. _unpackFlipY(value: boolean): void;
  32147. /** @hidden */
  32148. _getUnpackAlignement(): number;
  32149. /**
  32150. * Creates a dynamic texture
  32151. * @param width defines the width of the texture
  32152. * @param height defines the height of the texture
  32153. * @param generateMipMaps defines if the engine should generate the mip levels
  32154. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  32155. * @returns the dynamic texture inside an InternalTexture
  32156. */
  32157. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  32158. /**
  32159. * Update the sampling mode of a given texture
  32160. * @param samplingMode defines the required sampling mode
  32161. * @param texture defines the texture to update
  32162. */
  32163. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  32164. /**
  32165. * Update the content of a dynamic texture
  32166. * @param texture defines the texture to update
  32167. * @param canvas defines the canvas containing the source
  32168. * @param invertY defines if data must be stored with Y axis inverted
  32169. * @param premulAlpha defines if alpha is stored as premultiplied
  32170. * @param format defines the format of the data
  32171. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  32172. */
  32173. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  32174. /**
  32175. * Update a video texture
  32176. * @param texture defines the texture to update
  32177. * @param video defines the video element to use
  32178. * @param invertY defines if data must be stored with Y axis inverted
  32179. */
  32180. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  32181. /**
  32182. * Updates a depth texture Comparison Mode and Function.
  32183. * If the comparison Function is equal to 0, the mode will be set to none.
  32184. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  32185. * @param texture The texture to set the comparison function for
  32186. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  32187. */
  32188. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  32189. /** @hidden */
  32190. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  32191. width: number;
  32192. height: number;
  32193. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  32194. /**
  32195. * Creates a depth stencil texture.
  32196. * This is only available in WebGL 2 or with the depth texture extension available.
  32197. * @param size The size of face edge in the texture.
  32198. * @param options The options defining the texture.
  32199. * @returns The texture
  32200. */
  32201. createDepthStencilTexture(size: number | {
  32202. width: number;
  32203. height: number;
  32204. }, options: DepthTextureCreationOptions): InternalTexture;
  32205. /**
  32206. * Creates a depth stencil texture.
  32207. * This is only available in WebGL 2 or with the depth texture extension available.
  32208. * @param size The size of face edge in the texture.
  32209. * @param options The options defining the texture.
  32210. * @returns The texture
  32211. */
  32212. private _createDepthStencilTexture;
  32213. /**
  32214. * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
  32215. * @param renderTarget The render target to set the frame buffer for
  32216. */
  32217. setFrameBufferDepthStencilTexture(renderTarget: RenderTargetTexture): void;
  32218. /**
  32219. * Creates a new render target texture
  32220. * @param size defines the size of the texture
  32221. * @param options defines the options used to create the texture
  32222. * @returns a new render target texture stored in an InternalTexture
  32223. */
  32224. createRenderTargetTexture(size: number | {
  32225. width: number;
  32226. height: number;
  32227. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  32228. /** @hidden */
  32229. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  32230. /**
  32231. * Updates the sample count of a render target texture
  32232. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  32233. * @param texture defines the texture to update
  32234. * @param samples defines the sample count to set
  32235. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  32236. */
  32237. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  32238. /** @hidden */
  32239. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  32240. /** @hidden */
  32241. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  32242. /** @hidden */
  32243. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  32244. /** @hidden */
  32245. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  32246. /**
  32247. * @hidden
  32248. */
  32249. _setCubeMapTextureParams(loadMipmap: boolean): void;
  32250. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<Scene>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  32251. private _prepareWebGLTexture;
  32252. /** @hidden */
  32253. _convertRGBtoRGBATextureData(rgbData: any, width: number, height: number, textureType: number): ArrayBufferView;
  32254. /** @hidden */
  32255. _releaseFramebufferObjects(texture: InternalTexture): void;
  32256. /** @hidden */
  32257. _releaseTexture(texture: InternalTexture): void;
  32258. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  32259. protected _setProgram(program: WebGLProgram): void;
  32260. protected _boundUniforms: {
  32261. [key: number]: WebGLUniformLocation;
  32262. };
  32263. /**
  32264. * Binds an effect to the webGL context
  32265. * @param effect defines the effect to bind
  32266. */
  32267. bindSamplers(effect: Effect): void;
  32268. private _activateCurrentTexture;
  32269. /** @hidden */
  32270. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  32271. /** @hidden */
  32272. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  32273. /**
  32274. * Sets a texture to the webGL context from a postprocess
  32275. * @param channel defines the channel to use
  32276. * @param postProcess defines the source postprocess
  32277. */
  32278. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  32279. /**
  32280. * Binds the output of the passed in post process to the texture channel specified
  32281. * @param channel The channel the texture should be bound to
  32282. * @param postProcess The post process which's output should be bound
  32283. */
  32284. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  32285. /**
  32286. * Unbind all textures from the webGL context
  32287. */
  32288. unbindAllTextures(): void;
  32289. /**
  32290. * Sets a texture to the according uniform.
  32291. * @param channel The texture channel
  32292. * @param uniform The uniform to set
  32293. * @param texture The texture to apply
  32294. */
  32295. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  32296. /**
  32297. * Sets a depth stencil texture from a render target to the according uniform.
  32298. * @param channel The texture channel
  32299. * @param uniform The uniform to set
  32300. * @param texture The render target texture containing the depth stencil texture to apply
  32301. */
  32302. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  32303. private _bindSamplerUniformToChannel;
  32304. private _getTextureWrapMode;
  32305. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  32306. /**
  32307. * Sets an array of texture to the webGL context
  32308. * @param channel defines the channel where the texture array must be set
  32309. * @param uniform defines the associated uniform location
  32310. * @param textures defines the array of textures to bind
  32311. */
  32312. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  32313. /** @hidden */
  32314. _setAnisotropicLevel(target: number, texture: BaseTexture): void;
  32315. private _setTextureParameterFloat;
  32316. private _setTextureParameterInteger;
  32317. /**
  32318. * Reads pixels from the current frame buffer. Please note that this function can be slow
  32319. * @param x defines the x coordinate of the rectangle where pixels must be read
  32320. * @param y defines the y coordinate of the rectangle where pixels must be read
  32321. * @param width defines the width of the rectangle where pixels must be read
  32322. * @param height defines the height of the rectangle where pixels must be read
  32323. * @returns a Uint8Array containing RGBA colors
  32324. */
  32325. readPixels(x: number, y: number, width: number, height: number): Uint8Array;
  32326. /**
  32327. * Add an externaly attached data from its key.
  32328. * This method call will fail and return false, if such key already exists.
  32329. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  32330. * @param key the unique key that identifies the data
  32331. * @param data the data object to associate to the key for this Engine instance
  32332. * @return true if no such key were already present and the data was added successfully, false otherwise
  32333. */
  32334. addExternalData<T>(key: string, data: T): boolean;
  32335. /**
  32336. * Get an externaly attached data from its key
  32337. * @param key the unique key that identifies the data
  32338. * @return the associated data, if present (can be null), or undefined if not present
  32339. */
  32340. getExternalData<T>(key: string): T;
  32341. /**
  32342. * Get an externaly attached data from its key, create it using a factory if it's not already present
  32343. * @param key the unique key that identifies the data
  32344. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  32345. * @return the associated data, can be null if the factory returned null.
  32346. */
  32347. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  32348. /**
  32349. * Remove an externaly attached data from the Engine instance
  32350. * @param key the unique key that identifies the data
  32351. * @return true if the data was successfully removed, false if it doesn't exist
  32352. */
  32353. removeExternalData(key: string): boolean;
  32354. /**
  32355. * Unbind all vertex attributes from the webGL context
  32356. */
  32357. unbindAllAttributes(): void;
  32358. /**
  32359. * 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
  32360. */
  32361. releaseEffects(): void;
  32362. /**
  32363. * Dispose and release all associated resources
  32364. */
  32365. dispose(): void;
  32366. /**
  32367. * Display the loading screen
  32368. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  32369. */
  32370. displayLoadingUI(): void;
  32371. /**
  32372. * Hide the loading screen
  32373. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  32374. */
  32375. hideLoadingUI(): void;
  32376. /**
  32377. * Gets the current loading screen object
  32378. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  32379. */
  32380. /**
  32381. * Sets the current loading screen object
  32382. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  32383. */
  32384. loadingScreen: ILoadingScreen;
  32385. /**
  32386. * Sets the current loading screen text
  32387. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  32388. */
  32389. loadingUIText: string;
  32390. /**
  32391. * Sets the current loading screen background color
  32392. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  32393. */
  32394. loadingUIBackgroundColor: string;
  32395. /**
  32396. * Attach a new callback raised when context lost event is fired
  32397. * @param callback defines the callback to call
  32398. */
  32399. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  32400. /**
  32401. * Attach a new callback raised when context restored event is fired
  32402. * @param callback defines the callback to call
  32403. */
  32404. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  32405. /**
  32406. * Gets the source code of the vertex shader associated with a specific webGL program
  32407. * @param program defines the program to use
  32408. * @returns a string containing the source code of the vertex shader associated with the program
  32409. */
  32410. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  32411. /**
  32412. * Gets the source code of the fragment shader associated with a specific webGL program
  32413. * @param program defines the program to use
  32414. * @returns a string containing the source code of the fragment shader associated with the program
  32415. */
  32416. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  32417. /**
  32418. * Get the current error code of the webGL context
  32419. * @returns the error code
  32420. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  32421. */
  32422. getError(): number;
  32423. /**
  32424. * Gets the current framerate
  32425. * @returns a number representing the framerate
  32426. */
  32427. getFps(): number;
  32428. /**
  32429. * Gets the time spent between current and previous frame
  32430. * @returns a number representing the delta time in ms
  32431. */
  32432. getDeltaTime(): number;
  32433. private _measureFps;
  32434. /** @hidden */
  32435. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  32436. private _canRenderToFloatFramebuffer;
  32437. private _canRenderToHalfFloatFramebuffer;
  32438. private _canRenderToFramebuffer;
  32439. /** @hidden */
  32440. _getWebGLTextureType(type: number): number;
  32441. /** @hidden */
  32442. _getInternalFormat(format: number): number;
  32443. /** @hidden */
  32444. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  32445. /** @hidden */
  32446. _getRGBAMultiSampleBufferFormat(type: number): number;
  32447. /** @hidden */
  32448. _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;
  32449. /** @hidden */
  32450. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  32451. /**
  32452. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  32453. * @returns true if the engine can be created
  32454. * @ignorenaming
  32455. */
  32456. static isSupported(): boolean;
  32457. /**
  32458. * Find the next highest power of two.
  32459. * @param x Number to start search from.
  32460. * @return Next highest power of two.
  32461. */
  32462. static CeilingPOT(x: number): number;
  32463. /**
  32464. * Find the next lowest power of two.
  32465. * @param x Number to start search from.
  32466. * @return Next lowest power of two.
  32467. */
  32468. static FloorPOT(x: number): number;
  32469. /**
  32470. * Find the nearest power of two.
  32471. * @param x Number to start search from.
  32472. * @return Next nearest power of two.
  32473. */
  32474. static NearestPOT(x: number): number;
  32475. /**
  32476. * Get the closest exponent of two
  32477. * @param value defines the value to approximate
  32478. * @param max defines the maximum value to return
  32479. * @param mode defines how to define the closest value
  32480. * @returns closest exponent of two of the given value
  32481. */
  32482. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  32483. /**
  32484. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  32485. * @param func - the function to be called
  32486. * @param requester - the object that will request the next frame. Falls back to window.
  32487. * @returns frame number
  32488. */
  32489. static QueueNewFrame(func: () => void, requester?: any): number;
  32490. /**
  32491. * Ask the browser to promote the current element to pointerlock mode
  32492. * @param element defines the DOM element to promote
  32493. */
  32494. static _RequestPointerlock(element: HTMLElement): void;
  32495. /**
  32496. * Asks the browser to exit pointerlock mode
  32497. */
  32498. static _ExitPointerlock(): void;
  32499. /**
  32500. * Ask the browser to promote the current element to fullscreen rendering mode
  32501. * @param element defines the DOM element to promote
  32502. */
  32503. static _RequestFullscreen(element: HTMLElement): void;
  32504. /**
  32505. * Asks the browser to exit fullscreen mode
  32506. */
  32507. static _ExitFullscreen(): void;
  32508. }
  32509. }
  32510. declare module "babylonjs/Engines/engineStore" {
  32511. import { Nullable } from "babylonjs/types";
  32512. import { Engine } from "babylonjs/Engines/engine";
  32513. import { Scene } from "babylonjs/scene";
  32514. /**
  32515. * The engine store class is responsible to hold all the instances of Engine and Scene created
  32516. * during the life time of the application.
  32517. */
  32518. export class EngineStore {
  32519. /** Gets the list of created engines */
  32520. static Instances: import("babylonjs/Engines/engine").Engine[];
  32521. /** @hidden */
  32522. static _LastCreatedScene: Nullable<Scene>;
  32523. /**
  32524. * Gets the latest created engine
  32525. */
  32526. static readonly LastCreatedEngine: Nullable<Engine>;
  32527. /**
  32528. * Gets the latest created scene
  32529. */
  32530. static readonly LastCreatedScene: Nullable<Scene>;
  32531. /**
  32532. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  32533. * @ignorenaming
  32534. */
  32535. static UseFallbackTexture: boolean;
  32536. /**
  32537. * Texture content used if a texture cannot loaded
  32538. * @ignorenaming
  32539. */
  32540. static FallbackTexture: string;
  32541. }
  32542. }
  32543. declare module "babylonjs/Misc/promise" {
  32544. /**
  32545. * Helper class that provides a small promise polyfill
  32546. */
  32547. export class PromisePolyfill {
  32548. /**
  32549. * Static function used to check if the polyfill is required
  32550. * If this is the case then the function will inject the polyfill to window.Promise
  32551. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  32552. */
  32553. static Apply(force?: boolean): void;
  32554. }
  32555. }
  32556. declare module "babylonjs/Misc/interfaces/screenshotSize" {
  32557. /**
  32558. * Interface for screenshot methods with describe argument called `size` as object with options
  32559. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  32560. */
  32561. export interface IScreenshotSize {
  32562. /**
  32563. * number in pixels for canvas height
  32564. */
  32565. height?: number;
  32566. /**
  32567. * multiplier allowing render at a higher or lower resolution
  32568. * If value is defined then height and width will be ignored and taken from camera
  32569. */
  32570. precision?: number;
  32571. /**
  32572. * number in pixels for canvas width
  32573. */
  32574. width?: number;
  32575. }
  32576. }
  32577. declare module "babylonjs/Misc/tools" {
  32578. import { Nullable, float } from "babylonjs/types";
  32579. import { DomManagement } from "babylonjs/Misc/domManagement";
  32580. import { WebRequest } from "babylonjs/Misc/webRequest";
  32581. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  32582. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  32583. import { IScreenshotSize } from "babylonjs/Misc/interfaces/screenshotSize";
  32584. import { Camera } from "babylonjs/Cameras/camera";
  32585. import { Engine } from "babylonjs/Engines/engine";
  32586. interface IColor4Like {
  32587. r: float;
  32588. g: float;
  32589. b: float;
  32590. a: float;
  32591. }
  32592. /**
  32593. * Class containing a set of static utilities functions
  32594. */
  32595. export class Tools {
  32596. /**
  32597. * Gets or sets the base URL to use to load assets
  32598. */
  32599. static BaseUrl: string;
  32600. /**
  32601. * Enable/Disable Custom HTTP Request Headers globally.
  32602. * default = false
  32603. * @see CustomRequestHeaders
  32604. */
  32605. static UseCustomRequestHeaders: boolean;
  32606. /**
  32607. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  32608. * i.e. when loading files, where the server/service expects an Authorization header
  32609. */
  32610. static CustomRequestHeaders: {
  32611. [key: string]: string;
  32612. };
  32613. /**
  32614. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  32615. */
  32616. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  32617. /**
  32618. * Default behaviour for cors in the application.
  32619. * It can be a string if the expected behavior is identical in the entire app.
  32620. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  32621. */
  32622. static CorsBehavior: string | ((url: string | string[]) => string);
  32623. /**
  32624. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  32625. * @ignorenaming
  32626. */
  32627. static UseFallbackTexture: boolean;
  32628. /**
  32629. * Use this object to register external classes like custom textures or material
  32630. * to allow the laoders to instantiate them
  32631. */
  32632. static RegisteredExternalClasses: {
  32633. [key: string]: Object;
  32634. };
  32635. /**
  32636. * Texture content used if a texture cannot loaded
  32637. * @ignorenaming
  32638. */
  32639. static fallbackTexture: string;
  32640. /**
  32641. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  32642. * @param u defines the coordinate on X axis
  32643. * @param v defines the coordinate on Y axis
  32644. * @param width defines the width of the source data
  32645. * @param height defines the height of the source data
  32646. * @param pixels defines the source byte array
  32647. * @param color defines the output color
  32648. */
  32649. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  32650. /**
  32651. * Interpolates between a and b via alpha
  32652. * @param a The lower value (returned when alpha = 0)
  32653. * @param b The upper value (returned when alpha = 1)
  32654. * @param alpha The interpolation-factor
  32655. * @return The mixed value
  32656. */
  32657. static Mix(a: number, b: number, alpha: number): number;
  32658. /**
  32659. * Tries to instantiate a new object from a given class name
  32660. * @param className defines the class name to instantiate
  32661. * @returns the new object or null if the system was not able to do the instantiation
  32662. */
  32663. static Instantiate(className: string): any;
  32664. /**
  32665. * Provides a slice function that will work even on IE
  32666. * @param data defines the array to slice
  32667. * @param start defines the start of the data (optional)
  32668. * @param end defines the end of the data (optional)
  32669. * @returns the new sliced array
  32670. */
  32671. static Slice<T>(data: T, start?: number, end?: number): T;
  32672. /**
  32673. * Polyfill for setImmediate
  32674. * @param action defines the action to execute after the current execution block
  32675. */
  32676. static SetImmediate(action: () => void): void;
  32677. /**
  32678. * Function indicating if a number is an exponent of 2
  32679. * @param value defines the value to test
  32680. * @returns true if the value is an exponent of 2
  32681. */
  32682. static IsExponentOfTwo(value: number): boolean;
  32683. private static _tmpFloatArray;
  32684. /**
  32685. * Returns the nearest 32-bit single precision float representation of a Number
  32686. * @param value A Number. If the parameter is of a different type, it will get converted
  32687. * to a number or to NaN if it cannot be converted
  32688. * @returns number
  32689. */
  32690. static FloatRound(value: number): number;
  32691. /**
  32692. * Extracts the filename from a path
  32693. * @param path defines the path to use
  32694. * @returns the filename
  32695. */
  32696. static GetFilename(path: string): string;
  32697. /**
  32698. * Extracts the "folder" part of a path (everything before the filename).
  32699. * @param uri The URI to extract the info from
  32700. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  32701. * @returns The "folder" part of the path
  32702. */
  32703. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  32704. /**
  32705. * Extracts text content from a DOM element hierarchy
  32706. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  32707. */
  32708. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  32709. /**
  32710. * Convert an angle in radians to degrees
  32711. * @param angle defines the angle to convert
  32712. * @returns the angle in degrees
  32713. */
  32714. static ToDegrees(angle: number): number;
  32715. /**
  32716. * Convert an angle in degrees to radians
  32717. * @param angle defines the angle to convert
  32718. * @returns the angle in radians
  32719. */
  32720. static ToRadians(angle: number): number;
  32721. /**
  32722. * Encode a buffer to a base64 string
  32723. * @param buffer defines the buffer to encode
  32724. * @returns the encoded string
  32725. */
  32726. static EncodeArrayBufferTobase64(buffer: ArrayBuffer): string;
  32727. /**
  32728. * Returns an array if obj is not an array
  32729. * @param obj defines the object to evaluate as an array
  32730. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  32731. * @returns either obj directly if obj is an array or a new array containing obj
  32732. */
  32733. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  32734. /**
  32735. * Gets the pointer prefix to use
  32736. * @returns "pointer" if touch is enabled. Else returns "mouse"
  32737. */
  32738. static GetPointerPrefix(): string;
  32739. /**
  32740. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  32741. * @param url define the url we are trying
  32742. * @param element define the dom element where to configure the cors policy
  32743. */
  32744. static SetCorsBehavior(url: string | string[], element: {
  32745. crossOrigin: string | null;
  32746. }): void;
  32747. /**
  32748. * Removes unwanted characters from an url
  32749. * @param url defines the url to clean
  32750. * @returns the cleaned url
  32751. */
  32752. static CleanUrl(url: string): string;
  32753. /**
  32754. * Gets or sets a function used to pre-process url before using them to load assets
  32755. */
  32756. static PreprocessUrl: (url: string) => string;
  32757. /**
  32758. * Loads an image as an HTMLImageElement.
  32759. * @param input url string, ArrayBuffer, or Blob to load
  32760. * @param onLoad callback called when the image successfully loads
  32761. * @param onError callback called when the image fails to load
  32762. * @param offlineProvider offline provider for caching
  32763. * @returns the HTMLImageElement of the loaded image
  32764. */
  32765. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>): HTMLImageElement;
  32766. /**
  32767. * Loads a file
  32768. * @param url url string, ArrayBuffer, or Blob to load
  32769. * @param onSuccess callback called when the file successfully loads
  32770. * @param onProgress callback called while file is loading (if the server supports this mode)
  32771. * @param offlineProvider defines the offline provider for caching
  32772. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  32773. * @param onError callback called when the file fails to load
  32774. * @returns a file request object
  32775. */
  32776. 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;
  32777. /**
  32778. * Loads a file from a url
  32779. * @param url the file url to load
  32780. * @returns a promise containing an ArrayBuffer corrisponding to the loaded file
  32781. */
  32782. static LoadFileAsync(url: string): Promise<ArrayBuffer>;
  32783. /**
  32784. * Load a script (identified by an url). When the url returns, the
  32785. * content of this file is added into a new script element, attached to the DOM (body element)
  32786. * @param scriptUrl defines the url of the script to laod
  32787. * @param onSuccess defines the callback called when the script is loaded
  32788. * @param onError defines the callback to call if an error occurs
  32789. * @param scriptId defines the id of the script element
  32790. */
  32791. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  32792. /**
  32793. * Load an asynchronous script (identified by an url). When the url returns, the
  32794. * content of this file is added into a new script element, attached to the DOM (body element)
  32795. * @param scriptUrl defines the url of the script to laod
  32796. * @param scriptId defines the id of the script element
  32797. * @returns a promise request object
  32798. */
  32799. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<boolean>;
  32800. /**
  32801. * Loads a file from a blob
  32802. * @param fileToLoad defines the blob to use
  32803. * @param callback defines the callback to call when data is loaded
  32804. * @param progressCallback defines the callback to call during loading process
  32805. * @returns a file request object
  32806. */
  32807. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  32808. /**
  32809. * Loads a file
  32810. * @param fileToLoad defines the file to load
  32811. * @param callback defines the callback to call when data is loaded
  32812. * @param progressCallBack defines the callback to call during loading process
  32813. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  32814. * @returns a file request object
  32815. */
  32816. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  32817. /**
  32818. * Creates a data url from a given string content
  32819. * @param content defines the content to convert
  32820. * @returns the new data url link
  32821. */
  32822. static FileAsURL(content: string): string;
  32823. /**
  32824. * Format the given number to a specific decimal format
  32825. * @param value defines the number to format
  32826. * @param decimals defines the number of decimals to use
  32827. * @returns the formatted string
  32828. */
  32829. static Format(value: number, decimals?: number): string;
  32830. /**
  32831. * Tries to copy an object by duplicating every property
  32832. * @param source defines the source object
  32833. * @param destination defines the target object
  32834. * @param doNotCopyList defines a list of properties to avoid
  32835. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  32836. */
  32837. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  32838. /**
  32839. * Gets a boolean indicating if the given object has no own property
  32840. * @param obj defines the object to test
  32841. * @returns true if object has no own property
  32842. */
  32843. static IsEmpty(obj: any): boolean;
  32844. /**
  32845. * Function used to register events at window level
  32846. * @param windowElement defines the Window object to use
  32847. * @param events defines the events to register
  32848. */
  32849. static RegisterTopRootEvents(windowElement: Window, events: {
  32850. name: string;
  32851. handler: Nullable<(e: FocusEvent) => any>;
  32852. }[]): void;
  32853. /**
  32854. * Function used to unregister events from window level
  32855. * @param windowElement defines the Window object to use
  32856. * @param events defines the events to unregister
  32857. */
  32858. static UnregisterTopRootEvents(windowElement: Window, events: {
  32859. name: string;
  32860. handler: Nullable<(e: FocusEvent) => any>;
  32861. }[]): void;
  32862. /**
  32863. * @ignore
  32864. */
  32865. static _ScreenshotCanvas: HTMLCanvasElement;
  32866. /**
  32867. * Dumps the current bound framebuffer
  32868. * @param width defines the rendering width
  32869. * @param height defines the rendering height
  32870. * @param engine defines the hosting engine
  32871. * @param successCallback defines the callback triggered once the data are available
  32872. * @param mimeType defines the mime type of the result
  32873. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  32874. */
  32875. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  32876. /**
  32877. * Converts the canvas data to blob.
  32878. * This acts as a polyfill for browsers not supporting the to blob function.
  32879. * @param canvas Defines the canvas to extract the data from
  32880. * @param successCallback Defines the callback triggered once the data are available
  32881. * @param mimeType Defines the mime type of the result
  32882. */
  32883. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  32884. /**
  32885. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  32886. * @param successCallback defines the callback triggered once the data are available
  32887. * @param mimeType defines the mime type of the result
  32888. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  32889. */
  32890. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  32891. /**
  32892. * Downloads a blob in the browser
  32893. * @param blob defines the blob to download
  32894. * @param fileName defines the name of the downloaded file
  32895. */
  32896. static Download(blob: Blob, fileName: string): void;
  32897. /**
  32898. * Captures a screenshot of the current rendering
  32899. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  32900. * @param engine defines the rendering engine
  32901. * @param camera defines the source camera
  32902. * @param size This parameter can be set to a single number or to an object with the
  32903. * following (optional) properties: precision, width, height. If a single number is passed,
  32904. * it will be used for both width and height. If an object is passed, the screenshot size
  32905. * will be derived from the parameters. The precision property is a multiplier allowing
  32906. * rendering at a higher or lower resolution
  32907. * @param successCallback defines the callback receives a single parameter which contains the
  32908. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  32909. * src parameter of an <img> to display it
  32910. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  32911. * Check your browser for supported MIME types
  32912. */
  32913. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  32914. /**
  32915. * Captures a screenshot of the current rendering
  32916. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  32917. * @param engine defines the rendering engine
  32918. * @param camera defines the source camera
  32919. * @param size This parameter can be set to a single number or to an object with the
  32920. * following (optional) properties: precision, width, height. If a single number is passed,
  32921. * it will be used for both width and height. If an object is passed, the screenshot size
  32922. * will be derived from the parameters. The precision property is a multiplier allowing
  32923. * rendering at a higher or lower resolution
  32924. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  32925. * Check your browser for supported MIME types
  32926. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  32927. * to the src parameter of an <img> to display it
  32928. */
  32929. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  32930. /**
  32931. * Generates an image screenshot from the specified camera.
  32932. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  32933. * @param engine The engine to use for rendering
  32934. * @param camera The camera to use for rendering
  32935. * @param size This parameter can be set to a single number or to an object with the
  32936. * following (optional) properties: precision, width, height. If a single number is passed,
  32937. * it will be used for both width and height. If an object is passed, the screenshot size
  32938. * will be derived from the parameters. The precision property is a multiplier allowing
  32939. * rendering at a higher or lower resolution
  32940. * @param successCallback The callback receives a single parameter which contains the
  32941. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  32942. * src parameter of an <img> to display it
  32943. * @param mimeType The MIME type of the screenshot image (default: image/png).
  32944. * Check your browser for supported MIME types
  32945. * @param samples Texture samples (default: 1)
  32946. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  32947. * @param fileName A name for for the downloaded file.
  32948. */
  32949. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  32950. /**
  32951. * Generates an image screenshot from the specified camera.
  32952. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  32953. * @param engine The engine to use for rendering
  32954. * @param camera The camera to use for rendering
  32955. * @param size This parameter can be set to a single number or to an object with the
  32956. * following (optional) properties: precision, width, height. If a single number is passed,
  32957. * it will be used for both width and height. If an object is passed, the screenshot size
  32958. * will be derived from the parameters. The precision property is a multiplier allowing
  32959. * rendering at a higher or lower resolution
  32960. * @param mimeType The MIME type of the screenshot image (default: image/png).
  32961. * Check your browser for supported MIME types
  32962. * @param samples Texture samples (default: 1)
  32963. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  32964. * @param fileName A name for for the downloaded file.
  32965. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  32966. * to the src parameter of an <img> to display it
  32967. */
  32968. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  32969. /**
  32970. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  32971. * Be aware Math.random() could cause collisions, but:
  32972. * "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"
  32973. * @returns a pseudo random id
  32974. */
  32975. static RandomId(): string;
  32976. /**
  32977. * Test if the given uri is a base64 string
  32978. * @param uri The uri to test
  32979. * @return True if the uri is a base64 string or false otherwise
  32980. */
  32981. static IsBase64(uri: string): boolean;
  32982. /**
  32983. * Decode the given base64 uri.
  32984. * @param uri The uri to decode
  32985. * @return The decoded base64 data.
  32986. */
  32987. static DecodeBase64(uri: string): ArrayBuffer;
  32988. /**
  32989. * Gets the absolute url.
  32990. * @param url the input url
  32991. * @return the absolute url
  32992. */
  32993. static GetAbsoluteUrl(url: string): string;
  32994. /**
  32995. * No log
  32996. */
  32997. static readonly NoneLogLevel: number;
  32998. /**
  32999. * Only message logs
  33000. */
  33001. static readonly MessageLogLevel: number;
  33002. /**
  33003. * Only warning logs
  33004. */
  33005. static readonly WarningLogLevel: number;
  33006. /**
  33007. * Only error logs
  33008. */
  33009. static readonly ErrorLogLevel: number;
  33010. /**
  33011. * All logs
  33012. */
  33013. static readonly AllLogLevel: number;
  33014. /**
  33015. * Gets a value indicating the number of loading errors
  33016. * @ignorenaming
  33017. */
  33018. static readonly errorsCount: number;
  33019. /**
  33020. * Callback called when a new log is added
  33021. */
  33022. static OnNewCacheEntry: (entry: string) => void;
  33023. /**
  33024. * Log a message to the console
  33025. * @param message defines the message to log
  33026. */
  33027. static Log(message: string): void;
  33028. /**
  33029. * Write a warning message to the console
  33030. * @param message defines the message to log
  33031. */
  33032. static Warn(message: string): void;
  33033. /**
  33034. * Write an error message to the console
  33035. * @param message defines the message to log
  33036. */
  33037. static Error(message: string): void;
  33038. /**
  33039. * Gets current log cache (list of logs)
  33040. */
  33041. static readonly LogCache: string;
  33042. /**
  33043. * Clears the log cache
  33044. */
  33045. static ClearLogCache(): void;
  33046. /**
  33047. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  33048. */
  33049. static LogLevels: number;
  33050. /**
  33051. * Checks if the window object exists
  33052. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  33053. */
  33054. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  33055. /**
  33056. * No performance log
  33057. */
  33058. static readonly PerformanceNoneLogLevel: number;
  33059. /**
  33060. * Use user marks to log performance
  33061. */
  33062. static readonly PerformanceUserMarkLogLevel: number;
  33063. /**
  33064. * Log performance to the console
  33065. */
  33066. static readonly PerformanceConsoleLogLevel: number;
  33067. private static _performance;
  33068. /**
  33069. * Sets the current performance log level
  33070. */
  33071. static PerformanceLogLevel: number;
  33072. private static _StartPerformanceCounterDisabled;
  33073. private static _EndPerformanceCounterDisabled;
  33074. private static _StartUserMark;
  33075. private static _EndUserMark;
  33076. private static _StartPerformanceConsole;
  33077. private static _EndPerformanceConsole;
  33078. /**
  33079. * Starts a performance counter
  33080. */
  33081. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  33082. /**
  33083. * Ends a specific performance coutner
  33084. */
  33085. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  33086. /**
  33087. * Gets either window.performance.now() if supported or Date.now() else
  33088. */
  33089. static readonly Now: number;
  33090. /**
  33091. * This method will return the name of the class used to create the instance of the given object.
  33092. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  33093. * @param object the object to get the class name from
  33094. * @param isType defines if the object is actually a type
  33095. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  33096. */
  33097. static GetClassName(object: any, isType?: boolean): string;
  33098. /**
  33099. * Gets the first element of an array satisfying a given predicate
  33100. * @param array defines the array to browse
  33101. * @param predicate defines the predicate to use
  33102. * @returns null if not found or the element
  33103. */
  33104. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  33105. /**
  33106. * This method will return the name of the full name of the class, including its owning module (if any).
  33107. * 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).
  33108. * @param object the object to get the class name from
  33109. * @param isType defines if the object is actually a type
  33110. * @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.
  33111. * @ignorenaming
  33112. */
  33113. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  33114. /**
  33115. * Returns a promise that resolves after the given amount of time.
  33116. * @param delay Number of milliseconds to delay
  33117. * @returns Promise that resolves after the given amount of time
  33118. */
  33119. static DelayAsync(delay: number): Promise<void>;
  33120. }
  33121. /**
  33122. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  33123. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  33124. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  33125. * @param name The name of the class, case should be preserved
  33126. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  33127. */
  33128. export function className(name: string, module?: string): (target: Object) => void;
  33129. /**
  33130. * An implementation of a loop for asynchronous functions.
  33131. */
  33132. export class AsyncLoop {
  33133. /**
  33134. * Defines the number of iterations for the loop
  33135. */
  33136. iterations: number;
  33137. /**
  33138. * Defines the current index of the loop.
  33139. */
  33140. index: number;
  33141. private _done;
  33142. private _fn;
  33143. private _successCallback;
  33144. /**
  33145. * Constructor.
  33146. * @param iterations the number of iterations.
  33147. * @param func the function to run each iteration
  33148. * @param successCallback the callback that will be called upon succesful execution
  33149. * @param offset starting offset.
  33150. */
  33151. constructor(
  33152. /**
  33153. * Defines the number of iterations for the loop
  33154. */
  33155. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  33156. /**
  33157. * Execute the next iteration. Must be called after the last iteration was finished.
  33158. */
  33159. executeNext(): void;
  33160. /**
  33161. * Break the loop and run the success callback.
  33162. */
  33163. breakLoop(): void;
  33164. /**
  33165. * Create and run an async loop.
  33166. * @param iterations the number of iterations.
  33167. * @param fn the function to run each iteration
  33168. * @param successCallback the callback that will be called upon succesful execution
  33169. * @param offset starting offset.
  33170. * @returns the created async loop object
  33171. */
  33172. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  33173. /**
  33174. * A for-loop that will run a given number of iterations synchronous and the rest async.
  33175. * @param iterations total number of iterations
  33176. * @param syncedIterations number of synchronous iterations in each async iteration.
  33177. * @param fn the function to call each iteration.
  33178. * @param callback a success call back that will be called when iterating stops.
  33179. * @param breakFunction a break condition (optional)
  33180. * @param timeout timeout settings for the setTimeout function. default - 0.
  33181. * @returns the created async loop object
  33182. */
  33183. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  33184. }
  33185. }
  33186. declare module "babylonjs/Collisions/collisionCoordinator" {
  33187. import { Nullable } from "babylonjs/types";
  33188. import { Scene } from "babylonjs/scene";
  33189. import { Vector3 } from "babylonjs/Maths/math.vector";
  33190. import { Collider } from "babylonjs/Collisions/collider";
  33191. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  33192. /** @hidden */
  33193. export interface ICollisionCoordinator {
  33194. createCollider(): Collider;
  33195. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  33196. init(scene: Scene): void;
  33197. }
  33198. /** @hidden */
  33199. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  33200. private _scene;
  33201. private _scaledPosition;
  33202. private _scaledVelocity;
  33203. private _finalPosition;
  33204. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  33205. createCollider(): Collider;
  33206. init(scene: Scene): void;
  33207. private _collideWithWorld;
  33208. }
  33209. }
  33210. declare module "babylonjs/Inputs/scene.inputManager" {
  33211. import { Nullable } from "babylonjs/types";
  33212. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  33213. import { Vector2 } from "babylonjs/Maths/math.vector";
  33214. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  33215. import { Scene } from "babylonjs/scene";
  33216. /**
  33217. * Class used to manage all inputs for the scene.
  33218. */
  33219. export class InputManager {
  33220. /** The distance in pixel that you have to move to prevent some events */
  33221. static DragMovementThreshold: number;
  33222. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  33223. static LongPressDelay: number;
  33224. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  33225. static DoubleClickDelay: number;
  33226. /** If you need to check double click without raising a single click at first click, enable this flag */
  33227. static ExclusiveDoubleClickMode: boolean;
  33228. private _wheelEventName;
  33229. private _onPointerMove;
  33230. private _onPointerDown;
  33231. private _onPointerUp;
  33232. private _initClickEvent;
  33233. private _initActionManager;
  33234. private _delayedSimpleClick;
  33235. private _delayedSimpleClickTimeout;
  33236. private _previousDelayedSimpleClickTimeout;
  33237. private _meshPickProceed;
  33238. private _previousButtonPressed;
  33239. private _currentPickResult;
  33240. private _previousPickResult;
  33241. private _totalPointersPressed;
  33242. private _doubleClickOccured;
  33243. private _pointerOverMesh;
  33244. private _pickedDownMesh;
  33245. private _pickedUpMesh;
  33246. private _pointerX;
  33247. private _pointerY;
  33248. private _unTranslatedPointerX;
  33249. private _unTranslatedPointerY;
  33250. private _startingPointerPosition;
  33251. private _previousStartingPointerPosition;
  33252. private _startingPointerTime;
  33253. private _previousStartingPointerTime;
  33254. private _pointerCaptures;
  33255. private _onKeyDown;
  33256. private _onKeyUp;
  33257. private _onCanvasFocusObserver;
  33258. private _onCanvasBlurObserver;
  33259. private _scene;
  33260. /**
  33261. * Creates a new InputManager
  33262. * @param scene defines the hosting scene
  33263. */
  33264. constructor(scene: Scene);
  33265. /**
  33266. * Gets the mesh that is currently under the pointer
  33267. */
  33268. readonly meshUnderPointer: Nullable<AbstractMesh>;
  33269. /**
  33270. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  33271. */
  33272. readonly unTranslatedPointer: Vector2;
  33273. /**
  33274. * Gets or sets the current on-screen X position of the pointer
  33275. */
  33276. pointerX: number;
  33277. /**
  33278. * Gets or sets the current on-screen Y position of the pointer
  33279. */
  33280. pointerY: number;
  33281. private _updatePointerPosition;
  33282. private _processPointerMove;
  33283. private _setRayOnPointerInfo;
  33284. private _checkPrePointerObservable;
  33285. /**
  33286. * Use this method to simulate a pointer move on a mesh
  33287. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  33288. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  33289. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  33290. */
  33291. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  33292. /**
  33293. * Use this method to simulate a pointer down on a mesh
  33294. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  33295. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  33296. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  33297. */
  33298. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  33299. private _processPointerDown;
  33300. /** @hidden */
  33301. _isPointerSwiping(): boolean;
  33302. /**
  33303. * Use this method to simulate a pointer up on a mesh
  33304. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  33305. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  33306. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  33307. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  33308. */
  33309. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  33310. private _processPointerUp;
  33311. /**
  33312. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  33313. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  33314. * @returns true if the pointer was captured
  33315. */
  33316. isPointerCaptured(pointerId?: number): boolean;
  33317. /**
  33318. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  33319. * @param attachUp defines if you want to attach events to pointerup
  33320. * @param attachDown defines if you want to attach events to pointerdown
  33321. * @param attachMove defines if you want to attach events to pointermove
  33322. */
  33323. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  33324. /**
  33325. * Detaches all event handlers
  33326. */
  33327. detachControl(): void;
  33328. /**
  33329. * Force the value of meshUnderPointer
  33330. * @param mesh defines the mesh to use
  33331. */
  33332. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  33333. /**
  33334. * Gets the mesh under the pointer
  33335. * @returns a Mesh or null if no mesh is under the pointer
  33336. */
  33337. getPointerOverMesh(): Nullable<AbstractMesh>;
  33338. }
  33339. }
  33340. declare module "babylonjs/Misc/uniqueIdGenerator" {
  33341. /**
  33342. * Helper class used to generate session unique ID
  33343. */
  33344. export class UniqueIdGenerator {
  33345. private static _UniqueIdCounter;
  33346. /**
  33347. * Gets an unique (relatively to the current scene) Id
  33348. */
  33349. static readonly UniqueId: number;
  33350. }
  33351. }
  33352. declare module "babylonjs/Animations/animationGroup" {
  33353. import { Animatable } from "babylonjs/Animations/animatable";
  33354. import { Animation } from "babylonjs/Animations/animation";
  33355. import { Scene, IDisposable } from "babylonjs/scene";
  33356. import { Observable } from "babylonjs/Misc/observable";
  33357. import { Nullable } from "babylonjs/types";
  33358. import "babylonjs/Animations/animatable";
  33359. /**
  33360. * This class defines the direct association between an animation and a target
  33361. */
  33362. export class TargetedAnimation {
  33363. /**
  33364. * Animation to perform
  33365. */
  33366. animation: Animation;
  33367. /**
  33368. * Target to animate
  33369. */
  33370. target: any;
  33371. /**
  33372. * Serialize the object
  33373. * @returns the JSON object representing the current entity
  33374. */
  33375. serialize(): any;
  33376. }
  33377. /**
  33378. * Use this class to create coordinated animations on multiple targets
  33379. */
  33380. export class AnimationGroup implements IDisposable {
  33381. /** The name of the animation group */
  33382. name: string;
  33383. private _scene;
  33384. private _targetedAnimations;
  33385. private _animatables;
  33386. private _from;
  33387. private _to;
  33388. private _isStarted;
  33389. private _isPaused;
  33390. private _speedRatio;
  33391. private _loopAnimation;
  33392. /**
  33393. * Gets or sets the unique id of the node
  33394. */
  33395. uniqueId: number;
  33396. /**
  33397. * This observable will notify when one animation have ended
  33398. */
  33399. onAnimationEndObservable: Observable<TargetedAnimation>;
  33400. /**
  33401. * Observer raised when one animation loops
  33402. */
  33403. onAnimationLoopObservable: Observable<TargetedAnimation>;
  33404. /**
  33405. * This observable will notify when all animations have ended.
  33406. */
  33407. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  33408. /**
  33409. * This observable will notify when all animations have paused.
  33410. */
  33411. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  33412. /**
  33413. * This observable will notify when all animations are playing.
  33414. */
  33415. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  33416. /**
  33417. * Gets the first frame
  33418. */
  33419. readonly from: number;
  33420. /**
  33421. * Gets the last frame
  33422. */
  33423. readonly to: number;
  33424. /**
  33425. * Define if the animations are started
  33426. */
  33427. readonly isStarted: boolean;
  33428. /**
  33429. * Gets a value indicating that the current group is playing
  33430. */
  33431. readonly isPlaying: boolean;
  33432. /**
  33433. * Gets or sets the speed ratio to use for all animations
  33434. */
  33435. /**
  33436. * Gets or sets the speed ratio to use for all animations
  33437. */
  33438. speedRatio: number;
  33439. /**
  33440. * Gets or sets if all animations should loop or not
  33441. */
  33442. loopAnimation: boolean;
  33443. /**
  33444. * Gets the targeted animations for this animation group
  33445. */
  33446. readonly targetedAnimations: Array<TargetedAnimation>;
  33447. /**
  33448. * returning the list of animatables controlled by this animation group.
  33449. */
  33450. readonly animatables: Array<Animatable>;
  33451. /**
  33452. * Instantiates a new Animation Group.
  33453. * This helps managing several animations at once.
  33454. * @see http://doc.babylonjs.com/how_to/group
  33455. * @param name Defines the name of the group
  33456. * @param scene Defines the scene the group belongs to
  33457. */
  33458. constructor(
  33459. /** The name of the animation group */
  33460. name: string, scene?: Nullable<Scene>);
  33461. /**
  33462. * Add an animation (with its target) in the group
  33463. * @param animation defines the animation we want to add
  33464. * @param target defines the target of the animation
  33465. * @returns the TargetedAnimation object
  33466. */
  33467. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  33468. /**
  33469. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  33470. * It can add constant keys at begin or end
  33471. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  33472. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  33473. * @returns the animation group
  33474. */
  33475. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  33476. /**
  33477. * Start all animations on given targets
  33478. * @param loop defines if animations must loop
  33479. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  33480. * @param from defines the from key (optional)
  33481. * @param to defines the to key (optional)
  33482. * @returns the current animation group
  33483. */
  33484. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  33485. /**
  33486. * Pause all animations
  33487. * @returns the animation group
  33488. */
  33489. pause(): AnimationGroup;
  33490. /**
  33491. * Play all animations to initial state
  33492. * This function will start() the animations if they were not started or will restart() them if they were paused
  33493. * @param loop defines if animations must loop
  33494. * @returns the animation group
  33495. */
  33496. play(loop?: boolean): AnimationGroup;
  33497. /**
  33498. * Reset all animations to initial state
  33499. * @returns the animation group
  33500. */
  33501. reset(): AnimationGroup;
  33502. /**
  33503. * Restart animations from key 0
  33504. * @returns the animation group
  33505. */
  33506. restart(): AnimationGroup;
  33507. /**
  33508. * Stop all animations
  33509. * @returns the animation group
  33510. */
  33511. stop(): AnimationGroup;
  33512. /**
  33513. * Set animation weight for all animatables
  33514. * @param weight defines the weight to use
  33515. * @return the animationGroup
  33516. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  33517. */
  33518. setWeightForAllAnimatables(weight: number): AnimationGroup;
  33519. /**
  33520. * Synchronize and normalize all animatables with a source animatable
  33521. * @param root defines the root animatable to synchronize with
  33522. * @return the animationGroup
  33523. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  33524. */
  33525. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  33526. /**
  33527. * Goes to a specific frame in this animation group
  33528. * @param frame the frame number to go to
  33529. * @return the animationGroup
  33530. */
  33531. goToFrame(frame: number): AnimationGroup;
  33532. /**
  33533. * Dispose all associated resources
  33534. */
  33535. dispose(): void;
  33536. private _checkAnimationGroupEnded;
  33537. /**
  33538. * Clone the current animation group and returns a copy
  33539. * @param newName defines the name of the new group
  33540. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  33541. * @returns the new aniamtion group
  33542. */
  33543. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  33544. /**
  33545. * Serializes the animationGroup to an object
  33546. * @returns Serialized object
  33547. */
  33548. serialize(): any;
  33549. /**
  33550. * Returns a new AnimationGroup object parsed from the source provided.
  33551. * @param parsedAnimationGroup defines the source
  33552. * @param scene defines the scene that will receive the animationGroup
  33553. * @returns a new AnimationGroup
  33554. */
  33555. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  33556. /**
  33557. * Returns the string "AnimationGroup"
  33558. * @returns "AnimationGroup"
  33559. */
  33560. getClassName(): string;
  33561. /**
  33562. * Creates a detailled string about the object
  33563. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  33564. * @returns a string representing the object
  33565. */
  33566. toString(fullDetails?: boolean): string;
  33567. }
  33568. }
  33569. declare module "babylonjs/scene" {
  33570. import { Nullable } from "babylonjs/types";
  33571. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  33572. import { Observable } from "babylonjs/Misc/observable";
  33573. import { SmartArrayNoDuplicate, SmartArray, ISmartArrayLike } from "babylonjs/Misc/smartArray";
  33574. import { Vector2, Vector3, Matrix } from "babylonjs/Maths/math.vector";
  33575. import { Geometry } from "babylonjs/Meshes/geometry";
  33576. import { TransformNode } from "babylonjs/Meshes/transformNode";
  33577. import { SubMesh } from "babylonjs/Meshes/subMesh";
  33578. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  33579. import { Mesh } from "babylonjs/Meshes/mesh";
  33580. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  33581. import { Bone } from "babylonjs/Bones/bone";
  33582. import { Skeleton } from "babylonjs/Bones/skeleton";
  33583. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  33584. import { Camera } from "babylonjs/Cameras/camera";
  33585. import { AbstractScene } from "babylonjs/abstractScene";
  33586. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  33587. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  33588. import { Material } from "babylonjs/Materials/material";
  33589. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  33590. import { Effect } from "babylonjs/Materials/effect";
  33591. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  33592. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  33593. import { Light } from "babylonjs/Lights/light";
  33594. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  33595. import { ICollisionCoordinator } from "babylonjs/Collisions/collisionCoordinator";
  33596. import { PointerEventTypes, PointerInfoPre, PointerInfo } from "babylonjs/Events/pointerEvents";
  33597. import { KeyboardInfoPre, KeyboardInfo } from "babylonjs/Events/keyboardEvents";
  33598. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  33599. import { PostProcessManager } from "babylonjs/PostProcesses/postProcessManager";
  33600. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  33601. import { RenderingGroupInfo, IRenderingManagerAutoClearSetup } from "babylonjs/Rendering/renderingManager";
  33602. import { ISceneComponent, ISceneSerializableComponent, Stage, SimpleStageAction, RenderTargetsStageAction, RenderTargetStageAction, MeshStageAction, EvaluateSubMeshStageAction, ActiveMeshStageAction, CameraStageAction, RenderingGroupStageAction, RenderingMeshStageAction, PointerMoveStageAction, PointerUpDownStageAction, CameraStageFrameBufferAction } from "babylonjs/sceneComponent";
  33603. import { Engine } from "babylonjs/Engines/engine";
  33604. import { Node } from "babylonjs/node";
  33605. import { MorphTarget } from "babylonjs/Morph/morphTarget";
  33606. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  33607. import { WebRequest } from "babylonjs/Misc/webRequest";
  33608. import { InputManager } from "babylonjs/Inputs/scene.inputManager";
  33609. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  33610. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  33611. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  33612. import { Plane } from "babylonjs/Maths/math.plane";
  33613. import { Ray } from "babylonjs/Culling/ray";
  33614. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  33615. import { Animation } from "babylonjs/Animations/animation";
  33616. import { Animatable } from "babylonjs/Animations/animatable";
  33617. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  33618. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  33619. import { Collider } from "babylonjs/Collisions/collider";
  33620. /**
  33621. * Define an interface for all classes that will hold resources
  33622. */
  33623. export interface IDisposable {
  33624. /**
  33625. * Releases all held resources
  33626. */
  33627. dispose(): void;
  33628. }
  33629. /** Interface defining initialization parameters for Scene class */
  33630. export interface SceneOptions {
  33631. /**
  33632. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  33633. * It will improve performance when the number of geometries becomes important.
  33634. */
  33635. useGeometryUniqueIdsMap?: boolean;
  33636. /**
  33637. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  33638. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  33639. */
  33640. useMaterialMeshMap?: boolean;
  33641. /**
  33642. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  33643. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  33644. */
  33645. useClonedMeshhMap?: boolean;
  33646. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  33647. virtual?: boolean;
  33648. }
  33649. /**
  33650. * Represents a scene to be rendered by the engine.
  33651. * @see http://doc.babylonjs.com/features/scene
  33652. */
  33653. export class Scene extends AbstractScene implements IAnimatable {
  33654. /** The fog is deactivated */
  33655. static readonly FOGMODE_NONE: number;
  33656. /** The fog density is following an exponential function */
  33657. static readonly FOGMODE_EXP: number;
  33658. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  33659. static readonly FOGMODE_EXP2: number;
  33660. /** The fog density is following a linear function. */
  33661. static readonly FOGMODE_LINEAR: number;
  33662. /**
  33663. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  33664. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  33665. */
  33666. static MinDeltaTime: number;
  33667. /**
  33668. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  33669. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  33670. */
  33671. static MaxDeltaTime: number;
  33672. /**
  33673. * Factory used to create the default material.
  33674. * @param name The name of the material to create
  33675. * @param scene The scene to create the material for
  33676. * @returns The default material
  33677. */
  33678. static DefaultMaterialFactory(scene: Scene): Material;
  33679. /**
  33680. * Factory used to create the a collision coordinator.
  33681. * @returns The collision coordinator
  33682. */
  33683. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  33684. /** @hidden */
  33685. _inputManager: InputManager;
  33686. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  33687. cameraToUseForPointers: Nullable<Camera>;
  33688. /** @hidden */
  33689. readonly _isScene: boolean;
  33690. /**
  33691. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  33692. */
  33693. autoClear: boolean;
  33694. /**
  33695. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  33696. */
  33697. autoClearDepthAndStencil: boolean;
  33698. /**
  33699. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  33700. */
  33701. clearColor: Color4;
  33702. /**
  33703. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  33704. */
  33705. ambientColor: Color3;
  33706. /**
  33707. * This is use to store the default BRDF lookup for PBR materials in your scene.
  33708. * It should only be one of the following (if not the default embedded one):
  33709. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  33710. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  33711. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  33712. * The material properties need to be setup according to the type of texture in use.
  33713. */
  33714. environmentBRDFTexture: BaseTexture;
  33715. /** @hidden */
  33716. protected _environmentTexture: Nullable<BaseTexture>;
  33717. /**
  33718. * Texture used in all pbr material as the reflection texture.
  33719. * As in the majority of the scene they are the same (exception for multi room and so on),
  33720. * this is easier to reference from here than from all the materials.
  33721. */
  33722. /**
  33723. * Texture used in all pbr material as the reflection texture.
  33724. * As in the majority of the scene they are the same (exception for multi room and so on),
  33725. * this is easier to set here than in all the materials.
  33726. */
  33727. environmentTexture: Nullable<BaseTexture>;
  33728. /** @hidden */
  33729. protected _environmentIntensity: number;
  33730. /**
  33731. * Intensity of the environment in all pbr material.
  33732. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  33733. * As in the majority of the scene they are the same (exception for multi room and so on),
  33734. * this is easier to reference from here than from all the materials.
  33735. */
  33736. /**
  33737. * Intensity of the environment in all pbr material.
  33738. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  33739. * As in the majority of the scene they are the same (exception for multi room and so on),
  33740. * this is easier to set here than in all the materials.
  33741. */
  33742. environmentIntensity: number;
  33743. /** @hidden */
  33744. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  33745. /**
  33746. * Default image processing configuration used either in the rendering
  33747. * Forward main pass or through the imageProcessingPostProcess if present.
  33748. * As in the majority of the scene they are the same (exception for multi camera),
  33749. * this is easier to reference from here than from all the materials and post process.
  33750. *
  33751. * No setter as we it is a shared configuration, you can set the values instead.
  33752. */
  33753. readonly imageProcessingConfiguration: ImageProcessingConfiguration;
  33754. private _forceWireframe;
  33755. /**
  33756. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  33757. */
  33758. forceWireframe: boolean;
  33759. private _forcePointsCloud;
  33760. /**
  33761. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  33762. */
  33763. forcePointsCloud: boolean;
  33764. /**
  33765. * Gets or sets the active clipplane 1
  33766. */
  33767. clipPlane: Nullable<Plane>;
  33768. /**
  33769. * Gets or sets the active clipplane 2
  33770. */
  33771. clipPlane2: Nullable<Plane>;
  33772. /**
  33773. * Gets or sets the active clipplane 3
  33774. */
  33775. clipPlane3: Nullable<Plane>;
  33776. /**
  33777. * Gets or sets the active clipplane 4
  33778. */
  33779. clipPlane4: Nullable<Plane>;
  33780. /**
  33781. * Gets or sets a boolean indicating if animations are enabled
  33782. */
  33783. animationsEnabled: boolean;
  33784. private _animationPropertiesOverride;
  33785. /**
  33786. * Gets or sets the animation properties override
  33787. */
  33788. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  33789. /**
  33790. * Gets or sets a boolean indicating if a constant deltatime has to be used
  33791. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  33792. */
  33793. useConstantAnimationDeltaTime: boolean;
  33794. /**
  33795. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  33796. * Please note that it requires to run a ray cast through the scene on every frame
  33797. */
  33798. constantlyUpdateMeshUnderPointer: boolean;
  33799. /**
  33800. * Defines the HTML cursor to use when hovering over interactive elements
  33801. */
  33802. hoverCursor: string;
  33803. /**
  33804. * Defines the HTML default cursor to use (empty by default)
  33805. */
  33806. defaultCursor: string;
  33807. /**
  33808. * This is used to call preventDefault() on pointer down
  33809. * in order to block unwanted artifacts like system double clicks
  33810. */
  33811. preventDefaultOnPointerDown: boolean;
  33812. /**
  33813. * This is used to call preventDefault() on pointer up
  33814. * in order to block unwanted artifacts like system double clicks
  33815. */
  33816. preventDefaultOnPointerUp: boolean;
  33817. /**
  33818. * Gets or sets user defined metadata
  33819. */
  33820. metadata: any;
  33821. /**
  33822. * For internal use only. Please do not use.
  33823. */
  33824. reservedDataStore: any;
  33825. /**
  33826. * Gets the name of the plugin used to load this scene (null by default)
  33827. */
  33828. loadingPluginName: string;
  33829. /**
  33830. * Use this array to add regular expressions used to disable offline support for specific urls
  33831. */
  33832. disableOfflineSupportExceptionRules: RegExp[];
  33833. /**
  33834. * An event triggered when the scene is disposed.
  33835. */
  33836. onDisposeObservable: Observable<Scene>;
  33837. private _onDisposeObserver;
  33838. /** Sets a function to be executed when this scene is disposed. */
  33839. onDispose: () => void;
  33840. /**
  33841. * An event triggered before rendering the scene (right after animations and physics)
  33842. */
  33843. onBeforeRenderObservable: Observable<Scene>;
  33844. private _onBeforeRenderObserver;
  33845. /** Sets a function to be executed before rendering this scene */
  33846. beforeRender: Nullable<() => void>;
  33847. /**
  33848. * An event triggered after rendering the scene
  33849. */
  33850. onAfterRenderObservable: Observable<Scene>;
  33851. /**
  33852. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  33853. */
  33854. onAfterRenderCameraObservable: Observable<Camera>;
  33855. private _onAfterRenderObserver;
  33856. /** Sets a function to be executed after rendering this scene */
  33857. afterRender: Nullable<() => void>;
  33858. /**
  33859. * An event triggered before animating the scene
  33860. */
  33861. onBeforeAnimationsObservable: Observable<Scene>;
  33862. /**
  33863. * An event triggered after animations processing
  33864. */
  33865. onAfterAnimationsObservable: Observable<Scene>;
  33866. /**
  33867. * An event triggered before draw calls are ready to be sent
  33868. */
  33869. onBeforeDrawPhaseObservable: Observable<Scene>;
  33870. /**
  33871. * An event triggered after draw calls have been sent
  33872. */
  33873. onAfterDrawPhaseObservable: Observable<Scene>;
  33874. /**
  33875. * An event triggered when the scene is ready
  33876. */
  33877. onReadyObservable: Observable<Scene>;
  33878. /**
  33879. * An event triggered before rendering a camera
  33880. */
  33881. onBeforeCameraRenderObservable: Observable<Camera>;
  33882. private _onBeforeCameraRenderObserver;
  33883. /** Sets a function to be executed before rendering a camera*/
  33884. beforeCameraRender: () => void;
  33885. /**
  33886. * An event triggered after rendering a camera
  33887. */
  33888. onAfterCameraRenderObservable: Observable<Camera>;
  33889. private _onAfterCameraRenderObserver;
  33890. /** Sets a function to be executed after rendering a camera*/
  33891. afterCameraRender: () => void;
  33892. /**
  33893. * An event triggered when active meshes evaluation is about to start
  33894. */
  33895. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  33896. /**
  33897. * An event triggered when active meshes evaluation is done
  33898. */
  33899. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  33900. /**
  33901. * An event triggered when particles rendering is about to start
  33902. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  33903. */
  33904. onBeforeParticlesRenderingObservable: Observable<Scene>;
  33905. /**
  33906. * An event triggered when particles rendering is done
  33907. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  33908. */
  33909. onAfterParticlesRenderingObservable: Observable<Scene>;
  33910. /**
  33911. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  33912. */
  33913. onDataLoadedObservable: Observable<Scene>;
  33914. /**
  33915. * An event triggered when a camera is created
  33916. */
  33917. onNewCameraAddedObservable: Observable<Camera>;
  33918. /**
  33919. * An event triggered when a camera is removed
  33920. */
  33921. onCameraRemovedObservable: Observable<Camera>;
  33922. /**
  33923. * An event triggered when a light is created
  33924. */
  33925. onNewLightAddedObservable: Observable<Light>;
  33926. /**
  33927. * An event triggered when a light is removed
  33928. */
  33929. onLightRemovedObservable: Observable<Light>;
  33930. /**
  33931. * An event triggered when a geometry is created
  33932. */
  33933. onNewGeometryAddedObservable: Observable<Geometry>;
  33934. /**
  33935. * An event triggered when a geometry is removed
  33936. */
  33937. onGeometryRemovedObservable: Observable<Geometry>;
  33938. /**
  33939. * An event triggered when a transform node is created
  33940. */
  33941. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  33942. /**
  33943. * An event triggered when a transform node is removed
  33944. */
  33945. onTransformNodeRemovedObservable: Observable<TransformNode>;
  33946. /**
  33947. * An event triggered when a mesh is created
  33948. */
  33949. onNewMeshAddedObservable: Observable<AbstractMesh>;
  33950. /**
  33951. * An event triggered when a mesh is removed
  33952. */
  33953. onMeshRemovedObservable: Observable<AbstractMesh>;
  33954. /**
  33955. * An event triggered when a skeleton is created
  33956. */
  33957. onNewSkeletonAddedObservable: Observable<Skeleton>;
  33958. /**
  33959. * An event triggered when a skeleton is removed
  33960. */
  33961. onSkeletonRemovedObservable: Observable<Skeleton>;
  33962. /**
  33963. * An event triggered when a material is created
  33964. */
  33965. onNewMaterialAddedObservable: Observable<Material>;
  33966. /**
  33967. * An event triggered when a material is removed
  33968. */
  33969. onMaterialRemovedObservable: Observable<Material>;
  33970. /**
  33971. * An event triggered when a texture is created
  33972. */
  33973. onNewTextureAddedObservable: Observable<BaseTexture>;
  33974. /**
  33975. * An event triggered when a texture is removed
  33976. */
  33977. onTextureRemovedObservable: Observable<BaseTexture>;
  33978. /**
  33979. * An event triggered when render targets are about to be rendered
  33980. * Can happen multiple times per frame.
  33981. */
  33982. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  33983. /**
  33984. * An event triggered when render targets were rendered.
  33985. * Can happen multiple times per frame.
  33986. */
  33987. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  33988. /**
  33989. * An event triggered before calculating deterministic simulation step
  33990. */
  33991. onBeforeStepObservable: Observable<Scene>;
  33992. /**
  33993. * An event triggered after calculating deterministic simulation step
  33994. */
  33995. onAfterStepObservable: Observable<Scene>;
  33996. /**
  33997. * An event triggered when the activeCamera property is updated
  33998. */
  33999. onActiveCameraChanged: Observable<Scene>;
  34000. /**
  34001. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  34002. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  34003. * 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)
  34004. */
  34005. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  34006. /**
  34007. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  34008. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  34009. * 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)
  34010. */
  34011. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  34012. /**
  34013. * This Observable will when a mesh has been imported into the scene.
  34014. */
  34015. onMeshImportedObservable: Observable<AbstractMesh>;
  34016. /**
  34017. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  34018. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  34019. */
  34020. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  34021. /** @hidden */
  34022. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  34023. /**
  34024. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  34025. */
  34026. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  34027. /**
  34028. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  34029. */
  34030. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  34031. /**
  34032. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  34033. */
  34034. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  34035. /** Callback called when a pointer move is detected */
  34036. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  34037. /** Callback called when a pointer down is detected */
  34038. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  34039. /** Callback called when a pointer up is detected */
  34040. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  34041. /** Callback called when a pointer pick is detected */
  34042. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  34043. /**
  34044. * 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).
  34045. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  34046. */
  34047. onPrePointerObservable: Observable<PointerInfoPre>;
  34048. /**
  34049. * Observable event triggered each time an input event is received from the rendering canvas
  34050. */
  34051. onPointerObservable: Observable<PointerInfo>;
  34052. /**
  34053. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  34054. */
  34055. readonly unTranslatedPointer: Vector2;
  34056. /**
  34057. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  34058. */
  34059. static DragMovementThreshold: number;
  34060. /**
  34061. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  34062. */
  34063. static LongPressDelay: number;
  34064. /**
  34065. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  34066. */
  34067. static DoubleClickDelay: number;
  34068. /** If you need to check double click without raising a single click at first click, enable this flag */
  34069. static ExclusiveDoubleClickMode: boolean;
  34070. /** @hidden */
  34071. _mirroredCameraPosition: Nullable<Vector3>;
  34072. /**
  34073. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  34074. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  34075. */
  34076. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  34077. /**
  34078. * Observable event triggered each time an keyboard event is received from the hosting window
  34079. */
  34080. onKeyboardObservable: Observable<KeyboardInfo>;
  34081. private _useRightHandedSystem;
  34082. /**
  34083. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  34084. */
  34085. useRightHandedSystem: boolean;
  34086. private _timeAccumulator;
  34087. private _currentStepId;
  34088. private _currentInternalStep;
  34089. /**
  34090. * Sets the step Id used by deterministic lock step
  34091. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  34092. * @param newStepId defines the step Id
  34093. */
  34094. setStepId(newStepId: number): void;
  34095. /**
  34096. * Gets the step Id used by deterministic lock step
  34097. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  34098. * @returns the step Id
  34099. */
  34100. getStepId(): number;
  34101. /**
  34102. * Gets the internal step used by deterministic lock step
  34103. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  34104. * @returns the internal step
  34105. */
  34106. getInternalStep(): number;
  34107. private _fogEnabled;
  34108. /**
  34109. * Gets or sets a boolean indicating if fog is enabled on this scene
  34110. * @see http://doc.babylonjs.com/babylon101/environment#fog
  34111. * (Default is true)
  34112. */
  34113. fogEnabled: boolean;
  34114. private _fogMode;
  34115. /**
  34116. * Gets or sets the fog mode to use
  34117. * @see http://doc.babylonjs.com/babylon101/environment#fog
  34118. * | mode | value |
  34119. * | --- | --- |
  34120. * | FOGMODE_NONE | 0 |
  34121. * | FOGMODE_EXP | 1 |
  34122. * | FOGMODE_EXP2 | 2 |
  34123. * | FOGMODE_LINEAR | 3 |
  34124. */
  34125. fogMode: number;
  34126. /**
  34127. * Gets or sets the fog color to use
  34128. * @see http://doc.babylonjs.com/babylon101/environment#fog
  34129. * (Default is Color3(0.2, 0.2, 0.3))
  34130. */
  34131. fogColor: Color3;
  34132. /**
  34133. * Gets or sets the fog density to use
  34134. * @see http://doc.babylonjs.com/babylon101/environment#fog
  34135. * (Default is 0.1)
  34136. */
  34137. fogDensity: number;
  34138. /**
  34139. * Gets or sets the fog start distance to use
  34140. * @see http://doc.babylonjs.com/babylon101/environment#fog
  34141. * (Default is 0)
  34142. */
  34143. fogStart: number;
  34144. /**
  34145. * Gets or sets the fog end distance to use
  34146. * @see http://doc.babylonjs.com/babylon101/environment#fog
  34147. * (Default is 1000)
  34148. */
  34149. fogEnd: number;
  34150. private _shadowsEnabled;
  34151. /**
  34152. * Gets or sets a boolean indicating if shadows are enabled on this scene
  34153. */
  34154. shadowsEnabled: boolean;
  34155. private _lightsEnabled;
  34156. /**
  34157. * Gets or sets a boolean indicating if lights are enabled on this scene
  34158. */
  34159. lightsEnabled: boolean;
  34160. /** All of the active cameras added to this scene. */
  34161. activeCameras: Camera[];
  34162. /** @hidden */
  34163. _activeCamera: Nullable<Camera>;
  34164. /** Gets or sets the current active camera */
  34165. activeCamera: Nullable<Camera>;
  34166. private _defaultMaterial;
  34167. /** The default material used on meshes when no material is affected */
  34168. /** The default material used on meshes when no material is affected */
  34169. defaultMaterial: Material;
  34170. private _texturesEnabled;
  34171. /**
  34172. * Gets or sets a boolean indicating if textures are enabled on this scene
  34173. */
  34174. texturesEnabled: boolean;
  34175. /**
  34176. * Gets or sets a boolean indicating if particles are enabled on this scene
  34177. */
  34178. particlesEnabled: boolean;
  34179. /**
  34180. * Gets or sets a boolean indicating if sprites are enabled on this scene
  34181. */
  34182. spritesEnabled: boolean;
  34183. private _skeletonsEnabled;
  34184. /**
  34185. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  34186. */
  34187. skeletonsEnabled: boolean;
  34188. /**
  34189. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  34190. */
  34191. lensFlaresEnabled: boolean;
  34192. /**
  34193. * Gets or sets a boolean indicating if collisions are enabled on this scene
  34194. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  34195. */
  34196. collisionsEnabled: boolean;
  34197. private _collisionCoordinator;
  34198. /** @hidden */
  34199. readonly collisionCoordinator: ICollisionCoordinator;
  34200. /**
  34201. * Defines the gravity applied to this scene (used only for collisions)
  34202. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  34203. */
  34204. gravity: Vector3;
  34205. /**
  34206. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  34207. */
  34208. postProcessesEnabled: boolean;
  34209. /**
  34210. * The list of postprocesses added to the scene
  34211. */
  34212. postProcesses: PostProcess[];
  34213. /**
  34214. * Gets the current postprocess manager
  34215. */
  34216. postProcessManager: PostProcessManager;
  34217. /**
  34218. * Gets or sets a boolean indicating if render targets are enabled on this scene
  34219. */
  34220. renderTargetsEnabled: boolean;
  34221. /**
  34222. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  34223. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  34224. */
  34225. dumpNextRenderTargets: boolean;
  34226. /**
  34227. * The list of user defined render targets added to the scene
  34228. */
  34229. customRenderTargets: RenderTargetTexture[];
  34230. /**
  34231. * Defines if texture loading must be delayed
  34232. * If true, textures will only be loaded when they need to be rendered
  34233. */
  34234. useDelayedTextureLoading: boolean;
  34235. /**
  34236. * Gets the list of meshes imported to the scene through SceneLoader
  34237. */
  34238. importedMeshesFiles: String[];
  34239. /**
  34240. * Gets or sets a boolean indicating if probes are enabled on this scene
  34241. */
  34242. probesEnabled: boolean;
  34243. /**
  34244. * Gets or sets the current offline provider to use to store scene data
  34245. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  34246. */
  34247. offlineProvider: IOfflineProvider;
  34248. /**
  34249. * Gets or sets the action manager associated with the scene
  34250. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  34251. */
  34252. actionManager: AbstractActionManager;
  34253. private _meshesForIntersections;
  34254. /**
  34255. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  34256. */
  34257. proceduralTexturesEnabled: boolean;
  34258. private _engine;
  34259. private _totalVertices;
  34260. /** @hidden */
  34261. _activeIndices: PerfCounter;
  34262. /** @hidden */
  34263. _activeParticles: PerfCounter;
  34264. /** @hidden */
  34265. _activeBones: PerfCounter;
  34266. private _animationRatio;
  34267. /** @hidden */
  34268. _animationTimeLast: number;
  34269. /** @hidden */
  34270. _animationTime: number;
  34271. /**
  34272. * Gets or sets a general scale for animation speed
  34273. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  34274. */
  34275. animationTimeScale: number;
  34276. /** @hidden */
  34277. _cachedMaterial: Nullable<Material>;
  34278. /** @hidden */
  34279. _cachedEffect: Nullable<Effect>;
  34280. /** @hidden */
  34281. _cachedVisibility: Nullable<number>;
  34282. private _renderId;
  34283. private _frameId;
  34284. private _executeWhenReadyTimeoutId;
  34285. private _intermediateRendering;
  34286. private _viewUpdateFlag;
  34287. private _projectionUpdateFlag;
  34288. /** @hidden */
  34289. _toBeDisposed: Nullable<IDisposable>[];
  34290. private _activeRequests;
  34291. /** @hidden */
  34292. _pendingData: any[];
  34293. private _isDisposed;
  34294. /**
  34295. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  34296. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  34297. */
  34298. dispatchAllSubMeshesOfActiveMeshes: boolean;
  34299. private _activeMeshes;
  34300. private _processedMaterials;
  34301. private _renderTargets;
  34302. /** @hidden */
  34303. _activeParticleSystems: SmartArray<IParticleSystem>;
  34304. private _activeSkeletons;
  34305. private _softwareSkinnedMeshes;
  34306. private _renderingManager;
  34307. /** @hidden */
  34308. _activeAnimatables: import("babylonjs/Animations/animatable").Animatable[];
  34309. private _transformMatrix;
  34310. private _sceneUbo;
  34311. /** @hidden */
  34312. _viewMatrix: Matrix;
  34313. private _projectionMatrix;
  34314. /** @hidden */
  34315. _forcedViewPosition: Nullable<Vector3>;
  34316. /** @hidden */
  34317. _frustumPlanes: Plane[];
  34318. /**
  34319. * Gets the list of frustum planes (built from the active camera)
  34320. */
  34321. readonly frustumPlanes: Plane[];
  34322. /**
  34323. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  34324. * This is useful if there are more lights that the maximum simulteanous authorized
  34325. */
  34326. requireLightSorting: boolean;
  34327. /** @hidden */
  34328. readonly useMaterialMeshMap: boolean;
  34329. /** @hidden */
  34330. readonly useClonedMeshhMap: boolean;
  34331. private _externalData;
  34332. private _uid;
  34333. /**
  34334. * @hidden
  34335. * Backing store of defined scene components.
  34336. */
  34337. _components: ISceneComponent[];
  34338. /**
  34339. * @hidden
  34340. * Backing store of defined scene components.
  34341. */
  34342. _serializableComponents: ISceneSerializableComponent[];
  34343. /**
  34344. * List of components to register on the next registration step.
  34345. */
  34346. private _transientComponents;
  34347. /**
  34348. * Registers the transient components if needed.
  34349. */
  34350. private _registerTransientComponents;
  34351. /**
  34352. * @hidden
  34353. * Add a component to the scene.
  34354. * Note that the ccomponent could be registered on th next frame if this is called after
  34355. * the register component stage.
  34356. * @param component Defines the component to add to the scene
  34357. */
  34358. _addComponent(component: ISceneComponent): void;
  34359. /**
  34360. * @hidden
  34361. * Gets a component from the scene.
  34362. * @param name defines the name of the component to retrieve
  34363. * @returns the component or null if not present
  34364. */
  34365. _getComponent(name: string): Nullable<ISceneComponent>;
  34366. /**
  34367. * @hidden
  34368. * Defines the actions happening before camera updates.
  34369. */
  34370. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  34371. /**
  34372. * @hidden
  34373. * Defines the actions happening before clear the canvas.
  34374. */
  34375. _beforeClearStage: Stage<SimpleStageAction>;
  34376. /**
  34377. * @hidden
  34378. * Defines the actions when collecting render targets for the frame.
  34379. */
  34380. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  34381. /**
  34382. * @hidden
  34383. * Defines the actions happening for one camera in the frame.
  34384. */
  34385. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  34386. /**
  34387. * @hidden
  34388. * Defines the actions happening during the per mesh ready checks.
  34389. */
  34390. _isReadyForMeshStage: Stage<MeshStageAction>;
  34391. /**
  34392. * @hidden
  34393. * Defines the actions happening before evaluate active mesh checks.
  34394. */
  34395. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  34396. /**
  34397. * @hidden
  34398. * Defines the actions happening during the evaluate sub mesh checks.
  34399. */
  34400. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  34401. /**
  34402. * @hidden
  34403. * Defines the actions happening during the active mesh stage.
  34404. */
  34405. _activeMeshStage: Stage<ActiveMeshStageAction>;
  34406. /**
  34407. * @hidden
  34408. * Defines the actions happening during the per camera render target step.
  34409. */
  34410. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  34411. /**
  34412. * @hidden
  34413. * Defines the actions happening just before the active camera is drawing.
  34414. */
  34415. _beforeCameraDrawStage: Stage<CameraStageAction>;
  34416. /**
  34417. * @hidden
  34418. * Defines the actions happening just before a render target is drawing.
  34419. */
  34420. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  34421. /**
  34422. * @hidden
  34423. * Defines the actions happening just before a rendering group is drawing.
  34424. */
  34425. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  34426. /**
  34427. * @hidden
  34428. * Defines the actions happening just before a mesh is drawing.
  34429. */
  34430. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  34431. /**
  34432. * @hidden
  34433. * Defines the actions happening just after a mesh has been drawn.
  34434. */
  34435. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  34436. /**
  34437. * @hidden
  34438. * Defines the actions happening just after a rendering group has been drawn.
  34439. */
  34440. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  34441. /**
  34442. * @hidden
  34443. * Defines the actions happening just after the active camera has been drawn.
  34444. */
  34445. _afterCameraDrawStage: Stage<CameraStageAction>;
  34446. /**
  34447. * @hidden
  34448. * Defines the actions happening just after a render target has been drawn.
  34449. */
  34450. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  34451. /**
  34452. * @hidden
  34453. * Defines the actions happening just after rendering all cameras and computing intersections.
  34454. */
  34455. _afterRenderStage: Stage<SimpleStageAction>;
  34456. /**
  34457. * @hidden
  34458. * Defines the actions happening when a pointer move event happens.
  34459. */
  34460. _pointerMoveStage: Stage<PointerMoveStageAction>;
  34461. /**
  34462. * @hidden
  34463. * Defines the actions happening when a pointer down event happens.
  34464. */
  34465. _pointerDownStage: Stage<PointerUpDownStageAction>;
  34466. /**
  34467. * @hidden
  34468. * Defines the actions happening when a pointer up event happens.
  34469. */
  34470. _pointerUpStage: Stage<PointerUpDownStageAction>;
  34471. /**
  34472. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  34473. */
  34474. private geometriesByUniqueId;
  34475. /**
  34476. * Creates a new Scene
  34477. * @param engine defines the engine to use to render this scene
  34478. * @param options defines the scene options
  34479. */
  34480. constructor(engine: Engine, options?: SceneOptions);
  34481. /**
  34482. * Gets a string idenfifying the name of the class
  34483. * @returns "Scene" string
  34484. */
  34485. getClassName(): string;
  34486. private _defaultMeshCandidates;
  34487. /**
  34488. * @hidden
  34489. */
  34490. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  34491. private _defaultSubMeshCandidates;
  34492. /**
  34493. * @hidden
  34494. */
  34495. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  34496. /**
  34497. * Sets the default candidate providers for the scene.
  34498. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  34499. * and getCollidingSubMeshCandidates to their default function
  34500. */
  34501. setDefaultCandidateProviders(): void;
  34502. /**
  34503. * Gets the mesh that is currently under the pointer
  34504. */
  34505. readonly meshUnderPointer: Nullable<AbstractMesh>;
  34506. /**
  34507. * Gets or sets the current on-screen X position of the pointer
  34508. */
  34509. pointerX: number;
  34510. /**
  34511. * Gets or sets the current on-screen Y position of the pointer
  34512. */
  34513. pointerY: number;
  34514. /**
  34515. * Gets the cached material (ie. the latest rendered one)
  34516. * @returns the cached material
  34517. */
  34518. getCachedMaterial(): Nullable<Material>;
  34519. /**
  34520. * Gets the cached effect (ie. the latest rendered one)
  34521. * @returns the cached effect
  34522. */
  34523. getCachedEffect(): Nullable<Effect>;
  34524. /**
  34525. * Gets the cached visibility state (ie. the latest rendered one)
  34526. * @returns the cached visibility state
  34527. */
  34528. getCachedVisibility(): Nullable<number>;
  34529. /**
  34530. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  34531. * @param material defines the current material
  34532. * @param effect defines the current effect
  34533. * @param visibility defines the current visibility state
  34534. * @returns true if one parameter is not cached
  34535. */
  34536. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  34537. /**
  34538. * Gets the engine associated with the scene
  34539. * @returns an Engine
  34540. */
  34541. getEngine(): Engine;
  34542. /**
  34543. * Gets the total number of vertices rendered per frame
  34544. * @returns the total number of vertices rendered per frame
  34545. */
  34546. getTotalVertices(): number;
  34547. /**
  34548. * Gets the performance counter for total vertices
  34549. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  34550. */
  34551. readonly totalVerticesPerfCounter: PerfCounter;
  34552. /**
  34553. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  34554. * @returns the total number of active indices rendered per frame
  34555. */
  34556. getActiveIndices(): number;
  34557. /**
  34558. * Gets the performance counter for active indices
  34559. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  34560. */
  34561. readonly totalActiveIndicesPerfCounter: PerfCounter;
  34562. /**
  34563. * Gets the total number of active particles rendered per frame
  34564. * @returns the total number of active particles rendered per frame
  34565. */
  34566. getActiveParticles(): number;
  34567. /**
  34568. * Gets the performance counter for active particles
  34569. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  34570. */
  34571. readonly activeParticlesPerfCounter: PerfCounter;
  34572. /**
  34573. * Gets the total number of active bones rendered per frame
  34574. * @returns the total number of active bones rendered per frame
  34575. */
  34576. getActiveBones(): number;
  34577. /**
  34578. * Gets the performance counter for active bones
  34579. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  34580. */
  34581. readonly activeBonesPerfCounter: PerfCounter;
  34582. /**
  34583. * Gets the array of active meshes
  34584. * @returns an array of AbstractMesh
  34585. */
  34586. getActiveMeshes(): SmartArray<AbstractMesh>;
  34587. /**
  34588. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  34589. * @returns a number
  34590. */
  34591. getAnimationRatio(): number;
  34592. /**
  34593. * Gets an unique Id for the current render phase
  34594. * @returns a number
  34595. */
  34596. getRenderId(): number;
  34597. /**
  34598. * Gets an unique Id for the current frame
  34599. * @returns a number
  34600. */
  34601. getFrameId(): number;
  34602. /** Call this function if you want to manually increment the render Id*/
  34603. incrementRenderId(): void;
  34604. private _createUbo;
  34605. /**
  34606. * Use this method to simulate a pointer move on a mesh
  34607. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  34608. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  34609. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  34610. * @returns the current scene
  34611. */
  34612. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  34613. /**
  34614. * Use this method to simulate a pointer down on a mesh
  34615. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  34616. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  34617. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  34618. * @returns the current scene
  34619. */
  34620. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  34621. /**
  34622. * Use this method to simulate a pointer up on a mesh
  34623. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  34624. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  34625. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  34626. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  34627. * @returns the current scene
  34628. */
  34629. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  34630. /**
  34631. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  34632. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  34633. * @returns true if the pointer was captured
  34634. */
  34635. isPointerCaptured(pointerId?: number): boolean;
  34636. /**
  34637. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  34638. * @param attachUp defines if you want to attach events to pointerup
  34639. * @param attachDown defines if you want to attach events to pointerdown
  34640. * @param attachMove defines if you want to attach events to pointermove
  34641. */
  34642. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  34643. /** Detaches all event handlers*/
  34644. detachControl(): void;
  34645. /**
  34646. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  34647. * Delay loaded resources are not taking in account
  34648. * @return true if all required resources are ready
  34649. */
  34650. isReady(): boolean;
  34651. /** Resets all cached information relative to material (including effect and visibility) */
  34652. resetCachedMaterial(): void;
  34653. /**
  34654. * Registers a function to be called before every frame render
  34655. * @param func defines the function to register
  34656. */
  34657. registerBeforeRender(func: () => void): void;
  34658. /**
  34659. * Unregisters a function called before every frame render
  34660. * @param func defines the function to unregister
  34661. */
  34662. unregisterBeforeRender(func: () => void): void;
  34663. /**
  34664. * Registers a function to be called after every frame render
  34665. * @param func defines the function to register
  34666. */
  34667. registerAfterRender(func: () => void): void;
  34668. /**
  34669. * Unregisters a function called after every frame render
  34670. * @param func defines the function to unregister
  34671. */
  34672. unregisterAfterRender(func: () => void): void;
  34673. private _executeOnceBeforeRender;
  34674. /**
  34675. * The provided function will run before render once and will be disposed afterwards.
  34676. * A timeout delay can be provided so that the function will be executed in N ms.
  34677. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  34678. * @param func The function to be executed.
  34679. * @param timeout optional delay in ms
  34680. */
  34681. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  34682. /** @hidden */
  34683. _addPendingData(data: any): void;
  34684. /** @hidden */
  34685. _removePendingData(data: any): void;
  34686. /**
  34687. * Returns the number of items waiting to be loaded
  34688. * @returns the number of items waiting to be loaded
  34689. */
  34690. getWaitingItemsCount(): number;
  34691. /**
  34692. * Returns a boolean indicating if the scene is still loading data
  34693. */
  34694. readonly isLoading: boolean;
  34695. /**
  34696. * Registers a function to be executed when the scene is ready
  34697. * @param {Function} func - the function to be executed
  34698. */
  34699. executeWhenReady(func: () => void): void;
  34700. /**
  34701. * Returns a promise that resolves when the scene is ready
  34702. * @returns A promise that resolves when the scene is ready
  34703. */
  34704. whenReadyAsync(): Promise<void>;
  34705. /** @hidden */
  34706. _checkIsReady(): void;
  34707. /**
  34708. * Gets all animatable attached to the scene
  34709. */
  34710. readonly animatables: Animatable[];
  34711. /**
  34712. * Resets the last animation time frame.
  34713. * Useful to override when animations start running when loading a scene for the first time.
  34714. */
  34715. resetLastAnimationTimeFrame(): void;
  34716. /**
  34717. * Gets the current view matrix
  34718. * @returns a Matrix
  34719. */
  34720. getViewMatrix(): Matrix;
  34721. /**
  34722. * Gets the current projection matrix
  34723. * @returns a Matrix
  34724. */
  34725. getProjectionMatrix(): Matrix;
  34726. /**
  34727. * Gets the current transform matrix
  34728. * @returns a Matrix made of View * Projection
  34729. */
  34730. getTransformMatrix(): Matrix;
  34731. /**
  34732. * Sets the current transform matrix
  34733. * @param viewL defines the View matrix to use
  34734. * @param projectionL defines the Projection matrix to use
  34735. * @param viewR defines the right View matrix to use (if provided)
  34736. * @param projectionR defines the right Projection matrix to use (if provided)
  34737. */
  34738. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  34739. /**
  34740. * Gets the uniform buffer used to store scene data
  34741. * @returns a UniformBuffer
  34742. */
  34743. getSceneUniformBuffer(): UniformBuffer;
  34744. /**
  34745. * Gets an unique (relatively to the current scene) Id
  34746. * @returns an unique number for the scene
  34747. */
  34748. getUniqueId(): number;
  34749. /**
  34750. * Add a mesh to the list of scene's meshes
  34751. * @param newMesh defines the mesh to add
  34752. * @param recursive if all child meshes should also be added to the scene
  34753. */
  34754. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  34755. /**
  34756. * Remove a mesh for the list of scene's meshes
  34757. * @param toRemove defines the mesh to remove
  34758. * @param recursive if all child meshes should also be removed from the scene
  34759. * @returns the index where the mesh was in the mesh list
  34760. */
  34761. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  34762. /**
  34763. * Add a transform node to the list of scene's transform nodes
  34764. * @param newTransformNode defines the transform node to add
  34765. */
  34766. addTransformNode(newTransformNode: TransformNode): void;
  34767. /**
  34768. * Remove a transform node for the list of scene's transform nodes
  34769. * @param toRemove defines the transform node to remove
  34770. * @returns the index where the transform node was in the transform node list
  34771. */
  34772. removeTransformNode(toRemove: TransformNode): number;
  34773. /**
  34774. * Remove a skeleton for the list of scene's skeletons
  34775. * @param toRemove defines the skeleton to remove
  34776. * @returns the index where the skeleton was in the skeleton list
  34777. */
  34778. removeSkeleton(toRemove: Skeleton): number;
  34779. /**
  34780. * Remove a morph target for the list of scene's morph targets
  34781. * @param toRemove defines the morph target to remove
  34782. * @returns the index where the morph target was in the morph target list
  34783. */
  34784. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  34785. /**
  34786. * Remove a light for the list of scene's lights
  34787. * @param toRemove defines the light to remove
  34788. * @returns the index where the light was in the light list
  34789. */
  34790. removeLight(toRemove: Light): number;
  34791. /**
  34792. * Remove a camera for the list of scene's cameras
  34793. * @param toRemove defines the camera to remove
  34794. * @returns the index where the camera was in the camera list
  34795. */
  34796. removeCamera(toRemove: Camera): number;
  34797. /**
  34798. * Remove a particle system for the list of scene's particle systems
  34799. * @param toRemove defines the particle system to remove
  34800. * @returns the index where the particle system was in the particle system list
  34801. */
  34802. removeParticleSystem(toRemove: IParticleSystem): number;
  34803. /**
  34804. * Remove a animation for the list of scene's animations
  34805. * @param toRemove defines the animation to remove
  34806. * @returns the index where the animation was in the animation list
  34807. */
  34808. removeAnimation(toRemove: Animation): number;
  34809. /**
  34810. * Will stop the animation of the given target
  34811. * @param target - the target
  34812. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  34813. * @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)
  34814. */
  34815. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  34816. /**
  34817. * Removes the given animation group from this scene.
  34818. * @param toRemove The animation group to remove
  34819. * @returns The index of the removed animation group
  34820. */
  34821. removeAnimationGroup(toRemove: AnimationGroup): number;
  34822. /**
  34823. * Removes the given multi-material from this scene.
  34824. * @param toRemove The multi-material to remove
  34825. * @returns The index of the removed multi-material
  34826. */
  34827. removeMultiMaterial(toRemove: MultiMaterial): number;
  34828. /**
  34829. * Removes the given material from this scene.
  34830. * @param toRemove The material to remove
  34831. * @returns The index of the removed material
  34832. */
  34833. removeMaterial(toRemove: Material): number;
  34834. /**
  34835. * Removes the given action manager from this scene.
  34836. * @param toRemove The action manager to remove
  34837. * @returns The index of the removed action manager
  34838. */
  34839. removeActionManager(toRemove: AbstractActionManager): number;
  34840. /**
  34841. * Removes the given texture from this scene.
  34842. * @param toRemove The texture to remove
  34843. * @returns The index of the removed texture
  34844. */
  34845. removeTexture(toRemove: BaseTexture): number;
  34846. /**
  34847. * Adds the given light to this scene
  34848. * @param newLight The light to add
  34849. */
  34850. addLight(newLight: Light): void;
  34851. /**
  34852. * Sorts the list list based on light priorities
  34853. */
  34854. sortLightsByPriority(): void;
  34855. /**
  34856. * Adds the given camera to this scene
  34857. * @param newCamera The camera to add
  34858. */
  34859. addCamera(newCamera: Camera): void;
  34860. /**
  34861. * Adds the given skeleton to this scene
  34862. * @param newSkeleton The skeleton to add
  34863. */
  34864. addSkeleton(newSkeleton: Skeleton): void;
  34865. /**
  34866. * Adds the given particle system to this scene
  34867. * @param newParticleSystem The particle system to add
  34868. */
  34869. addParticleSystem(newParticleSystem: IParticleSystem): void;
  34870. /**
  34871. * Adds the given animation to this scene
  34872. * @param newAnimation The animation to add
  34873. */
  34874. addAnimation(newAnimation: Animation): void;
  34875. /**
  34876. * Adds the given animation group to this scene.
  34877. * @param newAnimationGroup The animation group to add
  34878. */
  34879. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  34880. /**
  34881. * Adds the given multi-material to this scene
  34882. * @param newMultiMaterial The multi-material to add
  34883. */
  34884. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  34885. /**
  34886. * Adds the given material to this scene
  34887. * @param newMaterial The material to add
  34888. */
  34889. addMaterial(newMaterial: Material): void;
  34890. /**
  34891. * Adds the given morph target to this scene
  34892. * @param newMorphTargetManager The morph target to add
  34893. */
  34894. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  34895. /**
  34896. * Adds the given geometry to this scene
  34897. * @param newGeometry The geometry to add
  34898. */
  34899. addGeometry(newGeometry: Geometry): void;
  34900. /**
  34901. * Adds the given action manager to this scene
  34902. * @param newActionManager The action manager to add
  34903. */
  34904. addActionManager(newActionManager: AbstractActionManager): void;
  34905. /**
  34906. * Adds the given texture to this scene.
  34907. * @param newTexture The texture to add
  34908. */
  34909. addTexture(newTexture: BaseTexture): void;
  34910. /**
  34911. * Switch active camera
  34912. * @param newCamera defines the new active camera
  34913. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  34914. */
  34915. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  34916. /**
  34917. * sets the active camera of the scene using its ID
  34918. * @param id defines the camera's ID
  34919. * @return the new active camera or null if none found.
  34920. */
  34921. setActiveCameraByID(id: string): Nullable<Camera>;
  34922. /**
  34923. * sets the active camera of the scene using its name
  34924. * @param name defines the camera's name
  34925. * @returns the new active camera or null if none found.
  34926. */
  34927. setActiveCameraByName(name: string): Nullable<Camera>;
  34928. /**
  34929. * get an animation group using its name
  34930. * @param name defines the material's name
  34931. * @return the animation group or null if none found.
  34932. */
  34933. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  34934. /**
  34935. * Get a material using its unique id
  34936. * @param uniqueId defines the material's unique id
  34937. * @return the material or null if none found.
  34938. */
  34939. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  34940. /**
  34941. * get a material using its id
  34942. * @param id defines the material's ID
  34943. * @return the material or null if none found.
  34944. */
  34945. getMaterialByID(id: string): Nullable<Material>;
  34946. /**
  34947. * Gets a the last added material using a given id
  34948. * @param id defines the material's ID
  34949. * @return the last material with the given id or null if none found.
  34950. */
  34951. getLastMaterialByID(id: string): Nullable<Material>;
  34952. /**
  34953. * Gets a material using its name
  34954. * @param name defines the material's name
  34955. * @return the material or null if none found.
  34956. */
  34957. getMaterialByName(name: string): Nullable<Material>;
  34958. /**
  34959. * Get a texture using its unique id
  34960. * @param uniqueId defines the texture's unique id
  34961. * @return the texture or null if none found.
  34962. */
  34963. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  34964. /**
  34965. * Gets a camera using its id
  34966. * @param id defines the id to look for
  34967. * @returns the camera or null if not found
  34968. */
  34969. getCameraByID(id: string): Nullable<Camera>;
  34970. /**
  34971. * Gets a camera using its unique id
  34972. * @param uniqueId defines the unique id to look for
  34973. * @returns the camera or null if not found
  34974. */
  34975. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  34976. /**
  34977. * Gets a camera using its name
  34978. * @param name defines the camera's name
  34979. * @return the camera or null if none found.
  34980. */
  34981. getCameraByName(name: string): Nullable<Camera>;
  34982. /**
  34983. * Gets a bone using its id
  34984. * @param id defines the bone's id
  34985. * @return the bone or null if not found
  34986. */
  34987. getBoneByID(id: string): Nullable<Bone>;
  34988. /**
  34989. * Gets a bone using its id
  34990. * @param name defines the bone's name
  34991. * @return the bone or null if not found
  34992. */
  34993. getBoneByName(name: string): Nullable<Bone>;
  34994. /**
  34995. * Gets a light node using its name
  34996. * @param name defines the the light's name
  34997. * @return the light or null if none found.
  34998. */
  34999. getLightByName(name: string): Nullable<Light>;
  35000. /**
  35001. * Gets a light node using its id
  35002. * @param id defines the light's id
  35003. * @return the light or null if none found.
  35004. */
  35005. getLightByID(id: string): Nullable<Light>;
  35006. /**
  35007. * Gets a light node using its scene-generated unique ID
  35008. * @param uniqueId defines the light's unique id
  35009. * @return the light or null if none found.
  35010. */
  35011. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  35012. /**
  35013. * Gets a particle system by id
  35014. * @param id defines the particle system id
  35015. * @return the corresponding system or null if none found
  35016. */
  35017. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  35018. /**
  35019. * Gets a geometry using its ID
  35020. * @param id defines the geometry's id
  35021. * @return the geometry or null if none found.
  35022. */
  35023. getGeometryByID(id: string): Nullable<Geometry>;
  35024. private _getGeometryByUniqueID;
  35025. /**
  35026. * Add a new geometry to this scene
  35027. * @param geometry defines the geometry to be added to the scene.
  35028. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  35029. * @return a boolean defining if the geometry was added or not
  35030. */
  35031. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  35032. /**
  35033. * Removes an existing geometry
  35034. * @param geometry defines the geometry to be removed from the scene
  35035. * @return a boolean defining if the geometry was removed or not
  35036. */
  35037. removeGeometry(geometry: Geometry): boolean;
  35038. /**
  35039. * Gets the list of geometries attached to the scene
  35040. * @returns an array of Geometry
  35041. */
  35042. getGeometries(): Geometry[];
  35043. /**
  35044. * Gets the first added mesh found of a given ID
  35045. * @param id defines the id to search for
  35046. * @return the mesh found or null if not found at all
  35047. */
  35048. getMeshByID(id: string): Nullable<AbstractMesh>;
  35049. /**
  35050. * Gets a list of meshes using their id
  35051. * @param id defines the id to search for
  35052. * @returns a list of meshes
  35053. */
  35054. getMeshesByID(id: string): Array<AbstractMesh>;
  35055. /**
  35056. * Gets the first added transform node found of a given ID
  35057. * @param id defines the id to search for
  35058. * @return the found transform node or null if not found at all.
  35059. */
  35060. getTransformNodeByID(id: string): Nullable<TransformNode>;
  35061. /**
  35062. * Gets a transform node with its auto-generated unique id
  35063. * @param uniqueId efines the unique id to search for
  35064. * @return the found transform node or null if not found at all.
  35065. */
  35066. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  35067. /**
  35068. * Gets a list of transform nodes using their id
  35069. * @param id defines the id to search for
  35070. * @returns a list of transform nodes
  35071. */
  35072. getTransformNodesByID(id: string): Array<TransformNode>;
  35073. /**
  35074. * Gets a mesh with its auto-generated unique id
  35075. * @param uniqueId defines the unique id to search for
  35076. * @return the found mesh or null if not found at all.
  35077. */
  35078. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  35079. /**
  35080. * Gets a the last added mesh using a given id
  35081. * @param id defines the id to search for
  35082. * @return the found mesh or null if not found at all.
  35083. */
  35084. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  35085. /**
  35086. * Gets a the last added node (Mesh, Camera, Light) using a given id
  35087. * @param id defines the id to search for
  35088. * @return the found node or null if not found at all
  35089. */
  35090. getLastEntryByID(id: string): Nullable<Node>;
  35091. /**
  35092. * Gets a node (Mesh, Camera, Light) using a given id
  35093. * @param id defines the id to search for
  35094. * @return the found node or null if not found at all
  35095. */
  35096. getNodeByID(id: string): Nullable<Node>;
  35097. /**
  35098. * Gets a node (Mesh, Camera, Light) using a given name
  35099. * @param name defines the name to search for
  35100. * @return the found node or null if not found at all.
  35101. */
  35102. getNodeByName(name: string): Nullable<Node>;
  35103. /**
  35104. * Gets a mesh using a given name
  35105. * @param name defines the name to search for
  35106. * @return the found mesh or null if not found at all.
  35107. */
  35108. getMeshByName(name: string): Nullable<AbstractMesh>;
  35109. /**
  35110. * Gets a transform node using a given name
  35111. * @param name defines the name to search for
  35112. * @return the found transform node or null if not found at all.
  35113. */
  35114. getTransformNodeByName(name: string): Nullable<TransformNode>;
  35115. /**
  35116. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  35117. * @param id defines the id to search for
  35118. * @return the found skeleton or null if not found at all.
  35119. */
  35120. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  35121. /**
  35122. * Gets a skeleton using a given auto generated unique id
  35123. * @param uniqueId defines the unique id to search for
  35124. * @return the found skeleton or null if not found at all.
  35125. */
  35126. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  35127. /**
  35128. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  35129. * @param id defines the id to search for
  35130. * @return the found skeleton or null if not found at all.
  35131. */
  35132. getSkeletonById(id: string): Nullable<Skeleton>;
  35133. /**
  35134. * Gets a skeleton using a given name
  35135. * @param name defines the name to search for
  35136. * @return the found skeleton or null if not found at all.
  35137. */
  35138. getSkeletonByName(name: string): Nullable<Skeleton>;
  35139. /**
  35140. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  35141. * @param id defines the id to search for
  35142. * @return the found morph target manager or null if not found at all.
  35143. */
  35144. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  35145. /**
  35146. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  35147. * @param id defines the id to search for
  35148. * @return the found morph target or null if not found at all.
  35149. */
  35150. getMorphTargetById(id: string): Nullable<MorphTarget>;
  35151. /**
  35152. * Gets a boolean indicating if the given mesh is active
  35153. * @param mesh defines the mesh to look for
  35154. * @returns true if the mesh is in the active list
  35155. */
  35156. isActiveMesh(mesh: AbstractMesh): boolean;
  35157. /**
  35158. * Return a unique id as a string which can serve as an identifier for the scene
  35159. */
  35160. readonly uid: string;
  35161. /**
  35162. * Add an externaly attached data from its key.
  35163. * This method call will fail and return false, if such key already exists.
  35164. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  35165. * @param key the unique key that identifies the data
  35166. * @param data the data object to associate to the key for this Engine instance
  35167. * @return true if no such key were already present and the data was added successfully, false otherwise
  35168. */
  35169. addExternalData<T>(key: string, data: T): boolean;
  35170. /**
  35171. * Get an externaly attached data from its key
  35172. * @param key the unique key that identifies the data
  35173. * @return the associated data, if present (can be null), or undefined if not present
  35174. */
  35175. getExternalData<T>(key: string): Nullable<T>;
  35176. /**
  35177. * Get an externaly attached data from its key, create it using a factory if it's not already present
  35178. * @param key the unique key that identifies the data
  35179. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  35180. * @return the associated data, can be null if the factory returned null.
  35181. */
  35182. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  35183. /**
  35184. * Remove an externaly attached data from the Engine instance
  35185. * @param key the unique key that identifies the data
  35186. * @return true if the data was successfully removed, false if it doesn't exist
  35187. */
  35188. removeExternalData(key: string): boolean;
  35189. private _evaluateSubMesh;
  35190. /**
  35191. * Clear the processed materials smart array preventing retention point in material dispose.
  35192. */
  35193. freeProcessedMaterials(): void;
  35194. private _preventFreeActiveMeshesAndRenderingGroups;
  35195. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  35196. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  35197. * when disposing several meshes in a row or a hierarchy of meshes.
  35198. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  35199. */
  35200. blockfreeActiveMeshesAndRenderingGroups: boolean;
  35201. /**
  35202. * Clear the active meshes smart array preventing retention point in mesh dispose.
  35203. */
  35204. freeActiveMeshes(): void;
  35205. /**
  35206. * Clear the info related to rendering groups preventing retention points during dispose.
  35207. */
  35208. freeRenderingGroups(): void;
  35209. /** @hidden */
  35210. _isInIntermediateRendering(): boolean;
  35211. /**
  35212. * Lambda returning the list of potentially active meshes.
  35213. */
  35214. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  35215. /**
  35216. * Lambda returning the list of potentially active sub meshes.
  35217. */
  35218. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  35219. /**
  35220. * Lambda returning the list of potentially intersecting sub meshes.
  35221. */
  35222. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  35223. /**
  35224. * Lambda returning the list of potentially colliding sub meshes.
  35225. */
  35226. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  35227. private _activeMeshesFrozen;
  35228. /**
  35229. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  35230. * @returns the current scene
  35231. */
  35232. freezeActiveMeshes(): Scene;
  35233. /**
  35234. * Use this function to restart evaluating active meshes on every frame
  35235. * @returns the current scene
  35236. */
  35237. unfreezeActiveMeshes(): Scene;
  35238. private _evaluateActiveMeshes;
  35239. private _activeMesh;
  35240. /**
  35241. * Update the transform matrix to update from the current active camera
  35242. * @param force defines a boolean used to force the update even if cache is up to date
  35243. */
  35244. updateTransformMatrix(force?: boolean): void;
  35245. private _bindFrameBuffer;
  35246. /** @hidden */
  35247. _allowPostProcessClearColor: boolean;
  35248. /** @hidden */
  35249. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  35250. private _processSubCameras;
  35251. private _checkIntersections;
  35252. /** @hidden */
  35253. _advancePhysicsEngineStep(step: number): void;
  35254. /**
  35255. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  35256. */
  35257. getDeterministicFrameTime: () => number;
  35258. /** @hidden */
  35259. _animate(): void;
  35260. /** Execute all animations (for a frame) */
  35261. animate(): void;
  35262. /**
  35263. * Render the scene
  35264. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  35265. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  35266. */
  35267. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  35268. /**
  35269. * Freeze all materials
  35270. * A frozen material will not be updatable but should be faster to render
  35271. */
  35272. freezeMaterials(): void;
  35273. /**
  35274. * Unfreeze all materials
  35275. * A frozen material will not be updatable but should be faster to render
  35276. */
  35277. unfreezeMaterials(): void;
  35278. /**
  35279. * Releases all held ressources
  35280. */
  35281. dispose(): void;
  35282. /**
  35283. * Gets if the scene is already disposed
  35284. */
  35285. readonly isDisposed: boolean;
  35286. /**
  35287. * Call this function to reduce memory footprint of the scene.
  35288. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  35289. */
  35290. clearCachedVertexData(): void;
  35291. /**
  35292. * This function will remove the local cached buffer data from texture.
  35293. * It will save memory but will prevent the texture from being rebuilt
  35294. */
  35295. cleanCachedTextureBuffer(): void;
  35296. /**
  35297. * Get the world extend vectors with an optional filter
  35298. *
  35299. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  35300. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  35301. */
  35302. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  35303. min: Vector3;
  35304. max: Vector3;
  35305. };
  35306. /**
  35307. * Creates a ray that can be used to pick in the scene
  35308. * @param x defines the x coordinate of the origin (on-screen)
  35309. * @param y defines the y coordinate of the origin (on-screen)
  35310. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  35311. * @param camera defines the camera to use for the picking
  35312. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  35313. * @returns a Ray
  35314. */
  35315. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  35316. /**
  35317. * Creates a ray that can be used to pick in the scene
  35318. * @param x defines the x coordinate of the origin (on-screen)
  35319. * @param y defines the y coordinate of the origin (on-screen)
  35320. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  35321. * @param result defines the ray where to store the picking ray
  35322. * @param camera defines the camera to use for the picking
  35323. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  35324. * @returns the current scene
  35325. */
  35326. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  35327. /**
  35328. * Creates a ray that can be used to pick in the scene
  35329. * @param x defines the x coordinate of the origin (on-screen)
  35330. * @param y defines the y coordinate of the origin (on-screen)
  35331. * @param camera defines the camera to use for the picking
  35332. * @returns a Ray
  35333. */
  35334. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  35335. /**
  35336. * Creates a ray that can be used to pick in the scene
  35337. * @param x defines the x coordinate of the origin (on-screen)
  35338. * @param y defines the y coordinate of the origin (on-screen)
  35339. * @param result defines the ray where to store the picking ray
  35340. * @param camera defines the camera to use for the picking
  35341. * @returns the current scene
  35342. */
  35343. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  35344. /** Launch a ray to try to pick a mesh in the scene
  35345. * @param x position on screen
  35346. * @param y position on screen
  35347. * @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
  35348. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  35349. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  35350. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  35351. * @returns a PickingInfo
  35352. */
  35353. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  35354. /** Use the given ray to pick a mesh in the scene
  35355. * @param ray The ray to use to pick meshes
  35356. * @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
  35357. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  35358. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  35359. * @returns a PickingInfo
  35360. */
  35361. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  35362. /**
  35363. * Launch a ray to try to pick a mesh in the scene
  35364. * @param x X position on screen
  35365. * @param y Y position on screen
  35366. * @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
  35367. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  35368. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  35369. * @returns an array of PickingInfo
  35370. */
  35371. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  35372. /**
  35373. * Launch a ray to try to pick a mesh in the scene
  35374. * @param ray Ray to use
  35375. * @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
  35376. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  35377. * @returns an array of PickingInfo
  35378. */
  35379. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  35380. /**
  35381. * Force the value of meshUnderPointer
  35382. * @param mesh defines the mesh to use
  35383. */
  35384. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  35385. /**
  35386. * Gets the mesh under the pointer
  35387. * @returns a Mesh or null if no mesh is under the pointer
  35388. */
  35389. getPointerOverMesh(): Nullable<AbstractMesh>;
  35390. /** @hidden */
  35391. _rebuildGeometries(): void;
  35392. /** @hidden */
  35393. _rebuildTextures(): void;
  35394. private _getByTags;
  35395. /**
  35396. * Get a list of meshes by tags
  35397. * @param tagsQuery defines the tags query to use
  35398. * @param forEach defines a predicate used to filter results
  35399. * @returns an array of Mesh
  35400. */
  35401. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  35402. /**
  35403. * Get a list of cameras by tags
  35404. * @param tagsQuery defines the tags query to use
  35405. * @param forEach defines a predicate used to filter results
  35406. * @returns an array of Camera
  35407. */
  35408. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  35409. /**
  35410. * Get a list of lights by tags
  35411. * @param tagsQuery defines the tags query to use
  35412. * @param forEach defines a predicate used to filter results
  35413. * @returns an array of Light
  35414. */
  35415. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  35416. /**
  35417. * Get a list of materials by tags
  35418. * @param tagsQuery defines the tags query to use
  35419. * @param forEach defines a predicate used to filter results
  35420. * @returns an array of Material
  35421. */
  35422. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  35423. /**
  35424. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  35425. * This allowed control for front to back rendering or reversly depending of the special needs.
  35426. *
  35427. * @param renderingGroupId The rendering group id corresponding to its index
  35428. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  35429. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  35430. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  35431. */
  35432. 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;
  35433. /**
  35434. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  35435. *
  35436. * @param renderingGroupId The rendering group id corresponding to its index
  35437. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  35438. * @param depth Automatically clears depth between groups if true and autoClear is true.
  35439. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  35440. */
  35441. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  35442. /**
  35443. * Gets the current auto clear configuration for one rendering group of the rendering
  35444. * manager.
  35445. * @param index the rendering group index to get the information for
  35446. * @returns The auto clear setup for the requested rendering group
  35447. */
  35448. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  35449. private _blockMaterialDirtyMechanism;
  35450. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  35451. blockMaterialDirtyMechanism: boolean;
  35452. /**
  35453. * Will flag all materials as dirty to trigger new shader compilation
  35454. * @param flag defines the flag used to specify which material part must be marked as dirty
  35455. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  35456. */
  35457. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  35458. /** @hidden */
  35459. _loadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onError?: (request?: WebRequest, exception?: any) => void): IFileRequest;
  35460. /** @hidden */
  35461. _loadFileAsync(url: string, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  35462. }
  35463. }
  35464. declare module "babylonjs/assetContainer" {
  35465. import { AbstractScene } from "babylonjs/abstractScene";
  35466. import { Scene } from "babylonjs/scene";
  35467. import { Mesh } from "babylonjs/Meshes/mesh";
  35468. /**
  35469. * Set of assets to keep when moving a scene into an asset container.
  35470. */
  35471. export class KeepAssets extends AbstractScene {
  35472. }
  35473. /**
  35474. * Container with a set of assets that can be added or removed from a scene.
  35475. */
  35476. export class AssetContainer extends AbstractScene {
  35477. /**
  35478. * The scene the AssetContainer belongs to.
  35479. */
  35480. scene: Scene;
  35481. /**
  35482. * Instantiates an AssetContainer.
  35483. * @param scene The scene the AssetContainer belongs to.
  35484. */
  35485. constructor(scene: Scene);
  35486. /**
  35487. * Adds all the assets from the container to the scene.
  35488. */
  35489. addAllToScene(): void;
  35490. /**
  35491. * Removes all the assets in the container from the scene
  35492. */
  35493. removeAllFromScene(): void;
  35494. /**
  35495. * Disposes all the assets in the container
  35496. */
  35497. dispose(): void;
  35498. private _moveAssets;
  35499. /**
  35500. * Removes all the assets contained in the scene and adds them to the container.
  35501. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  35502. */
  35503. moveAllFromScene(keepAssets?: KeepAssets): void;
  35504. /**
  35505. * 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.
  35506. * @returns the root mesh
  35507. */
  35508. createRootMesh(): Mesh;
  35509. }
  35510. }
  35511. declare module "babylonjs/abstractScene" {
  35512. import { Scene } from "babylonjs/scene";
  35513. import { Nullable } from "babylonjs/types";
  35514. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  35515. import { TransformNode } from "babylonjs/Meshes/transformNode";
  35516. import { Geometry } from "babylonjs/Meshes/geometry";
  35517. import { Skeleton } from "babylonjs/Bones/skeleton";
  35518. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  35519. import { AssetContainer } from "babylonjs/assetContainer";
  35520. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  35521. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  35522. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  35523. import { Material } from "babylonjs/Materials/material";
  35524. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  35525. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  35526. import { Camera } from "babylonjs/Cameras/camera";
  35527. import { Light } from "babylonjs/Lights/light";
  35528. import { Node } from "babylonjs/node";
  35529. import { Animation } from "babylonjs/Animations/animation";
  35530. /**
  35531. * Defines how the parser contract is defined.
  35532. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  35533. */
  35534. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  35535. /**
  35536. * Defines how the individual parser contract is defined.
  35537. * These parser can parse an individual asset
  35538. */
  35539. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  35540. /**
  35541. * Base class of the scene acting as a container for the different elements composing a scene.
  35542. * This class is dynamically extended by the different components of the scene increasing
  35543. * flexibility and reducing coupling
  35544. */
  35545. export abstract class AbstractScene {
  35546. /**
  35547. * Stores the list of available parsers in the application.
  35548. */
  35549. private static _BabylonFileParsers;
  35550. /**
  35551. * Stores the list of available individual parsers in the application.
  35552. */
  35553. private static _IndividualBabylonFileParsers;
  35554. /**
  35555. * Adds a parser in the list of available ones
  35556. * @param name Defines the name of the parser
  35557. * @param parser Defines the parser to add
  35558. */
  35559. static AddParser(name: string, parser: BabylonFileParser): void;
  35560. /**
  35561. * Gets a general parser from the list of avaialble ones
  35562. * @param name Defines the name of the parser
  35563. * @returns the requested parser or null
  35564. */
  35565. static GetParser(name: string): Nullable<BabylonFileParser>;
  35566. /**
  35567. * Adds n individual parser in the list of available ones
  35568. * @param name Defines the name of the parser
  35569. * @param parser Defines the parser to add
  35570. */
  35571. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  35572. /**
  35573. * Gets an individual parser from the list of avaialble ones
  35574. * @param name Defines the name of the parser
  35575. * @returns the requested parser or null
  35576. */
  35577. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  35578. /**
  35579. * Parser json data and populate both a scene and its associated container object
  35580. * @param jsonData Defines the data to parse
  35581. * @param scene Defines the scene to parse the data for
  35582. * @param container Defines the container attached to the parsing sequence
  35583. * @param rootUrl Defines the root url of the data
  35584. */
  35585. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  35586. /**
  35587. * Gets the list of root nodes (ie. nodes with no parent)
  35588. */
  35589. rootNodes: Node[];
  35590. /** All of the cameras added to this scene
  35591. * @see http://doc.babylonjs.com/babylon101/cameras
  35592. */
  35593. cameras: Camera[];
  35594. /**
  35595. * All of the lights added to this scene
  35596. * @see http://doc.babylonjs.com/babylon101/lights
  35597. */
  35598. lights: Light[];
  35599. /**
  35600. * All of the (abstract) meshes added to this scene
  35601. */
  35602. meshes: AbstractMesh[];
  35603. /**
  35604. * The list of skeletons added to the scene
  35605. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  35606. */
  35607. skeletons: Skeleton[];
  35608. /**
  35609. * All of the particle systems added to this scene
  35610. * @see http://doc.babylonjs.com/babylon101/particles
  35611. */
  35612. particleSystems: IParticleSystem[];
  35613. /**
  35614. * Gets a list of Animations associated with the scene
  35615. */
  35616. animations: Animation[];
  35617. /**
  35618. * All of the animation groups added to this scene
  35619. * @see http://doc.babylonjs.com/how_to/group
  35620. */
  35621. animationGroups: AnimationGroup[];
  35622. /**
  35623. * All of the multi-materials added to this scene
  35624. * @see http://doc.babylonjs.com/how_to/multi_materials
  35625. */
  35626. multiMaterials: MultiMaterial[];
  35627. /**
  35628. * All of the materials added to this scene
  35629. * In the context of a Scene, it is not supposed to be modified manually.
  35630. * Any addition or removal should be done using the addMaterial and removeMAterial Scene methods.
  35631. * Note also that the order of the Material wihin the array is not significant and might change.
  35632. * @see http://doc.babylonjs.com/babylon101/materials
  35633. */
  35634. materials: Material[];
  35635. /**
  35636. * The list of morph target managers added to the scene
  35637. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  35638. */
  35639. morphTargetManagers: MorphTargetManager[];
  35640. /**
  35641. * The list of geometries used in the scene.
  35642. */
  35643. geometries: Geometry[];
  35644. /**
  35645. * All of the tranform nodes added to this scene
  35646. * In the context of a Scene, it is not supposed to be modified manually.
  35647. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  35648. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  35649. * @see http://doc.babylonjs.com/how_to/transformnode
  35650. */
  35651. transformNodes: TransformNode[];
  35652. /**
  35653. * ActionManagers available on the scene.
  35654. */
  35655. actionManagers: AbstractActionManager[];
  35656. /**
  35657. * Textures to keep.
  35658. */
  35659. textures: BaseTexture[];
  35660. /**
  35661. * Environment texture for the scene
  35662. */
  35663. environmentTexture: Nullable<BaseTexture>;
  35664. }
  35665. }
  35666. declare module "babylonjs/Audio/sound" {
  35667. import { Observable } from "babylonjs/Misc/observable";
  35668. import { Vector3 } from "babylonjs/Maths/math.vector";
  35669. import { Nullable } from "babylonjs/types";
  35670. import { Scene } from "babylonjs/scene";
  35671. import { TransformNode } from "babylonjs/Meshes/transformNode";
  35672. /**
  35673. * Interface used to define options for Sound class
  35674. */
  35675. export interface ISoundOptions {
  35676. /**
  35677. * Does the sound autoplay once loaded.
  35678. */
  35679. autoplay?: boolean;
  35680. /**
  35681. * Does the sound loop after it finishes playing once.
  35682. */
  35683. loop?: boolean;
  35684. /**
  35685. * Sound's volume
  35686. */
  35687. volume?: number;
  35688. /**
  35689. * Is it a spatial sound?
  35690. */
  35691. spatialSound?: boolean;
  35692. /**
  35693. * Maximum distance to hear that sound
  35694. */
  35695. maxDistance?: number;
  35696. /**
  35697. * Uses user defined attenuation function
  35698. */
  35699. useCustomAttenuation?: boolean;
  35700. /**
  35701. * Define the roll off factor of spatial sounds.
  35702. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35703. */
  35704. rolloffFactor?: number;
  35705. /**
  35706. * Define the reference distance the sound should be heard perfectly.
  35707. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35708. */
  35709. refDistance?: number;
  35710. /**
  35711. * Define the distance attenuation model the sound will follow.
  35712. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35713. */
  35714. distanceModel?: string;
  35715. /**
  35716. * Defines the playback speed (1 by default)
  35717. */
  35718. playbackRate?: number;
  35719. /**
  35720. * Defines if the sound is from a streaming source
  35721. */
  35722. streaming?: boolean;
  35723. /**
  35724. * Defines an optional length (in seconds) inside the sound file
  35725. */
  35726. length?: number;
  35727. /**
  35728. * Defines an optional offset (in seconds) inside the sound file
  35729. */
  35730. offset?: number;
  35731. /**
  35732. * If true, URLs will not be required to state the audio file codec to use.
  35733. */
  35734. skipCodecCheck?: boolean;
  35735. }
  35736. /**
  35737. * Defines a sound that can be played in the application.
  35738. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  35739. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  35740. */
  35741. export class Sound {
  35742. /**
  35743. * The name of the sound in the scene.
  35744. */
  35745. name: string;
  35746. /**
  35747. * Does the sound autoplay once loaded.
  35748. */
  35749. autoplay: boolean;
  35750. /**
  35751. * Does the sound loop after it finishes playing once.
  35752. */
  35753. loop: boolean;
  35754. /**
  35755. * Does the sound use a custom attenuation curve to simulate the falloff
  35756. * happening when the source gets further away from the camera.
  35757. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  35758. */
  35759. useCustomAttenuation: boolean;
  35760. /**
  35761. * The sound track id this sound belongs to.
  35762. */
  35763. soundTrackId: number;
  35764. /**
  35765. * Is this sound currently played.
  35766. */
  35767. isPlaying: boolean;
  35768. /**
  35769. * Is this sound currently paused.
  35770. */
  35771. isPaused: boolean;
  35772. /**
  35773. * Does this sound enables spatial sound.
  35774. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35775. */
  35776. spatialSound: boolean;
  35777. /**
  35778. * Define the reference distance the sound should be heard perfectly.
  35779. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35780. */
  35781. refDistance: number;
  35782. /**
  35783. * Define the roll off factor of spatial sounds.
  35784. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35785. */
  35786. rolloffFactor: number;
  35787. /**
  35788. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  35789. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35790. */
  35791. maxDistance: number;
  35792. /**
  35793. * Define the distance attenuation model the sound will follow.
  35794. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35795. */
  35796. distanceModel: string;
  35797. /**
  35798. * @hidden
  35799. * Back Compat
  35800. **/
  35801. onended: () => any;
  35802. /**
  35803. * Observable event when the current playing sound finishes.
  35804. */
  35805. onEndedObservable: Observable<Sound>;
  35806. private _panningModel;
  35807. private _playbackRate;
  35808. private _streaming;
  35809. private _startTime;
  35810. private _startOffset;
  35811. private _position;
  35812. /** @hidden */
  35813. _positionInEmitterSpace: boolean;
  35814. private _localDirection;
  35815. private _volume;
  35816. private _isReadyToPlay;
  35817. private _isDirectional;
  35818. private _readyToPlayCallback;
  35819. private _audioBuffer;
  35820. private _soundSource;
  35821. private _streamingSource;
  35822. private _soundPanner;
  35823. private _soundGain;
  35824. private _inputAudioNode;
  35825. private _outputAudioNode;
  35826. private _coneInnerAngle;
  35827. private _coneOuterAngle;
  35828. private _coneOuterGain;
  35829. private _scene;
  35830. private _connectedTransformNode;
  35831. private _customAttenuationFunction;
  35832. private _registerFunc;
  35833. private _isOutputConnected;
  35834. private _htmlAudioElement;
  35835. private _urlType;
  35836. private _length?;
  35837. private _offset?;
  35838. /** @hidden */
  35839. static _SceneComponentInitialization: (scene: Scene) => void;
  35840. /**
  35841. * Create a sound and attach it to a scene
  35842. * @param name Name of your sound
  35843. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  35844. * @param scene defines the scene the sound belongs to
  35845. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  35846. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  35847. */
  35848. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  35849. /**
  35850. * Release the sound and its associated resources
  35851. */
  35852. dispose(): void;
  35853. /**
  35854. * Gets if the sounds is ready to be played or not.
  35855. * @returns true if ready, otherwise false
  35856. */
  35857. isReady(): boolean;
  35858. private _soundLoaded;
  35859. /**
  35860. * Sets the data of the sound from an audiobuffer
  35861. * @param audioBuffer The audioBuffer containing the data
  35862. */
  35863. setAudioBuffer(audioBuffer: AudioBuffer): void;
  35864. /**
  35865. * Updates the current sounds options such as maxdistance, loop...
  35866. * @param options A JSON object containing values named as the object properties
  35867. */
  35868. updateOptions(options: ISoundOptions): void;
  35869. private _createSpatialParameters;
  35870. private _updateSpatialParameters;
  35871. /**
  35872. * Switch the panning model to HRTF:
  35873. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  35874. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35875. */
  35876. switchPanningModelToHRTF(): void;
  35877. /**
  35878. * Switch the panning model to Equal Power:
  35879. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  35880. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35881. */
  35882. switchPanningModelToEqualPower(): void;
  35883. private _switchPanningModel;
  35884. /**
  35885. * Connect this sound to a sound track audio node like gain...
  35886. * @param soundTrackAudioNode the sound track audio node to connect to
  35887. */
  35888. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  35889. /**
  35890. * Transform this sound into a directional source
  35891. * @param coneInnerAngle Size of the inner cone in degree
  35892. * @param coneOuterAngle Size of the outer cone in degree
  35893. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  35894. */
  35895. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  35896. /**
  35897. * Gets or sets the inner angle for the directional cone.
  35898. */
  35899. /**
  35900. * Gets or sets the inner angle for the directional cone.
  35901. */
  35902. directionalConeInnerAngle: number;
  35903. /**
  35904. * Gets or sets the outer angle for the directional cone.
  35905. */
  35906. /**
  35907. * Gets or sets the outer angle for the directional cone.
  35908. */
  35909. directionalConeOuterAngle: number;
  35910. /**
  35911. * Sets the position of the emitter if spatial sound is enabled
  35912. * @param newPosition Defines the new posisiton
  35913. */
  35914. setPosition(newPosition: Vector3): void;
  35915. /**
  35916. * Sets the local direction of the emitter if spatial sound is enabled
  35917. * @param newLocalDirection Defines the new local direction
  35918. */
  35919. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  35920. private _updateDirection;
  35921. /** @hidden */
  35922. updateDistanceFromListener(): void;
  35923. /**
  35924. * Sets a new custom attenuation function for the sound.
  35925. * @param callback Defines the function used for the attenuation
  35926. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  35927. */
  35928. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  35929. /**
  35930. * Play the sound
  35931. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  35932. * @param offset (optional) Start the sound at a specific time in seconds
  35933. * @param length (optional) Sound duration (in seconds)
  35934. */
  35935. play(time?: number, offset?: number, length?: number): void;
  35936. private _onended;
  35937. /**
  35938. * Stop the sound
  35939. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  35940. */
  35941. stop(time?: number): void;
  35942. /**
  35943. * Put the sound in pause
  35944. */
  35945. pause(): void;
  35946. /**
  35947. * Sets a dedicated volume for this sounds
  35948. * @param newVolume Define the new volume of the sound
  35949. * @param time Define time for gradual change to new volume
  35950. */
  35951. setVolume(newVolume: number, time?: number): void;
  35952. /**
  35953. * Set the sound play back rate
  35954. * @param newPlaybackRate Define the playback rate the sound should be played at
  35955. */
  35956. setPlaybackRate(newPlaybackRate: number): void;
  35957. /**
  35958. * Gets the volume of the sound.
  35959. * @returns the volume of the sound
  35960. */
  35961. getVolume(): number;
  35962. /**
  35963. * Attach the sound to a dedicated mesh
  35964. * @param transformNode The transform node to connect the sound with
  35965. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  35966. */
  35967. attachToMesh(transformNode: TransformNode): void;
  35968. /**
  35969. * Detach the sound from the previously attached mesh
  35970. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  35971. */
  35972. detachFromMesh(): void;
  35973. private _onRegisterAfterWorldMatrixUpdate;
  35974. /**
  35975. * Clone the current sound in the scene.
  35976. * @returns the new sound clone
  35977. */
  35978. clone(): Nullable<Sound>;
  35979. /**
  35980. * Gets the current underlying audio buffer containing the data
  35981. * @returns the audio buffer
  35982. */
  35983. getAudioBuffer(): Nullable<AudioBuffer>;
  35984. /**
  35985. * Serializes the Sound in a JSON representation
  35986. * @returns the JSON representation of the sound
  35987. */
  35988. serialize(): any;
  35989. /**
  35990. * Parse a JSON representation of a sound to innstantiate in a given scene
  35991. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  35992. * @param scene Define the scene the new parsed sound should be created in
  35993. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  35994. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  35995. * @returns the newly parsed sound
  35996. */
  35997. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  35998. }
  35999. }
  36000. declare module "babylonjs/Actions/directAudioActions" {
  36001. import { Action } from "babylonjs/Actions/action";
  36002. import { Condition } from "babylonjs/Actions/condition";
  36003. import { Sound } from "babylonjs/Audio/sound";
  36004. /**
  36005. * This defines an action helpful to play a defined sound on a triggered action.
  36006. */
  36007. export class PlaySoundAction extends Action {
  36008. private _sound;
  36009. /**
  36010. * Instantiate the action
  36011. * @param triggerOptions defines the trigger options
  36012. * @param sound defines the sound to play
  36013. * @param condition defines the trigger related conditions
  36014. */
  36015. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  36016. /** @hidden */
  36017. _prepare(): void;
  36018. /**
  36019. * Execute the action and play the sound.
  36020. */
  36021. execute(): void;
  36022. /**
  36023. * Serializes the actions and its related information.
  36024. * @param parent defines the object to serialize in
  36025. * @returns the serialized object
  36026. */
  36027. serialize(parent: any): any;
  36028. }
  36029. /**
  36030. * This defines an action helpful to stop a defined sound on a triggered action.
  36031. */
  36032. export class StopSoundAction extends Action {
  36033. private _sound;
  36034. /**
  36035. * Instantiate the action
  36036. * @param triggerOptions defines the trigger options
  36037. * @param sound defines the sound to stop
  36038. * @param condition defines the trigger related conditions
  36039. */
  36040. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  36041. /** @hidden */
  36042. _prepare(): void;
  36043. /**
  36044. * Execute the action and stop the sound.
  36045. */
  36046. execute(): void;
  36047. /**
  36048. * Serializes the actions and its related information.
  36049. * @param parent defines the object to serialize in
  36050. * @returns the serialized object
  36051. */
  36052. serialize(parent: any): any;
  36053. }
  36054. }
  36055. declare module "babylonjs/Actions/interpolateValueAction" {
  36056. import { Action } from "babylonjs/Actions/action";
  36057. import { Condition } from "babylonjs/Actions/condition";
  36058. import { Observable } from "babylonjs/Misc/observable";
  36059. /**
  36060. * This defines an action responsible to change the value of a property
  36061. * by interpolating between its current value and the newly set one once triggered.
  36062. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  36063. */
  36064. export class InterpolateValueAction extends Action {
  36065. /**
  36066. * Defines the path of the property where the value should be interpolated
  36067. */
  36068. propertyPath: string;
  36069. /**
  36070. * Defines the target value at the end of the interpolation.
  36071. */
  36072. value: any;
  36073. /**
  36074. * Defines the time it will take for the property to interpolate to the value.
  36075. */
  36076. duration: number;
  36077. /**
  36078. * Defines if the other scene animations should be stopped when the action has been triggered
  36079. */
  36080. stopOtherAnimations?: boolean;
  36081. /**
  36082. * Defines a callback raised once the interpolation animation has been done.
  36083. */
  36084. onInterpolationDone?: () => void;
  36085. /**
  36086. * Observable triggered once the interpolation animation has been done.
  36087. */
  36088. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  36089. private _target;
  36090. private _effectiveTarget;
  36091. private _property;
  36092. /**
  36093. * Instantiate the action
  36094. * @param triggerOptions defines the trigger options
  36095. * @param target defines the object containing the value to interpolate
  36096. * @param propertyPath defines the path to the property in the target object
  36097. * @param value defines the target value at the end of the interpolation
  36098. * @param duration deines the time it will take for the property to interpolate to the value.
  36099. * @param condition defines the trigger related conditions
  36100. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  36101. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  36102. */
  36103. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  36104. /** @hidden */
  36105. _prepare(): void;
  36106. /**
  36107. * Execute the action starts the value interpolation.
  36108. */
  36109. execute(): void;
  36110. /**
  36111. * Serializes the actions and its related information.
  36112. * @param parent defines the object to serialize in
  36113. * @returns the serialized object
  36114. */
  36115. serialize(parent: any): any;
  36116. }
  36117. }
  36118. declare module "babylonjs/Actions/index" {
  36119. export * from "babylonjs/Actions/abstractActionManager";
  36120. export * from "babylonjs/Actions/action";
  36121. export * from "babylonjs/Actions/actionEvent";
  36122. export * from "babylonjs/Actions/actionManager";
  36123. export * from "babylonjs/Actions/condition";
  36124. export * from "babylonjs/Actions/directActions";
  36125. export * from "babylonjs/Actions/directAudioActions";
  36126. export * from "babylonjs/Actions/interpolateValueAction";
  36127. }
  36128. declare module "babylonjs/Animations/index" {
  36129. export * from "babylonjs/Animations/animatable";
  36130. export * from "babylonjs/Animations/animation";
  36131. export * from "babylonjs/Animations/animationGroup";
  36132. export * from "babylonjs/Animations/animationPropertiesOverride";
  36133. export * from "babylonjs/Animations/easing";
  36134. export * from "babylonjs/Animations/runtimeAnimation";
  36135. export * from "babylonjs/Animations/animationEvent";
  36136. export * from "babylonjs/Animations/animationGroup";
  36137. export * from "babylonjs/Animations/animationKey";
  36138. export * from "babylonjs/Animations/animationRange";
  36139. export * from "babylonjs/Animations/animatable.interface";
  36140. }
  36141. declare module "babylonjs/Audio/soundTrack" {
  36142. import { Sound } from "babylonjs/Audio/sound";
  36143. import { Analyser } from "babylonjs/Audio/analyser";
  36144. import { Scene } from "babylonjs/scene";
  36145. /**
  36146. * Options allowed during the creation of a sound track.
  36147. */
  36148. export interface ISoundTrackOptions {
  36149. /**
  36150. * The volume the sound track should take during creation
  36151. */
  36152. volume?: number;
  36153. /**
  36154. * Define if the sound track is the main sound track of the scene
  36155. */
  36156. mainTrack?: boolean;
  36157. }
  36158. /**
  36159. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  36160. * It will be also used in a future release to apply effects on a specific track.
  36161. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  36162. */
  36163. export class SoundTrack {
  36164. /**
  36165. * The unique identifier of the sound track in the scene.
  36166. */
  36167. id: number;
  36168. /**
  36169. * The list of sounds included in the sound track.
  36170. */
  36171. soundCollection: Array<Sound>;
  36172. private _outputAudioNode;
  36173. private _scene;
  36174. private _isMainTrack;
  36175. private _connectedAnalyser;
  36176. private _options;
  36177. private _isInitialized;
  36178. /**
  36179. * Creates a new sound track.
  36180. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  36181. * @param scene Define the scene the sound track belongs to
  36182. * @param options
  36183. */
  36184. constructor(scene: Scene, options?: ISoundTrackOptions);
  36185. private _initializeSoundTrackAudioGraph;
  36186. /**
  36187. * Release the sound track and its associated resources
  36188. */
  36189. dispose(): void;
  36190. /**
  36191. * Adds a sound to this sound track
  36192. * @param sound define the cound to add
  36193. * @ignoreNaming
  36194. */
  36195. AddSound(sound: Sound): void;
  36196. /**
  36197. * Removes a sound to this sound track
  36198. * @param sound define the cound to remove
  36199. * @ignoreNaming
  36200. */
  36201. RemoveSound(sound: Sound): void;
  36202. /**
  36203. * Set a global volume for the full sound track.
  36204. * @param newVolume Define the new volume of the sound track
  36205. */
  36206. setVolume(newVolume: number): void;
  36207. /**
  36208. * Switch the panning model to HRTF:
  36209. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  36210. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36211. */
  36212. switchPanningModelToHRTF(): void;
  36213. /**
  36214. * Switch the panning model to Equal Power:
  36215. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  36216. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36217. */
  36218. switchPanningModelToEqualPower(): void;
  36219. /**
  36220. * Connect the sound track to an audio analyser allowing some amazing
  36221. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  36222. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  36223. * @param analyser The analyser to connect to the engine
  36224. */
  36225. connectToAnalyser(analyser: Analyser): void;
  36226. }
  36227. }
  36228. declare module "babylonjs/Audio/audioSceneComponent" {
  36229. import { Sound } from "babylonjs/Audio/sound";
  36230. import { SoundTrack } from "babylonjs/Audio/soundTrack";
  36231. import { Nullable } from "babylonjs/types";
  36232. import { Vector3 } from "babylonjs/Maths/math.vector";
  36233. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  36234. import { Scene } from "babylonjs/scene";
  36235. import { AbstractScene } from "babylonjs/abstractScene";
  36236. import "babylonjs/Audio/audioEngine";
  36237. module "babylonjs/abstractScene" {
  36238. interface AbstractScene {
  36239. /**
  36240. * The list of sounds used in the scene.
  36241. */
  36242. sounds: Nullable<Array<Sound>>;
  36243. }
  36244. }
  36245. module "babylonjs/scene" {
  36246. interface Scene {
  36247. /**
  36248. * @hidden
  36249. * Backing field
  36250. */
  36251. _mainSoundTrack: SoundTrack;
  36252. /**
  36253. * The main sound track played by the scene.
  36254. * It cotains your primary collection of sounds.
  36255. */
  36256. mainSoundTrack: SoundTrack;
  36257. /**
  36258. * The list of sound tracks added to the scene
  36259. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  36260. */
  36261. soundTracks: Nullable<Array<SoundTrack>>;
  36262. /**
  36263. * Gets a sound using a given name
  36264. * @param name defines the name to search for
  36265. * @return the found sound or null if not found at all.
  36266. */
  36267. getSoundByName(name: string): Nullable<Sound>;
  36268. /**
  36269. * Gets or sets if audio support is enabled
  36270. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  36271. */
  36272. audioEnabled: boolean;
  36273. /**
  36274. * Gets or sets if audio will be output to headphones
  36275. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  36276. */
  36277. headphone: boolean;
  36278. /**
  36279. * Gets or sets custom audio listener position provider
  36280. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  36281. */
  36282. audioListenerPositionProvider: Nullable<() => Vector3>;
  36283. }
  36284. }
  36285. /**
  36286. * Defines the sound scene component responsible to manage any sounds
  36287. * in a given scene.
  36288. */
  36289. export class AudioSceneComponent implements ISceneSerializableComponent {
  36290. /**
  36291. * The component name helpfull to identify the component in the list of scene components.
  36292. */
  36293. readonly name: string;
  36294. /**
  36295. * The scene the component belongs to.
  36296. */
  36297. scene: Scene;
  36298. private _audioEnabled;
  36299. /**
  36300. * Gets whether audio is enabled or not.
  36301. * Please use related enable/disable method to switch state.
  36302. */
  36303. readonly audioEnabled: boolean;
  36304. private _headphone;
  36305. /**
  36306. * Gets whether audio is outputing to headphone or not.
  36307. * Please use the according Switch methods to change output.
  36308. */
  36309. readonly headphone: boolean;
  36310. private _audioListenerPositionProvider;
  36311. /**
  36312. * Gets the current audio listener position provider
  36313. */
  36314. /**
  36315. * Sets a custom listener position for all sounds in the scene
  36316. * By default, this is the position of the first active camera
  36317. */
  36318. audioListenerPositionProvider: Nullable<() => Vector3>;
  36319. /**
  36320. * Creates a new instance of the component for the given scene
  36321. * @param scene Defines the scene to register the component in
  36322. */
  36323. constructor(scene: Scene);
  36324. /**
  36325. * Registers the component in a given scene
  36326. */
  36327. register(): void;
  36328. /**
  36329. * Rebuilds the elements related to this component in case of
  36330. * context lost for instance.
  36331. */
  36332. rebuild(): void;
  36333. /**
  36334. * Serializes the component data to the specified json object
  36335. * @param serializationObject The object to serialize to
  36336. */
  36337. serialize(serializationObject: any): void;
  36338. /**
  36339. * Adds all the elements from the container to the scene
  36340. * @param container the container holding the elements
  36341. */
  36342. addFromContainer(container: AbstractScene): void;
  36343. /**
  36344. * Removes all the elements in the container from the scene
  36345. * @param container contains the elements to remove
  36346. * @param dispose if the removed element should be disposed (default: false)
  36347. */
  36348. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  36349. /**
  36350. * Disposes the component and the associated ressources.
  36351. */
  36352. dispose(): void;
  36353. /**
  36354. * Disables audio in the associated scene.
  36355. */
  36356. disableAudio(): void;
  36357. /**
  36358. * Enables audio in the associated scene.
  36359. */
  36360. enableAudio(): void;
  36361. /**
  36362. * Switch audio to headphone output.
  36363. */
  36364. switchAudioModeForHeadphones(): void;
  36365. /**
  36366. * Switch audio to normal speakers.
  36367. */
  36368. switchAudioModeForNormalSpeakers(): void;
  36369. private _afterRender;
  36370. }
  36371. }
  36372. declare module "babylonjs/Audio/weightedsound" {
  36373. import { Sound } from "babylonjs/Audio/sound";
  36374. /**
  36375. * Wraps one or more Sound objects and selects one with random weight for playback.
  36376. */
  36377. export class WeightedSound {
  36378. /** When true a Sound will be selected and played when the current playing Sound completes. */
  36379. loop: boolean;
  36380. private _coneInnerAngle;
  36381. private _coneOuterAngle;
  36382. private _volume;
  36383. /** A Sound is currently playing. */
  36384. isPlaying: boolean;
  36385. /** A Sound is currently paused. */
  36386. isPaused: boolean;
  36387. private _sounds;
  36388. private _weights;
  36389. private _currentIndex?;
  36390. /**
  36391. * Creates a new WeightedSound from the list of sounds given.
  36392. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  36393. * @param sounds Array of Sounds that will be selected from.
  36394. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  36395. */
  36396. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  36397. /**
  36398. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  36399. */
  36400. /**
  36401. * The size of cone in degress for a directional sound in which there will be no attenuation.
  36402. */
  36403. directionalConeInnerAngle: number;
  36404. /**
  36405. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  36406. * Listener angles between innerAngle and outerAngle will falloff linearly.
  36407. */
  36408. /**
  36409. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  36410. * Listener angles between innerAngle and outerAngle will falloff linearly.
  36411. */
  36412. directionalConeOuterAngle: number;
  36413. /**
  36414. * Playback volume.
  36415. */
  36416. /**
  36417. * Playback volume.
  36418. */
  36419. volume: number;
  36420. private _onended;
  36421. /**
  36422. * Suspend playback
  36423. */
  36424. pause(): void;
  36425. /**
  36426. * Stop playback
  36427. */
  36428. stop(): void;
  36429. /**
  36430. * Start playback.
  36431. * @param startOffset Position the clip head at a specific time in seconds.
  36432. */
  36433. play(startOffset?: number): void;
  36434. }
  36435. }
  36436. declare module "babylonjs/Audio/index" {
  36437. export * from "babylonjs/Audio/analyser";
  36438. export * from "babylonjs/Audio/audioEngine";
  36439. export * from "babylonjs/Audio/audioSceneComponent";
  36440. export * from "babylonjs/Audio/sound";
  36441. export * from "babylonjs/Audio/soundTrack";
  36442. export * from "babylonjs/Audio/weightedsound";
  36443. }
  36444. declare module "babylonjs/Behaviors/Cameras/bouncingBehavior" {
  36445. import { Behavior } from "babylonjs/Behaviors/behavior";
  36446. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  36447. import { BackEase } from "babylonjs/Animations/easing";
  36448. /**
  36449. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  36450. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  36451. */
  36452. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  36453. /**
  36454. * Gets the name of the behavior.
  36455. */
  36456. readonly name: string;
  36457. /**
  36458. * The easing function used by animations
  36459. */
  36460. static EasingFunction: BackEase;
  36461. /**
  36462. * The easing mode used by animations
  36463. */
  36464. static EasingMode: number;
  36465. /**
  36466. * The duration of the animation, in milliseconds
  36467. */
  36468. transitionDuration: number;
  36469. /**
  36470. * Length of the distance animated by the transition when lower radius is reached
  36471. */
  36472. lowerRadiusTransitionRange: number;
  36473. /**
  36474. * Length of the distance animated by the transition when upper radius is reached
  36475. */
  36476. upperRadiusTransitionRange: number;
  36477. private _autoTransitionRange;
  36478. /**
  36479. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  36480. */
  36481. /**
  36482. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  36483. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  36484. */
  36485. autoTransitionRange: boolean;
  36486. private _attachedCamera;
  36487. private _onAfterCheckInputsObserver;
  36488. private _onMeshTargetChangedObserver;
  36489. /**
  36490. * Initializes the behavior.
  36491. */
  36492. init(): void;
  36493. /**
  36494. * Attaches the behavior to its arc rotate camera.
  36495. * @param camera Defines the camera to attach the behavior to
  36496. */
  36497. attach(camera: ArcRotateCamera): void;
  36498. /**
  36499. * Detaches the behavior from its current arc rotate camera.
  36500. */
  36501. detach(): void;
  36502. private _radiusIsAnimating;
  36503. private _radiusBounceTransition;
  36504. private _animatables;
  36505. private _cachedWheelPrecision;
  36506. /**
  36507. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  36508. * @param radiusLimit The limit to check against.
  36509. * @return Bool to indicate if at limit.
  36510. */
  36511. private _isRadiusAtLimit;
  36512. /**
  36513. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  36514. * @param radiusDelta The delta by which to animate to. Can be negative.
  36515. */
  36516. private _applyBoundRadiusAnimation;
  36517. /**
  36518. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  36519. */
  36520. protected _clearAnimationLocks(): void;
  36521. /**
  36522. * Stops and removes all animations that have been applied to the camera
  36523. */
  36524. stopAllAnimations(): void;
  36525. }
  36526. }
  36527. declare module "babylonjs/Behaviors/Cameras/framingBehavior" {
  36528. import { Behavior } from "babylonjs/Behaviors/behavior";
  36529. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  36530. import { ExponentialEase } from "babylonjs/Animations/easing";
  36531. import { Nullable } from "babylonjs/types";
  36532. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  36533. import { Vector3 } from "babylonjs/Maths/math.vector";
  36534. /**
  36535. * 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.
  36536. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  36537. */
  36538. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  36539. /**
  36540. * Gets the name of the behavior.
  36541. */
  36542. readonly name: string;
  36543. private _mode;
  36544. private _radiusScale;
  36545. private _positionScale;
  36546. private _defaultElevation;
  36547. private _elevationReturnTime;
  36548. private _elevationReturnWaitTime;
  36549. private _zoomStopsAnimation;
  36550. private _framingTime;
  36551. /**
  36552. * The easing function used by animations
  36553. */
  36554. static EasingFunction: ExponentialEase;
  36555. /**
  36556. * The easing mode used by animations
  36557. */
  36558. static EasingMode: number;
  36559. /**
  36560. * Sets the current mode used by the behavior
  36561. */
  36562. /**
  36563. * Gets current mode used by the behavior.
  36564. */
  36565. mode: number;
  36566. /**
  36567. * Sets the scale applied to the radius (1 by default)
  36568. */
  36569. /**
  36570. * Gets the scale applied to the radius
  36571. */
  36572. radiusScale: number;
  36573. /**
  36574. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  36575. */
  36576. /**
  36577. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  36578. */
  36579. positionScale: number;
  36580. /**
  36581. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  36582. * behaviour is triggered, in radians.
  36583. */
  36584. /**
  36585. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  36586. * behaviour is triggered, in radians.
  36587. */
  36588. defaultElevation: number;
  36589. /**
  36590. * Sets the time (in milliseconds) taken to return to the default beta position.
  36591. * Negative value indicates camera should not return to default.
  36592. */
  36593. /**
  36594. * Gets the time (in milliseconds) taken to return to the default beta position.
  36595. * Negative value indicates camera should not return to default.
  36596. */
  36597. elevationReturnTime: number;
  36598. /**
  36599. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  36600. */
  36601. /**
  36602. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  36603. */
  36604. elevationReturnWaitTime: number;
  36605. /**
  36606. * Sets the flag that indicates if user zooming should stop animation.
  36607. */
  36608. /**
  36609. * Gets the flag that indicates if user zooming should stop animation.
  36610. */
  36611. zoomStopsAnimation: boolean;
  36612. /**
  36613. * Sets the transition time when framing the mesh, in milliseconds
  36614. */
  36615. /**
  36616. * Gets the transition time when framing the mesh, in milliseconds
  36617. */
  36618. framingTime: number;
  36619. /**
  36620. * Define if the behavior should automatically change the configured
  36621. * camera limits and sensibilities.
  36622. */
  36623. autoCorrectCameraLimitsAndSensibility: boolean;
  36624. private _onPrePointerObservableObserver;
  36625. private _onAfterCheckInputsObserver;
  36626. private _onMeshTargetChangedObserver;
  36627. private _attachedCamera;
  36628. private _isPointerDown;
  36629. private _lastInteractionTime;
  36630. /**
  36631. * Initializes the behavior.
  36632. */
  36633. init(): void;
  36634. /**
  36635. * Attaches the behavior to its arc rotate camera.
  36636. * @param camera Defines the camera to attach the behavior to
  36637. */
  36638. attach(camera: ArcRotateCamera): void;
  36639. /**
  36640. * Detaches the behavior from its current arc rotate camera.
  36641. */
  36642. detach(): void;
  36643. private _animatables;
  36644. private _betaIsAnimating;
  36645. private _betaTransition;
  36646. private _radiusTransition;
  36647. private _vectorTransition;
  36648. /**
  36649. * Targets the given mesh and updates zoom level accordingly.
  36650. * @param mesh The mesh to target.
  36651. * @param radius Optional. If a cached radius position already exists, overrides default.
  36652. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  36653. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  36654. * @param onAnimationEnd Callback triggered at the end of the framing animation
  36655. */
  36656. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  36657. /**
  36658. * Targets the given mesh with its children and updates zoom level accordingly.
  36659. * @param mesh The mesh to target.
  36660. * @param radius Optional. If a cached radius position already exists, overrides default.
  36661. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  36662. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  36663. * @param onAnimationEnd Callback triggered at the end of the framing animation
  36664. */
  36665. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  36666. /**
  36667. * Targets the given meshes with their children and updates zoom level accordingly.
  36668. * @param meshes The mesh to target.
  36669. * @param radius Optional. If a cached radius position already exists, overrides default.
  36670. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  36671. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  36672. * @param onAnimationEnd Callback triggered at the end of the framing animation
  36673. */
  36674. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  36675. /**
  36676. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  36677. * @param minimumWorld Determines the smaller position of the bounding box extend
  36678. * @param maximumWorld Determines the bigger position of the bounding box extend
  36679. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  36680. * @param onAnimationEnd Callback triggered at the end of the framing animation
  36681. */
  36682. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  36683. /**
  36684. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  36685. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  36686. * frustum width.
  36687. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  36688. * to fully enclose the mesh in the viewing frustum.
  36689. */
  36690. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  36691. /**
  36692. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  36693. * is automatically returned to its default position (expected to be above ground plane).
  36694. */
  36695. private _maintainCameraAboveGround;
  36696. /**
  36697. * Returns the frustum slope based on the canvas ratio and camera FOV
  36698. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  36699. */
  36700. private _getFrustumSlope;
  36701. /**
  36702. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  36703. */
  36704. private _clearAnimationLocks;
  36705. /**
  36706. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  36707. */
  36708. private _applyUserInteraction;
  36709. /**
  36710. * Stops and removes all animations that have been applied to the camera
  36711. */
  36712. stopAllAnimations(): void;
  36713. /**
  36714. * Gets a value indicating if the user is moving the camera
  36715. */
  36716. readonly isUserIsMoving: boolean;
  36717. /**
  36718. * The camera can move all the way towards the mesh.
  36719. */
  36720. static IgnoreBoundsSizeMode: number;
  36721. /**
  36722. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  36723. */
  36724. static FitFrustumSidesMode: number;
  36725. }
  36726. }
  36727. declare module "babylonjs/Cameras/Inputs/BaseCameraPointersInput" {
  36728. import { Nullable } from "babylonjs/types";
  36729. import { Camera } from "babylonjs/Cameras/camera";
  36730. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  36731. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  36732. /**
  36733. * Base class for Camera Pointer Inputs.
  36734. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  36735. * for example usage.
  36736. */
  36737. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  36738. /**
  36739. * Defines the camera the input is attached to.
  36740. */
  36741. abstract camera: Camera;
  36742. /**
  36743. * Whether keyboard modifier keys are pressed at time of last mouse event.
  36744. */
  36745. protected _altKey: boolean;
  36746. protected _ctrlKey: boolean;
  36747. protected _metaKey: boolean;
  36748. protected _shiftKey: boolean;
  36749. /**
  36750. * Which mouse buttons were pressed at time of last mouse event.
  36751. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  36752. */
  36753. protected _buttonsPressed: number;
  36754. /**
  36755. * Defines the buttons associated with the input to handle camera move.
  36756. */
  36757. buttons: number[];
  36758. /**
  36759. * Attach the input controls to a specific dom element to get the input from.
  36760. * @param element Defines the element the controls should be listened from
  36761. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36762. */
  36763. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36764. /**
  36765. * Detach the current controls from the specified dom element.
  36766. * @param element Defines the element to stop listening the inputs from
  36767. */
  36768. detachControl(element: Nullable<HTMLElement>): void;
  36769. /**
  36770. * Gets the class name of the current input.
  36771. * @returns the class name
  36772. */
  36773. getClassName(): string;
  36774. /**
  36775. * Get the friendly name associated with the input class.
  36776. * @returns the input friendly name
  36777. */
  36778. getSimpleName(): string;
  36779. /**
  36780. * Called on pointer POINTERDOUBLETAP event.
  36781. * Override this method to provide functionality on POINTERDOUBLETAP event.
  36782. */
  36783. protected onDoubleTap(type: string): void;
  36784. /**
  36785. * Called on pointer POINTERMOVE event if only a single touch is active.
  36786. * Override this method to provide functionality.
  36787. */
  36788. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  36789. /**
  36790. * Called on pointer POINTERMOVE event if multiple touches are active.
  36791. * Override this method to provide functionality.
  36792. */
  36793. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  36794. /**
  36795. * Called on JS contextmenu event.
  36796. * Override this method to provide functionality.
  36797. */
  36798. protected onContextMenu(evt: PointerEvent): void;
  36799. /**
  36800. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  36801. * press.
  36802. * Override this method to provide functionality.
  36803. */
  36804. protected onButtonDown(evt: PointerEvent): void;
  36805. /**
  36806. * Called each time a new POINTERUP event occurs. Ie, for each button
  36807. * release.
  36808. * Override this method to provide functionality.
  36809. */
  36810. protected onButtonUp(evt: PointerEvent): void;
  36811. /**
  36812. * Called when window becomes inactive.
  36813. * Override this method to provide functionality.
  36814. */
  36815. protected onLostFocus(): void;
  36816. private _pointerInput;
  36817. private _observer;
  36818. private _onLostFocus;
  36819. private pointA;
  36820. private pointB;
  36821. }
  36822. }
  36823. declare module "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput" {
  36824. import { Nullable } from "babylonjs/types";
  36825. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  36826. import { BaseCameraPointersInput } from "babylonjs/Cameras/Inputs/BaseCameraPointersInput";
  36827. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  36828. /**
  36829. * Manage the pointers inputs to control an arc rotate camera.
  36830. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36831. */
  36832. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  36833. /**
  36834. * Defines the camera the input is attached to.
  36835. */
  36836. camera: ArcRotateCamera;
  36837. /**
  36838. * Gets the class name of the current input.
  36839. * @returns the class name
  36840. */
  36841. getClassName(): string;
  36842. /**
  36843. * Defines the buttons associated with the input to handle camera move.
  36844. */
  36845. buttons: number[];
  36846. /**
  36847. * Defines the pointer angular sensibility along the X axis or how fast is
  36848. * the camera rotating.
  36849. */
  36850. angularSensibilityX: number;
  36851. /**
  36852. * Defines the pointer angular sensibility along the Y axis or how fast is
  36853. * the camera rotating.
  36854. */
  36855. angularSensibilityY: number;
  36856. /**
  36857. * Defines the pointer pinch precision or how fast is the camera zooming.
  36858. */
  36859. pinchPrecision: number;
  36860. /**
  36861. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  36862. * from 0.
  36863. * It defines the percentage of current camera.radius to use as delta when
  36864. * pinch zoom is used.
  36865. */
  36866. pinchDeltaPercentage: number;
  36867. /**
  36868. * Defines the pointer panning sensibility or how fast is the camera moving.
  36869. */
  36870. panningSensibility: number;
  36871. /**
  36872. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  36873. */
  36874. multiTouchPanning: boolean;
  36875. /**
  36876. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  36877. * zoom (pinch) through multitouch.
  36878. */
  36879. multiTouchPanAndZoom: boolean;
  36880. /**
  36881. * Revers pinch action direction.
  36882. */
  36883. pinchInwards: boolean;
  36884. private _isPanClick;
  36885. private _twoFingerActivityCount;
  36886. private _isPinching;
  36887. /**
  36888. * Called on pointer POINTERMOVE event if only a single touch is active.
  36889. */
  36890. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  36891. /**
  36892. * Called on pointer POINTERDOUBLETAP event.
  36893. */
  36894. protected onDoubleTap(type: string): void;
  36895. /**
  36896. * Called on pointer POINTERMOVE event if multiple touches are active.
  36897. */
  36898. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  36899. /**
  36900. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  36901. * press.
  36902. */
  36903. protected onButtonDown(evt: PointerEvent): void;
  36904. /**
  36905. * Called each time a new POINTERUP event occurs. Ie, for each button
  36906. * release.
  36907. */
  36908. protected onButtonUp(evt: PointerEvent): void;
  36909. /**
  36910. * Called when window becomes inactive.
  36911. */
  36912. protected onLostFocus(): void;
  36913. }
  36914. }
  36915. declare module "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput" {
  36916. import { Nullable } from "babylonjs/types";
  36917. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  36918. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  36919. /**
  36920. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  36921. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36922. */
  36923. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  36924. /**
  36925. * Defines the camera the input is attached to.
  36926. */
  36927. camera: ArcRotateCamera;
  36928. /**
  36929. * Defines the list of key codes associated with the up action (increase alpha)
  36930. */
  36931. keysUp: number[];
  36932. /**
  36933. * Defines the list of key codes associated with the down action (decrease alpha)
  36934. */
  36935. keysDown: number[];
  36936. /**
  36937. * Defines the list of key codes associated with the left action (increase beta)
  36938. */
  36939. keysLeft: number[];
  36940. /**
  36941. * Defines the list of key codes associated with the right action (decrease beta)
  36942. */
  36943. keysRight: number[];
  36944. /**
  36945. * Defines the list of key codes associated with the reset action.
  36946. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  36947. */
  36948. keysReset: number[];
  36949. /**
  36950. * Defines the panning sensibility of the inputs.
  36951. * (How fast is the camera paning)
  36952. */
  36953. panningSensibility: number;
  36954. /**
  36955. * Defines the zooming sensibility of the inputs.
  36956. * (How fast is the camera zooming)
  36957. */
  36958. zoomingSensibility: number;
  36959. /**
  36960. * Defines wether maintaining the alt key down switch the movement mode from
  36961. * orientation to zoom.
  36962. */
  36963. useAltToZoom: boolean;
  36964. /**
  36965. * Rotation speed of the camera
  36966. */
  36967. angularSpeed: number;
  36968. private _keys;
  36969. private _ctrlPressed;
  36970. private _altPressed;
  36971. private _onCanvasBlurObserver;
  36972. private _onKeyboardObserver;
  36973. private _engine;
  36974. private _scene;
  36975. /**
  36976. * Attach the input controls to a specific dom element to get the input from.
  36977. * @param element Defines the element the controls should be listened from
  36978. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36979. */
  36980. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36981. /**
  36982. * Detach the current controls from the specified dom element.
  36983. * @param element Defines the element to stop listening the inputs from
  36984. */
  36985. detachControl(element: Nullable<HTMLElement>): void;
  36986. /**
  36987. * Update the current camera state depending on the inputs that have been used this frame.
  36988. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  36989. */
  36990. checkInputs(): void;
  36991. /**
  36992. * Gets the class name of the current intput.
  36993. * @returns the class name
  36994. */
  36995. getClassName(): string;
  36996. /**
  36997. * Get the friendly name associated with the input class.
  36998. * @returns the input friendly name
  36999. */
  37000. getSimpleName(): string;
  37001. }
  37002. }
  37003. declare module "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput" {
  37004. import { Nullable } from "babylonjs/types";
  37005. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  37006. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  37007. /**
  37008. * Manage the mouse wheel inputs to control an arc rotate camera.
  37009. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37010. */
  37011. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  37012. /**
  37013. * Defines the camera the input is attached to.
  37014. */
  37015. camera: ArcRotateCamera;
  37016. /**
  37017. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  37018. */
  37019. wheelPrecision: number;
  37020. /**
  37021. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  37022. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  37023. */
  37024. wheelDeltaPercentage: number;
  37025. private _wheel;
  37026. private _observer;
  37027. private computeDeltaFromMouseWheelLegacyEvent;
  37028. /**
  37029. * Attach the input controls to a specific dom element to get the input from.
  37030. * @param element Defines the element the controls should be listened from
  37031. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37032. */
  37033. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37034. /**
  37035. * Detach the current controls from the specified dom element.
  37036. * @param element Defines the element to stop listening the inputs from
  37037. */
  37038. detachControl(element: Nullable<HTMLElement>): void;
  37039. /**
  37040. * Gets the class name of the current intput.
  37041. * @returns the class name
  37042. */
  37043. getClassName(): string;
  37044. /**
  37045. * Get the friendly name associated with the input class.
  37046. * @returns the input friendly name
  37047. */
  37048. getSimpleName(): string;
  37049. }
  37050. }
  37051. declare module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  37052. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  37053. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  37054. /**
  37055. * Default Inputs manager for the ArcRotateCamera.
  37056. * It groups all the default supported inputs for ease of use.
  37057. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37058. */
  37059. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  37060. /**
  37061. * Instantiates a new ArcRotateCameraInputsManager.
  37062. * @param camera Defines the camera the inputs belong to
  37063. */
  37064. constructor(camera: ArcRotateCamera);
  37065. /**
  37066. * Add mouse wheel input support to the input manager.
  37067. * @returns the current input manager
  37068. */
  37069. addMouseWheel(): ArcRotateCameraInputsManager;
  37070. /**
  37071. * Add pointers input support to the input manager.
  37072. * @returns the current input manager
  37073. */
  37074. addPointers(): ArcRotateCameraInputsManager;
  37075. /**
  37076. * Add keyboard input support to the input manager.
  37077. * @returns the current input manager
  37078. */
  37079. addKeyboard(): ArcRotateCameraInputsManager;
  37080. }
  37081. }
  37082. declare module "babylonjs/Cameras/arcRotateCamera" {
  37083. import { Observable } from "babylonjs/Misc/observable";
  37084. import { Nullable } from "babylonjs/types";
  37085. import { Scene } from "babylonjs/scene";
  37086. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  37087. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  37088. import { AutoRotationBehavior } from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  37089. import { BouncingBehavior } from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  37090. import { FramingBehavior } from "babylonjs/Behaviors/Cameras/framingBehavior";
  37091. import { Camera } from "babylonjs/Cameras/camera";
  37092. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  37093. import { ArcRotateCameraInputsManager } from "babylonjs/Cameras/arcRotateCameraInputsManager";
  37094. import { Collider } from "babylonjs/Collisions/collider";
  37095. /**
  37096. * This represents an orbital type of camera.
  37097. *
  37098. * 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.
  37099. * 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.
  37100. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  37101. */
  37102. export class ArcRotateCamera extends TargetCamera {
  37103. /**
  37104. * Defines the rotation angle of the camera along the longitudinal axis.
  37105. */
  37106. alpha: number;
  37107. /**
  37108. * Defines the rotation angle of the camera along the latitudinal axis.
  37109. */
  37110. beta: number;
  37111. /**
  37112. * Defines the radius of the camera from it s target point.
  37113. */
  37114. radius: number;
  37115. protected _target: Vector3;
  37116. protected _targetHost: Nullable<AbstractMesh>;
  37117. /**
  37118. * Defines the target point of the camera.
  37119. * The camera looks towards it form the radius distance.
  37120. */
  37121. target: Vector3;
  37122. /**
  37123. * Define the current local position of the camera in the scene
  37124. */
  37125. position: Vector3;
  37126. protected _upVector: Vector3;
  37127. protected _upToYMatrix: Matrix;
  37128. protected _YToUpMatrix: Matrix;
  37129. /**
  37130. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  37131. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  37132. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  37133. */
  37134. upVector: Vector3;
  37135. /**
  37136. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  37137. */
  37138. setMatUp(): void;
  37139. /**
  37140. * Current inertia value on the longitudinal axis.
  37141. * The bigger this number the longer it will take for the camera to stop.
  37142. */
  37143. inertialAlphaOffset: number;
  37144. /**
  37145. * Current inertia value on the latitudinal axis.
  37146. * The bigger this number the longer it will take for the camera to stop.
  37147. */
  37148. inertialBetaOffset: number;
  37149. /**
  37150. * Current inertia value on the radius axis.
  37151. * The bigger this number the longer it will take for the camera to stop.
  37152. */
  37153. inertialRadiusOffset: number;
  37154. /**
  37155. * Minimum allowed angle on the longitudinal axis.
  37156. * This can help limiting how the Camera is able to move in the scene.
  37157. */
  37158. lowerAlphaLimit: Nullable<number>;
  37159. /**
  37160. * Maximum allowed angle on the longitudinal axis.
  37161. * This can help limiting how the Camera is able to move in the scene.
  37162. */
  37163. upperAlphaLimit: Nullable<number>;
  37164. /**
  37165. * Minimum allowed angle on the latitudinal axis.
  37166. * This can help limiting how the Camera is able to move in the scene.
  37167. */
  37168. lowerBetaLimit: number;
  37169. /**
  37170. * Maximum allowed angle on the latitudinal axis.
  37171. * This can help limiting how the Camera is able to move in the scene.
  37172. */
  37173. upperBetaLimit: number;
  37174. /**
  37175. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  37176. * This can help limiting how the Camera is able to move in the scene.
  37177. */
  37178. lowerRadiusLimit: Nullable<number>;
  37179. /**
  37180. * Maximum allowed distance of the camera to the target (The camera can not get further).
  37181. * This can help limiting how the Camera is able to move in the scene.
  37182. */
  37183. upperRadiusLimit: Nullable<number>;
  37184. /**
  37185. * Defines the current inertia value used during panning of the camera along the X axis.
  37186. */
  37187. inertialPanningX: number;
  37188. /**
  37189. * Defines the current inertia value used during panning of the camera along the Y axis.
  37190. */
  37191. inertialPanningY: number;
  37192. /**
  37193. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  37194. * Basically if your fingers moves away from more than this distance you will be considered
  37195. * in pinch mode.
  37196. */
  37197. pinchToPanMaxDistance: number;
  37198. /**
  37199. * Defines the maximum distance the camera can pan.
  37200. * This could help keeping the cammera always in your scene.
  37201. */
  37202. panningDistanceLimit: Nullable<number>;
  37203. /**
  37204. * Defines the target of the camera before paning.
  37205. */
  37206. panningOriginTarget: Vector3;
  37207. /**
  37208. * Defines the value of the inertia used during panning.
  37209. * 0 would mean stop inertia and one would mean no decelleration at all.
  37210. */
  37211. panningInertia: number;
  37212. /**
  37213. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  37214. */
  37215. angularSensibilityX: number;
  37216. /**
  37217. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  37218. */
  37219. angularSensibilityY: number;
  37220. /**
  37221. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  37222. */
  37223. pinchPrecision: number;
  37224. /**
  37225. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  37226. * It will be used instead of pinchDeltaPrecision if different from 0.
  37227. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  37228. */
  37229. pinchDeltaPercentage: number;
  37230. /**
  37231. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  37232. */
  37233. panningSensibility: number;
  37234. /**
  37235. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  37236. */
  37237. keysUp: number[];
  37238. /**
  37239. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  37240. */
  37241. keysDown: number[];
  37242. /**
  37243. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  37244. */
  37245. keysLeft: number[];
  37246. /**
  37247. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  37248. */
  37249. keysRight: number[];
  37250. /**
  37251. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  37252. */
  37253. wheelPrecision: number;
  37254. /**
  37255. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  37256. * It will be used instead of pinchDeltaPrecision if different from 0.
  37257. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  37258. */
  37259. wheelDeltaPercentage: number;
  37260. /**
  37261. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  37262. */
  37263. zoomOnFactor: number;
  37264. /**
  37265. * Defines a screen offset for the camera position.
  37266. */
  37267. targetScreenOffset: Vector2;
  37268. /**
  37269. * Allows the camera to be completely reversed.
  37270. * If false the camera can not arrive upside down.
  37271. */
  37272. allowUpsideDown: boolean;
  37273. /**
  37274. * Define if double tap/click is used to restore the previously saved state of the camera.
  37275. */
  37276. useInputToRestoreState: boolean;
  37277. /** @hidden */
  37278. _viewMatrix: Matrix;
  37279. /** @hidden */
  37280. _useCtrlForPanning: boolean;
  37281. /** @hidden */
  37282. _panningMouseButton: number;
  37283. /**
  37284. * Defines the input associated to the camera.
  37285. */
  37286. inputs: ArcRotateCameraInputsManager;
  37287. /** @hidden */
  37288. _reset: () => void;
  37289. /**
  37290. * Defines the allowed panning axis.
  37291. */
  37292. panningAxis: Vector3;
  37293. protected _localDirection: Vector3;
  37294. protected _transformedDirection: Vector3;
  37295. private _bouncingBehavior;
  37296. /**
  37297. * Gets the bouncing behavior of the camera if it has been enabled.
  37298. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  37299. */
  37300. readonly bouncingBehavior: Nullable<BouncingBehavior>;
  37301. /**
  37302. * Defines if the bouncing behavior of the camera is enabled on the camera.
  37303. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  37304. */
  37305. useBouncingBehavior: boolean;
  37306. private _framingBehavior;
  37307. /**
  37308. * Gets the framing behavior of the camera if it has been enabled.
  37309. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  37310. */
  37311. readonly framingBehavior: Nullable<FramingBehavior>;
  37312. /**
  37313. * Defines if the framing behavior of the camera is enabled on the camera.
  37314. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  37315. */
  37316. useFramingBehavior: boolean;
  37317. private _autoRotationBehavior;
  37318. /**
  37319. * Gets the auto rotation behavior of the camera if it has been enabled.
  37320. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  37321. */
  37322. readonly autoRotationBehavior: Nullable<AutoRotationBehavior>;
  37323. /**
  37324. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  37325. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  37326. */
  37327. useAutoRotationBehavior: boolean;
  37328. /**
  37329. * Observable triggered when the mesh target has been changed on the camera.
  37330. */
  37331. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  37332. /**
  37333. * Event raised when the camera is colliding with a mesh.
  37334. */
  37335. onCollide: (collidedMesh: AbstractMesh) => void;
  37336. /**
  37337. * Defines whether the camera should check collision with the objects oh the scene.
  37338. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  37339. */
  37340. checkCollisions: boolean;
  37341. /**
  37342. * Defines the collision radius of the camera.
  37343. * This simulates a sphere around the camera.
  37344. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  37345. */
  37346. collisionRadius: Vector3;
  37347. protected _collider: Collider;
  37348. protected _previousPosition: Vector3;
  37349. protected _collisionVelocity: Vector3;
  37350. protected _newPosition: Vector3;
  37351. protected _previousAlpha: number;
  37352. protected _previousBeta: number;
  37353. protected _previousRadius: number;
  37354. protected _collisionTriggered: boolean;
  37355. protected _targetBoundingCenter: Nullable<Vector3>;
  37356. private _computationVector;
  37357. /**
  37358. * Instantiates a new ArcRotateCamera in a given scene
  37359. * @param name Defines the name of the camera
  37360. * @param alpha Defines the camera rotation along the logitudinal axis
  37361. * @param beta Defines the camera rotation along the latitudinal axis
  37362. * @param radius Defines the camera distance from its target
  37363. * @param target Defines the camera target
  37364. * @param scene Defines the scene the camera belongs to
  37365. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  37366. */
  37367. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  37368. /** @hidden */
  37369. _initCache(): void;
  37370. /** @hidden */
  37371. _updateCache(ignoreParentClass?: boolean): void;
  37372. protected _getTargetPosition(): Vector3;
  37373. private _storedAlpha;
  37374. private _storedBeta;
  37375. private _storedRadius;
  37376. private _storedTarget;
  37377. private _storedTargetScreenOffset;
  37378. /**
  37379. * Stores the current state of the camera (alpha, beta, radius and target)
  37380. * @returns the camera itself
  37381. */
  37382. storeState(): Camera;
  37383. /**
  37384. * @hidden
  37385. * Restored camera state. You must call storeState() first
  37386. */
  37387. _restoreStateValues(): boolean;
  37388. /** @hidden */
  37389. _isSynchronizedViewMatrix(): boolean;
  37390. /**
  37391. * Attached controls to the current camera.
  37392. * @param element Defines the element the controls should be listened from
  37393. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37394. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  37395. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  37396. */
  37397. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  37398. /**
  37399. * Detach the current controls from the camera.
  37400. * The camera will stop reacting to inputs.
  37401. * @param element Defines the element to stop listening the inputs from
  37402. */
  37403. detachControl(element: HTMLElement): void;
  37404. /** @hidden */
  37405. _checkInputs(): void;
  37406. protected _checkLimits(): void;
  37407. /**
  37408. * Rebuilds angles (alpha, beta) and radius from the give position and target
  37409. */
  37410. rebuildAnglesAndRadius(): void;
  37411. /**
  37412. * Use a position to define the current camera related information like aplha, beta and radius
  37413. * @param position Defines the position to set the camera at
  37414. */
  37415. setPosition(position: Vector3): void;
  37416. /**
  37417. * Defines the target the camera should look at.
  37418. * This will automatically adapt alpha beta and radius to fit within the new target.
  37419. * @param target Defines the new target as a Vector or a mesh
  37420. * @param toBoundingCenter In case of a mesh target, defines wether to target the mesh position or its bounding information center
  37421. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  37422. */
  37423. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  37424. /** @hidden */
  37425. _getViewMatrix(): Matrix;
  37426. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  37427. /**
  37428. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  37429. * @param meshes Defines the mesh to zoom on
  37430. * @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)
  37431. */
  37432. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  37433. /**
  37434. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  37435. * The target will be changed but the radius
  37436. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  37437. * @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)
  37438. */
  37439. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  37440. min: Vector3;
  37441. max: Vector3;
  37442. distance: number;
  37443. }, doNotUpdateMaxZ?: boolean): void;
  37444. /**
  37445. * @override
  37446. * Override Camera.createRigCamera
  37447. */
  37448. createRigCamera(name: string, cameraIndex: number): Camera;
  37449. /**
  37450. * @hidden
  37451. * @override
  37452. * Override Camera._updateRigCameras
  37453. */
  37454. _updateRigCameras(): void;
  37455. /**
  37456. * Destroy the camera and release the current resources hold by it.
  37457. */
  37458. dispose(): void;
  37459. /**
  37460. * Gets the current object class name.
  37461. * @return the class name
  37462. */
  37463. getClassName(): string;
  37464. }
  37465. }
  37466. declare module "babylonjs/Behaviors/Cameras/autoRotationBehavior" {
  37467. import { Behavior } from "babylonjs/Behaviors/behavior";
  37468. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  37469. /**
  37470. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  37471. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  37472. */
  37473. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  37474. /**
  37475. * Gets the name of the behavior.
  37476. */
  37477. readonly name: string;
  37478. private _zoomStopsAnimation;
  37479. private _idleRotationSpeed;
  37480. private _idleRotationWaitTime;
  37481. private _idleRotationSpinupTime;
  37482. /**
  37483. * Sets the flag that indicates if user zooming should stop animation.
  37484. */
  37485. /**
  37486. * Gets the flag that indicates if user zooming should stop animation.
  37487. */
  37488. zoomStopsAnimation: boolean;
  37489. /**
  37490. * Sets the default speed at which the camera rotates around the model.
  37491. */
  37492. /**
  37493. * Gets the default speed at which the camera rotates around the model.
  37494. */
  37495. idleRotationSpeed: number;
  37496. /**
  37497. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  37498. */
  37499. /**
  37500. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  37501. */
  37502. idleRotationWaitTime: number;
  37503. /**
  37504. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  37505. */
  37506. /**
  37507. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  37508. */
  37509. idleRotationSpinupTime: number;
  37510. /**
  37511. * Gets a value indicating if the camera is currently rotating because of this behavior
  37512. */
  37513. readonly rotationInProgress: boolean;
  37514. private _onPrePointerObservableObserver;
  37515. private _onAfterCheckInputsObserver;
  37516. private _attachedCamera;
  37517. private _isPointerDown;
  37518. private _lastFrameTime;
  37519. private _lastInteractionTime;
  37520. private _cameraRotationSpeed;
  37521. /**
  37522. * Initializes the behavior.
  37523. */
  37524. init(): void;
  37525. /**
  37526. * Attaches the behavior to its arc rotate camera.
  37527. * @param camera Defines the camera to attach the behavior to
  37528. */
  37529. attach(camera: ArcRotateCamera): void;
  37530. /**
  37531. * Detaches the behavior from its current arc rotate camera.
  37532. */
  37533. detach(): void;
  37534. /**
  37535. * Returns true if user is scrolling.
  37536. * @return true if user is scrolling.
  37537. */
  37538. private _userIsZooming;
  37539. private _lastFrameRadius;
  37540. private _shouldAnimationStopForInteraction;
  37541. /**
  37542. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  37543. */
  37544. private _applyUserInteraction;
  37545. private _userIsMoving;
  37546. }
  37547. }
  37548. declare module "babylonjs/Behaviors/Cameras/index" {
  37549. export * from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  37550. export * from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  37551. export * from "babylonjs/Behaviors/Cameras/framingBehavior";
  37552. }
  37553. declare module "babylonjs/Behaviors/Meshes/attachToBoxBehavior" {
  37554. import { Mesh } from "babylonjs/Meshes/mesh";
  37555. import { TransformNode } from "babylonjs/Meshes/transformNode";
  37556. import { Behavior } from "babylonjs/Behaviors/behavior";
  37557. /**
  37558. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  37559. */
  37560. export class AttachToBoxBehavior implements Behavior<Mesh> {
  37561. private ui;
  37562. /**
  37563. * The name of the behavior
  37564. */
  37565. name: string;
  37566. /**
  37567. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  37568. */
  37569. distanceAwayFromFace: number;
  37570. /**
  37571. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  37572. */
  37573. distanceAwayFromBottomOfFace: number;
  37574. private _faceVectors;
  37575. private _target;
  37576. private _scene;
  37577. private _onRenderObserver;
  37578. private _tmpMatrix;
  37579. private _tmpVector;
  37580. /**
  37581. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  37582. * @param ui The transform node that should be attched to the mesh
  37583. */
  37584. constructor(ui: TransformNode);
  37585. /**
  37586. * Initializes the behavior
  37587. */
  37588. init(): void;
  37589. private _closestFace;
  37590. private _zeroVector;
  37591. private _lookAtTmpMatrix;
  37592. private _lookAtToRef;
  37593. /**
  37594. * Attaches the AttachToBoxBehavior to the passed in mesh
  37595. * @param target The mesh that the specified node will be attached to
  37596. */
  37597. attach(target: Mesh): void;
  37598. /**
  37599. * Detaches the behavior from the mesh
  37600. */
  37601. detach(): void;
  37602. }
  37603. }
  37604. declare module "babylonjs/Behaviors/Meshes/fadeInOutBehavior" {
  37605. import { Behavior } from "babylonjs/Behaviors/behavior";
  37606. import { Mesh } from "babylonjs/Meshes/mesh";
  37607. /**
  37608. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  37609. */
  37610. export class FadeInOutBehavior implements Behavior<Mesh> {
  37611. /**
  37612. * Time in milliseconds to delay before fading in (Default: 0)
  37613. */
  37614. delay: number;
  37615. /**
  37616. * Time in milliseconds for the mesh to fade in (Default: 300)
  37617. */
  37618. fadeInTime: number;
  37619. private _millisecondsPerFrame;
  37620. private _hovered;
  37621. private _hoverValue;
  37622. private _ownerNode;
  37623. /**
  37624. * Instatiates the FadeInOutBehavior
  37625. */
  37626. constructor();
  37627. /**
  37628. * The name of the behavior
  37629. */
  37630. readonly name: string;
  37631. /**
  37632. * Initializes the behavior
  37633. */
  37634. init(): void;
  37635. /**
  37636. * Attaches the fade behavior on the passed in mesh
  37637. * @param ownerNode The mesh that will be faded in/out once attached
  37638. */
  37639. attach(ownerNode: Mesh): void;
  37640. /**
  37641. * Detaches the behavior from the mesh
  37642. */
  37643. detach(): void;
  37644. /**
  37645. * Triggers the mesh to begin fading in or out
  37646. * @param value if the object should fade in or out (true to fade in)
  37647. */
  37648. fadeIn(value: boolean): void;
  37649. private _update;
  37650. private _setAllVisibility;
  37651. }
  37652. }
  37653. declare module "babylonjs/Misc/pivotTools" {
  37654. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  37655. /**
  37656. * Class containing a set of static utilities functions for managing Pivots
  37657. * @hidden
  37658. */
  37659. export class PivotTools {
  37660. private static _PivotCached;
  37661. private static _OldPivotPoint;
  37662. private static _PivotTranslation;
  37663. private static _PivotTmpVector;
  37664. /** @hidden */
  37665. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  37666. /** @hidden */
  37667. static _RestorePivotPoint(mesh: AbstractMesh): void;
  37668. }
  37669. }
  37670. declare module "babylonjs/Meshes/Builders/planeBuilder" {
  37671. import { Scene } from "babylonjs/scene";
  37672. import { Vector4 } from "babylonjs/Maths/math.vector";
  37673. import { Mesh } from "babylonjs/Meshes/mesh";
  37674. import { Nullable } from "babylonjs/types";
  37675. import { Plane } from "babylonjs/Maths/math.plane";
  37676. /**
  37677. * Class containing static functions to help procedurally build meshes
  37678. */
  37679. export class PlaneBuilder {
  37680. /**
  37681. * Creates a plane mesh
  37682. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  37683. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  37684. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  37685. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  37686. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  37687. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  37688. * @param name defines the name of the mesh
  37689. * @param options defines the options used to create the mesh
  37690. * @param scene defines the hosting scene
  37691. * @returns the plane mesh
  37692. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  37693. */
  37694. static CreatePlane(name: string, options: {
  37695. size?: number;
  37696. width?: number;
  37697. height?: number;
  37698. sideOrientation?: number;
  37699. frontUVs?: Vector4;
  37700. backUVs?: Vector4;
  37701. updatable?: boolean;
  37702. sourcePlane?: Plane;
  37703. }, scene?: Nullable<Scene>): Mesh;
  37704. }
  37705. }
  37706. declare module "babylonjs/Behaviors/Meshes/pointerDragBehavior" {
  37707. import { Behavior } from "babylonjs/Behaviors/behavior";
  37708. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  37709. import { Observable } from "babylonjs/Misc/observable";
  37710. import { Vector3 } from "babylonjs/Maths/math.vector";
  37711. import { Ray } from "babylonjs/Culling/ray";
  37712. import "babylonjs/Meshes/Builders/planeBuilder";
  37713. /**
  37714. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  37715. */
  37716. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  37717. private static _AnyMouseID;
  37718. /**
  37719. * Abstract mesh the behavior is set on
  37720. */
  37721. attachedNode: AbstractMesh;
  37722. private _dragPlane;
  37723. private _scene;
  37724. private _pointerObserver;
  37725. private _beforeRenderObserver;
  37726. private static _planeScene;
  37727. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  37728. /**
  37729. * 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)
  37730. */
  37731. maxDragAngle: number;
  37732. /**
  37733. * @hidden
  37734. */
  37735. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  37736. /**
  37737. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  37738. */
  37739. currentDraggingPointerID: number;
  37740. /**
  37741. * The last position where the pointer hit the drag plane in world space
  37742. */
  37743. lastDragPosition: Vector3;
  37744. /**
  37745. * If the behavior is currently in a dragging state
  37746. */
  37747. dragging: boolean;
  37748. /**
  37749. * 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)
  37750. */
  37751. dragDeltaRatio: number;
  37752. /**
  37753. * If the drag plane orientation should be updated during the dragging (Default: true)
  37754. */
  37755. updateDragPlane: boolean;
  37756. private _debugMode;
  37757. private _moving;
  37758. /**
  37759. * Fires each time the attached mesh is dragged with the pointer
  37760. * * delta between last drag position and current drag position in world space
  37761. * * dragDistance along the drag axis
  37762. * * dragPlaneNormal normal of the current drag plane used during the drag
  37763. * * dragPlanePoint in world space where the drag intersects the drag plane
  37764. */
  37765. onDragObservable: Observable<{
  37766. delta: Vector3;
  37767. dragPlanePoint: Vector3;
  37768. dragPlaneNormal: Vector3;
  37769. dragDistance: number;
  37770. pointerId: number;
  37771. }>;
  37772. /**
  37773. * Fires each time a drag begins (eg. mouse down on mesh)
  37774. */
  37775. onDragStartObservable: Observable<{
  37776. dragPlanePoint: Vector3;
  37777. pointerId: number;
  37778. }>;
  37779. /**
  37780. * Fires each time a drag ends (eg. mouse release after drag)
  37781. */
  37782. onDragEndObservable: Observable<{
  37783. dragPlanePoint: Vector3;
  37784. pointerId: number;
  37785. }>;
  37786. /**
  37787. * If the attached mesh should be moved when dragged
  37788. */
  37789. moveAttached: boolean;
  37790. /**
  37791. * If the drag behavior will react to drag events (Default: true)
  37792. */
  37793. enabled: boolean;
  37794. /**
  37795. * If pointer events should start and release the drag (Default: true)
  37796. */
  37797. startAndReleaseDragOnPointerEvents: boolean;
  37798. /**
  37799. * If camera controls should be detached during the drag
  37800. */
  37801. detachCameraControls: boolean;
  37802. /**
  37803. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  37804. */
  37805. useObjectOrienationForDragging: boolean;
  37806. private _options;
  37807. /**
  37808. * Creates a pointer drag behavior that can be attached to a mesh
  37809. * @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)
  37810. */
  37811. constructor(options?: {
  37812. dragAxis?: Vector3;
  37813. dragPlaneNormal?: Vector3;
  37814. });
  37815. /**
  37816. * Predicate to determine if it is valid to move the object to a new position when it is moved
  37817. */
  37818. validateDrag: (targetPosition: Vector3) => boolean;
  37819. /**
  37820. * The name of the behavior
  37821. */
  37822. readonly name: string;
  37823. /**
  37824. * Initializes the behavior
  37825. */
  37826. init(): void;
  37827. private _tmpVector;
  37828. private _alternatePickedPoint;
  37829. private _worldDragAxis;
  37830. private _targetPosition;
  37831. private _attachedElement;
  37832. /**
  37833. * Attaches the drag behavior the passed in mesh
  37834. * @param ownerNode The mesh that will be dragged around once attached
  37835. */
  37836. attach(ownerNode: AbstractMesh): void;
  37837. /**
  37838. * Force relase the drag action by code.
  37839. */
  37840. releaseDrag(): void;
  37841. private _startDragRay;
  37842. private _lastPointerRay;
  37843. /**
  37844. * Simulates the start of a pointer drag event on the behavior
  37845. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  37846. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  37847. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  37848. */
  37849. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  37850. private _startDrag;
  37851. private _dragDelta;
  37852. private _moveDrag;
  37853. private _pickWithRayOnDragPlane;
  37854. private _pointA;
  37855. private _pointB;
  37856. private _pointC;
  37857. private _lineA;
  37858. private _lineB;
  37859. private _localAxis;
  37860. private _lookAt;
  37861. private _updateDragPlanePosition;
  37862. /**
  37863. * Detaches the behavior from the mesh
  37864. */
  37865. detach(): void;
  37866. }
  37867. }
  37868. declare module "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior" {
  37869. import { Mesh } from "babylonjs/Meshes/mesh";
  37870. import { Behavior } from "babylonjs/Behaviors/behavior";
  37871. /**
  37872. * A behavior that when attached to a mesh will allow the mesh to be scaled
  37873. */
  37874. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  37875. private _dragBehaviorA;
  37876. private _dragBehaviorB;
  37877. private _startDistance;
  37878. private _initialScale;
  37879. private _targetScale;
  37880. private _ownerNode;
  37881. private _sceneRenderObserver;
  37882. /**
  37883. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  37884. */
  37885. constructor();
  37886. /**
  37887. * The name of the behavior
  37888. */
  37889. readonly name: string;
  37890. /**
  37891. * Initializes the behavior
  37892. */
  37893. init(): void;
  37894. private _getCurrentDistance;
  37895. /**
  37896. * Attaches the scale behavior the passed in mesh
  37897. * @param ownerNode The mesh that will be scaled around once attached
  37898. */
  37899. attach(ownerNode: Mesh): void;
  37900. /**
  37901. * Detaches the behavior from the mesh
  37902. */
  37903. detach(): void;
  37904. }
  37905. }
  37906. declare module "babylonjs/Behaviors/Meshes/sixDofDragBehavior" {
  37907. import { Behavior } from "babylonjs/Behaviors/behavior";
  37908. import { Mesh } from "babylonjs/Meshes/mesh";
  37909. import { Observable } from "babylonjs/Misc/observable";
  37910. /**
  37911. * 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
  37912. */
  37913. export class SixDofDragBehavior implements Behavior<Mesh> {
  37914. private static _virtualScene;
  37915. private _ownerNode;
  37916. private _sceneRenderObserver;
  37917. private _scene;
  37918. private _targetPosition;
  37919. private _virtualOriginMesh;
  37920. private _virtualDragMesh;
  37921. private _pointerObserver;
  37922. private _moving;
  37923. private _startingOrientation;
  37924. /**
  37925. * 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)
  37926. */
  37927. private zDragFactor;
  37928. /**
  37929. * If the object should rotate to face the drag origin
  37930. */
  37931. rotateDraggedObject: boolean;
  37932. /**
  37933. * If the behavior is currently in a dragging state
  37934. */
  37935. dragging: boolean;
  37936. /**
  37937. * 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)
  37938. */
  37939. dragDeltaRatio: number;
  37940. /**
  37941. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  37942. */
  37943. currentDraggingPointerID: number;
  37944. /**
  37945. * If camera controls should be detached during the drag
  37946. */
  37947. detachCameraControls: boolean;
  37948. /**
  37949. * Fires each time a drag starts
  37950. */
  37951. onDragStartObservable: Observable<{}>;
  37952. /**
  37953. * Fires each time a drag ends (eg. mouse release after drag)
  37954. */
  37955. onDragEndObservable: Observable<{}>;
  37956. /**
  37957. * 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
  37958. */
  37959. constructor();
  37960. /**
  37961. * The name of the behavior
  37962. */
  37963. readonly name: string;
  37964. /**
  37965. * Initializes the behavior
  37966. */
  37967. init(): void;
  37968. /**
  37969. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  37970. */
  37971. private readonly _pointerCamera;
  37972. /**
  37973. * Attaches the scale behavior the passed in mesh
  37974. * @param ownerNode The mesh that will be scaled around once attached
  37975. */
  37976. attach(ownerNode: Mesh): void;
  37977. /**
  37978. * Detaches the behavior from the mesh
  37979. */
  37980. detach(): void;
  37981. }
  37982. }
  37983. declare module "babylonjs/Behaviors/Meshes/index" {
  37984. export * from "babylonjs/Behaviors/Meshes/attachToBoxBehavior";
  37985. export * from "babylonjs/Behaviors/Meshes/fadeInOutBehavior";
  37986. export * from "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior";
  37987. export * from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  37988. export * from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  37989. }
  37990. declare module "babylonjs/Behaviors/index" {
  37991. export * from "babylonjs/Behaviors/behavior";
  37992. export * from "babylonjs/Behaviors/Cameras/index";
  37993. export * from "babylonjs/Behaviors/Meshes/index";
  37994. }
  37995. declare module "babylonjs/Bones/boneIKController" {
  37996. import { Bone } from "babylonjs/Bones/bone";
  37997. import { Vector3 } from "babylonjs/Maths/math.vector";
  37998. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  37999. import { Nullable } from "babylonjs/types";
  38000. /**
  38001. * Class used to apply inverse kinematics to bones
  38002. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  38003. */
  38004. export class BoneIKController {
  38005. private static _tmpVecs;
  38006. private static _tmpQuat;
  38007. private static _tmpMats;
  38008. /**
  38009. * Gets or sets the target mesh
  38010. */
  38011. targetMesh: AbstractMesh;
  38012. /** Gets or sets the mesh used as pole */
  38013. poleTargetMesh: AbstractMesh;
  38014. /**
  38015. * Gets or sets the bone used as pole
  38016. */
  38017. poleTargetBone: Nullable<Bone>;
  38018. /**
  38019. * Gets or sets the target position
  38020. */
  38021. targetPosition: Vector3;
  38022. /**
  38023. * Gets or sets the pole target position
  38024. */
  38025. poleTargetPosition: Vector3;
  38026. /**
  38027. * Gets or sets the pole target local offset
  38028. */
  38029. poleTargetLocalOffset: Vector3;
  38030. /**
  38031. * Gets or sets the pole angle
  38032. */
  38033. poleAngle: number;
  38034. /**
  38035. * Gets or sets the mesh associated with the controller
  38036. */
  38037. mesh: AbstractMesh;
  38038. /**
  38039. * 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)
  38040. */
  38041. slerpAmount: number;
  38042. private _bone1Quat;
  38043. private _bone1Mat;
  38044. private _bone2Ang;
  38045. private _bone1;
  38046. private _bone2;
  38047. private _bone1Length;
  38048. private _bone2Length;
  38049. private _maxAngle;
  38050. private _maxReach;
  38051. private _rightHandedSystem;
  38052. private _bendAxis;
  38053. private _slerping;
  38054. private _adjustRoll;
  38055. /**
  38056. * Gets or sets maximum allowed angle
  38057. */
  38058. maxAngle: number;
  38059. /**
  38060. * Creates a new BoneIKController
  38061. * @param mesh defines the mesh to control
  38062. * @param bone defines the bone to control
  38063. * @param options defines options to set up the controller
  38064. */
  38065. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  38066. targetMesh?: AbstractMesh;
  38067. poleTargetMesh?: AbstractMesh;
  38068. poleTargetBone?: Bone;
  38069. poleTargetLocalOffset?: Vector3;
  38070. poleAngle?: number;
  38071. bendAxis?: Vector3;
  38072. maxAngle?: number;
  38073. slerpAmount?: number;
  38074. });
  38075. private _setMaxAngle;
  38076. /**
  38077. * Force the controller to update the bones
  38078. */
  38079. update(): void;
  38080. }
  38081. }
  38082. declare module "babylonjs/Bones/boneLookController" {
  38083. import { Vector3 } from "babylonjs/Maths/math.vector";
  38084. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  38085. import { Bone } from "babylonjs/Bones/bone";
  38086. import { Space } from "babylonjs/Maths/math.axis";
  38087. /**
  38088. * Class used to make a bone look toward a point in space
  38089. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  38090. */
  38091. export class BoneLookController {
  38092. private static _tmpVecs;
  38093. private static _tmpQuat;
  38094. private static _tmpMats;
  38095. /**
  38096. * The target Vector3 that the bone will look at
  38097. */
  38098. target: Vector3;
  38099. /**
  38100. * The mesh that the bone is attached to
  38101. */
  38102. mesh: AbstractMesh;
  38103. /**
  38104. * The bone that will be looking to the target
  38105. */
  38106. bone: Bone;
  38107. /**
  38108. * The up axis of the coordinate system that is used when the bone is rotated
  38109. */
  38110. upAxis: Vector3;
  38111. /**
  38112. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  38113. */
  38114. upAxisSpace: Space;
  38115. /**
  38116. * Used to make an adjustment to the yaw of the bone
  38117. */
  38118. adjustYaw: number;
  38119. /**
  38120. * Used to make an adjustment to the pitch of the bone
  38121. */
  38122. adjustPitch: number;
  38123. /**
  38124. * Used to make an adjustment to the roll of the bone
  38125. */
  38126. adjustRoll: number;
  38127. /**
  38128. * 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)
  38129. */
  38130. slerpAmount: number;
  38131. private _minYaw;
  38132. private _maxYaw;
  38133. private _minPitch;
  38134. private _maxPitch;
  38135. private _minYawSin;
  38136. private _minYawCos;
  38137. private _maxYawSin;
  38138. private _maxYawCos;
  38139. private _midYawConstraint;
  38140. private _minPitchTan;
  38141. private _maxPitchTan;
  38142. private _boneQuat;
  38143. private _slerping;
  38144. private _transformYawPitch;
  38145. private _transformYawPitchInv;
  38146. private _firstFrameSkipped;
  38147. private _yawRange;
  38148. private _fowardAxis;
  38149. /**
  38150. * Gets or sets the minimum yaw angle that the bone can look to
  38151. */
  38152. minYaw: number;
  38153. /**
  38154. * Gets or sets the maximum yaw angle that the bone can look to
  38155. */
  38156. maxYaw: number;
  38157. /**
  38158. * Gets or sets the minimum pitch angle that the bone can look to
  38159. */
  38160. minPitch: number;
  38161. /**
  38162. * Gets or sets the maximum pitch angle that the bone can look to
  38163. */
  38164. maxPitch: number;
  38165. /**
  38166. * Create a BoneLookController
  38167. * @param mesh the mesh that the bone belongs to
  38168. * @param bone the bone that will be looking to the target
  38169. * @param target the target Vector3 to look at
  38170. * @param options optional settings:
  38171. * * maxYaw: the maximum angle the bone will yaw to
  38172. * * minYaw: the minimum angle the bone will yaw to
  38173. * * maxPitch: the maximum angle the bone will pitch to
  38174. * * minPitch: the minimum angle the bone will yaw to
  38175. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  38176. * * upAxis: the up axis of the coordinate system
  38177. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  38178. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  38179. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  38180. * * adjustYaw: used to make an adjustment to the yaw of the bone
  38181. * * adjustPitch: used to make an adjustment to the pitch of the bone
  38182. * * adjustRoll: used to make an adjustment to the roll of the bone
  38183. **/
  38184. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  38185. maxYaw?: number;
  38186. minYaw?: number;
  38187. maxPitch?: number;
  38188. minPitch?: number;
  38189. slerpAmount?: number;
  38190. upAxis?: Vector3;
  38191. upAxisSpace?: Space;
  38192. yawAxis?: Vector3;
  38193. pitchAxis?: Vector3;
  38194. adjustYaw?: number;
  38195. adjustPitch?: number;
  38196. adjustRoll?: number;
  38197. });
  38198. /**
  38199. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  38200. */
  38201. update(): void;
  38202. private _getAngleDiff;
  38203. private _getAngleBetween;
  38204. private _isAngleBetween;
  38205. }
  38206. }
  38207. declare module "babylonjs/Bones/index" {
  38208. export * from "babylonjs/Bones/bone";
  38209. export * from "babylonjs/Bones/boneIKController";
  38210. export * from "babylonjs/Bones/boneLookController";
  38211. export * from "babylonjs/Bones/skeleton";
  38212. }
  38213. declare module "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput" {
  38214. import { Nullable } from "babylonjs/types";
  38215. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  38216. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  38217. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  38218. /**
  38219. * Manage the gamepad inputs to control an arc rotate camera.
  38220. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38221. */
  38222. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  38223. /**
  38224. * Defines the camera the input is attached to.
  38225. */
  38226. camera: ArcRotateCamera;
  38227. /**
  38228. * Defines the gamepad the input is gathering event from.
  38229. */
  38230. gamepad: Nullable<Gamepad>;
  38231. /**
  38232. * Defines the gamepad rotation sensiblity.
  38233. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  38234. */
  38235. gamepadRotationSensibility: number;
  38236. /**
  38237. * Defines the gamepad move sensiblity.
  38238. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  38239. */
  38240. gamepadMoveSensibility: number;
  38241. private _onGamepadConnectedObserver;
  38242. private _onGamepadDisconnectedObserver;
  38243. /**
  38244. * Attach the input controls to a specific dom element to get the input from.
  38245. * @param element Defines the element the controls should be listened from
  38246. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38247. */
  38248. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38249. /**
  38250. * Detach the current controls from the specified dom element.
  38251. * @param element Defines the element to stop listening the inputs from
  38252. */
  38253. detachControl(element: Nullable<HTMLElement>): void;
  38254. /**
  38255. * Update the current camera state depending on the inputs that have been used this frame.
  38256. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  38257. */
  38258. checkInputs(): void;
  38259. /**
  38260. * Gets the class name of the current intput.
  38261. * @returns the class name
  38262. */
  38263. getClassName(): string;
  38264. /**
  38265. * Get the friendly name associated with the input class.
  38266. * @returns the input friendly name
  38267. */
  38268. getSimpleName(): string;
  38269. }
  38270. }
  38271. declare module "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput" {
  38272. import { Nullable } from "babylonjs/types";
  38273. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  38274. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  38275. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  38276. interface ArcRotateCameraInputsManager {
  38277. /**
  38278. * Add orientation input support to the input manager.
  38279. * @returns the current input manager
  38280. */
  38281. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  38282. }
  38283. }
  38284. /**
  38285. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  38286. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38287. */
  38288. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  38289. /**
  38290. * Defines the camera the input is attached to.
  38291. */
  38292. camera: ArcRotateCamera;
  38293. /**
  38294. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  38295. */
  38296. alphaCorrection: number;
  38297. /**
  38298. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  38299. */
  38300. gammaCorrection: number;
  38301. private _alpha;
  38302. private _gamma;
  38303. private _dirty;
  38304. private _deviceOrientationHandler;
  38305. /**
  38306. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  38307. */
  38308. constructor();
  38309. /**
  38310. * Attach the input controls to a specific dom element to get the input from.
  38311. * @param element Defines the element the controls should be listened from
  38312. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38313. */
  38314. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38315. /** @hidden */
  38316. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  38317. /**
  38318. * Update the current camera state depending on the inputs that have been used this frame.
  38319. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  38320. */
  38321. checkInputs(): void;
  38322. /**
  38323. * Detach the current controls from the specified dom element.
  38324. * @param element Defines the element to stop listening the inputs from
  38325. */
  38326. detachControl(element: Nullable<HTMLElement>): void;
  38327. /**
  38328. * Gets the class name of the current intput.
  38329. * @returns the class name
  38330. */
  38331. getClassName(): string;
  38332. /**
  38333. * Get the friendly name associated with the input class.
  38334. * @returns the input friendly name
  38335. */
  38336. getSimpleName(): string;
  38337. }
  38338. }
  38339. declare module "babylonjs/Cameras/Inputs/flyCameraMouseInput" {
  38340. import { Nullable } from "babylonjs/types";
  38341. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  38342. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  38343. /**
  38344. * Listen to mouse events to control the camera.
  38345. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38346. */
  38347. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  38348. /**
  38349. * Defines the camera the input is attached to.
  38350. */
  38351. camera: FlyCamera;
  38352. /**
  38353. * Defines if touch is enabled. (Default is true.)
  38354. */
  38355. touchEnabled: boolean;
  38356. /**
  38357. * Defines the buttons associated with the input to handle camera rotation.
  38358. */
  38359. buttons: number[];
  38360. /**
  38361. * Assign buttons for Yaw control.
  38362. */
  38363. buttonsYaw: number[];
  38364. /**
  38365. * Assign buttons for Pitch control.
  38366. */
  38367. buttonsPitch: number[];
  38368. /**
  38369. * Assign buttons for Roll control.
  38370. */
  38371. buttonsRoll: number[];
  38372. /**
  38373. * Detect if any button is being pressed while mouse is moved.
  38374. * -1 = Mouse locked.
  38375. * 0 = Left button.
  38376. * 1 = Middle Button.
  38377. * 2 = Right Button.
  38378. */
  38379. activeButton: number;
  38380. /**
  38381. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  38382. * Higher values reduce its sensitivity.
  38383. */
  38384. angularSensibility: number;
  38385. private _mousemoveCallback;
  38386. private _observer;
  38387. private _rollObserver;
  38388. private previousPosition;
  38389. private noPreventDefault;
  38390. private element;
  38391. /**
  38392. * Listen to mouse events to control the camera.
  38393. * @param touchEnabled Define if touch is enabled. (Default is true.)
  38394. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38395. */
  38396. constructor(touchEnabled?: boolean);
  38397. /**
  38398. * Attach the mouse control to the HTML DOM element.
  38399. * @param element Defines the element that listens to the input events.
  38400. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  38401. */
  38402. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38403. /**
  38404. * Detach the current controls from the specified dom element.
  38405. * @param element Defines the element to stop listening the inputs from
  38406. */
  38407. detachControl(element: Nullable<HTMLElement>): void;
  38408. /**
  38409. * Gets the class name of the current input.
  38410. * @returns the class name.
  38411. */
  38412. getClassName(): string;
  38413. /**
  38414. * Get the friendly name associated with the input class.
  38415. * @returns the input's friendly name.
  38416. */
  38417. getSimpleName(): string;
  38418. private _pointerInput;
  38419. private _onMouseMove;
  38420. /**
  38421. * Rotate camera by mouse offset.
  38422. */
  38423. private rotateCamera;
  38424. }
  38425. }
  38426. declare module "babylonjs/Cameras/flyCameraInputsManager" {
  38427. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  38428. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  38429. /**
  38430. * Default Inputs manager for the FlyCamera.
  38431. * It groups all the default supported inputs for ease of use.
  38432. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38433. */
  38434. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  38435. /**
  38436. * Instantiates a new FlyCameraInputsManager.
  38437. * @param camera Defines the camera the inputs belong to.
  38438. */
  38439. constructor(camera: FlyCamera);
  38440. /**
  38441. * Add keyboard input support to the input manager.
  38442. * @returns the new FlyCameraKeyboardMoveInput().
  38443. */
  38444. addKeyboard(): FlyCameraInputsManager;
  38445. /**
  38446. * Add mouse input support to the input manager.
  38447. * @param touchEnabled Enable touch screen support.
  38448. * @returns the new FlyCameraMouseInput().
  38449. */
  38450. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  38451. }
  38452. }
  38453. declare module "babylonjs/Cameras/flyCamera" {
  38454. import { Scene } from "babylonjs/scene";
  38455. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  38456. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  38457. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  38458. import { FlyCameraInputsManager } from "babylonjs/Cameras/flyCameraInputsManager";
  38459. /**
  38460. * This is a flying camera, designed for 3D movement and rotation in all directions,
  38461. * such as in a 3D Space Shooter or a Flight Simulator.
  38462. */
  38463. export class FlyCamera extends TargetCamera {
  38464. /**
  38465. * Define the collision ellipsoid of the camera.
  38466. * This is helpful for simulating a camera body, like a player's body.
  38467. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  38468. */
  38469. ellipsoid: Vector3;
  38470. /**
  38471. * Define an offset for the position of the ellipsoid around the camera.
  38472. * This can be helpful if the camera is attached away from the player's body center,
  38473. * such as at its head.
  38474. */
  38475. ellipsoidOffset: Vector3;
  38476. /**
  38477. * Enable or disable collisions of the camera with the rest of the scene objects.
  38478. */
  38479. checkCollisions: boolean;
  38480. /**
  38481. * Enable or disable gravity on the camera.
  38482. */
  38483. applyGravity: boolean;
  38484. /**
  38485. * Define the current direction the camera is moving to.
  38486. */
  38487. cameraDirection: Vector3;
  38488. /**
  38489. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  38490. * This overrides and empties cameraRotation.
  38491. */
  38492. rotationQuaternion: Quaternion;
  38493. /**
  38494. * Track Roll to maintain the wanted Rolling when looking around.
  38495. */
  38496. _trackRoll: number;
  38497. /**
  38498. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  38499. */
  38500. rollCorrect: number;
  38501. /**
  38502. * Mimic a banked turn, Rolling the camera when Yawing.
  38503. * It's recommended to use rollCorrect = 10 for faster banking correction.
  38504. */
  38505. bankedTurn: boolean;
  38506. /**
  38507. * Limit in radians for how much Roll banking will add. (Default: 90°)
  38508. */
  38509. bankedTurnLimit: number;
  38510. /**
  38511. * Value of 0 disables the banked Roll.
  38512. * Value of 1 is equal to the Yaw angle in radians.
  38513. */
  38514. bankedTurnMultiplier: number;
  38515. /**
  38516. * The inputs manager loads all the input sources, such as keyboard and mouse.
  38517. */
  38518. inputs: FlyCameraInputsManager;
  38519. /**
  38520. * Gets the input sensibility for mouse input.
  38521. * Higher values reduce sensitivity.
  38522. */
  38523. /**
  38524. * Sets the input sensibility for a mouse input.
  38525. * Higher values reduce sensitivity.
  38526. */
  38527. angularSensibility: number;
  38528. /**
  38529. * Get the keys for camera movement forward.
  38530. */
  38531. /**
  38532. * Set the keys for camera movement forward.
  38533. */
  38534. keysForward: number[];
  38535. /**
  38536. * Get the keys for camera movement backward.
  38537. */
  38538. keysBackward: number[];
  38539. /**
  38540. * Get the keys for camera movement up.
  38541. */
  38542. /**
  38543. * Set the keys for camera movement up.
  38544. */
  38545. keysUp: number[];
  38546. /**
  38547. * Get the keys for camera movement down.
  38548. */
  38549. /**
  38550. * Set the keys for camera movement down.
  38551. */
  38552. keysDown: number[];
  38553. /**
  38554. * Get the keys for camera movement left.
  38555. */
  38556. /**
  38557. * Set the keys for camera movement left.
  38558. */
  38559. keysLeft: number[];
  38560. /**
  38561. * Set the keys for camera movement right.
  38562. */
  38563. /**
  38564. * Set the keys for camera movement right.
  38565. */
  38566. keysRight: number[];
  38567. /**
  38568. * Event raised when the camera collides with a mesh in the scene.
  38569. */
  38570. onCollide: (collidedMesh: AbstractMesh) => void;
  38571. private _collider;
  38572. private _needMoveForGravity;
  38573. private _oldPosition;
  38574. private _diffPosition;
  38575. private _newPosition;
  38576. /** @hidden */
  38577. _localDirection: Vector3;
  38578. /** @hidden */
  38579. _transformedDirection: Vector3;
  38580. /**
  38581. * Instantiates a FlyCamera.
  38582. * This is a flying camera, designed for 3D movement and rotation in all directions,
  38583. * such as in a 3D Space Shooter or a Flight Simulator.
  38584. * @param name Define the name of the camera in the scene.
  38585. * @param position Define the starting position of the camera in the scene.
  38586. * @param scene Define the scene the camera belongs to.
  38587. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  38588. */
  38589. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  38590. /**
  38591. * Attach a control to the HTML DOM element.
  38592. * @param element Defines the element that listens to the input events.
  38593. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  38594. */
  38595. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38596. /**
  38597. * Detach a control from the HTML DOM element.
  38598. * The camera will stop reacting to that input.
  38599. * @param element Defines the element that listens to the input events.
  38600. */
  38601. detachControl(element: HTMLElement): void;
  38602. private _collisionMask;
  38603. /**
  38604. * Get the mask that the camera ignores in collision events.
  38605. */
  38606. /**
  38607. * Set the mask that the camera ignores in collision events.
  38608. */
  38609. collisionMask: number;
  38610. /** @hidden */
  38611. _collideWithWorld(displacement: Vector3): void;
  38612. /** @hidden */
  38613. private _onCollisionPositionChange;
  38614. /** @hidden */
  38615. _checkInputs(): void;
  38616. /** @hidden */
  38617. _decideIfNeedsToMove(): boolean;
  38618. /** @hidden */
  38619. _updatePosition(): void;
  38620. /**
  38621. * Restore the Roll to its target value at the rate specified.
  38622. * @param rate - Higher means slower restoring.
  38623. * @hidden
  38624. */
  38625. restoreRoll(rate: number): void;
  38626. /**
  38627. * Destroy the camera and release the current resources held by it.
  38628. */
  38629. dispose(): void;
  38630. /**
  38631. * Get the current object class name.
  38632. * @returns the class name.
  38633. */
  38634. getClassName(): string;
  38635. }
  38636. }
  38637. declare module "babylonjs/Cameras/Inputs/flyCameraKeyboardInput" {
  38638. import { Nullable } from "babylonjs/types";
  38639. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  38640. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  38641. /**
  38642. * Listen to keyboard events to control the camera.
  38643. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38644. */
  38645. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  38646. /**
  38647. * Defines the camera the input is attached to.
  38648. */
  38649. camera: FlyCamera;
  38650. /**
  38651. * The list of keyboard keys used to control the forward move of the camera.
  38652. */
  38653. keysForward: number[];
  38654. /**
  38655. * The list of keyboard keys used to control the backward move of the camera.
  38656. */
  38657. keysBackward: number[];
  38658. /**
  38659. * The list of keyboard keys used to control the forward move of the camera.
  38660. */
  38661. keysUp: number[];
  38662. /**
  38663. * The list of keyboard keys used to control the backward move of the camera.
  38664. */
  38665. keysDown: number[];
  38666. /**
  38667. * The list of keyboard keys used to control the right strafe move of the camera.
  38668. */
  38669. keysRight: number[];
  38670. /**
  38671. * The list of keyboard keys used to control the left strafe move of the camera.
  38672. */
  38673. keysLeft: number[];
  38674. private _keys;
  38675. private _onCanvasBlurObserver;
  38676. private _onKeyboardObserver;
  38677. private _engine;
  38678. private _scene;
  38679. /**
  38680. * Attach the input controls to a specific dom element to get the input from.
  38681. * @param element Defines the element the controls should be listened from
  38682. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38683. */
  38684. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38685. /**
  38686. * Detach the current controls from the specified dom element.
  38687. * @param element Defines the element to stop listening the inputs from
  38688. */
  38689. detachControl(element: Nullable<HTMLElement>): void;
  38690. /**
  38691. * Gets the class name of the current intput.
  38692. * @returns the class name
  38693. */
  38694. getClassName(): string;
  38695. /** @hidden */
  38696. _onLostFocus(e: FocusEvent): void;
  38697. /**
  38698. * Get the friendly name associated with the input class.
  38699. * @returns the input friendly name
  38700. */
  38701. getSimpleName(): string;
  38702. /**
  38703. * Update the current camera state depending on the inputs that have been used this frame.
  38704. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  38705. */
  38706. checkInputs(): void;
  38707. }
  38708. }
  38709. declare module "babylonjs/Cameras/Inputs/followCameraMouseWheelInput" {
  38710. import { Nullable } from "babylonjs/types";
  38711. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  38712. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  38713. /**
  38714. * Manage the mouse wheel inputs to control a follow camera.
  38715. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38716. */
  38717. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  38718. /**
  38719. * Defines the camera the input is attached to.
  38720. */
  38721. camera: FollowCamera;
  38722. /**
  38723. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  38724. */
  38725. axisControlRadius: boolean;
  38726. /**
  38727. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  38728. */
  38729. axisControlHeight: boolean;
  38730. /**
  38731. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  38732. */
  38733. axisControlRotation: boolean;
  38734. /**
  38735. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  38736. * relation to mouseWheel events.
  38737. */
  38738. wheelPrecision: number;
  38739. /**
  38740. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  38741. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  38742. */
  38743. wheelDeltaPercentage: number;
  38744. private _wheel;
  38745. private _observer;
  38746. /**
  38747. * Attach the input controls to a specific dom element to get the input from.
  38748. * @param element Defines the element the controls should be listened from
  38749. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38750. */
  38751. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38752. /**
  38753. * Detach the current controls from the specified dom element.
  38754. * @param element Defines the element to stop listening the inputs from
  38755. */
  38756. detachControl(element: Nullable<HTMLElement>): void;
  38757. /**
  38758. * Gets the class name of the current intput.
  38759. * @returns the class name
  38760. */
  38761. getClassName(): string;
  38762. /**
  38763. * Get the friendly name associated with the input class.
  38764. * @returns the input friendly name
  38765. */
  38766. getSimpleName(): string;
  38767. }
  38768. }
  38769. declare module "babylonjs/Cameras/Inputs/followCameraPointersInput" {
  38770. import { Nullable } from "babylonjs/types";
  38771. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  38772. import { BaseCameraPointersInput } from "babylonjs/Cameras/Inputs/BaseCameraPointersInput";
  38773. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  38774. /**
  38775. * Manage the pointers inputs to control an follow camera.
  38776. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38777. */
  38778. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  38779. /**
  38780. * Defines the camera the input is attached to.
  38781. */
  38782. camera: FollowCamera;
  38783. /**
  38784. * Gets the class name of the current input.
  38785. * @returns the class name
  38786. */
  38787. getClassName(): string;
  38788. /**
  38789. * Defines the pointer angular sensibility along the X axis or how fast is
  38790. * the camera rotating.
  38791. * A negative number will reverse the axis direction.
  38792. */
  38793. angularSensibilityX: number;
  38794. /**
  38795. * Defines the pointer angular sensibility along the Y axis or how fast is
  38796. * the camera rotating.
  38797. * A negative number will reverse the axis direction.
  38798. */
  38799. angularSensibilityY: number;
  38800. /**
  38801. * Defines the pointer pinch precision or how fast is the camera zooming.
  38802. * A negative number will reverse the axis direction.
  38803. */
  38804. pinchPrecision: number;
  38805. /**
  38806. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  38807. * from 0.
  38808. * It defines the percentage of current camera.radius to use as delta when
  38809. * pinch zoom is used.
  38810. */
  38811. pinchDeltaPercentage: number;
  38812. /**
  38813. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  38814. */
  38815. axisXControlRadius: boolean;
  38816. /**
  38817. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  38818. */
  38819. axisXControlHeight: boolean;
  38820. /**
  38821. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  38822. */
  38823. axisXControlRotation: boolean;
  38824. /**
  38825. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  38826. */
  38827. axisYControlRadius: boolean;
  38828. /**
  38829. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  38830. */
  38831. axisYControlHeight: boolean;
  38832. /**
  38833. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  38834. */
  38835. axisYControlRotation: boolean;
  38836. /**
  38837. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  38838. */
  38839. axisPinchControlRadius: boolean;
  38840. /**
  38841. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  38842. */
  38843. axisPinchControlHeight: boolean;
  38844. /**
  38845. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  38846. */
  38847. axisPinchControlRotation: boolean;
  38848. /**
  38849. * Log error messages if basic misconfiguration has occurred.
  38850. */
  38851. warningEnable: boolean;
  38852. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  38853. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  38854. private _warningCounter;
  38855. private _warning;
  38856. }
  38857. }
  38858. declare module "babylonjs/Cameras/followCameraInputsManager" {
  38859. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  38860. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  38861. /**
  38862. * Default Inputs manager for the FollowCamera.
  38863. * It groups all the default supported inputs for ease of use.
  38864. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38865. */
  38866. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  38867. /**
  38868. * Instantiates a new FollowCameraInputsManager.
  38869. * @param camera Defines the camera the inputs belong to
  38870. */
  38871. constructor(camera: FollowCamera);
  38872. /**
  38873. * Add keyboard input support to the input manager.
  38874. * @returns the current input manager
  38875. */
  38876. addKeyboard(): FollowCameraInputsManager;
  38877. /**
  38878. * Add mouse wheel input support to the input manager.
  38879. * @returns the current input manager
  38880. */
  38881. addMouseWheel(): FollowCameraInputsManager;
  38882. /**
  38883. * Add pointers input support to the input manager.
  38884. * @returns the current input manager
  38885. */
  38886. addPointers(): FollowCameraInputsManager;
  38887. /**
  38888. * Add orientation input support to the input manager.
  38889. * @returns the current input manager
  38890. */
  38891. addVRDeviceOrientation(): FollowCameraInputsManager;
  38892. }
  38893. }
  38894. declare module "babylonjs/Cameras/followCamera" {
  38895. import { Nullable } from "babylonjs/types";
  38896. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  38897. import { Scene } from "babylonjs/scene";
  38898. import { Vector3 } from "babylonjs/Maths/math.vector";
  38899. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  38900. import { FollowCameraInputsManager } from "babylonjs/Cameras/followCameraInputsManager";
  38901. /**
  38902. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  38903. * an arc rotate version arcFollowCamera are available.
  38904. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  38905. */
  38906. export class FollowCamera extends TargetCamera {
  38907. /**
  38908. * Distance the follow camera should follow an object at
  38909. */
  38910. radius: number;
  38911. /**
  38912. * Minimum allowed distance of the camera to the axis of rotation
  38913. * (The camera can not get closer).
  38914. * This can help limiting how the Camera is able to move in the scene.
  38915. */
  38916. lowerRadiusLimit: Nullable<number>;
  38917. /**
  38918. * Maximum allowed distance of the camera to the axis of rotation
  38919. * (The camera can not get further).
  38920. * This can help limiting how the Camera is able to move in the scene.
  38921. */
  38922. upperRadiusLimit: Nullable<number>;
  38923. /**
  38924. * Define a rotation offset between the camera and the object it follows
  38925. */
  38926. rotationOffset: number;
  38927. /**
  38928. * Minimum allowed angle to camera position relative to target object.
  38929. * This can help limiting how the Camera is able to move in the scene.
  38930. */
  38931. lowerRotationOffsetLimit: Nullable<number>;
  38932. /**
  38933. * Maximum allowed angle to camera position relative to target object.
  38934. * This can help limiting how the Camera is able to move in the scene.
  38935. */
  38936. upperRotationOffsetLimit: Nullable<number>;
  38937. /**
  38938. * Define a height offset between the camera and the object it follows.
  38939. * It can help following an object from the top (like a car chaing a plane)
  38940. */
  38941. heightOffset: number;
  38942. /**
  38943. * Minimum allowed height of camera position relative to target object.
  38944. * This can help limiting how the Camera is able to move in the scene.
  38945. */
  38946. lowerHeightOffsetLimit: Nullable<number>;
  38947. /**
  38948. * Maximum allowed height of camera position relative to target object.
  38949. * This can help limiting how the Camera is able to move in the scene.
  38950. */
  38951. upperHeightOffsetLimit: Nullable<number>;
  38952. /**
  38953. * Define how fast the camera can accelerate to follow it s target.
  38954. */
  38955. cameraAcceleration: number;
  38956. /**
  38957. * Define the speed limit of the camera following an object.
  38958. */
  38959. maxCameraSpeed: number;
  38960. /**
  38961. * Define the target of the camera.
  38962. */
  38963. lockedTarget: Nullable<AbstractMesh>;
  38964. /**
  38965. * Defines the input associated with the camera.
  38966. */
  38967. inputs: FollowCameraInputsManager;
  38968. /**
  38969. * Instantiates the follow camera.
  38970. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  38971. * @param name Define the name of the camera in the scene
  38972. * @param position Define the position of the camera
  38973. * @param scene Define the scene the camera belong to
  38974. * @param lockedTarget Define the target of the camera
  38975. */
  38976. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  38977. private _follow;
  38978. /**
  38979. * Attached controls to the current camera.
  38980. * @param element Defines the element the controls should be listened from
  38981. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38982. */
  38983. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38984. /**
  38985. * Detach the current controls from the camera.
  38986. * The camera will stop reacting to inputs.
  38987. * @param element Defines the element to stop listening the inputs from
  38988. */
  38989. detachControl(element: HTMLElement): void;
  38990. /** @hidden */
  38991. _checkInputs(): void;
  38992. private _checkLimits;
  38993. /**
  38994. * Gets the camera class name.
  38995. * @returns the class name
  38996. */
  38997. getClassName(): string;
  38998. }
  38999. /**
  39000. * Arc Rotate version of the follow camera.
  39001. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  39002. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  39003. */
  39004. export class ArcFollowCamera extends TargetCamera {
  39005. /** The longitudinal angle of the camera */
  39006. alpha: number;
  39007. /** The latitudinal angle of the camera */
  39008. beta: number;
  39009. /** The radius of the camera from its target */
  39010. radius: number;
  39011. /** Define the camera target (the messh it should follow) */
  39012. target: Nullable<AbstractMesh>;
  39013. private _cartesianCoordinates;
  39014. /**
  39015. * Instantiates a new ArcFollowCamera
  39016. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  39017. * @param name Define the name of the camera
  39018. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  39019. * @param beta Define the rotation angle of the camera around the elevation axis
  39020. * @param radius Define the radius of the camera from its target point
  39021. * @param target Define the target of the camera
  39022. * @param scene Define the scene the camera belongs to
  39023. */
  39024. constructor(name: string,
  39025. /** The longitudinal angle of the camera */
  39026. alpha: number,
  39027. /** The latitudinal angle of the camera */
  39028. beta: number,
  39029. /** The radius of the camera from its target */
  39030. radius: number,
  39031. /** Define the camera target (the messh it should follow) */
  39032. target: Nullable<AbstractMesh>, scene: Scene);
  39033. private _follow;
  39034. /** @hidden */
  39035. _checkInputs(): void;
  39036. /**
  39037. * Returns the class name of the object.
  39038. * It is mostly used internally for serialization purposes.
  39039. */
  39040. getClassName(): string;
  39041. }
  39042. }
  39043. declare module "babylonjs/Cameras/Inputs/followCameraKeyboardMoveInput" {
  39044. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  39045. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  39046. import { Nullable } from "babylonjs/types";
  39047. /**
  39048. * Manage the keyboard inputs to control the movement of a follow camera.
  39049. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39050. */
  39051. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  39052. /**
  39053. * Defines the camera the input is attached to.
  39054. */
  39055. camera: FollowCamera;
  39056. /**
  39057. * Defines the list of key codes associated with the up action (increase heightOffset)
  39058. */
  39059. keysHeightOffsetIncr: number[];
  39060. /**
  39061. * Defines the list of key codes associated with the down action (decrease heightOffset)
  39062. */
  39063. keysHeightOffsetDecr: number[];
  39064. /**
  39065. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  39066. */
  39067. keysHeightOffsetModifierAlt: boolean;
  39068. /**
  39069. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  39070. */
  39071. keysHeightOffsetModifierCtrl: boolean;
  39072. /**
  39073. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  39074. */
  39075. keysHeightOffsetModifierShift: boolean;
  39076. /**
  39077. * Defines the list of key codes associated with the left action (increase rotationOffset)
  39078. */
  39079. keysRotationOffsetIncr: number[];
  39080. /**
  39081. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  39082. */
  39083. keysRotationOffsetDecr: number[];
  39084. /**
  39085. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  39086. */
  39087. keysRotationOffsetModifierAlt: boolean;
  39088. /**
  39089. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  39090. */
  39091. keysRotationOffsetModifierCtrl: boolean;
  39092. /**
  39093. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  39094. */
  39095. keysRotationOffsetModifierShift: boolean;
  39096. /**
  39097. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  39098. */
  39099. keysRadiusIncr: number[];
  39100. /**
  39101. * Defines the list of key codes associated with the zoom-out action (increase radius)
  39102. */
  39103. keysRadiusDecr: number[];
  39104. /**
  39105. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  39106. */
  39107. keysRadiusModifierAlt: boolean;
  39108. /**
  39109. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  39110. */
  39111. keysRadiusModifierCtrl: boolean;
  39112. /**
  39113. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  39114. */
  39115. keysRadiusModifierShift: boolean;
  39116. /**
  39117. * Defines the rate of change of heightOffset.
  39118. */
  39119. heightSensibility: number;
  39120. /**
  39121. * Defines the rate of change of rotationOffset.
  39122. */
  39123. rotationSensibility: number;
  39124. /**
  39125. * Defines the rate of change of radius.
  39126. */
  39127. radiusSensibility: number;
  39128. private _keys;
  39129. private _ctrlPressed;
  39130. private _altPressed;
  39131. private _shiftPressed;
  39132. private _onCanvasBlurObserver;
  39133. private _onKeyboardObserver;
  39134. private _engine;
  39135. private _scene;
  39136. /**
  39137. * Attach the input controls to a specific dom element to get the input from.
  39138. * @param element Defines the element the controls should be listened from
  39139. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39140. */
  39141. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39142. /**
  39143. * Detach the current controls from the specified dom element.
  39144. * @param element Defines the element to stop listening the inputs from
  39145. */
  39146. detachControl(element: Nullable<HTMLElement>): void;
  39147. /**
  39148. * Update the current camera state depending on the inputs that have been used this frame.
  39149. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  39150. */
  39151. checkInputs(): void;
  39152. /**
  39153. * Gets the class name of the current input.
  39154. * @returns the class name
  39155. */
  39156. getClassName(): string;
  39157. /**
  39158. * Get the friendly name associated with the input class.
  39159. * @returns the input friendly name
  39160. */
  39161. getSimpleName(): string;
  39162. /**
  39163. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  39164. * allow modification of the heightOffset value.
  39165. */
  39166. private _modifierHeightOffset;
  39167. /**
  39168. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  39169. * allow modification of the rotationOffset value.
  39170. */
  39171. private _modifierRotationOffset;
  39172. /**
  39173. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  39174. * allow modification of the radius value.
  39175. */
  39176. private _modifierRadius;
  39177. }
  39178. }
  39179. declare module "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput" {
  39180. import { Nullable } from "babylonjs/types";
  39181. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  39182. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  39183. import { Observable } from "babylonjs/Misc/observable";
  39184. module "babylonjs/Cameras/freeCameraInputsManager" {
  39185. interface FreeCameraInputsManager {
  39186. /**
  39187. * @hidden
  39188. */
  39189. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  39190. /**
  39191. * Add orientation input support to the input manager.
  39192. * @returns the current input manager
  39193. */
  39194. addDeviceOrientation(): FreeCameraInputsManager;
  39195. }
  39196. }
  39197. /**
  39198. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  39199. * Screen rotation is taken into account.
  39200. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39201. */
  39202. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  39203. private _camera;
  39204. private _screenOrientationAngle;
  39205. private _constantTranform;
  39206. private _screenQuaternion;
  39207. private _alpha;
  39208. private _beta;
  39209. private _gamma;
  39210. /**
  39211. * Can be used to detect if a device orientation sensor is availible on a device
  39212. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  39213. * @returns a promise that will resolve on orientation change
  39214. */
  39215. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  39216. /**
  39217. * @hidden
  39218. */
  39219. _onDeviceOrientationChangedObservable: Observable<void>;
  39220. /**
  39221. * Instantiates a new input
  39222. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39223. */
  39224. constructor();
  39225. /**
  39226. * Define the camera controlled by the input.
  39227. */
  39228. camera: FreeCamera;
  39229. /**
  39230. * Attach the input controls to a specific dom element to get the input from.
  39231. * @param element Defines the element the controls should be listened from
  39232. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39233. */
  39234. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39235. private _orientationChanged;
  39236. private _deviceOrientation;
  39237. /**
  39238. * Detach the current controls from the specified dom element.
  39239. * @param element Defines the element to stop listening the inputs from
  39240. */
  39241. detachControl(element: Nullable<HTMLElement>): void;
  39242. /**
  39243. * Update the current camera state depending on the inputs that have been used this frame.
  39244. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  39245. */
  39246. checkInputs(): void;
  39247. /**
  39248. * Gets the class name of the current intput.
  39249. * @returns the class name
  39250. */
  39251. getClassName(): string;
  39252. /**
  39253. * Get the friendly name associated with the input class.
  39254. * @returns the input friendly name
  39255. */
  39256. getSimpleName(): string;
  39257. }
  39258. }
  39259. declare module "babylonjs/Cameras/Inputs/freeCameraGamepadInput" {
  39260. import { Nullable } from "babylonjs/types";
  39261. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  39262. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  39263. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  39264. /**
  39265. * Manage the gamepad inputs to control a free camera.
  39266. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39267. */
  39268. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  39269. /**
  39270. * Define the camera the input is attached to.
  39271. */
  39272. camera: FreeCamera;
  39273. /**
  39274. * Define the Gamepad controlling the input
  39275. */
  39276. gamepad: Nullable<Gamepad>;
  39277. /**
  39278. * Defines the gamepad rotation sensiblity.
  39279. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  39280. */
  39281. gamepadAngularSensibility: number;
  39282. /**
  39283. * Defines the gamepad move sensiblity.
  39284. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  39285. */
  39286. gamepadMoveSensibility: number;
  39287. private _onGamepadConnectedObserver;
  39288. private _onGamepadDisconnectedObserver;
  39289. private _cameraTransform;
  39290. private _deltaTransform;
  39291. private _vector3;
  39292. private _vector2;
  39293. /**
  39294. * Attach the input controls to a specific dom element to get the input from.
  39295. * @param element Defines the element the controls should be listened from
  39296. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39297. */
  39298. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39299. /**
  39300. * Detach the current controls from the specified dom element.
  39301. * @param element Defines the element to stop listening the inputs from
  39302. */
  39303. detachControl(element: Nullable<HTMLElement>): void;
  39304. /**
  39305. * Update the current camera state depending on the inputs that have been used this frame.
  39306. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  39307. */
  39308. checkInputs(): void;
  39309. /**
  39310. * Gets the class name of the current intput.
  39311. * @returns the class name
  39312. */
  39313. getClassName(): string;
  39314. /**
  39315. * Get the friendly name associated with the input class.
  39316. * @returns the input friendly name
  39317. */
  39318. getSimpleName(): string;
  39319. }
  39320. }
  39321. declare module "babylonjs/Misc/virtualJoystick" {
  39322. import { Nullable } from "babylonjs/types";
  39323. import { Vector3 } from "babylonjs/Maths/math.vector";
  39324. /**
  39325. * Defines the potential axis of a Joystick
  39326. */
  39327. export enum JoystickAxis {
  39328. /** X axis */
  39329. X = 0,
  39330. /** Y axis */
  39331. Y = 1,
  39332. /** Z axis */
  39333. Z = 2
  39334. }
  39335. /**
  39336. * Class used to define virtual joystick (used in touch mode)
  39337. */
  39338. export class VirtualJoystick {
  39339. /**
  39340. * Gets or sets a boolean indicating that left and right values must be inverted
  39341. */
  39342. reverseLeftRight: boolean;
  39343. /**
  39344. * Gets or sets a boolean indicating that up and down values must be inverted
  39345. */
  39346. reverseUpDown: boolean;
  39347. /**
  39348. * Gets the offset value for the position (ie. the change of the position value)
  39349. */
  39350. deltaPosition: Vector3;
  39351. /**
  39352. * Gets a boolean indicating if the virtual joystick was pressed
  39353. */
  39354. pressed: boolean;
  39355. /**
  39356. * Canvas the virtual joystick will render onto, default z-index of this is 5
  39357. */
  39358. static Canvas: Nullable<HTMLCanvasElement>;
  39359. private static _globalJoystickIndex;
  39360. private static vjCanvasContext;
  39361. private static vjCanvasWidth;
  39362. private static vjCanvasHeight;
  39363. private static halfWidth;
  39364. private _action;
  39365. private _axisTargetedByLeftAndRight;
  39366. private _axisTargetedByUpAndDown;
  39367. private _joystickSensibility;
  39368. private _inversedSensibility;
  39369. private _joystickPointerID;
  39370. private _joystickColor;
  39371. private _joystickPointerPos;
  39372. private _joystickPreviousPointerPos;
  39373. private _joystickPointerStartPos;
  39374. private _deltaJoystickVector;
  39375. private _leftJoystick;
  39376. private _touches;
  39377. private _onPointerDownHandlerRef;
  39378. private _onPointerMoveHandlerRef;
  39379. private _onPointerUpHandlerRef;
  39380. private _onResize;
  39381. /**
  39382. * Creates a new virtual joystick
  39383. * @param leftJoystick defines that the joystick is for left hand (false by default)
  39384. */
  39385. constructor(leftJoystick?: boolean);
  39386. /**
  39387. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  39388. * @param newJoystickSensibility defines the new sensibility
  39389. */
  39390. setJoystickSensibility(newJoystickSensibility: number): void;
  39391. private _onPointerDown;
  39392. private _onPointerMove;
  39393. private _onPointerUp;
  39394. /**
  39395. * Change the color of the virtual joystick
  39396. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  39397. */
  39398. setJoystickColor(newColor: string): void;
  39399. /**
  39400. * Defines a callback to call when the joystick is touched
  39401. * @param action defines the callback
  39402. */
  39403. setActionOnTouch(action: () => any): void;
  39404. /**
  39405. * Defines which axis you'd like to control for left & right
  39406. * @param axis defines the axis to use
  39407. */
  39408. setAxisForLeftRight(axis: JoystickAxis): void;
  39409. /**
  39410. * Defines which axis you'd like to control for up & down
  39411. * @param axis defines the axis to use
  39412. */
  39413. setAxisForUpDown(axis: JoystickAxis): void;
  39414. private _drawVirtualJoystick;
  39415. /**
  39416. * Release internal HTML canvas
  39417. */
  39418. releaseCanvas(): void;
  39419. }
  39420. }
  39421. declare module "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput" {
  39422. import { VirtualJoystick } from "babylonjs/Misc/virtualJoystick";
  39423. import { Nullable } from "babylonjs/types";
  39424. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  39425. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  39426. module "babylonjs/Cameras/freeCameraInputsManager" {
  39427. interface FreeCameraInputsManager {
  39428. /**
  39429. * Add virtual joystick input support to the input manager.
  39430. * @returns the current input manager
  39431. */
  39432. addVirtualJoystick(): FreeCameraInputsManager;
  39433. }
  39434. }
  39435. /**
  39436. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  39437. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39438. */
  39439. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  39440. /**
  39441. * Defines the camera the input is attached to.
  39442. */
  39443. camera: FreeCamera;
  39444. private _leftjoystick;
  39445. private _rightjoystick;
  39446. /**
  39447. * Gets the left stick of the virtual joystick.
  39448. * @returns The virtual Joystick
  39449. */
  39450. getLeftJoystick(): VirtualJoystick;
  39451. /**
  39452. * Gets the right stick of the virtual joystick.
  39453. * @returns The virtual Joystick
  39454. */
  39455. getRightJoystick(): VirtualJoystick;
  39456. /**
  39457. * Update the current camera state depending on the inputs that have been used this frame.
  39458. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  39459. */
  39460. checkInputs(): void;
  39461. /**
  39462. * Attach the input controls to a specific dom element to get the input from.
  39463. * @param element Defines the element the controls should be listened from
  39464. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39465. */
  39466. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39467. /**
  39468. * Detach the current controls from the specified dom element.
  39469. * @param element Defines the element to stop listening the inputs from
  39470. */
  39471. detachControl(element: Nullable<HTMLElement>): void;
  39472. /**
  39473. * Gets the class name of the current intput.
  39474. * @returns the class name
  39475. */
  39476. getClassName(): string;
  39477. /**
  39478. * Get the friendly name associated with the input class.
  39479. * @returns the input friendly name
  39480. */
  39481. getSimpleName(): string;
  39482. }
  39483. }
  39484. declare module "babylonjs/Cameras/Inputs/index" {
  39485. export * from "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput";
  39486. export * from "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput";
  39487. export * from "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput";
  39488. export * from "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput";
  39489. export * from "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  39490. export * from "babylonjs/Cameras/Inputs/flyCameraKeyboardInput";
  39491. export * from "babylonjs/Cameras/Inputs/flyCameraMouseInput";
  39492. export * from "babylonjs/Cameras/Inputs/followCameraKeyboardMoveInput";
  39493. export * from "babylonjs/Cameras/Inputs/followCameraMouseWheelInput";
  39494. export * from "babylonjs/Cameras/Inputs/followCameraPointersInput";
  39495. export * from "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  39496. export * from "babylonjs/Cameras/Inputs/freeCameraGamepadInput";
  39497. export * from "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput";
  39498. export * from "babylonjs/Cameras/Inputs/freeCameraMouseInput";
  39499. export * from "babylonjs/Cameras/Inputs/freeCameraTouchInput";
  39500. export * from "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  39501. }
  39502. declare module "babylonjs/Cameras/touchCamera" {
  39503. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  39504. import { Scene } from "babylonjs/scene";
  39505. import { Vector3 } from "babylonjs/Maths/math.vector";
  39506. /**
  39507. * This represents a FPS type of camera controlled by touch.
  39508. * This is like a universal camera minus the Gamepad controls.
  39509. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  39510. */
  39511. export class TouchCamera extends FreeCamera {
  39512. /**
  39513. * Defines the touch sensibility for rotation.
  39514. * The higher the faster.
  39515. */
  39516. touchAngularSensibility: number;
  39517. /**
  39518. * Defines the touch sensibility for move.
  39519. * The higher the faster.
  39520. */
  39521. touchMoveSensibility: number;
  39522. /**
  39523. * Instantiates a new touch camera.
  39524. * This represents a FPS type of camera controlled by touch.
  39525. * This is like a universal camera minus the Gamepad controls.
  39526. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  39527. * @param name Define the name of the camera in the scene
  39528. * @param position Define the start position of the camera in the scene
  39529. * @param scene Define the scene the camera belongs to
  39530. */
  39531. constructor(name: string, position: Vector3, scene: Scene);
  39532. /**
  39533. * Gets the current object class name.
  39534. * @return the class name
  39535. */
  39536. getClassName(): string;
  39537. /** @hidden */
  39538. _setupInputs(): void;
  39539. }
  39540. }
  39541. declare module "babylonjs/Cameras/deviceOrientationCamera" {
  39542. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  39543. import { Scene } from "babylonjs/scene";
  39544. import { Vector3 } from "babylonjs/Maths/math.vector";
  39545. import "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  39546. import { Axis } from "babylonjs/Maths/math.axis";
  39547. /**
  39548. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  39549. * being tilted forward or back and left or right.
  39550. */
  39551. export class DeviceOrientationCamera extends FreeCamera {
  39552. private _initialQuaternion;
  39553. private _quaternionCache;
  39554. private _tmpDragQuaternion;
  39555. private _disablePointerInputWhenUsingDeviceOrientation;
  39556. /**
  39557. * Creates a new device orientation camera
  39558. * @param name The name of the camera
  39559. * @param position The start position camera
  39560. * @param scene The scene the camera belongs to
  39561. */
  39562. constructor(name: string, position: Vector3, scene: Scene);
  39563. /**
  39564. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  39565. */
  39566. disablePointerInputWhenUsingDeviceOrientation: boolean;
  39567. private _dragFactor;
  39568. /**
  39569. * Enabled turning on the y axis when the orientation sensor is active
  39570. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  39571. */
  39572. enableHorizontalDragging(dragFactor?: number): void;
  39573. /**
  39574. * Gets the current instance class name ("DeviceOrientationCamera").
  39575. * This helps avoiding instanceof at run time.
  39576. * @returns the class name
  39577. */
  39578. getClassName(): string;
  39579. /**
  39580. * @hidden
  39581. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  39582. */
  39583. _checkInputs(): void;
  39584. /**
  39585. * Reset the camera to its default orientation on the specified axis only.
  39586. * @param axis The axis to reset
  39587. */
  39588. resetToCurrentRotation(axis?: Axis): void;
  39589. }
  39590. }
  39591. declare module "babylonjs/Gamepads/xboxGamepad" {
  39592. import { Observable } from "babylonjs/Misc/observable";
  39593. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  39594. /**
  39595. * Defines supported buttons for XBox360 compatible gamepads
  39596. */
  39597. export enum Xbox360Button {
  39598. /** A */
  39599. A = 0,
  39600. /** B */
  39601. B = 1,
  39602. /** X */
  39603. X = 2,
  39604. /** Y */
  39605. Y = 3,
  39606. /** Start */
  39607. Start = 4,
  39608. /** Back */
  39609. Back = 5,
  39610. /** Left button */
  39611. LB = 6,
  39612. /** Right button */
  39613. RB = 7,
  39614. /** Left stick */
  39615. LeftStick = 8,
  39616. /** Right stick */
  39617. RightStick = 9
  39618. }
  39619. /** Defines values for XBox360 DPad */
  39620. export enum Xbox360Dpad {
  39621. /** Up */
  39622. Up = 0,
  39623. /** Down */
  39624. Down = 1,
  39625. /** Left */
  39626. Left = 2,
  39627. /** Right */
  39628. Right = 3
  39629. }
  39630. /**
  39631. * Defines a XBox360 gamepad
  39632. */
  39633. export class Xbox360Pad extends Gamepad {
  39634. private _leftTrigger;
  39635. private _rightTrigger;
  39636. private _onlefttriggerchanged;
  39637. private _onrighttriggerchanged;
  39638. private _onbuttondown;
  39639. private _onbuttonup;
  39640. private _ondpaddown;
  39641. private _ondpadup;
  39642. /** Observable raised when a button is pressed */
  39643. onButtonDownObservable: Observable<Xbox360Button>;
  39644. /** Observable raised when a button is released */
  39645. onButtonUpObservable: Observable<Xbox360Button>;
  39646. /** Observable raised when a pad is pressed */
  39647. onPadDownObservable: Observable<Xbox360Dpad>;
  39648. /** Observable raised when a pad is released */
  39649. onPadUpObservable: Observable<Xbox360Dpad>;
  39650. private _buttonA;
  39651. private _buttonB;
  39652. private _buttonX;
  39653. private _buttonY;
  39654. private _buttonBack;
  39655. private _buttonStart;
  39656. private _buttonLB;
  39657. private _buttonRB;
  39658. private _buttonLeftStick;
  39659. private _buttonRightStick;
  39660. private _dPadUp;
  39661. private _dPadDown;
  39662. private _dPadLeft;
  39663. private _dPadRight;
  39664. private _isXboxOnePad;
  39665. /**
  39666. * Creates a new XBox360 gamepad object
  39667. * @param id defines the id of this gamepad
  39668. * @param index defines its index
  39669. * @param gamepad defines the internal HTML gamepad object
  39670. * @param xboxOne defines if it is a XBox One gamepad
  39671. */
  39672. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  39673. /**
  39674. * Defines the callback to call when left trigger is pressed
  39675. * @param callback defines the callback to use
  39676. */
  39677. onlefttriggerchanged(callback: (value: number) => void): void;
  39678. /**
  39679. * Defines the callback to call when right trigger is pressed
  39680. * @param callback defines the callback to use
  39681. */
  39682. onrighttriggerchanged(callback: (value: number) => void): void;
  39683. /**
  39684. * Gets the left trigger value
  39685. */
  39686. /**
  39687. * Sets the left trigger value
  39688. */
  39689. leftTrigger: number;
  39690. /**
  39691. * Gets the right trigger value
  39692. */
  39693. /**
  39694. * Sets the right trigger value
  39695. */
  39696. rightTrigger: number;
  39697. /**
  39698. * Defines the callback to call when a button is pressed
  39699. * @param callback defines the callback to use
  39700. */
  39701. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  39702. /**
  39703. * Defines the callback to call when a button is released
  39704. * @param callback defines the callback to use
  39705. */
  39706. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  39707. /**
  39708. * Defines the callback to call when a pad is pressed
  39709. * @param callback defines the callback to use
  39710. */
  39711. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  39712. /**
  39713. * Defines the callback to call when a pad is released
  39714. * @param callback defines the callback to use
  39715. */
  39716. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  39717. private _setButtonValue;
  39718. private _setDPadValue;
  39719. /**
  39720. * Gets the value of the `A` button
  39721. */
  39722. /**
  39723. * Sets the value of the `A` button
  39724. */
  39725. buttonA: number;
  39726. /**
  39727. * Gets the value of the `B` button
  39728. */
  39729. /**
  39730. * Sets the value of the `B` button
  39731. */
  39732. buttonB: number;
  39733. /**
  39734. * Gets the value of the `X` button
  39735. */
  39736. /**
  39737. * Sets the value of the `X` button
  39738. */
  39739. buttonX: number;
  39740. /**
  39741. * Gets the value of the `Y` button
  39742. */
  39743. /**
  39744. * Sets the value of the `Y` button
  39745. */
  39746. buttonY: number;
  39747. /**
  39748. * Gets the value of the `Start` button
  39749. */
  39750. /**
  39751. * Sets the value of the `Start` button
  39752. */
  39753. buttonStart: number;
  39754. /**
  39755. * Gets the value of the `Back` button
  39756. */
  39757. /**
  39758. * Sets the value of the `Back` button
  39759. */
  39760. buttonBack: number;
  39761. /**
  39762. * Gets the value of the `Left` button
  39763. */
  39764. /**
  39765. * Sets the value of the `Left` button
  39766. */
  39767. buttonLB: number;
  39768. /**
  39769. * Gets the value of the `Right` button
  39770. */
  39771. /**
  39772. * Sets the value of the `Right` button
  39773. */
  39774. buttonRB: number;
  39775. /**
  39776. * Gets the value of the Left joystick
  39777. */
  39778. /**
  39779. * Sets the value of the Left joystick
  39780. */
  39781. buttonLeftStick: number;
  39782. /**
  39783. * Gets the value of the Right joystick
  39784. */
  39785. /**
  39786. * Sets the value of the Right joystick
  39787. */
  39788. buttonRightStick: number;
  39789. /**
  39790. * Gets the value of D-pad up
  39791. */
  39792. /**
  39793. * Sets the value of D-pad up
  39794. */
  39795. dPadUp: number;
  39796. /**
  39797. * Gets the value of D-pad down
  39798. */
  39799. /**
  39800. * Sets the value of D-pad down
  39801. */
  39802. dPadDown: number;
  39803. /**
  39804. * Gets the value of D-pad left
  39805. */
  39806. /**
  39807. * Sets the value of D-pad left
  39808. */
  39809. dPadLeft: number;
  39810. /**
  39811. * Gets the value of D-pad right
  39812. */
  39813. /**
  39814. * Sets the value of D-pad right
  39815. */
  39816. dPadRight: number;
  39817. /**
  39818. * Force the gamepad to synchronize with device values
  39819. */
  39820. update(): void;
  39821. /**
  39822. * Disposes the gamepad
  39823. */
  39824. dispose(): void;
  39825. }
  39826. }
  39827. declare module "babylonjs/Gamepads/dualShockGamepad" {
  39828. import { Observable } from "babylonjs/Misc/observable";
  39829. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  39830. /**
  39831. * Defines supported buttons for DualShock compatible gamepads
  39832. */
  39833. export enum DualShockButton {
  39834. /** Cross */
  39835. Cross = 0,
  39836. /** Circle */
  39837. Circle = 1,
  39838. /** Square */
  39839. Square = 2,
  39840. /** Triangle */
  39841. Triangle = 3,
  39842. /** Options */
  39843. Options = 4,
  39844. /** Share */
  39845. Share = 5,
  39846. /** L1 */
  39847. L1 = 6,
  39848. /** R1 */
  39849. R1 = 7,
  39850. /** Left stick */
  39851. LeftStick = 8,
  39852. /** Right stick */
  39853. RightStick = 9
  39854. }
  39855. /** Defines values for DualShock DPad */
  39856. export enum DualShockDpad {
  39857. /** Up */
  39858. Up = 0,
  39859. /** Down */
  39860. Down = 1,
  39861. /** Left */
  39862. Left = 2,
  39863. /** Right */
  39864. Right = 3
  39865. }
  39866. /**
  39867. * Defines a DualShock gamepad
  39868. */
  39869. export class DualShockPad extends Gamepad {
  39870. private _leftTrigger;
  39871. private _rightTrigger;
  39872. private _onlefttriggerchanged;
  39873. private _onrighttriggerchanged;
  39874. private _onbuttondown;
  39875. private _onbuttonup;
  39876. private _ondpaddown;
  39877. private _ondpadup;
  39878. /** Observable raised when a button is pressed */
  39879. onButtonDownObservable: Observable<DualShockButton>;
  39880. /** Observable raised when a button is released */
  39881. onButtonUpObservable: Observable<DualShockButton>;
  39882. /** Observable raised when a pad is pressed */
  39883. onPadDownObservable: Observable<DualShockDpad>;
  39884. /** Observable raised when a pad is released */
  39885. onPadUpObservable: Observable<DualShockDpad>;
  39886. private _buttonCross;
  39887. private _buttonCircle;
  39888. private _buttonSquare;
  39889. private _buttonTriangle;
  39890. private _buttonShare;
  39891. private _buttonOptions;
  39892. private _buttonL1;
  39893. private _buttonR1;
  39894. private _buttonLeftStick;
  39895. private _buttonRightStick;
  39896. private _dPadUp;
  39897. private _dPadDown;
  39898. private _dPadLeft;
  39899. private _dPadRight;
  39900. /**
  39901. * Creates a new DualShock gamepad object
  39902. * @param id defines the id of this gamepad
  39903. * @param index defines its index
  39904. * @param gamepad defines the internal HTML gamepad object
  39905. */
  39906. constructor(id: string, index: number, gamepad: any);
  39907. /**
  39908. * Defines the callback to call when left trigger is pressed
  39909. * @param callback defines the callback to use
  39910. */
  39911. onlefttriggerchanged(callback: (value: number) => void): void;
  39912. /**
  39913. * Defines the callback to call when right trigger is pressed
  39914. * @param callback defines the callback to use
  39915. */
  39916. onrighttriggerchanged(callback: (value: number) => void): void;
  39917. /**
  39918. * Gets the left trigger value
  39919. */
  39920. /**
  39921. * Sets the left trigger value
  39922. */
  39923. leftTrigger: number;
  39924. /**
  39925. * Gets the right trigger value
  39926. */
  39927. /**
  39928. * Sets the right trigger value
  39929. */
  39930. rightTrigger: number;
  39931. /**
  39932. * Defines the callback to call when a button is pressed
  39933. * @param callback defines the callback to use
  39934. */
  39935. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  39936. /**
  39937. * Defines the callback to call when a button is released
  39938. * @param callback defines the callback to use
  39939. */
  39940. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  39941. /**
  39942. * Defines the callback to call when a pad is pressed
  39943. * @param callback defines the callback to use
  39944. */
  39945. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  39946. /**
  39947. * Defines the callback to call when a pad is released
  39948. * @param callback defines the callback to use
  39949. */
  39950. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  39951. private _setButtonValue;
  39952. private _setDPadValue;
  39953. /**
  39954. * Gets the value of the `Cross` button
  39955. */
  39956. /**
  39957. * Sets the value of the `Cross` button
  39958. */
  39959. buttonCross: number;
  39960. /**
  39961. * Gets the value of the `Circle` button
  39962. */
  39963. /**
  39964. * Sets the value of the `Circle` button
  39965. */
  39966. buttonCircle: number;
  39967. /**
  39968. * Gets the value of the `Square` button
  39969. */
  39970. /**
  39971. * Sets the value of the `Square` button
  39972. */
  39973. buttonSquare: number;
  39974. /**
  39975. * Gets the value of the `Triangle` button
  39976. */
  39977. /**
  39978. * Sets the value of the `Triangle` button
  39979. */
  39980. buttonTriangle: number;
  39981. /**
  39982. * Gets the value of the `Options` button
  39983. */
  39984. /**
  39985. * Sets the value of the `Options` button
  39986. */
  39987. buttonOptions: number;
  39988. /**
  39989. * Gets the value of the `Share` button
  39990. */
  39991. /**
  39992. * Sets the value of the `Share` button
  39993. */
  39994. buttonShare: number;
  39995. /**
  39996. * Gets the value of the `L1` button
  39997. */
  39998. /**
  39999. * Sets the value of the `L1` button
  40000. */
  40001. buttonL1: number;
  40002. /**
  40003. * Gets the value of the `R1` button
  40004. */
  40005. /**
  40006. * Sets the value of the `R1` button
  40007. */
  40008. buttonR1: number;
  40009. /**
  40010. * Gets the value of the Left joystick
  40011. */
  40012. /**
  40013. * Sets the value of the Left joystick
  40014. */
  40015. buttonLeftStick: number;
  40016. /**
  40017. * Gets the value of the Right joystick
  40018. */
  40019. /**
  40020. * Sets the value of the Right joystick
  40021. */
  40022. buttonRightStick: number;
  40023. /**
  40024. * Gets the value of D-pad up
  40025. */
  40026. /**
  40027. * Sets the value of D-pad up
  40028. */
  40029. dPadUp: number;
  40030. /**
  40031. * Gets the value of D-pad down
  40032. */
  40033. /**
  40034. * Sets the value of D-pad down
  40035. */
  40036. dPadDown: number;
  40037. /**
  40038. * Gets the value of D-pad left
  40039. */
  40040. /**
  40041. * Sets the value of D-pad left
  40042. */
  40043. dPadLeft: number;
  40044. /**
  40045. * Gets the value of D-pad right
  40046. */
  40047. /**
  40048. * Sets the value of D-pad right
  40049. */
  40050. dPadRight: number;
  40051. /**
  40052. * Force the gamepad to synchronize with device values
  40053. */
  40054. update(): void;
  40055. /**
  40056. * Disposes the gamepad
  40057. */
  40058. dispose(): void;
  40059. }
  40060. }
  40061. declare module "babylonjs/Gamepads/gamepadManager" {
  40062. import { Observable } from "babylonjs/Misc/observable";
  40063. import { Nullable } from "babylonjs/types";
  40064. import { Scene } from "babylonjs/scene";
  40065. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  40066. /**
  40067. * Manager for handling gamepads
  40068. */
  40069. export class GamepadManager {
  40070. private _scene?;
  40071. private _babylonGamepads;
  40072. private _oneGamepadConnected;
  40073. /** @hidden */
  40074. _isMonitoring: boolean;
  40075. private _gamepadEventSupported;
  40076. private _gamepadSupport;
  40077. /**
  40078. * observable to be triggered when the gamepad controller has been connected
  40079. */
  40080. onGamepadConnectedObservable: Observable<Gamepad>;
  40081. /**
  40082. * observable to be triggered when the gamepad controller has been disconnected
  40083. */
  40084. onGamepadDisconnectedObservable: Observable<Gamepad>;
  40085. private _onGamepadConnectedEvent;
  40086. private _onGamepadDisconnectedEvent;
  40087. /**
  40088. * Initializes the gamepad manager
  40089. * @param _scene BabylonJS scene
  40090. */
  40091. constructor(_scene?: Scene | undefined);
  40092. /**
  40093. * The gamepads in the game pad manager
  40094. */
  40095. readonly gamepads: Gamepad[];
  40096. /**
  40097. * Get the gamepad controllers based on type
  40098. * @param type The type of gamepad controller
  40099. * @returns Nullable gamepad
  40100. */
  40101. getGamepadByType(type?: number): Nullable<Gamepad>;
  40102. /**
  40103. * Disposes the gamepad manager
  40104. */
  40105. dispose(): void;
  40106. private _addNewGamepad;
  40107. private _startMonitoringGamepads;
  40108. private _stopMonitoringGamepads;
  40109. /** @hidden */
  40110. _checkGamepadsStatus(): void;
  40111. private _updateGamepadObjects;
  40112. }
  40113. }
  40114. declare module "babylonjs/Gamepads/gamepadSceneComponent" {
  40115. import { Nullable } from "babylonjs/types";
  40116. import { Scene } from "babylonjs/scene";
  40117. import { ISceneComponent } from "babylonjs/sceneComponent";
  40118. import { GamepadManager } from "babylonjs/Gamepads/gamepadManager";
  40119. module "babylonjs/scene" {
  40120. interface Scene {
  40121. /** @hidden */
  40122. _gamepadManager: Nullable<GamepadManager>;
  40123. /**
  40124. * Gets the gamepad manager associated with the scene
  40125. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  40126. */
  40127. gamepadManager: GamepadManager;
  40128. }
  40129. }
  40130. module "babylonjs/Cameras/freeCameraInputsManager" {
  40131. /**
  40132. * Interface representing a free camera inputs manager
  40133. */
  40134. interface FreeCameraInputsManager {
  40135. /**
  40136. * Adds gamepad input support to the FreeCameraInputsManager.
  40137. * @returns the FreeCameraInputsManager
  40138. */
  40139. addGamepad(): FreeCameraInputsManager;
  40140. }
  40141. }
  40142. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  40143. /**
  40144. * Interface representing an arc rotate camera inputs manager
  40145. */
  40146. interface ArcRotateCameraInputsManager {
  40147. /**
  40148. * Adds gamepad input support to the ArcRotateCamera InputManager.
  40149. * @returns the camera inputs manager
  40150. */
  40151. addGamepad(): ArcRotateCameraInputsManager;
  40152. }
  40153. }
  40154. /**
  40155. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  40156. */
  40157. export class GamepadSystemSceneComponent implements ISceneComponent {
  40158. /**
  40159. * The component name helpfull to identify the component in the list of scene components.
  40160. */
  40161. readonly name: string;
  40162. /**
  40163. * The scene the component belongs to.
  40164. */
  40165. scene: Scene;
  40166. /**
  40167. * Creates a new instance of the component for the given scene
  40168. * @param scene Defines the scene to register the component in
  40169. */
  40170. constructor(scene: Scene);
  40171. /**
  40172. * Registers the component in a given scene
  40173. */
  40174. register(): void;
  40175. /**
  40176. * Rebuilds the elements related to this component in case of
  40177. * context lost for instance.
  40178. */
  40179. rebuild(): void;
  40180. /**
  40181. * Disposes the component and the associated ressources
  40182. */
  40183. dispose(): void;
  40184. private _beforeCameraUpdate;
  40185. }
  40186. }
  40187. declare module "babylonjs/Cameras/universalCamera" {
  40188. import { TouchCamera } from "babylonjs/Cameras/touchCamera";
  40189. import { Scene } from "babylonjs/scene";
  40190. import { Vector3 } from "babylonjs/Maths/math.vector";
  40191. import "babylonjs/Gamepads/gamepadSceneComponent";
  40192. /**
  40193. * 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,
  40194. * which still works and will still be found in many Playgrounds.
  40195. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  40196. */
  40197. export class UniversalCamera extends TouchCamera {
  40198. /**
  40199. * Defines the gamepad rotation sensiblity.
  40200. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  40201. */
  40202. gamepadAngularSensibility: number;
  40203. /**
  40204. * Defines the gamepad move sensiblity.
  40205. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  40206. */
  40207. gamepadMoveSensibility: number;
  40208. /**
  40209. * 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,
  40210. * which still works and will still be found in many Playgrounds.
  40211. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  40212. * @param name Define the name of the camera in the scene
  40213. * @param position Define the start position of the camera in the scene
  40214. * @param scene Define the scene the camera belongs to
  40215. */
  40216. constructor(name: string, position: Vector3, scene: Scene);
  40217. /**
  40218. * Gets the current object class name.
  40219. * @return the class name
  40220. */
  40221. getClassName(): string;
  40222. }
  40223. }
  40224. declare module "babylonjs/Cameras/gamepadCamera" {
  40225. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  40226. import { Scene } from "babylonjs/scene";
  40227. import { Vector3 } from "babylonjs/Maths/math.vector";
  40228. /**
  40229. * This represents a FPS type of camera. This is only here for back compat purpose.
  40230. * Please use the UniversalCamera instead as both are identical.
  40231. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  40232. */
  40233. export class GamepadCamera extends UniversalCamera {
  40234. /**
  40235. * Instantiates a new Gamepad Camera
  40236. * This represents a FPS type of camera. This is only here for back compat purpose.
  40237. * Please use the UniversalCamera instead as both are identical.
  40238. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  40239. * @param name Define the name of the camera in the scene
  40240. * @param position Define the start position of the camera in the scene
  40241. * @param scene Define the scene the camera belongs to
  40242. */
  40243. constructor(name: string, position: Vector3, scene: Scene);
  40244. /**
  40245. * Gets the current object class name.
  40246. * @return the class name
  40247. */
  40248. getClassName(): string;
  40249. }
  40250. }
  40251. declare module "babylonjs/Shaders/pass.fragment" {
  40252. /** @hidden */
  40253. export var passPixelShader: {
  40254. name: string;
  40255. shader: string;
  40256. };
  40257. }
  40258. declare module "babylonjs/Shaders/passCube.fragment" {
  40259. /** @hidden */
  40260. export var passCubePixelShader: {
  40261. name: string;
  40262. shader: string;
  40263. };
  40264. }
  40265. declare module "babylonjs/PostProcesses/passPostProcess" {
  40266. import { Nullable } from "babylonjs/types";
  40267. import { Camera } from "babylonjs/Cameras/camera";
  40268. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  40269. import { Engine } from "babylonjs/Engines/engine";
  40270. import "babylonjs/Shaders/pass.fragment";
  40271. import "babylonjs/Shaders/passCube.fragment";
  40272. /**
  40273. * PassPostProcess which produces an output the same as it's input
  40274. */
  40275. export class PassPostProcess extends PostProcess {
  40276. /**
  40277. * Creates the PassPostProcess
  40278. * @param name The name of the effect.
  40279. * @param options The required width/height ratio to downsize to before computing the render pass.
  40280. * @param camera The camera to apply the render pass to.
  40281. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  40282. * @param engine The engine which the post process will be applied. (default: current engine)
  40283. * @param reusable If the post process can be reused on the same frame. (default: false)
  40284. * @param textureType The type of texture to be used when performing the post processing.
  40285. * @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)
  40286. */
  40287. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  40288. }
  40289. /**
  40290. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  40291. */
  40292. export class PassCubePostProcess extends PostProcess {
  40293. private _face;
  40294. /**
  40295. * Gets or sets the cube face to display.
  40296. * * 0 is +X
  40297. * * 1 is -X
  40298. * * 2 is +Y
  40299. * * 3 is -Y
  40300. * * 4 is +Z
  40301. * * 5 is -Z
  40302. */
  40303. face: number;
  40304. /**
  40305. * Creates the PassCubePostProcess
  40306. * @param name The name of the effect.
  40307. * @param options The required width/height ratio to downsize to before computing the render pass.
  40308. * @param camera The camera to apply the render pass to.
  40309. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  40310. * @param engine The engine which the post process will be applied. (default: current engine)
  40311. * @param reusable If the post process can be reused on the same frame. (default: false)
  40312. * @param textureType The type of texture to be used when performing the post processing.
  40313. * @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)
  40314. */
  40315. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  40316. }
  40317. }
  40318. declare module "babylonjs/Shaders/anaglyph.fragment" {
  40319. /** @hidden */
  40320. export var anaglyphPixelShader: {
  40321. name: string;
  40322. shader: string;
  40323. };
  40324. }
  40325. declare module "babylonjs/PostProcesses/anaglyphPostProcess" {
  40326. import { Engine } from "babylonjs/Engines/engine";
  40327. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  40328. import { Camera } from "babylonjs/Cameras/camera";
  40329. import "babylonjs/Shaders/anaglyph.fragment";
  40330. /**
  40331. * Postprocess used to generate anaglyphic rendering
  40332. */
  40333. export class AnaglyphPostProcess extends PostProcess {
  40334. private _passedProcess;
  40335. /**
  40336. * Creates a new AnaglyphPostProcess
  40337. * @param name defines postprocess name
  40338. * @param options defines creation options or target ratio scale
  40339. * @param rigCameras defines cameras using this postprocess
  40340. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  40341. * @param engine defines hosting engine
  40342. * @param reusable defines if the postprocess will be reused multiple times per frame
  40343. */
  40344. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  40345. }
  40346. }
  40347. declare module "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode" { }
  40348. declare module "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera" {
  40349. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  40350. import { Scene } from "babylonjs/scene";
  40351. import { Vector3 } from "babylonjs/Maths/math.vector";
  40352. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  40353. /**
  40354. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  40355. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  40356. */
  40357. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  40358. /**
  40359. * Creates a new AnaglyphArcRotateCamera
  40360. * @param name defines camera name
  40361. * @param alpha defines alpha angle (in radians)
  40362. * @param beta defines beta angle (in radians)
  40363. * @param radius defines radius
  40364. * @param target defines camera target
  40365. * @param interaxialDistance defines distance between each color axis
  40366. * @param scene defines the hosting scene
  40367. */
  40368. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  40369. /**
  40370. * Gets camera class name
  40371. * @returns AnaglyphArcRotateCamera
  40372. */
  40373. getClassName(): string;
  40374. }
  40375. }
  40376. declare module "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera" {
  40377. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  40378. import { Scene } from "babylonjs/scene";
  40379. import { Vector3 } from "babylonjs/Maths/math.vector";
  40380. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  40381. /**
  40382. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  40383. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  40384. */
  40385. export class AnaglyphFreeCamera extends FreeCamera {
  40386. /**
  40387. * Creates a new AnaglyphFreeCamera
  40388. * @param name defines camera name
  40389. * @param position defines initial position
  40390. * @param interaxialDistance defines distance between each color axis
  40391. * @param scene defines the hosting scene
  40392. */
  40393. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  40394. /**
  40395. * Gets camera class name
  40396. * @returns AnaglyphFreeCamera
  40397. */
  40398. getClassName(): string;
  40399. }
  40400. }
  40401. declare module "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera" {
  40402. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  40403. import { Scene } from "babylonjs/scene";
  40404. import { Vector3 } from "babylonjs/Maths/math.vector";
  40405. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  40406. /**
  40407. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  40408. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  40409. */
  40410. export class AnaglyphGamepadCamera extends GamepadCamera {
  40411. /**
  40412. * Creates a new AnaglyphGamepadCamera
  40413. * @param name defines camera name
  40414. * @param position defines initial position
  40415. * @param interaxialDistance defines distance between each color axis
  40416. * @param scene defines the hosting scene
  40417. */
  40418. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  40419. /**
  40420. * Gets camera class name
  40421. * @returns AnaglyphGamepadCamera
  40422. */
  40423. getClassName(): string;
  40424. }
  40425. }
  40426. declare module "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera" {
  40427. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  40428. import { Scene } from "babylonjs/scene";
  40429. import { Vector3 } from "babylonjs/Maths/math.vector";
  40430. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  40431. /**
  40432. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  40433. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  40434. */
  40435. export class AnaglyphUniversalCamera extends UniversalCamera {
  40436. /**
  40437. * Creates a new AnaglyphUniversalCamera
  40438. * @param name defines camera name
  40439. * @param position defines initial position
  40440. * @param interaxialDistance defines distance between each color axis
  40441. * @param scene defines the hosting scene
  40442. */
  40443. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  40444. /**
  40445. * Gets camera class name
  40446. * @returns AnaglyphUniversalCamera
  40447. */
  40448. getClassName(): string;
  40449. }
  40450. }
  40451. declare module "babylonjs/Shaders/stereoscopicInterlace.fragment" {
  40452. /** @hidden */
  40453. export var stereoscopicInterlacePixelShader: {
  40454. name: string;
  40455. shader: string;
  40456. };
  40457. }
  40458. declare module "babylonjs/PostProcesses/stereoscopicInterlacePostProcess" {
  40459. import { Camera } from "babylonjs/Cameras/camera";
  40460. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  40461. import { Engine } from "babylonjs/Engines/engine";
  40462. import "babylonjs/Shaders/stereoscopicInterlace.fragment";
  40463. /**
  40464. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  40465. */
  40466. export class StereoscopicInterlacePostProcess extends PostProcess {
  40467. private _stepSize;
  40468. private _passedProcess;
  40469. /**
  40470. * Initializes a StereoscopicInterlacePostProcess
  40471. * @param name The name of the effect.
  40472. * @param rigCameras The rig cameras to be appled to the post process
  40473. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  40474. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  40475. * @param engine The engine which the post process will be applied. (default: current engine)
  40476. * @param reusable If the post process can be reused on the same frame. (default: false)
  40477. */
  40478. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  40479. }
  40480. }
  40481. declare module "babylonjs/Cameras/RigModes/stereoscopicRigMode" { }
  40482. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera" {
  40483. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  40484. import { Scene } from "babylonjs/scene";
  40485. import { Vector3 } from "babylonjs/Maths/math.vector";
  40486. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  40487. /**
  40488. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  40489. * @see http://doc.babylonjs.com/features/cameras
  40490. */
  40491. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  40492. /**
  40493. * Creates a new StereoscopicArcRotateCamera
  40494. * @param name defines camera name
  40495. * @param alpha defines alpha angle (in radians)
  40496. * @param beta defines beta angle (in radians)
  40497. * @param radius defines radius
  40498. * @param target defines camera target
  40499. * @param interaxialDistance defines distance between each color axis
  40500. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  40501. * @param scene defines the hosting scene
  40502. */
  40503. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  40504. /**
  40505. * Gets camera class name
  40506. * @returns StereoscopicArcRotateCamera
  40507. */
  40508. getClassName(): string;
  40509. }
  40510. }
  40511. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera" {
  40512. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  40513. import { Scene } from "babylonjs/scene";
  40514. import { Vector3 } from "babylonjs/Maths/math.vector";
  40515. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  40516. /**
  40517. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  40518. * @see http://doc.babylonjs.com/features/cameras
  40519. */
  40520. export class StereoscopicFreeCamera extends FreeCamera {
  40521. /**
  40522. * Creates a new StereoscopicFreeCamera
  40523. * @param name defines camera name
  40524. * @param position defines initial position
  40525. * @param interaxialDistance defines distance between each color axis
  40526. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  40527. * @param scene defines the hosting scene
  40528. */
  40529. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  40530. /**
  40531. * Gets camera class name
  40532. * @returns StereoscopicFreeCamera
  40533. */
  40534. getClassName(): string;
  40535. }
  40536. }
  40537. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera" {
  40538. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  40539. import { Scene } from "babylonjs/scene";
  40540. import { Vector3 } from "babylonjs/Maths/math.vector";
  40541. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  40542. /**
  40543. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  40544. * @see http://doc.babylonjs.com/features/cameras
  40545. */
  40546. export class StereoscopicGamepadCamera extends GamepadCamera {
  40547. /**
  40548. * Creates a new StereoscopicGamepadCamera
  40549. * @param name defines camera name
  40550. * @param position defines initial position
  40551. * @param interaxialDistance defines distance between each color axis
  40552. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  40553. * @param scene defines the hosting scene
  40554. */
  40555. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  40556. /**
  40557. * Gets camera class name
  40558. * @returns StereoscopicGamepadCamera
  40559. */
  40560. getClassName(): string;
  40561. }
  40562. }
  40563. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera" {
  40564. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  40565. import { Scene } from "babylonjs/scene";
  40566. import { Vector3 } from "babylonjs/Maths/math.vector";
  40567. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  40568. /**
  40569. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  40570. * @see http://doc.babylonjs.com/features/cameras
  40571. */
  40572. export class StereoscopicUniversalCamera extends UniversalCamera {
  40573. /**
  40574. * Creates a new StereoscopicUniversalCamera
  40575. * @param name defines camera name
  40576. * @param position defines initial position
  40577. * @param interaxialDistance defines distance between each color axis
  40578. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  40579. * @param scene defines the hosting scene
  40580. */
  40581. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  40582. /**
  40583. * Gets camera class name
  40584. * @returns StereoscopicUniversalCamera
  40585. */
  40586. getClassName(): string;
  40587. }
  40588. }
  40589. declare module "babylonjs/Cameras/Stereoscopic/index" {
  40590. export * from "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera";
  40591. export * from "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera";
  40592. export * from "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera";
  40593. export * from "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera";
  40594. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera";
  40595. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera";
  40596. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera";
  40597. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera";
  40598. }
  40599. declare module "babylonjs/Cameras/virtualJoysticksCamera" {
  40600. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  40601. import { Scene } from "babylonjs/scene";
  40602. import { Vector3 } from "babylonjs/Maths/math.vector";
  40603. import "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  40604. /**
  40605. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  40606. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  40607. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  40608. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  40609. */
  40610. export class VirtualJoysticksCamera extends FreeCamera {
  40611. /**
  40612. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  40613. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  40614. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  40615. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  40616. * @param name Define the name of the camera in the scene
  40617. * @param position Define the start position of the camera in the scene
  40618. * @param scene Define the scene the camera belongs to
  40619. */
  40620. constructor(name: string, position: Vector3, scene: Scene);
  40621. /**
  40622. * Gets the current object class name.
  40623. * @return the class name
  40624. */
  40625. getClassName(): string;
  40626. }
  40627. }
  40628. declare module "babylonjs/Cameras/VR/vrCameraMetrics" {
  40629. import { Matrix } from "babylonjs/Maths/math.vector";
  40630. /**
  40631. * This represents all the required metrics to create a VR camera.
  40632. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  40633. */
  40634. export class VRCameraMetrics {
  40635. /**
  40636. * Define the horizontal resolution off the screen.
  40637. */
  40638. hResolution: number;
  40639. /**
  40640. * Define the vertical resolution off the screen.
  40641. */
  40642. vResolution: number;
  40643. /**
  40644. * Define the horizontal screen size.
  40645. */
  40646. hScreenSize: number;
  40647. /**
  40648. * Define the vertical screen size.
  40649. */
  40650. vScreenSize: number;
  40651. /**
  40652. * Define the vertical screen center position.
  40653. */
  40654. vScreenCenter: number;
  40655. /**
  40656. * Define the distance of the eyes to the screen.
  40657. */
  40658. eyeToScreenDistance: number;
  40659. /**
  40660. * Define the distance between both lenses
  40661. */
  40662. lensSeparationDistance: number;
  40663. /**
  40664. * Define the distance between both viewer's eyes.
  40665. */
  40666. interpupillaryDistance: number;
  40667. /**
  40668. * Define the distortion factor of the VR postprocess.
  40669. * Please, touch with care.
  40670. */
  40671. distortionK: number[];
  40672. /**
  40673. * Define the chromatic aberration correction factors for the VR post process.
  40674. */
  40675. chromaAbCorrection: number[];
  40676. /**
  40677. * Define the scale factor of the post process.
  40678. * The smaller the better but the slower.
  40679. */
  40680. postProcessScaleFactor: number;
  40681. /**
  40682. * Define an offset for the lens center.
  40683. */
  40684. lensCenterOffset: number;
  40685. /**
  40686. * Define if the current vr camera should compensate the distortion of the lense or not.
  40687. */
  40688. compensateDistortion: boolean;
  40689. /**
  40690. * Defines if multiview should be enabled when rendering (Default: false)
  40691. */
  40692. multiviewEnabled: boolean;
  40693. /**
  40694. * Gets the rendering aspect ratio based on the provided resolutions.
  40695. */
  40696. readonly aspectRatio: number;
  40697. /**
  40698. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  40699. */
  40700. readonly aspectRatioFov: number;
  40701. /**
  40702. * @hidden
  40703. */
  40704. readonly leftHMatrix: Matrix;
  40705. /**
  40706. * @hidden
  40707. */
  40708. readonly rightHMatrix: Matrix;
  40709. /**
  40710. * @hidden
  40711. */
  40712. readonly leftPreViewMatrix: Matrix;
  40713. /**
  40714. * @hidden
  40715. */
  40716. readonly rightPreViewMatrix: Matrix;
  40717. /**
  40718. * Get the default VRMetrics based on the most generic setup.
  40719. * @returns the default vr metrics
  40720. */
  40721. static GetDefault(): VRCameraMetrics;
  40722. }
  40723. }
  40724. declare module "babylonjs/Shaders/vrDistortionCorrection.fragment" {
  40725. /** @hidden */
  40726. export var vrDistortionCorrectionPixelShader: {
  40727. name: string;
  40728. shader: string;
  40729. };
  40730. }
  40731. declare module "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess" {
  40732. import { Camera } from "babylonjs/Cameras/camera";
  40733. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  40734. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  40735. import "babylonjs/Shaders/vrDistortionCorrection.fragment";
  40736. /**
  40737. * VRDistortionCorrectionPostProcess used for mobile VR
  40738. */
  40739. export class VRDistortionCorrectionPostProcess extends PostProcess {
  40740. private _isRightEye;
  40741. private _distortionFactors;
  40742. private _postProcessScaleFactor;
  40743. private _lensCenterOffset;
  40744. private _scaleIn;
  40745. private _scaleFactor;
  40746. private _lensCenter;
  40747. /**
  40748. * Initializes the VRDistortionCorrectionPostProcess
  40749. * @param name The name of the effect.
  40750. * @param camera The camera to apply the render pass to.
  40751. * @param isRightEye If this is for the right eye distortion
  40752. * @param vrMetrics All the required metrics for the VR camera
  40753. */
  40754. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  40755. }
  40756. }
  40757. declare module "babylonjs/Cameras/RigModes/vrRigMode" { }
  40758. declare module "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera" {
  40759. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  40760. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  40761. import { Scene } from "babylonjs/scene";
  40762. import { Vector3 } from "babylonjs/Maths/math.vector";
  40763. import "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  40764. import "babylonjs/Cameras/RigModes/vrRigMode";
  40765. /**
  40766. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  40767. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  40768. */
  40769. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  40770. /**
  40771. * Creates a new VRDeviceOrientationArcRotateCamera
  40772. * @param name defines camera name
  40773. * @param alpha defines the camera rotation along the logitudinal axis
  40774. * @param beta defines the camera rotation along the latitudinal axis
  40775. * @param radius defines the camera distance from its target
  40776. * @param target defines the camera target
  40777. * @param scene defines the scene the camera belongs to
  40778. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  40779. * @param vrCameraMetrics defines the vr metrics associated to the camera
  40780. */
  40781. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  40782. /**
  40783. * Gets camera class name
  40784. * @returns VRDeviceOrientationArcRotateCamera
  40785. */
  40786. getClassName(): string;
  40787. }
  40788. }
  40789. declare module "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera" {
  40790. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  40791. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  40792. import { Scene } from "babylonjs/scene";
  40793. import { Vector3 } from "babylonjs/Maths/math.vector";
  40794. import "babylonjs/Cameras/RigModes/vrRigMode";
  40795. /**
  40796. * Camera used to simulate VR rendering (based on FreeCamera)
  40797. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  40798. */
  40799. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  40800. /**
  40801. * Creates a new VRDeviceOrientationFreeCamera
  40802. * @param name defines camera name
  40803. * @param position defines the start position of the camera
  40804. * @param scene defines the scene the camera belongs to
  40805. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  40806. * @param vrCameraMetrics defines the vr metrics associated to the camera
  40807. */
  40808. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  40809. /**
  40810. * Gets camera class name
  40811. * @returns VRDeviceOrientationFreeCamera
  40812. */
  40813. getClassName(): string;
  40814. }
  40815. }
  40816. declare module "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera" {
  40817. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  40818. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  40819. import { Scene } from "babylonjs/scene";
  40820. import { Vector3 } from "babylonjs/Maths/math.vector";
  40821. import "babylonjs/Gamepads/gamepadSceneComponent";
  40822. /**
  40823. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  40824. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  40825. */
  40826. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  40827. /**
  40828. * Creates a new VRDeviceOrientationGamepadCamera
  40829. * @param name defines camera name
  40830. * @param position defines the start position of the camera
  40831. * @param scene defines the scene the camera belongs to
  40832. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  40833. * @param vrCameraMetrics defines the vr metrics associated to the camera
  40834. */
  40835. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  40836. /**
  40837. * Gets camera class name
  40838. * @returns VRDeviceOrientationGamepadCamera
  40839. */
  40840. getClassName(): string;
  40841. }
  40842. }
  40843. declare module "babylonjs/Materials/pushMaterial" {
  40844. import { Nullable } from "babylonjs/types";
  40845. import { Scene } from "babylonjs/scene";
  40846. import { Matrix } from "babylonjs/Maths/math.vector";
  40847. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  40848. import { Mesh } from "babylonjs/Meshes/mesh";
  40849. import { Material } from "babylonjs/Materials/material";
  40850. import { Effect } from "babylonjs/Materials/effect";
  40851. /**
  40852. * Base class of materials working in push mode in babylon JS
  40853. * @hidden
  40854. */
  40855. export class PushMaterial extends Material {
  40856. protected _activeEffect: Effect;
  40857. protected _normalMatrix: Matrix;
  40858. /**
  40859. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  40860. * This means that the material can keep using a previous shader while a new one is being compiled.
  40861. * This is mostly used when shader parallel compilation is supported (true by default)
  40862. */
  40863. allowShaderHotSwapping: boolean;
  40864. constructor(name: string, scene: Scene);
  40865. getEffect(): Effect;
  40866. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  40867. /**
  40868. * Binds the given world matrix to the active effect
  40869. *
  40870. * @param world the matrix to bind
  40871. */
  40872. bindOnlyWorldMatrix(world: Matrix): void;
  40873. /**
  40874. * Binds the given normal matrix to the active effect
  40875. *
  40876. * @param normalMatrix the matrix to bind
  40877. */
  40878. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  40879. bind(world: Matrix, mesh?: Mesh): void;
  40880. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  40881. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  40882. }
  40883. }
  40884. declare module "babylonjs/Materials/materialFlags" {
  40885. /**
  40886. * This groups all the flags used to control the materials channel.
  40887. */
  40888. export class MaterialFlags {
  40889. private static _DiffuseTextureEnabled;
  40890. /**
  40891. * Are diffuse textures enabled in the application.
  40892. */
  40893. static DiffuseTextureEnabled: boolean;
  40894. private static _AmbientTextureEnabled;
  40895. /**
  40896. * Are ambient textures enabled in the application.
  40897. */
  40898. static AmbientTextureEnabled: boolean;
  40899. private static _OpacityTextureEnabled;
  40900. /**
  40901. * Are opacity textures enabled in the application.
  40902. */
  40903. static OpacityTextureEnabled: boolean;
  40904. private static _ReflectionTextureEnabled;
  40905. /**
  40906. * Are reflection textures enabled in the application.
  40907. */
  40908. static ReflectionTextureEnabled: boolean;
  40909. private static _EmissiveTextureEnabled;
  40910. /**
  40911. * Are emissive textures enabled in the application.
  40912. */
  40913. static EmissiveTextureEnabled: boolean;
  40914. private static _SpecularTextureEnabled;
  40915. /**
  40916. * Are specular textures enabled in the application.
  40917. */
  40918. static SpecularTextureEnabled: boolean;
  40919. private static _BumpTextureEnabled;
  40920. /**
  40921. * Are bump textures enabled in the application.
  40922. */
  40923. static BumpTextureEnabled: boolean;
  40924. private static _LightmapTextureEnabled;
  40925. /**
  40926. * Are lightmap textures enabled in the application.
  40927. */
  40928. static LightmapTextureEnabled: boolean;
  40929. private static _RefractionTextureEnabled;
  40930. /**
  40931. * Are refraction textures enabled in the application.
  40932. */
  40933. static RefractionTextureEnabled: boolean;
  40934. private static _ColorGradingTextureEnabled;
  40935. /**
  40936. * Are color grading textures enabled in the application.
  40937. */
  40938. static ColorGradingTextureEnabled: boolean;
  40939. private static _FresnelEnabled;
  40940. /**
  40941. * Are fresnels enabled in the application.
  40942. */
  40943. static FresnelEnabled: boolean;
  40944. private static _ClearCoatTextureEnabled;
  40945. /**
  40946. * Are clear coat textures enabled in the application.
  40947. */
  40948. static ClearCoatTextureEnabled: boolean;
  40949. private static _ClearCoatBumpTextureEnabled;
  40950. /**
  40951. * Are clear coat bump textures enabled in the application.
  40952. */
  40953. static ClearCoatBumpTextureEnabled: boolean;
  40954. private static _ClearCoatTintTextureEnabled;
  40955. /**
  40956. * Are clear coat tint textures enabled in the application.
  40957. */
  40958. static ClearCoatTintTextureEnabled: boolean;
  40959. private static _SheenTextureEnabled;
  40960. /**
  40961. * Are sheen textures enabled in the application.
  40962. */
  40963. static SheenTextureEnabled: boolean;
  40964. private static _AnisotropicTextureEnabled;
  40965. /**
  40966. * Are anisotropic textures enabled in the application.
  40967. */
  40968. static AnisotropicTextureEnabled: boolean;
  40969. private static _ThicknessTextureEnabled;
  40970. /**
  40971. * Are thickness textures enabled in the application.
  40972. */
  40973. static ThicknessTextureEnabled: boolean;
  40974. }
  40975. }
  40976. declare module "babylonjs/Shaders/ShadersInclude/defaultFragmentDeclaration" {
  40977. /** @hidden */
  40978. export var defaultFragmentDeclaration: {
  40979. name: string;
  40980. shader: string;
  40981. };
  40982. }
  40983. declare module "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration" {
  40984. /** @hidden */
  40985. export var defaultUboDeclaration: {
  40986. name: string;
  40987. shader: string;
  40988. };
  40989. }
  40990. declare module "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration" {
  40991. /** @hidden */
  40992. export var lightFragmentDeclaration: {
  40993. name: string;
  40994. shader: string;
  40995. };
  40996. }
  40997. declare module "babylonjs/Shaders/ShadersInclude/lightUboDeclaration" {
  40998. /** @hidden */
  40999. export var lightUboDeclaration: {
  41000. name: string;
  41001. shader: string;
  41002. };
  41003. }
  41004. declare module "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions" {
  41005. /** @hidden */
  41006. export var lightsFragmentFunctions: {
  41007. name: string;
  41008. shader: string;
  41009. };
  41010. }
  41011. declare module "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions" {
  41012. /** @hidden */
  41013. export var shadowsFragmentFunctions: {
  41014. name: string;
  41015. shader: string;
  41016. };
  41017. }
  41018. declare module "babylonjs/Shaders/ShadersInclude/fresnelFunction" {
  41019. /** @hidden */
  41020. export var fresnelFunction: {
  41021. name: string;
  41022. shader: string;
  41023. };
  41024. }
  41025. declare module "babylonjs/Shaders/ShadersInclude/reflectionFunction" {
  41026. /** @hidden */
  41027. export var reflectionFunction: {
  41028. name: string;
  41029. shader: string;
  41030. };
  41031. }
  41032. declare module "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions" {
  41033. /** @hidden */
  41034. export var bumpFragmentFunctions: {
  41035. name: string;
  41036. shader: string;
  41037. };
  41038. }
  41039. declare module "babylonjs/Shaders/ShadersInclude/logDepthDeclaration" {
  41040. /** @hidden */
  41041. export var logDepthDeclaration: {
  41042. name: string;
  41043. shader: string;
  41044. };
  41045. }
  41046. declare module "babylonjs/Shaders/ShadersInclude/bumpFragment" {
  41047. /** @hidden */
  41048. export var bumpFragment: {
  41049. name: string;
  41050. shader: string;
  41051. };
  41052. }
  41053. declare module "babylonjs/Shaders/ShadersInclude/depthPrePass" {
  41054. /** @hidden */
  41055. export var depthPrePass: {
  41056. name: string;
  41057. shader: string;
  41058. };
  41059. }
  41060. declare module "babylonjs/Shaders/ShadersInclude/lightFragment" {
  41061. /** @hidden */
  41062. export var lightFragment: {
  41063. name: string;
  41064. shader: string;
  41065. };
  41066. }
  41067. declare module "babylonjs/Shaders/ShadersInclude/logDepthFragment" {
  41068. /** @hidden */
  41069. export var logDepthFragment: {
  41070. name: string;
  41071. shader: string;
  41072. };
  41073. }
  41074. declare module "babylonjs/Shaders/default.fragment" {
  41075. import "babylonjs/Shaders/ShadersInclude/defaultFragmentDeclaration";
  41076. import "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration";
  41077. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  41078. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  41079. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  41080. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  41081. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  41082. import "babylonjs/Shaders/ShadersInclude/fresnelFunction";
  41083. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  41084. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  41085. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  41086. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  41087. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  41088. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  41089. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  41090. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  41091. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  41092. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  41093. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  41094. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  41095. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  41096. /** @hidden */
  41097. export var defaultPixelShader: {
  41098. name: string;
  41099. shader: string;
  41100. };
  41101. }
  41102. declare module "babylonjs/Shaders/ShadersInclude/defaultVertexDeclaration" {
  41103. /** @hidden */
  41104. export var defaultVertexDeclaration: {
  41105. name: string;
  41106. shader: string;
  41107. };
  41108. }
  41109. declare module "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration" {
  41110. /** @hidden */
  41111. export var bumpVertexDeclaration: {
  41112. name: string;
  41113. shader: string;
  41114. };
  41115. }
  41116. declare module "babylonjs/Shaders/ShadersInclude/bumpVertex" {
  41117. /** @hidden */
  41118. export var bumpVertex: {
  41119. name: string;
  41120. shader: string;
  41121. };
  41122. }
  41123. declare module "babylonjs/Shaders/ShadersInclude/fogVertex" {
  41124. /** @hidden */
  41125. export var fogVertex: {
  41126. name: string;
  41127. shader: string;
  41128. };
  41129. }
  41130. declare module "babylonjs/Shaders/ShadersInclude/shadowsVertex" {
  41131. /** @hidden */
  41132. export var shadowsVertex: {
  41133. name: string;
  41134. shader: string;
  41135. };
  41136. }
  41137. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertex" {
  41138. /** @hidden */
  41139. export var pointCloudVertex: {
  41140. name: string;
  41141. shader: string;
  41142. };
  41143. }
  41144. declare module "babylonjs/Shaders/ShadersInclude/logDepthVertex" {
  41145. /** @hidden */
  41146. export var logDepthVertex: {
  41147. name: string;
  41148. shader: string;
  41149. };
  41150. }
  41151. declare module "babylonjs/Shaders/default.vertex" {
  41152. import "babylonjs/Shaders/ShadersInclude/defaultVertexDeclaration";
  41153. import "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration";
  41154. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  41155. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  41156. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  41157. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  41158. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  41159. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  41160. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  41161. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  41162. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  41163. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  41164. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  41165. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  41166. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  41167. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  41168. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  41169. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  41170. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  41171. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  41172. import "babylonjs/Shaders/ShadersInclude/pointCloudVertex";
  41173. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  41174. /** @hidden */
  41175. export var defaultVertexShader: {
  41176. name: string;
  41177. shader: string;
  41178. };
  41179. }
  41180. declare module "babylonjs/Materials/standardMaterial" {
  41181. import { SmartArray } from "babylonjs/Misc/smartArray";
  41182. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  41183. import { Nullable } from "babylonjs/types";
  41184. import { Scene } from "babylonjs/scene";
  41185. import { Matrix } from "babylonjs/Maths/math.vector";
  41186. import { Color3 } from "babylonjs/Maths/math.color";
  41187. import { SubMesh } from "babylonjs/Meshes/subMesh";
  41188. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41189. import { Mesh } from "babylonjs/Meshes/mesh";
  41190. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  41191. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  41192. import { FresnelParameters } from "babylonjs/Materials/fresnelParameters";
  41193. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  41194. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  41195. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  41196. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  41197. import "babylonjs/Shaders/default.fragment";
  41198. import "babylonjs/Shaders/default.vertex";
  41199. /** @hidden */
  41200. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  41201. MAINUV1: boolean;
  41202. MAINUV2: boolean;
  41203. DIFFUSE: boolean;
  41204. DIFFUSEDIRECTUV: number;
  41205. AMBIENT: boolean;
  41206. AMBIENTDIRECTUV: number;
  41207. OPACITY: boolean;
  41208. OPACITYDIRECTUV: number;
  41209. OPACITYRGB: boolean;
  41210. REFLECTION: boolean;
  41211. EMISSIVE: boolean;
  41212. EMISSIVEDIRECTUV: number;
  41213. SPECULAR: boolean;
  41214. SPECULARDIRECTUV: number;
  41215. BUMP: boolean;
  41216. BUMPDIRECTUV: number;
  41217. PARALLAX: boolean;
  41218. PARALLAXOCCLUSION: boolean;
  41219. SPECULAROVERALPHA: boolean;
  41220. CLIPPLANE: boolean;
  41221. CLIPPLANE2: boolean;
  41222. CLIPPLANE3: boolean;
  41223. CLIPPLANE4: boolean;
  41224. ALPHATEST: boolean;
  41225. DEPTHPREPASS: boolean;
  41226. ALPHAFROMDIFFUSE: boolean;
  41227. POINTSIZE: boolean;
  41228. FOG: boolean;
  41229. SPECULARTERM: boolean;
  41230. DIFFUSEFRESNEL: boolean;
  41231. OPACITYFRESNEL: boolean;
  41232. REFLECTIONFRESNEL: boolean;
  41233. REFRACTIONFRESNEL: boolean;
  41234. EMISSIVEFRESNEL: boolean;
  41235. FRESNEL: boolean;
  41236. NORMAL: boolean;
  41237. UV1: boolean;
  41238. UV2: boolean;
  41239. VERTEXCOLOR: boolean;
  41240. VERTEXALPHA: boolean;
  41241. NUM_BONE_INFLUENCERS: number;
  41242. BonesPerMesh: number;
  41243. BONETEXTURE: boolean;
  41244. INSTANCES: boolean;
  41245. GLOSSINESS: boolean;
  41246. ROUGHNESS: boolean;
  41247. EMISSIVEASILLUMINATION: boolean;
  41248. LINKEMISSIVEWITHDIFFUSE: boolean;
  41249. REFLECTIONFRESNELFROMSPECULAR: boolean;
  41250. LIGHTMAP: boolean;
  41251. LIGHTMAPDIRECTUV: number;
  41252. OBJECTSPACE_NORMALMAP: boolean;
  41253. USELIGHTMAPASSHADOWMAP: boolean;
  41254. REFLECTIONMAP_3D: boolean;
  41255. REFLECTIONMAP_SPHERICAL: boolean;
  41256. REFLECTIONMAP_PLANAR: boolean;
  41257. REFLECTIONMAP_CUBIC: boolean;
  41258. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  41259. REFLECTIONMAP_PROJECTION: boolean;
  41260. REFLECTIONMAP_SKYBOX: boolean;
  41261. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  41262. REFLECTIONMAP_EXPLICIT: boolean;
  41263. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  41264. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  41265. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  41266. INVERTCUBICMAP: boolean;
  41267. LOGARITHMICDEPTH: boolean;
  41268. REFRACTION: boolean;
  41269. REFRACTIONMAP_3D: boolean;
  41270. REFLECTIONOVERALPHA: boolean;
  41271. TWOSIDEDLIGHTING: boolean;
  41272. SHADOWFLOAT: boolean;
  41273. MORPHTARGETS: boolean;
  41274. MORPHTARGETS_NORMAL: boolean;
  41275. MORPHTARGETS_TANGENT: boolean;
  41276. MORPHTARGETS_UV: boolean;
  41277. NUM_MORPH_INFLUENCERS: number;
  41278. NONUNIFORMSCALING: boolean;
  41279. PREMULTIPLYALPHA: boolean;
  41280. IMAGEPROCESSING: boolean;
  41281. VIGNETTE: boolean;
  41282. VIGNETTEBLENDMODEMULTIPLY: boolean;
  41283. VIGNETTEBLENDMODEOPAQUE: boolean;
  41284. TONEMAPPING: boolean;
  41285. TONEMAPPING_ACES: boolean;
  41286. CONTRAST: boolean;
  41287. COLORCURVES: boolean;
  41288. COLORGRADING: boolean;
  41289. COLORGRADING3D: boolean;
  41290. SAMPLER3DGREENDEPTH: boolean;
  41291. SAMPLER3DBGRMAP: boolean;
  41292. IMAGEPROCESSINGPOSTPROCESS: boolean;
  41293. MULTIVIEW: boolean;
  41294. /**
  41295. * If the reflection texture on this material is in linear color space
  41296. * @hidden
  41297. */
  41298. IS_REFLECTION_LINEAR: boolean;
  41299. /**
  41300. * If the refraction texture on this material is in linear color space
  41301. * @hidden
  41302. */
  41303. IS_REFRACTION_LINEAR: boolean;
  41304. EXPOSURE: boolean;
  41305. constructor();
  41306. setReflectionMode(modeToEnable: string): void;
  41307. }
  41308. /**
  41309. * This is the default material used in Babylon. It is the best trade off between quality
  41310. * and performances.
  41311. * @see http://doc.babylonjs.com/babylon101/materials
  41312. */
  41313. export class StandardMaterial extends PushMaterial {
  41314. private _diffuseTexture;
  41315. /**
  41316. * The basic texture of the material as viewed under a light.
  41317. */
  41318. diffuseTexture: Nullable<BaseTexture>;
  41319. private _ambientTexture;
  41320. /**
  41321. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  41322. */
  41323. ambientTexture: Nullable<BaseTexture>;
  41324. private _opacityTexture;
  41325. /**
  41326. * Define the transparency of the material from a texture.
  41327. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  41328. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  41329. */
  41330. opacityTexture: Nullable<BaseTexture>;
  41331. private _reflectionTexture;
  41332. /**
  41333. * Define the texture used to display the reflection.
  41334. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  41335. */
  41336. reflectionTexture: Nullable<BaseTexture>;
  41337. private _emissiveTexture;
  41338. /**
  41339. * Define texture of the material as if self lit.
  41340. * This will be mixed in the final result even in the absence of light.
  41341. */
  41342. emissiveTexture: Nullable<BaseTexture>;
  41343. private _specularTexture;
  41344. /**
  41345. * Define how the color and intensity of the highlight given by the light in the material.
  41346. */
  41347. specularTexture: Nullable<BaseTexture>;
  41348. private _bumpTexture;
  41349. /**
  41350. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  41351. * 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.
  41352. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  41353. */
  41354. bumpTexture: Nullable<BaseTexture>;
  41355. private _lightmapTexture;
  41356. /**
  41357. * Complex lighting can be computationally expensive to compute at runtime.
  41358. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  41359. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  41360. */
  41361. lightmapTexture: Nullable<BaseTexture>;
  41362. private _refractionTexture;
  41363. /**
  41364. * Define the texture used to display the refraction.
  41365. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  41366. */
  41367. refractionTexture: Nullable<BaseTexture>;
  41368. /**
  41369. * The color of the material lit by the environmental background lighting.
  41370. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  41371. */
  41372. ambientColor: Color3;
  41373. /**
  41374. * The basic color of the material as viewed under a light.
  41375. */
  41376. diffuseColor: Color3;
  41377. /**
  41378. * Define how the color and intensity of the highlight given by the light in the material.
  41379. */
  41380. specularColor: Color3;
  41381. /**
  41382. * Define the color of the material as if self lit.
  41383. * This will be mixed in the final result even in the absence of light.
  41384. */
  41385. emissiveColor: Color3;
  41386. /**
  41387. * Defines how sharp are the highlights in the material.
  41388. * The bigger the value the sharper giving a more glossy feeling to the result.
  41389. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  41390. */
  41391. specularPower: number;
  41392. private _useAlphaFromDiffuseTexture;
  41393. /**
  41394. * Does the transparency come from the diffuse texture alpha channel.
  41395. */
  41396. useAlphaFromDiffuseTexture: boolean;
  41397. private _useEmissiveAsIllumination;
  41398. /**
  41399. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  41400. */
  41401. useEmissiveAsIllumination: boolean;
  41402. private _linkEmissiveWithDiffuse;
  41403. /**
  41404. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  41405. * the emissive level when the final color is close to one.
  41406. */
  41407. linkEmissiveWithDiffuse: boolean;
  41408. private _useSpecularOverAlpha;
  41409. /**
  41410. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  41411. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  41412. */
  41413. useSpecularOverAlpha: boolean;
  41414. private _useReflectionOverAlpha;
  41415. /**
  41416. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  41417. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  41418. */
  41419. useReflectionOverAlpha: boolean;
  41420. private _disableLighting;
  41421. /**
  41422. * Does lights from the scene impacts this material.
  41423. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  41424. */
  41425. disableLighting: boolean;
  41426. private _useObjectSpaceNormalMap;
  41427. /**
  41428. * Allows using an object space normal map (instead of tangent space).
  41429. */
  41430. useObjectSpaceNormalMap: boolean;
  41431. private _useParallax;
  41432. /**
  41433. * Is parallax enabled or not.
  41434. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  41435. */
  41436. useParallax: boolean;
  41437. private _useParallaxOcclusion;
  41438. /**
  41439. * Is parallax occlusion enabled or not.
  41440. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  41441. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  41442. */
  41443. useParallaxOcclusion: boolean;
  41444. /**
  41445. * 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.
  41446. */
  41447. parallaxScaleBias: number;
  41448. private _roughness;
  41449. /**
  41450. * Helps to define how blurry the reflections should appears in the material.
  41451. */
  41452. roughness: number;
  41453. /**
  41454. * In case of refraction, define the value of the index of refraction.
  41455. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  41456. */
  41457. indexOfRefraction: number;
  41458. /**
  41459. * Invert the refraction texture alongside the y axis.
  41460. * It can be useful with procedural textures or probe for instance.
  41461. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  41462. */
  41463. invertRefractionY: boolean;
  41464. /**
  41465. * Defines the alpha limits in alpha test mode.
  41466. */
  41467. alphaCutOff: number;
  41468. private _useLightmapAsShadowmap;
  41469. /**
  41470. * In case of light mapping, define whether the map contains light or shadow informations.
  41471. */
  41472. useLightmapAsShadowmap: boolean;
  41473. private _diffuseFresnelParameters;
  41474. /**
  41475. * Define the diffuse fresnel parameters of the material.
  41476. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  41477. */
  41478. diffuseFresnelParameters: FresnelParameters;
  41479. private _opacityFresnelParameters;
  41480. /**
  41481. * Define the opacity fresnel parameters of the material.
  41482. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  41483. */
  41484. opacityFresnelParameters: FresnelParameters;
  41485. private _reflectionFresnelParameters;
  41486. /**
  41487. * Define the reflection fresnel parameters of the material.
  41488. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  41489. */
  41490. reflectionFresnelParameters: FresnelParameters;
  41491. private _refractionFresnelParameters;
  41492. /**
  41493. * Define the refraction fresnel parameters of the material.
  41494. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  41495. */
  41496. refractionFresnelParameters: FresnelParameters;
  41497. private _emissiveFresnelParameters;
  41498. /**
  41499. * Define the emissive fresnel parameters of the material.
  41500. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  41501. */
  41502. emissiveFresnelParameters: FresnelParameters;
  41503. private _useReflectionFresnelFromSpecular;
  41504. /**
  41505. * If true automatically deducts the fresnels values from the material specularity.
  41506. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  41507. */
  41508. useReflectionFresnelFromSpecular: boolean;
  41509. private _useGlossinessFromSpecularMapAlpha;
  41510. /**
  41511. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  41512. */
  41513. useGlossinessFromSpecularMapAlpha: boolean;
  41514. private _maxSimultaneousLights;
  41515. /**
  41516. * Defines the maximum number of lights that can be used in the material
  41517. */
  41518. maxSimultaneousLights: number;
  41519. private _invertNormalMapX;
  41520. /**
  41521. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  41522. */
  41523. invertNormalMapX: boolean;
  41524. private _invertNormalMapY;
  41525. /**
  41526. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  41527. */
  41528. invertNormalMapY: boolean;
  41529. private _twoSidedLighting;
  41530. /**
  41531. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  41532. */
  41533. twoSidedLighting: boolean;
  41534. /**
  41535. * Default configuration related to image processing available in the standard Material.
  41536. */
  41537. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  41538. /**
  41539. * Gets the image processing configuration used either in this material.
  41540. */
  41541. /**
  41542. * Sets the Default image processing configuration used either in the this material.
  41543. *
  41544. * If sets to null, the scene one is in use.
  41545. */
  41546. imageProcessingConfiguration: ImageProcessingConfiguration;
  41547. /**
  41548. * Keep track of the image processing observer to allow dispose and replace.
  41549. */
  41550. private _imageProcessingObserver;
  41551. /**
  41552. * Attaches a new image processing configuration to the Standard Material.
  41553. * @param configuration
  41554. */
  41555. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  41556. /**
  41557. * Gets wether the color curves effect is enabled.
  41558. */
  41559. /**
  41560. * Sets wether the color curves effect is enabled.
  41561. */
  41562. cameraColorCurvesEnabled: boolean;
  41563. /**
  41564. * Gets wether the color grading effect is enabled.
  41565. */
  41566. /**
  41567. * Gets wether the color grading effect is enabled.
  41568. */
  41569. cameraColorGradingEnabled: boolean;
  41570. /**
  41571. * Gets wether tonemapping is enabled or not.
  41572. */
  41573. /**
  41574. * Sets wether tonemapping is enabled or not
  41575. */
  41576. cameraToneMappingEnabled: boolean;
  41577. /**
  41578. * The camera exposure used on this material.
  41579. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  41580. * This corresponds to a photographic exposure.
  41581. */
  41582. /**
  41583. * The camera exposure used on this material.
  41584. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  41585. * This corresponds to a photographic exposure.
  41586. */
  41587. cameraExposure: number;
  41588. /**
  41589. * Gets The camera contrast used on this material.
  41590. */
  41591. /**
  41592. * Sets The camera contrast used on this material.
  41593. */
  41594. cameraContrast: number;
  41595. /**
  41596. * Gets the Color Grading 2D Lookup Texture.
  41597. */
  41598. /**
  41599. * Sets the Color Grading 2D Lookup Texture.
  41600. */
  41601. cameraColorGradingTexture: Nullable<BaseTexture>;
  41602. /**
  41603. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  41604. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  41605. * 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;
  41606. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  41607. */
  41608. /**
  41609. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  41610. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  41611. * 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;
  41612. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  41613. */
  41614. cameraColorCurves: Nullable<ColorCurves>;
  41615. /**
  41616. * Custom callback helping to override the default shader used in the material.
  41617. */
  41618. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  41619. protected _renderTargets: SmartArray<RenderTargetTexture>;
  41620. protected _worldViewProjectionMatrix: Matrix;
  41621. protected _globalAmbientColor: Color3;
  41622. protected _useLogarithmicDepth: boolean;
  41623. protected _rebuildInParallel: boolean;
  41624. /**
  41625. * Instantiates a new standard material.
  41626. * This is the default material used in Babylon. It is the best trade off between quality
  41627. * and performances.
  41628. * @see http://doc.babylonjs.com/babylon101/materials
  41629. * @param name Define the name of the material in the scene
  41630. * @param scene Define the scene the material belong to
  41631. */
  41632. constructor(name: string, scene: Scene);
  41633. /**
  41634. * Gets a boolean indicating that current material needs to register RTT
  41635. */
  41636. readonly hasRenderTargetTextures: boolean;
  41637. /**
  41638. * Gets the current class name of the material e.g. "StandardMaterial"
  41639. * Mainly use in serialization.
  41640. * @returns the class name
  41641. */
  41642. getClassName(): string;
  41643. /**
  41644. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  41645. * You can try switching to logarithmic depth.
  41646. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  41647. */
  41648. useLogarithmicDepth: boolean;
  41649. /**
  41650. * Specifies if the material will require alpha blending
  41651. * @returns a boolean specifying if alpha blending is needed
  41652. */
  41653. needAlphaBlending(): boolean;
  41654. /**
  41655. * Specifies if this material should be rendered in alpha test mode
  41656. * @returns a boolean specifying if an alpha test is needed.
  41657. */
  41658. needAlphaTesting(): boolean;
  41659. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  41660. /**
  41661. * Get the texture used for alpha test purpose.
  41662. * @returns the diffuse texture in case of the standard material.
  41663. */
  41664. getAlphaTestTexture(): Nullable<BaseTexture>;
  41665. /**
  41666. * Get if the submesh is ready to be used and all its information available.
  41667. * Child classes can use it to update shaders
  41668. * @param mesh defines the mesh to check
  41669. * @param subMesh defines which submesh to check
  41670. * @param useInstances specifies that instances should be used
  41671. * @returns a boolean indicating that the submesh is ready or not
  41672. */
  41673. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  41674. /**
  41675. * Builds the material UBO layouts.
  41676. * Used internally during the effect preparation.
  41677. */
  41678. buildUniformLayout(): void;
  41679. /**
  41680. * Unbinds the material from the mesh
  41681. */
  41682. unbind(): void;
  41683. /**
  41684. * Binds the submesh to this material by preparing the effect and shader to draw
  41685. * @param world defines the world transformation matrix
  41686. * @param mesh defines the mesh containing the submesh
  41687. * @param subMesh defines the submesh to bind the material to
  41688. */
  41689. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  41690. /**
  41691. * Get the list of animatables in the material.
  41692. * @returns the list of animatables object used in the material
  41693. */
  41694. getAnimatables(): IAnimatable[];
  41695. /**
  41696. * Gets the active textures from the material
  41697. * @returns an array of textures
  41698. */
  41699. getActiveTextures(): BaseTexture[];
  41700. /**
  41701. * Specifies if the material uses a texture
  41702. * @param texture defines the texture to check against the material
  41703. * @returns a boolean specifying if the material uses the texture
  41704. */
  41705. hasTexture(texture: BaseTexture): boolean;
  41706. /**
  41707. * Disposes the material
  41708. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  41709. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  41710. */
  41711. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  41712. /**
  41713. * Makes a duplicate of the material, and gives it a new name
  41714. * @param name defines the new name for the duplicated material
  41715. * @returns the cloned material
  41716. */
  41717. clone(name: string): StandardMaterial;
  41718. /**
  41719. * Serializes this material in a JSON representation
  41720. * @returns the serialized material object
  41721. */
  41722. serialize(): any;
  41723. /**
  41724. * Creates a standard material from parsed material data
  41725. * @param source defines the JSON representation of the material
  41726. * @param scene defines the hosting scene
  41727. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  41728. * @returns a new standard material
  41729. */
  41730. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  41731. /**
  41732. * Are diffuse textures enabled in the application.
  41733. */
  41734. static DiffuseTextureEnabled: boolean;
  41735. /**
  41736. * Are ambient textures enabled in the application.
  41737. */
  41738. static AmbientTextureEnabled: boolean;
  41739. /**
  41740. * Are opacity textures enabled in the application.
  41741. */
  41742. static OpacityTextureEnabled: boolean;
  41743. /**
  41744. * Are reflection textures enabled in the application.
  41745. */
  41746. static ReflectionTextureEnabled: boolean;
  41747. /**
  41748. * Are emissive textures enabled in the application.
  41749. */
  41750. static EmissiveTextureEnabled: boolean;
  41751. /**
  41752. * Are specular textures enabled in the application.
  41753. */
  41754. static SpecularTextureEnabled: boolean;
  41755. /**
  41756. * Are bump textures enabled in the application.
  41757. */
  41758. static BumpTextureEnabled: boolean;
  41759. /**
  41760. * Are lightmap textures enabled in the application.
  41761. */
  41762. static LightmapTextureEnabled: boolean;
  41763. /**
  41764. * Are refraction textures enabled in the application.
  41765. */
  41766. static RefractionTextureEnabled: boolean;
  41767. /**
  41768. * Are color grading textures enabled in the application.
  41769. */
  41770. static ColorGradingTextureEnabled: boolean;
  41771. /**
  41772. * Are fresnels enabled in the application.
  41773. */
  41774. static FresnelEnabled: boolean;
  41775. }
  41776. }
  41777. declare module "babylonjs/Materials/Textures/dynamicTexture" {
  41778. import { Scene } from "babylonjs/scene";
  41779. import { Texture } from "babylonjs/Materials/Textures/texture";
  41780. /**
  41781. * A class extending Texture allowing drawing on a texture
  41782. * @see http://doc.babylonjs.com/how_to/dynamictexture
  41783. */
  41784. export class DynamicTexture extends Texture {
  41785. private _generateMipMaps;
  41786. private _canvas;
  41787. private _context;
  41788. private _engine;
  41789. /**
  41790. * Creates a DynamicTexture
  41791. * @param name defines the name of the texture
  41792. * @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
  41793. * @param scene defines the scene where you want the texture
  41794. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  41795. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  41796. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  41797. */
  41798. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  41799. /**
  41800. * Get the current class name of the texture useful for serialization or dynamic coding.
  41801. * @returns "DynamicTexture"
  41802. */
  41803. getClassName(): string;
  41804. /**
  41805. * Gets the current state of canRescale
  41806. */
  41807. readonly canRescale: boolean;
  41808. private _recreate;
  41809. /**
  41810. * Scales the texture
  41811. * @param ratio the scale factor to apply to both width and height
  41812. */
  41813. scale(ratio: number): void;
  41814. /**
  41815. * Resizes the texture
  41816. * @param width the new width
  41817. * @param height the new height
  41818. */
  41819. scaleTo(width: number, height: number): void;
  41820. /**
  41821. * Gets the context of the canvas used by the texture
  41822. * @returns the canvas context of the dynamic texture
  41823. */
  41824. getContext(): CanvasRenderingContext2D;
  41825. /**
  41826. * Clears the texture
  41827. */
  41828. clear(): void;
  41829. /**
  41830. * Updates the texture
  41831. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  41832. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  41833. */
  41834. update(invertY?: boolean, premulAlpha?: boolean): void;
  41835. /**
  41836. * Draws text onto the texture
  41837. * @param text defines the text to be drawn
  41838. * @param x defines the placement of the text from the left
  41839. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  41840. * @param font defines the font to be used with font-style, font-size, font-name
  41841. * @param color defines the color used for the text
  41842. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  41843. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  41844. * @param update defines whether texture is immediately update (default is true)
  41845. */
  41846. drawText(text: string, x: number, y: number, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  41847. /**
  41848. * Clones the texture
  41849. * @returns the clone of the texture.
  41850. */
  41851. clone(): DynamicTexture;
  41852. /**
  41853. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  41854. * @returns a serialized dynamic texture object
  41855. */
  41856. serialize(): any;
  41857. /** @hidden */
  41858. _rebuild(): void;
  41859. }
  41860. }
  41861. declare module "babylonjs/Shaders/imageProcessing.fragment" {
  41862. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  41863. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  41864. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  41865. /** @hidden */
  41866. export var imageProcessingPixelShader: {
  41867. name: string;
  41868. shader: string;
  41869. };
  41870. }
  41871. declare module "babylonjs/PostProcesses/imageProcessingPostProcess" {
  41872. import { Nullable } from "babylonjs/types";
  41873. import { Color4 } from "babylonjs/Maths/math.color";
  41874. import { Camera } from "babylonjs/Cameras/camera";
  41875. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  41876. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  41877. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  41878. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  41879. import { Engine } from "babylonjs/Engines/engine";
  41880. import "babylonjs/Shaders/imageProcessing.fragment";
  41881. import "babylonjs/Shaders/postprocess.vertex";
  41882. /**
  41883. * ImageProcessingPostProcess
  41884. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  41885. */
  41886. export class ImageProcessingPostProcess extends PostProcess {
  41887. /**
  41888. * Default configuration related to image processing available in the PBR Material.
  41889. */
  41890. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  41891. /**
  41892. * Gets the image processing configuration used either in this material.
  41893. */
  41894. /**
  41895. * Sets the Default image processing configuration used either in the this material.
  41896. *
  41897. * If sets to null, the scene one is in use.
  41898. */
  41899. imageProcessingConfiguration: ImageProcessingConfiguration;
  41900. /**
  41901. * Keep track of the image processing observer to allow dispose and replace.
  41902. */
  41903. private _imageProcessingObserver;
  41904. /**
  41905. * Attaches a new image processing configuration to the PBR Material.
  41906. * @param configuration
  41907. */
  41908. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  41909. /**
  41910. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  41911. */
  41912. /**
  41913. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  41914. */
  41915. colorCurves: Nullable<ColorCurves>;
  41916. /**
  41917. * Gets wether the color curves effect is enabled.
  41918. */
  41919. /**
  41920. * Sets wether the color curves effect is enabled.
  41921. */
  41922. colorCurvesEnabled: boolean;
  41923. /**
  41924. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  41925. */
  41926. /**
  41927. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  41928. */
  41929. colorGradingTexture: Nullable<BaseTexture>;
  41930. /**
  41931. * Gets wether the color grading effect is enabled.
  41932. */
  41933. /**
  41934. * Gets wether the color grading effect is enabled.
  41935. */
  41936. colorGradingEnabled: boolean;
  41937. /**
  41938. * Gets exposure used in the effect.
  41939. */
  41940. /**
  41941. * Sets exposure used in the effect.
  41942. */
  41943. exposure: number;
  41944. /**
  41945. * Gets wether tonemapping is enabled or not.
  41946. */
  41947. /**
  41948. * Sets wether tonemapping is enabled or not
  41949. */
  41950. toneMappingEnabled: boolean;
  41951. /**
  41952. * Gets the type of tone mapping effect.
  41953. */
  41954. /**
  41955. * Sets the type of tone mapping effect.
  41956. */
  41957. toneMappingType: number;
  41958. /**
  41959. * Gets contrast used in the effect.
  41960. */
  41961. /**
  41962. * Sets contrast used in the effect.
  41963. */
  41964. contrast: number;
  41965. /**
  41966. * Gets Vignette stretch size.
  41967. */
  41968. /**
  41969. * Sets Vignette stretch size.
  41970. */
  41971. vignetteStretch: number;
  41972. /**
  41973. * Gets Vignette centre X Offset.
  41974. */
  41975. /**
  41976. * Sets Vignette centre X Offset.
  41977. */
  41978. vignetteCentreX: number;
  41979. /**
  41980. * Gets Vignette centre Y Offset.
  41981. */
  41982. /**
  41983. * Sets Vignette centre Y Offset.
  41984. */
  41985. vignetteCentreY: number;
  41986. /**
  41987. * Gets Vignette weight or intensity of the vignette effect.
  41988. */
  41989. /**
  41990. * Sets Vignette weight or intensity of the vignette effect.
  41991. */
  41992. vignetteWeight: number;
  41993. /**
  41994. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  41995. * if vignetteEnabled is set to true.
  41996. */
  41997. /**
  41998. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  41999. * if vignetteEnabled is set to true.
  42000. */
  42001. vignetteColor: Color4;
  42002. /**
  42003. * Gets Camera field of view used by the Vignette effect.
  42004. */
  42005. /**
  42006. * Sets Camera field of view used by the Vignette effect.
  42007. */
  42008. vignetteCameraFov: number;
  42009. /**
  42010. * Gets the vignette blend mode allowing different kind of effect.
  42011. */
  42012. /**
  42013. * Sets the vignette blend mode allowing different kind of effect.
  42014. */
  42015. vignetteBlendMode: number;
  42016. /**
  42017. * Gets wether the vignette effect is enabled.
  42018. */
  42019. /**
  42020. * Sets wether the vignette effect is enabled.
  42021. */
  42022. vignetteEnabled: boolean;
  42023. private _fromLinearSpace;
  42024. /**
  42025. * Gets wether the input of the processing is in Gamma or Linear Space.
  42026. */
  42027. /**
  42028. * Sets wether the input of the processing is in Gamma or Linear Space.
  42029. */
  42030. fromLinearSpace: boolean;
  42031. /**
  42032. * Defines cache preventing GC.
  42033. */
  42034. private _defines;
  42035. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  42036. /**
  42037. * "ImageProcessingPostProcess"
  42038. * @returns "ImageProcessingPostProcess"
  42039. */
  42040. getClassName(): string;
  42041. protected _updateParameters(): void;
  42042. dispose(camera?: Camera): void;
  42043. }
  42044. }
  42045. declare module "babylonjs/Meshes/Builders/groundBuilder" {
  42046. import { Scene } from "babylonjs/scene";
  42047. import { Color3 } from "babylonjs/Maths/math.color";
  42048. import { Mesh } from "babylonjs/Meshes/mesh";
  42049. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  42050. import { Nullable } from "babylonjs/types";
  42051. /**
  42052. * Class containing static functions to help procedurally build meshes
  42053. */
  42054. export class GroundBuilder {
  42055. /**
  42056. * Creates a ground mesh
  42057. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  42058. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  42059. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  42060. * @param name defines the name of the mesh
  42061. * @param options defines the options used to create the mesh
  42062. * @param scene defines the hosting scene
  42063. * @returns the ground mesh
  42064. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  42065. */
  42066. static CreateGround(name: string, options: {
  42067. width?: number;
  42068. height?: number;
  42069. subdivisions?: number;
  42070. subdivisionsX?: number;
  42071. subdivisionsY?: number;
  42072. updatable?: boolean;
  42073. }, scene: any): Mesh;
  42074. /**
  42075. * Creates a tiled ground mesh
  42076. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  42077. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  42078. * * 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
  42079. * * 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
  42080. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  42081. * @param name defines the name of the mesh
  42082. * @param options defines the options used to create the mesh
  42083. * @param scene defines the hosting scene
  42084. * @returns the tiled ground mesh
  42085. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  42086. */
  42087. static CreateTiledGround(name: string, options: {
  42088. xmin: number;
  42089. zmin: number;
  42090. xmax: number;
  42091. zmax: number;
  42092. subdivisions?: {
  42093. w: number;
  42094. h: number;
  42095. };
  42096. precision?: {
  42097. w: number;
  42098. h: number;
  42099. };
  42100. updatable?: boolean;
  42101. }, scene?: Nullable<Scene>): Mesh;
  42102. /**
  42103. * Creates a ground mesh from a height map
  42104. * * The parameter `url` sets the URL of the height map image resource.
  42105. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  42106. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  42107. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  42108. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  42109. * * 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.
  42110. * * 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).
  42111. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  42112. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  42113. * @param name defines the name of the mesh
  42114. * @param url defines the url to the height map
  42115. * @param options defines the options used to create the mesh
  42116. * @param scene defines the hosting scene
  42117. * @returns the ground mesh
  42118. * @see https://doc.babylonjs.com/babylon101/height_map
  42119. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  42120. */
  42121. static CreateGroundFromHeightMap(name: string, url: string, options: {
  42122. width?: number;
  42123. height?: number;
  42124. subdivisions?: number;
  42125. minHeight?: number;
  42126. maxHeight?: number;
  42127. colorFilter?: Color3;
  42128. alphaFilter?: number;
  42129. updatable?: boolean;
  42130. onReady?: (mesh: GroundMesh) => void;
  42131. }, scene?: Nullable<Scene>): GroundMesh;
  42132. }
  42133. }
  42134. declare module "babylonjs/Meshes/Builders/torusBuilder" {
  42135. import { Vector4 } from "babylonjs/Maths/math.vector";
  42136. import { Mesh } from "babylonjs/Meshes/mesh";
  42137. /**
  42138. * Class containing static functions to help procedurally build meshes
  42139. */
  42140. export class TorusBuilder {
  42141. /**
  42142. * Creates a torus mesh
  42143. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  42144. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  42145. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  42146. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  42147. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  42148. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  42149. * @param name defines the name of the mesh
  42150. * @param options defines the options used to create the mesh
  42151. * @param scene defines the hosting scene
  42152. * @returns the torus mesh
  42153. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  42154. */
  42155. static CreateTorus(name: string, options: {
  42156. diameter?: number;
  42157. thickness?: number;
  42158. tessellation?: number;
  42159. updatable?: boolean;
  42160. sideOrientation?: number;
  42161. frontUVs?: Vector4;
  42162. backUVs?: Vector4;
  42163. }, scene: any): Mesh;
  42164. }
  42165. }
  42166. declare module "babylonjs/Meshes/Builders/cylinderBuilder" {
  42167. import { Vector4 } from "babylonjs/Maths/math.vector";
  42168. import { Color4 } from "babylonjs/Maths/math.color";
  42169. import { Mesh } from "babylonjs/Meshes/mesh";
  42170. /**
  42171. * Class containing static functions to help procedurally build meshes
  42172. */
  42173. export class CylinderBuilder {
  42174. /**
  42175. * Creates a cylinder or a cone mesh
  42176. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  42177. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  42178. * * 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.
  42179. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  42180. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  42181. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  42182. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  42183. * * 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).
  42184. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  42185. * * 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).
  42186. * * 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
  42187. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  42188. * * 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
  42189. * * 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.
  42190. * * If `enclose` is false, a ring surface is one element.
  42191. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  42192. * * 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
  42193. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  42194. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  42195. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  42196. * @param name defines the name of the mesh
  42197. * @param options defines the options used to create the mesh
  42198. * @param scene defines the hosting scene
  42199. * @returns the cylinder mesh
  42200. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  42201. */
  42202. static CreateCylinder(name: string, options: {
  42203. height?: number;
  42204. diameterTop?: number;
  42205. diameterBottom?: number;
  42206. diameter?: number;
  42207. tessellation?: number;
  42208. subdivisions?: number;
  42209. arc?: number;
  42210. faceColors?: Color4[];
  42211. faceUV?: Vector4[];
  42212. updatable?: boolean;
  42213. hasRings?: boolean;
  42214. enclose?: boolean;
  42215. cap?: number;
  42216. sideOrientation?: number;
  42217. frontUVs?: Vector4;
  42218. backUVs?: Vector4;
  42219. }, scene: any): Mesh;
  42220. }
  42221. }
  42222. declare module "babylonjs/Cameras/VR/vrExperienceHelper" {
  42223. import { Observable } from "babylonjs/Misc/observable";
  42224. import { Nullable } from "babylonjs/types";
  42225. import { Camera } from "babylonjs/Cameras/camera";
  42226. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  42227. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  42228. import { WebVROptions, WebVRFreeCamera } from "babylonjs/Cameras/VR/webVRCamera";
  42229. import { Scene } from "babylonjs/scene";
  42230. import { Vector3 } from "babylonjs/Maths/math.vector";
  42231. import { Color3 } from "babylonjs/Maths/math.color";
  42232. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  42233. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42234. import { Mesh } from "babylonjs/Meshes/mesh";
  42235. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  42236. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  42237. import "babylonjs/Meshes/Builders/groundBuilder";
  42238. import "babylonjs/Meshes/Builders/torusBuilder";
  42239. import "babylonjs/Meshes/Builders/cylinderBuilder";
  42240. import "babylonjs/Gamepads/gamepadSceneComponent";
  42241. import "babylonjs/Animations/animatable";
  42242. /**
  42243. * Options to modify the vr teleportation behavior.
  42244. */
  42245. export interface VRTeleportationOptions {
  42246. /**
  42247. * The name of the mesh which should be used as the teleportation floor. (default: null)
  42248. */
  42249. floorMeshName?: string;
  42250. /**
  42251. * A list of meshes to be used as the teleportation floor. (default: empty)
  42252. */
  42253. floorMeshes?: Mesh[];
  42254. }
  42255. /**
  42256. * Options to modify the vr experience helper's behavior.
  42257. */
  42258. export interface VRExperienceHelperOptions extends WebVROptions {
  42259. /**
  42260. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  42261. */
  42262. createDeviceOrientationCamera?: boolean;
  42263. /**
  42264. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  42265. */
  42266. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  42267. /**
  42268. * Uses the main button on the controller to toggle the laser casted. (default: true)
  42269. */
  42270. laserToggle?: boolean;
  42271. /**
  42272. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  42273. */
  42274. floorMeshes?: Mesh[];
  42275. /**
  42276. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  42277. */
  42278. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  42279. }
  42280. /**
  42281. * Event containing information after VR has been entered
  42282. */
  42283. export class OnAfterEnteringVRObservableEvent {
  42284. /**
  42285. * If entering vr was successful
  42286. */
  42287. success: boolean;
  42288. }
  42289. /**
  42290. * Helps to quickly add VR support to an existing scene.
  42291. * See http://doc.babylonjs.com/how_to/webvr_helper
  42292. */
  42293. export class VRExperienceHelper {
  42294. /** Options to modify the vr experience helper's behavior. */
  42295. webVROptions: VRExperienceHelperOptions;
  42296. private _scene;
  42297. private _position;
  42298. private _btnVR;
  42299. private _btnVRDisplayed;
  42300. private _webVRsupported;
  42301. private _webVRready;
  42302. private _webVRrequesting;
  42303. private _webVRpresenting;
  42304. private _hasEnteredVR;
  42305. private _fullscreenVRpresenting;
  42306. private _canvas;
  42307. private _webVRCamera;
  42308. private _vrDeviceOrientationCamera;
  42309. private _deviceOrientationCamera;
  42310. private _existingCamera;
  42311. private _onKeyDown;
  42312. private _onVrDisplayPresentChange;
  42313. private _onVRDisplayChanged;
  42314. private _onVRRequestPresentStart;
  42315. private _onVRRequestPresentComplete;
  42316. /**
  42317. * 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)
  42318. */
  42319. enableGazeEvenWhenNoPointerLock: boolean;
  42320. /**
  42321. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  42322. */
  42323. exitVROnDoubleTap: boolean;
  42324. /**
  42325. * Observable raised right before entering VR.
  42326. */
  42327. onEnteringVRObservable: Observable<VRExperienceHelper>;
  42328. /**
  42329. * Observable raised when entering VR has completed.
  42330. */
  42331. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  42332. /**
  42333. * Observable raised when exiting VR.
  42334. */
  42335. onExitingVRObservable: Observable<VRExperienceHelper>;
  42336. /**
  42337. * Observable raised when controller mesh is loaded.
  42338. */
  42339. onControllerMeshLoadedObservable: Observable<WebVRController>;
  42340. /** Return this.onEnteringVRObservable
  42341. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  42342. */
  42343. readonly onEnteringVR: Observable<VRExperienceHelper>;
  42344. /** Return this.onExitingVRObservable
  42345. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  42346. */
  42347. readonly onExitingVR: Observable<VRExperienceHelper>;
  42348. /** Return this.onControllerMeshLoadedObservable
  42349. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  42350. */
  42351. readonly onControllerMeshLoaded: Observable<WebVRController>;
  42352. private _rayLength;
  42353. private _useCustomVRButton;
  42354. private _teleportationRequested;
  42355. private _teleportActive;
  42356. private _floorMeshName;
  42357. private _floorMeshesCollection;
  42358. private _rotationAllowed;
  42359. private _teleportBackwardsVector;
  42360. private _teleportationTarget;
  42361. private _isDefaultTeleportationTarget;
  42362. private _postProcessMove;
  42363. private _teleportationFillColor;
  42364. private _teleportationBorderColor;
  42365. private _rotationAngle;
  42366. private _haloCenter;
  42367. private _cameraGazer;
  42368. private _padSensibilityUp;
  42369. private _padSensibilityDown;
  42370. private _leftController;
  42371. private _rightController;
  42372. /**
  42373. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  42374. */
  42375. onNewMeshSelected: Observable<AbstractMesh>;
  42376. /**
  42377. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  42378. * This observable will provide the mesh and the controller used to select the mesh
  42379. */
  42380. onMeshSelectedWithController: Observable<{
  42381. mesh: AbstractMesh;
  42382. controller: WebVRController;
  42383. }>;
  42384. /**
  42385. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  42386. */
  42387. onNewMeshPicked: Observable<PickingInfo>;
  42388. private _circleEase;
  42389. /**
  42390. * Observable raised before camera teleportation
  42391. */
  42392. onBeforeCameraTeleport: Observable<Vector3>;
  42393. /**
  42394. * Observable raised after camera teleportation
  42395. */
  42396. onAfterCameraTeleport: Observable<Vector3>;
  42397. /**
  42398. * Observable raised when current selected mesh gets unselected
  42399. */
  42400. onSelectedMeshUnselected: Observable<AbstractMesh>;
  42401. private _raySelectionPredicate;
  42402. /**
  42403. * To be optionaly changed by user to define custom ray selection
  42404. */
  42405. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  42406. /**
  42407. * To be optionaly changed by user to define custom selection logic (after ray selection)
  42408. */
  42409. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  42410. /**
  42411. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  42412. */
  42413. teleportationEnabled: boolean;
  42414. private _defaultHeight;
  42415. private _teleportationInitialized;
  42416. private _interactionsEnabled;
  42417. private _interactionsRequested;
  42418. private _displayGaze;
  42419. private _displayLaserPointer;
  42420. /**
  42421. * The mesh used to display where the user is going to teleport.
  42422. */
  42423. /**
  42424. * Sets the mesh to be used to display where the user is going to teleport.
  42425. */
  42426. teleportationTarget: Mesh;
  42427. /**
  42428. * 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
  42429. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  42430. * See http://doc.babylonjs.com/resources/baking_transformations
  42431. */
  42432. gazeTrackerMesh: Mesh;
  42433. /**
  42434. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  42435. */
  42436. updateGazeTrackerScale: boolean;
  42437. /**
  42438. * If the gaze trackers color should be updated when selecting meshes
  42439. */
  42440. updateGazeTrackerColor: boolean;
  42441. /**
  42442. * The gaze tracking mesh corresponding to the left controller
  42443. */
  42444. readonly leftControllerGazeTrackerMesh: Nullable<Mesh>;
  42445. /**
  42446. * The gaze tracking mesh corresponding to the right controller
  42447. */
  42448. readonly rightControllerGazeTrackerMesh: Nullable<Mesh>;
  42449. /**
  42450. * If the ray of the gaze should be displayed.
  42451. */
  42452. /**
  42453. * Sets if the ray of the gaze should be displayed.
  42454. */
  42455. displayGaze: boolean;
  42456. /**
  42457. * If the ray of the LaserPointer should be displayed.
  42458. */
  42459. /**
  42460. * Sets if the ray of the LaserPointer should be displayed.
  42461. */
  42462. displayLaserPointer: boolean;
  42463. /**
  42464. * The deviceOrientationCamera used as the camera when not in VR.
  42465. */
  42466. readonly deviceOrientationCamera: Nullable<DeviceOrientationCamera>;
  42467. /**
  42468. * Based on the current WebVR support, returns the current VR camera used.
  42469. */
  42470. readonly currentVRCamera: Nullable<Camera>;
  42471. /**
  42472. * The webVRCamera which is used when in VR.
  42473. */
  42474. readonly webVRCamera: WebVRFreeCamera;
  42475. /**
  42476. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  42477. */
  42478. readonly vrDeviceOrientationCamera: Nullable<VRDeviceOrientationFreeCamera>;
  42479. /**
  42480. * The html button that is used to trigger entering into VR.
  42481. */
  42482. readonly vrButton: Nullable<HTMLButtonElement>;
  42483. private readonly _teleportationRequestInitiated;
  42484. /**
  42485. * Defines wether or not Pointer lock should be requested when switching to
  42486. * full screen.
  42487. */
  42488. requestPointerLockOnFullScreen: boolean;
  42489. /**
  42490. * Instantiates a VRExperienceHelper.
  42491. * Helps to quickly add VR support to an existing scene.
  42492. * @param scene The scene the VRExperienceHelper belongs to.
  42493. * @param webVROptions Options to modify the vr experience helper's behavior.
  42494. */
  42495. constructor(scene: Scene,
  42496. /** Options to modify the vr experience helper's behavior. */
  42497. webVROptions?: VRExperienceHelperOptions);
  42498. private _onDefaultMeshLoaded;
  42499. private _onResize;
  42500. private _onFullscreenChange;
  42501. /**
  42502. * Gets a value indicating if we are currently in VR mode.
  42503. */
  42504. readonly isInVRMode: boolean;
  42505. private onVrDisplayPresentChange;
  42506. private onVRDisplayChanged;
  42507. private moveButtonToBottomRight;
  42508. private displayVRButton;
  42509. private updateButtonVisibility;
  42510. private _cachedAngularSensibility;
  42511. /**
  42512. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  42513. * Otherwise, will use the fullscreen API.
  42514. */
  42515. enterVR(): void;
  42516. /**
  42517. * Attempt to exit VR, or fullscreen.
  42518. */
  42519. exitVR(): void;
  42520. /**
  42521. * The position of the vr experience helper.
  42522. */
  42523. /**
  42524. * Sets the position of the vr experience helper.
  42525. */
  42526. position: Vector3;
  42527. /**
  42528. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  42529. */
  42530. enableInteractions(): void;
  42531. private readonly _noControllerIsActive;
  42532. private beforeRender;
  42533. private _isTeleportationFloor;
  42534. /**
  42535. * Adds a floor mesh to be used for teleportation.
  42536. * @param floorMesh the mesh to be used for teleportation.
  42537. */
  42538. addFloorMesh(floorMesh: Mesh): void;
  42539. /**
  42540. * Removes a floor mesh from being used for teleportation.
  42541. * @param floorMesh the mesh to be removed.
  42542. */
  42543. removeFloorMesh(floorMesh: Mesh): void;
  42544. /**
  42545. * Enables interactions and teleportation using the VR controllers and gaze.
  42546. * @param vrTeleportationOptions options to modify teleportation behavior.
  42547. */
  42548. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  42549. private _onNewGamepadConnected;
  42550. private _tryEnableInteractionOnController;
  42551. private _onNewGamepadDisconnected;
  42552. private _enableInteractionOnController;
  42553. private _checkTeleportWithRay;
  42554. private _checkRotate;
  42555. private _checkTeleportBackwards;
  42556. private _enableTeleportationOnController;
  42557. private _createTeleportationCircles;
  42558. private _displayTeleportationTarget;
  42559. private _hideTeleportationTarget;
  42560. private _rotateCamera;
  42561. private _moveTeleportationSelectorTo;
  42562. private _workingVector;
  42563. private _workingQuaternion;
  42564. private _workingMatrix;
  42565. /**
  42566. * Teleports the users feet to the desired location
  42567. * @param location The location where the user's feet should be placed
  42568. */
  42569. teleportCamera(location: Vector3): void;
  42570. private _convertNormalToDirectionOfRay;
  42571. private _castRayAndSelectObject;
  42572. private _notifySelectedMeshUnselected;
  42573. /**
  42574. * Sets the color of the laser ray from the vr controllers.
  42575. * @param color new color for the ray.
  42576. */
  42577. changeLaserColor(color: Color3): void;
  42578. /**
  42579. * Sets the color of the ray from the vr headsets gaze.
  42580. * @param color new color for the ray.
  42581. */
  42582. changeGazeColor(color: Color3): void;
  42583. /**
  42584. * Exits VR and disposes of the vr experience helper
  42585. */
  42586. dispose(): void;
  42587. /**
  42588. * Gets the name of the VRExperienceHelper class
  42589. * @returns "VRExperienceHelper"
  42590. */
  42591. getClassName(): string;
  42592. }
  42593. }
  42594. declare module "babylonjs/Cameras/VR/index" {
  42595. export * from "babylonjs/Cameras/VR/vrCameraMetrics";
  42596. export * from "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera";
  42597. export * from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  42598. export * from "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera";
  42599. export * from "babylonjs/Cameras/VR/vrExperienceHelper";
  42600. export * from "babylonjs/Cameras/VR/webVRCamera";
  42601. }
  42602. declare module "babylonjs/Cameras/XR/webXRSessionManager" {
  42603. import { Observable } from "babylonjs/Misc/observable";
  42604. import { Nullable } from "babylonjs/types";
  42605. import { IDisposable, Scene } from "babylonjs/scene";
  42606. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  42607. /**
  42608. * Manages an XRSession to work with Babylon's engine
  42609. * @see https://doc.babylonjs.com/how_to/webxr
  42610. */
  42611. export class WebXRSessionManager implements IDisposable {
  42612. private scene;
  42613. /**
  42614. * Fires every time a new xrFrame arrives which can be used to update the camera
  42615. */
  42616. onXRFrameObservable: Observable<any>;
  42617. /**
  42618. * Fires when the xr session is ended either by the device or manually done
  42619. */
  42620. onXRSessionEnded: Observable<any>;
  42621. /**
  42622. * Underlying xr session
  42623. */
  42624. session: XRSession;
  42625. /**
  42626. * Type of reference space used when creating the session
  42627. */
  42628. referenceSpace: XRReferenceSpace;
  42629. /** @hidden */
  42630. _sessionRenderTargetTexture: Nullable<RenderTargetTexture>;
  42631. /**
  42632. * Current XR frame
  42633. */
  42634. currentFrame: Nullable<XRFrame>;
  42635. private _xrNavigator;
  42636. private baseLayer;
  42637. /**
  42638. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  42639. * @param scene The scene which the session should be created for
  42640. */
  42641. constructor(scene: Scene);
  42642. /**
  42643. * Initializes the manager
  42644. * After initialization enterXR can be called to start an XR session
  42645. * @returns Promise which resolves after it is initialized
  42646. */
  42647. initializeAsync(): Promise<void>;
  42648. /**
  42649. * Initializes an xr session
  42650. * @param xrSessionMode mode to initialize
  42651. * @returns a promise which will resolve once the session has been initialized
  42652. */
  42653. initializeSessionAsync(xrSessionMode: XRSessionMode): any;
  42654. /**
  42655. * Sets the reference space on the xr session
  42656. * @param referenceSpace space to set
  42657. * @returns a promise that will resolve once the reference space has been set
  42658. */
  42659. setReferenceSpaceAsync(referenceSpace: XRReferenceSpaceType): Promise<void>;
  42660. /**
  42661. * Updates the render state of the session
  42662. * @param state state to set
  42663. * @returns a promise that resolves once the render state has been updated
  42664. */
  42665. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  42666. /**
  42667. * Starts rendering to the xr layer
  42668. * @returns a promise that will resolve once rendering has started
  42669. */
  42670. startRenderingToXRAsync(): Promise<void>;
  42671. /**
  42672. * Stops the xrSession and restores the renderloop
  42673. * @returns Promise which resolves after it exits XR
  42674. */
  42675. exitXRAsync(): Promise<unknown>;
  42676. /**
  42677. * Checks if a session would be supported for the creation options specified
  42678. * @param sessionMode session mode to check if supported eg. immersive-vr
  42679. * @returns true if supported
  42680. */
  42681. supportsSessionAsync(sessionMode: XRSessionMode): any;
  42682. /**
  42683. * @hidden
  42684. * Converts the render layer of xrSession to a render target
  42685. * @param session session to create render target for
  42686. * @param scene scene the new render target should be created for
  42687. */
  42688. static _CreateRenderTargetTextureFromSession(session: XRSession, scene: Scene, baseLayer: XRWebGLLayer): RenderTargetTexture;
  42689. /**
  42690. * Disposes of the session manager
  42691. */
  42692. dispose(): void;
  42693. }
  42694. }
  42695. declare module "babylonjs/Cameras/XR/webXRCamera" {
  42696. import { Scene } from "babylonjs/scene";
  42697. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  42698. import { WebXRSessionManager } from "babylonjs/Cameras/XR/webXRSessionManager";
  42699. /**
  42700. * WebXR Camera which holds the views for the xrSession
  42701. * @see https://doc.babylonjs.com/how_to/webxr
  42702. */
  42703. export class WebXRCamera extends FreeCamera {
  42704. private static _TmpMatrix;
  42705. /**
  42706. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  42707. * @param name the name of the camera
  42708. * @param scene the scene to add the camera to
  42709. */
  42710. constructor(name: string, scene: Scene);
  42711. private _updateNumberOfRigCameras;
  42712. /** @hidden */
  42713. _updateForDualEyeDebugging(pupilDistance?: number): void;
  42714. /**
  42715. * Updates the cameras position from the current pose information of the XR session
  42716. * @param xrSessionManager the session containing pose information
  42717. * @returns true if the camera has been updated, false if the session did not contain pose or frame data
  42718. */
  42719. updateFromXRSessionManager(xrSessionManager: WebXRSessionManager): boolean;
  42720. }
  42721. }
  42722. declare module "babylonjs/Cameras/XR/webXRManagedOutputCanvas" {
  42723. import { Nullable } from "babylonjs/types";
  42724. import { IDisposable } from "babylonjs/scene";
  42725. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  42726. /**
  42727. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  42728. */
  42729. export class WebXRManagedOutputCanvas implements IDisposable {
  42730. private helper;
  42731. private _canvas;
  42732. /**
  42733. * xrpresent context of the canvas which can be used to display/mirror xr content
  42734. */
  42735. canvasContext: WebGLRenderingContext;
  42736. /**
  42737. * xr layer for the canvas
  42738. */
  42739. xrLayer: Nullable<XRWebGLLayer>;
  42740. /**
  42741. * Initializes the xr layer for the session
  42742. * @param xrSession xr session
  42743. * @returns a promise that will resolve once the XR Layer has been created
  42744. */
  42745. initializeXRLayerAsync(xrSession: any): any;
  42746. /**
  42747. * Initializes the canvas to be added/removed upon entering/exiting xr
  42748. * @param helper the xr experience helper used to trigger adding/removing of the canvas
  42749. * @param canvas The canvas to be added/removed (If not specified a full screen canvas will be created)
  42750. */
  42751. constructor(helper: WebXRExperienceHelper, canvas?: HTMLCanvasElement);
  42752. /**
  42753. * Disposes of the object
  42754. */
  42755. dispose(): void;
  42756. private _setManagedOutputCanvas;
  42757. private _addCanvas;
  42758. private _removeCanvas;
  42759. }
  42760. }
  42761. declare module "babylonjs/Cameras/XR/webXRExperienceHelper" {
  42762. import { Observable } from "babylonjs/Misc/observable";
  42763. import { IDisposable, Scene } from "babylonjs/scene";
  42764. import { Quaternion, Vector3 } from "babylonjs/Maths/math.vector";
  42765. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42766. import { WebXRSessionManager } from "babylonjs/Cameras/XR/webXRSessionManager";
  42767. import { WebXRCamera } from "babylonjs/Cameras/XR/webXRCamera";
  42768. import { WebXRManagedOutputCanvas } from "babylonjs/Cameras/XR/webXRManagedOutputCanvas";
  42769. /**
  42770. * States of the webXR experience
  42771. */
  42772. export enum WebXRState {
  42773. /**
  42774. * Transitioning to being in XR mode
  42775. */
  42776. ENTERING_XR = 0,
  42777. /**
  42778. * Transitioning to non XR mode
  42779. */
  42780. EXITING_XR = 1,
  42781. /**
  42782. * In XR mode and presenting
  42783. */
  42784. IN_XR = 2,
  42785. /**
  42786. * Not entered XR mode
  42787. */
  42788. NOT_IN_XR = 3
  42789. }
  42790. /**
  42791. * Base set of functionality needed to create an XR experince (WebXRSessionManager, Camera, StateManagement, etc.)
  42792. * @see https://doc.babylonjs.com/how_to/webxr
  42793. */
  42794. export class WebXRExperienceHelper implements IDisposable {
  42795. private scene;
  42796. /**
  42797. * 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
  42798. */
  42799. container: AbstractMesh;
  42800. /**
  42801. * Camera used to render xr content
  42802. */
  42803. camera: WebXRCamera;
  42804. /**
  42805. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  42806. */
  42807. state: WebXRState;
  42808. private _setState;
  42809. private static _TmpVector;
  42810. /**
  42811. * Fires when the state of the experience helper has changed
  42812. */
  42813. onStateChangedObservable: Observable<WebXRState>;
  42814. /** Session manager used to keep track of xr session */
  42815. sessionManager: WebXRSessionManager;
  42816. private _nonVRCamera;
  42817. private _originalSceneAutoClear;
  42818. private _supported;
  42819. /**
  42820. * Creates the experience helper
  42821. * @param scene the scene to attach the experience helper to
  42822. * @returns a promise for the experience helper
  42823. */
  42824. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  42825. /**
  42826. * Creates a WebXRExperienceHelper
  42827. * @param scene The scene the helper should be created in
  42828. */
  42829. private constructor();
  42830. /**
  42831. * Exits XR mode and returns the scene to its original state
  42832. * @returns promise that resolves after xr mode has exited
  42833. */
  42834. exitXRAsync(): Promise<unknown>;
  42835. /**
  42836. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  42837. * @param sessionCreationOptions options for the XR session
  42838. * @param referenceSpaceType frame of reference of the XR session
  42839. * @param outputCanvas the output canvas that will be used to enter XR mode
  42840. * @returns promise that resolves after xr mode has entered
  42841. */
  42842. enterXRAsync(sessionCreationOptions: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, outputCanvas: WebXRManagedOutputCanvas): any;
  42843. /**
  42844. * Updates the global position of the camera by moving the camera's container
  42845. * This should be used instead of modifying the camera's position as it will be overwritten by an xrSessions's update frame
  42846. * @param position The desired global position of the camera
  42847. */
  42848. setPositionOfCameraUsingContainer(position: Vector3): void;
  42849. /**
  42850. * Rotates the xr camera by rotating the camera's container around the camera's position
  42851. * This should be used instead of modifying the camera's rotation as it will be overwritten by an xrSessions's update frame
  42852. * @param rotation the desired quaternion rotation to apply to the camera
  42853. */
  42854. rotateCameraByQuaternionUsingContainer(rotation: Quaternion): void;
  42855. /**
  42856. * Disposes of the experience helper
  42857. */
  42858. dispose(): void;
  42859. }
  42860. }
  42861. declare module "babylonjs/Cameras/XR/webXREnterExitUI" {
  42862. import { Nullable } from "babylonjs/types";
  42863. import { Observable } from "babylonjs/Misc/observable";
  42864. import { IDisposable, Scene } from "babylonjs/scene";
  42865. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  42866. import { WebXRManagedOutputCanvas } from "babylonjs/Cameras/XR/webXRManagedOutputCanvas";
  42867. /**
  42868. * Button which can be used to enter a different mode of XR
  42869. */
  42870. export class WebXREnterExitUIButton {
  42871. /** button element */
  42872. element: HTMLElement;
  42873. /** XR initialization options for the button */
  42874. sessionMode: XRSessionMode;
  42875. /** Reference space type */
  42876. referenceSpaceType: XRReferenceSpaceType;
  42877. /**
  42878. * Creates a WebXREnterExitUIButton
  42879. * @param element button element
  42880. * @param sessionMode XR initialization session mode
  42881. * @param referenceSpaceType the type of reference space to be used
  42882. */
  42883. constructor(
  42884. /** button element */
  42885. element: HTMLElement,
  42886. /** XR initialization options for the button */
  42887. sessionMode: XRSessionMode,
  42888. /** Reference space type */
  42889. referenceSpaceType: XRReferenceSpaceType);
  42890. /**
  42891. * Overwritable function which can be used to update the button's visuals when the state changes
  42892. * @param activeButton the current active button in the UI
  42893. */
  42894. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  42895. }
  42896. /**
  42897. * Options to create the webXR UI
  42898. */
  42899. export class WebXREnterExitUIOptions {
  42900. /**
  42901. * Context to enter xr with
  42902. */
  42903. webXRManagedOutputCanvas?: Nullable<WebXRManagedOutputCanvas>;
  42904. /**
  42905. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  42906. */
  42907. customButtons?: Array<WebXREnterExitUIButton>;
  42908. }
  42909. /**
  42910. * UI to allow the user to enter/exit XR mode
  42911. */
  42912. export class WebXREnterExitUI implements IDisposable {
  42913. private scene;
  42914. private _overlay;
  42915. private _buttons;
  42916. private _activeButton;
  42917. /**
  42918. * Fired every time the active button is changed.
  42919. *
  42920. * When xr is entered via a button that launches xr that button will be the callback parameter
  42921. *
  42922. * When exiting xr the callback parameter will be null)
  42923. */
  42924. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  42925. /**
  42926. * Creates UI to allow the user to enter/exit XR mode
  42927. * @param scene the scene to add the ui to
  42928. * @param helper the xr experience helper to enter/exit xr with
  42929. * @param options options to configure the UI
  42930. * @returns the created ui
  42931. */
  42932. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  42933. private constructor();
  42934. private _updateButtons;
  42935. /**
  42936. * Disposes of the object
  42937. */
  42938. dispose(): void;
  42939. }
  42940. }
  42941. declare module "babylonjs/Cameras/XR/webXRController" {
  42942. import { Nullable } from "babylonjs/types";
  42943. import { Observable } from "babylonjs/Misc/observable";
  42944. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42945. import { Ray } from "babylonjs/Culling/ray";
  42946. import { Scene } from "babylonjs/scene";
  42947. /**
  42948. * Represents an XR input
  42949. */
  42950. export class WebXRController {
  42951. private scene;
  42952. /** The underlying input source for the controller */
  42953. inputSource: XRInputSource;
  42954. private parentContainer;
  42955. /**
  42956. * 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
  42957. */
  42958. grip?: AbstractMesh;
  42959. /**
  42960. * Pointer which can be used to select objects or attach a visible laser to
  42961. */
  42962. pointer: AbstractMesh;
  42963. /**
  42964. * Event that fires when the controller is removed/disposed
  42965. */
  42966. onDisposeObservable: Observable<{}>;
  42967. private _tmpMatrix;
  42968. private _tmpQuaternion;
  42969. private _tmpVector;
  42970. /**
  42971. * Creates the controller
  42972. * @see https://doc.babylonjs.com/how_to/webxr
  42973. * @param scene the scene which the controller should be associated to
  42974. * @param inputSource the underlying input source for the controller
  42975. * @param parentContainer parent that the controller meshes should be children of
  42976. */
  42977. constructor(scene: Scene,
  42978. /** The underlying input source for the controller */
  42979. inputSource: XRInputSource, parentContainer?: Nullable<AbstractMesh>);
  42980. /**
  42981. * Updates the controller pose based on the given XRFrame
  42982. * @param xrFrame xr frame to update the pose with
  42983. * @param referenceSpace reference space to use
  42984. */
  42985. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  42986. /**
  42987. * Gets a world space ray coming from the controller
  42988. * @param result the resulting ray
  42989. */
  42990. getWorldPointerRayToRef(result: Ray): void;
  42991. /**
  42992. * Disposes of the object
  42993. */
  42994. dispose(): void;
  42995. }
  42996. }
  42997. declare module "babylonjs/Cameras/XR/webXRInput" {
  42998. import { Observable } from "babylonjs/Misc/observable";
  42999. import { IDisposable } from "babylonjs/scene";
  43000. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  43001. import { WebXRController } from "babylonjs/Cameras/XR/webXRController";
  43002. /**
  43003. * XR input used to track XR inputs such as controllers/rays
  43004. */
  43005. export class WebXRInput implements IDisposable {
  43006. /**
  43007. * Base experience the input listens to
  43008. */
  43009. baseExperience: WebXRExperienceHelper;
  43010. /**
  43011. * XR controllers being tracked
  43012. */
  43013. controllers: Array<WebXRController>;
  43014. private _frameObserver;
  43015. private _stateObserver;
  43016. /**
  43017. * Event when a controller has been connected/added
  43018. */
  43019. onControllerAddedObservable: Observable<WebXRController>;
  43020. /**
  43021. * Event when a controller has been removed/disconnected
  43022. */
  43023. onControllerRemovedObservable: Observable<WebXRController>;
  43024. /**
  43025. * Initializes the WebXRInput
  43026. * @param baseExperience experience helper which the input should be created for
  43027. */
  43028. constructor(
  43029. /**
  43030. * Base experience the input listens to
  43031. */
  43032. baseExperience: WebXRExperienceHelper);
  43033. private _onInputSourcesChange;
  43034. private _addAndRemoveControllers;
  43035. /**
  43036. * Disposes of the object
  43037. */
  43038. dispose(): void;
  43039. }
  43040. }
  43041. declare module "babylonjs/Cameras/XR/webXRControllerTeleportation" {
  43042. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43043. import { WebXRInput } from "babylonjs/Cameras/XR/webXRInput";
  43044. /**
  43045. * Enables teleportation
  43046. */
  43047. export class WebXRControllerTeleportation {
  43048. private _teleportationFillColor;
  43049. private _teleportationBorderColor;
  43050. private _tmpRay;
  43051. private _tmpVector;
  43052. /**
  43053. * Creates a WebXRControllerTeleportation
  43054. * @param input input manager to add teleportation to
  43055. * @param floorMeshes floormeshes which can be teleported to
  43056. */
  43057. constructor(input: WebXRInput, floorMeshes?: Array<AbstractMesh>);
  43058. }
  43059. }
  43060. declare module "babylonjs/Cameras/XR/webXRControllerPointerSelection" {
  43061. import { WebXRInput } from "babylonjs/Cameras/XR/webXRInput";
  43062. /**
  43063. * Handles pointer input automatically for the pointer of XR controllers
  43064. */
  43065. export class WebXRControllerPointerSelection {
  43066. private static _idCounter;
  43067. private _tmpRay;
  43068. /**
  43069. * Creates a WebXRControllerPointerSelection
  43070. * @param input input manager to setup pointer selection
  43071. */
  43072. constructor(input: WebXRInput);
  43073. private _convertNormalToDirectionOfRay;
  43074. private _updatePointerDistance;
  43075. }
  43076. }
  43077. declare module "babylonjs/Loading/sceneLoader" {
  43078. import { Observable } from "babylonjs/Misc/observable";
  43079. import { Nullable } from "babylonjs/types";
  43080. import { Scene } from "babylonjs/scene";
  43081. import { Engine } from "babylonjs/Engines/engine";
  43082. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43083. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  43084. import { AssetContainer } from "babylonjs/assetContainer";
  43085. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  43086. import { Skeleton } from "babylonjs/Bones/skeleton";
  43087. /**
  43088. * Class used to represent data loading progression
  43089. */
  43090. export class SceneLoaderProgressEvent {
  43091. /** defines if data length to load can be evaluated */
  43092. readonly lengthComputable: boolean;
  43093. /** defines the loaded data length */
  43094. readonly loaded: number;
  43095. /** defines the data length to load */
  43096. readonly total: number;
  43097. /**
  43098. * Create a new progress event
  43099. * @param lengthComputable defines if data length to load can be evaluated
  43100. * @param loaded defines the loaded data length
  43101. * @param total defines the data length to load
  43102. */
  43103. constructor(
  43104. /** defines if data length to load can be evaluated */
  43105. lengthComputable: boolean,
  43106. /** defines the loaded data length */
  43107. loaded: number,
  43108. /** defines the data length to load */
  43109. total: number);
  43110. /**
  43111. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  43112. * @param event defines the source event
  43113. * @returns a new SceneLoaderProgressEvent
  43114. */
  43115. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  43116. }
  43117. /**
  43118. * Interface used by SceneLoader plugins to define supported file extensions
  43119. */
  43120. export interface ISceneLoaderPluginExtensions {
  43121. /**
  43122. * Defines the list of supported extensions
  43123. */
  43124. [extension: string]: {
  43125. isBinary: boolean;
  43126. };
  43127. }
  43128. /**
  43129. * Interface used by SceneLoader plugin factory
  43130. */
  43131. export interface ISceneLoaderPluginFactory {
  43132. /**
  43133. * Defines the name of the factory
  43134. */
  43135. name: string;
  43136. /**
  43137. * Function called to create a new plugin
  43138. * @return the new plugin
  43139. */
  43140. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  43141. /**
  43142. * Boolean indicating if the plugin can direct load specific data
  43143. */
  43144. canDirectLoad?: (data: string) => boolean;
  43145. }
  43146. /**
  43147. * Interface used to define a SceneLoader plugin
  43148. */
  43149. export interface ISceneLoaderPlugin {
  43150. /**
  43151. * The friendly name of this plugin.
  43152. */
  43153. name: string;
  43154. /**
  43155. * The file extensions supported by this plugin.
  43156. */
  43157. extensions: string | ISceneLoaderPluginExtensions;
  43158. /**
  43159. * Import meshes into a scene.
  43160. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  43161. * @param scene The scene to import into
  43162. * @param data The data to import
  43163. * @param rootUrl The root url for scene and resources
  43164. * @param meshes The meshes array to import into
  43165. * @param particleSystems The particle systems array to import into
  43166. * @param skeletons The skeletons array to import into
  43167. * @param onError The callback when import fails
  43168. * @returns True if successful or false otherwise
  43169. */
  43170. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  43171. /**
  43172. * Load into a scene.
  43173. * @param scene The scene to load into
  43174. * @param data The data to import
  43175. * @param rootUrl The root url for scene and resources
  43176. * @param onError The callback when import fails
  43177. * @returns true if successful or false otherwise
  43178. */
  43179. load(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  43180. /**
  43181. * The callback that returns true if the data can be directly loaded.
  43182. */
  43183. canDirectLoad?: (data: string) => boolean;
  43184. /**
  43185. * The callback that allows custom handling of the root url based on the response url.
  43186. */
  43187. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  43188. /**
  43189. * Load into an asset container.
  43190. * @param scene The scene to load into
  43191. * @param data The data to import
  43192. * @param rootUrl The root url for scene and resources
  43193. * @param onError The callback when import fails
  43194. * @returns The loaded asset container
  43195. */
  43196. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  43197. }
  43198. /**
  43199. * Interface used to define an async SceneLoader plugin
  43200. */
  43201. export interface ISceneLoaderPluginAsync {
  43202. /**
  43203. * The friendly name of this plugin.
  43204. */
  43205. name: string;
  43206. /**
  43207. * The file extensions supported by this plugin.
  43208. */
  43209. extensions: string | ISceneLoaderPluginExtensions;
  43210. /**
  43211. * Import meshes into a scene.
  43212. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  43213. * @param scene The scene to import into
  43214. * @param data The data to import
  43215. * @param rootUrl The root url for scene and resources
  43216. * @param onProgress The callback when the load progresses
  43217. * @param fileName Defines the name of the file to load
  43218. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  43219. */
  43220. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  43221. meshes: AbstractMesh[];
  43222. particleSystems: IParticleSystem[];
  43223. skeletons: Skeleton[];
  43224. animationGroups: AnimationGroup[];
  43225. }>;
  43226. /**
  43227. * Load into a scene.
  43228. * @param scene The scene to load into
  43229. * @param data The data to import
  43230. * @param rootUrl The root url for scene and resources
  43231. * @param onProgress The callback when the load progresses
  43232. * @param fileName Defines the name of the file to load
  43233. * @returns Nothing
  43234. */
  43235. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  43236. /**
  43237. * The callback that returns true if the data can be directly loaded.
  43238. */
  43239. canDirectLoad?: (data: string) => boolean;
  43240. /**
  43241. * The callback that allows custom handling of the root url based on the response url.
  43242. */
  43243. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  43244. /**
  43245. * Load into an asset container.
  43246. * @param scene The scene to load into
  43247. * @param data The data to import
  43248. * @param rootUrl The root url for scene and resources
  43249. * @param onProgress The callback when the load progresses
  43250. * @param fileName Defines the name of the file to load
  43251. * @returns The loaded asset container
  43252. */
  43253. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  43254. }
  43255. /**
  43256. * Class used to load scene from various file formats using registered plugins
  43257. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  43258. */
  43259. export class SceneLoader {
  43260. /**
  43261. * No logging while loading
  43262. */
  43263. static readonly NO_LOGGING: number;
  43264. /**
  43265. * Minimal logging while loading
  43266. */
  43267. static readonly MINIMAL_LOGGING: number;
  43268. /**
  43269. * Summary logging while loading
  43270. */
  43271. static readonly SUMMARY_LOGGING: number;
  43272. /**
  43273. * Detailled logging while loading
  43274. */
  43275. static readonly DETAILED_LOGGING: number;
  43276. /**
  43277. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  43278. */
  43279. static ForceFullSceneLoadingForIncremental: boolean;
  43280. /**
  43281. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  43282. */
  43283. static ShowLoadingScreen: boolean;
  43284. /**
  43285. * Defines the current logging level (while loading the scene)
  43286. * @ignorenaming
  43287. */
  43288. static loggingLevel: number;
  43289. /**
  43290. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  43291. */
  43292. static CleanBoneMatrixWeights: boolean;
  43293. /**
  43294. * Event raised when a plugin is used to load a scene
  43295. */
  43296. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  43297. private static _registeredPlugins;
  43298. private static _getDefaultPlugin;
  43299. private static _getPluginForExtension;
  43300. private static _getPluginForDirectLoad;
  43301. private static _getPluginForFilename;
  43302. private static _getDirectLoad;
  43303. private static _loadData;
  43304. private static _getFileInfo;
  43305. /**
  43306. * Gets a plugin that can load the given extension
  43307. * @param extension defines the extension to load
  43308. * @returns a plugin or null if none works
  43309. */
  43310. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  43311. /**
  43312. * Gets a boolean indicating that the given extension can be loaded
  43313. * @param extension defines the extension to load
  43314. * @returns true if the extension is supported
  43315. */
  43316. static IsPluginForExtensionAvailable(extension: string): boolean;
  43317. /**
  43318. * Adds a new plugin to the list of registered plugins
  43319. * @param plugin defines the plugin to add
  43320. */
  43321. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  43322. /**
  43323. * Import meshes into a scene
  43324. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  43325. * @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)
  43326. * @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)
  43327. * @param scene the instance of BABYLON.Scene to append to
  43328. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  43329. * @param onProgress a callback with a progress event for each file being loaded
  43330. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43331. * @param pluginExtension the extension used to determine the plugin
  43332. * @returns The loaded plugin
  43333. */
  43334. 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>;
  43335. /**
  43336. * Import meshes into a scene
  43337. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  43338. * @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)
  43339. * @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)
  43340. * @param scene the instance of BABYLON.Scene to append to
  43341. * @param onProgress a callback with a progress event for each file being loaded
  43342. * @param pluginExtension the extension used to determine the plugin
  43343. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  43344. */
  43345. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  43346. meshes: AbstractMesh[];
  43347. particleSystems: IParticleSystem[];
  43348. skeletons: Skeleton[];
  43349. animationGroups: AnimationGroup[];
  43350. }>;
  43351. /**
  43352. * Load a scene
  43353. * @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)
  43354. * @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)
  43355. * @param engine is the instance of BABYLON.Engine to use to create the scene
  43356. * @param onSuccess a callback with the scene when import succeeds
  43357. * @param onProgress a callback with a progress event for each file being loaded
  43358. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43359. * @param pluginExtension the extension used to determine the plugin
  43360. * @returns The loaded plugin
  43361. */
  43362. 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>;
  43363. /**
  43364. * Load a scene
  43365. * @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)
  43366. * @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)
  43367. * @param engine is the instance of BABYLON.Engine to use to create the scene
  43368. * @param onProgress a callback with a progress event for each file being loaded
  43369. * @param pluginExtension the extension used to determine the plugin
  43370. * @returns The loaded scene
  43371. */
  43372. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  43373. /**
  43374. * Append a scene
  43375. * @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)
  43376. * @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)
  43377. * @param scene is the instance of BABYLON.Scene to append to
  43378. * @param onSuccess a callback with the scene when import succeeds
  43379. * @param onProgress a callback with a progress event for each file being loaded
  43380. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43381. * @param pluginExtension the extension used to determine the plugin
  43382. * @returns The loaded plugin
  43383. */
  43384. 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>;
  43385. /**
  43386. * Append a scene
  43387. * @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)
  43388. * @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)
  43389. * @param scene is the instance of BABYLON.Scene to append to
  43390. * @param onProgress a callback with a progress event for each file being loaded
  43391. * @param pluginExtension the extension used to determine the plugin
  43392. * @returns The given scene
  43393. */
  43394. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  43395. /**
  43396. * Load a scene into an asset container
  43397. * @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)
  43398. * @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)
  43399. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  43400. * @param onSuccess a callback with the scene when import succeeds
  43401. * @param onProgress a callback with a progress event for each file being loaded
  43402. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43403. * @param pluginExtension the extension used to determine the plugin
  43404. * @returns The loaded plugin
  43405. */
  43406. 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>;
  43407. /**
  43408. * Load a scene into an asset container
  43409. * @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)
  43410. * @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)
  43411. * @param scene is the instance of Scene to append to
  43412. * @param onProgress a callback with a progress event for each file being loaded
  43413. * @param pluginExtension the extension used to determine the plugin
  43414. * @returns The loaded asset container
  43415. */
  43416. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  43417. }
  43418. }
  43419. declare module "babylonjs/Gamepads/Controllers/genericController" {
  43420. import { Scene } from "babylonjs/scene";
  43421. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43422. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  43423. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  43424. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  43425. /**
  43426. * Generic Controller
  43427. */
  43428. export class GenericController extends WebVRController {
  43429. /**
  43430. * Base Url for the controller model.
  43431. */
  43432. static readonly MODEL_BASE_URL: string;
  43433. /**
  43434. * File name for the controller model.
  43435. */
  43436. static readonly MODEL_FILENAME: string;
  43437. /**
  43438. * Creates a new GenericController from a gamepad
  43439. * @param vrGamepad the gamepad that the controller should be created from
  43440. */
  43441. constructor(vrGamepad: any);
  43442. /**
  43443. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43444. * @param scene scene in which to add meshes
  43445. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43446. */
  43447. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  43448. /**
  43449. * Called once for each button that changed state since the last frame
  43450. * @param buttonIdx Which button index changed
  43451. * @param state New state of the button
  43452. * @param changes Which properties on the state changed since last frame
  43453. */
  43454. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43455. }
  43456. }
  43457. declare module "babylonjs/Gamepads/Controllers/windowsMotionController" {
  43458. import { Observable } from "babylonjs/Misc/observable";
  43459. import { Scene } from "babylonjs/scene";
  43460. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43461. import { Ray } from "babylonjs/Culling/ray";
  43462. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  43463. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  43464. import { StickValues, GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  43465. /**
  43466. * Defines the WindowsMotionController object that the state of the windows motion controller
  43467. */
  43468. export class WindowsMotionController extends WebVRController {
  43469. /**
  43470. * The base url used to load the left and right controller models
  43471. */
  43472. static MODEL_BASE_URL: string;
  43473. /**
  43474. * The name of the left controller model file
  43475. */
  43476. static MODEL_LEFT_FILENAME: string;
  43477. /**
  43478. * The name of the right controller model file
  43479. */
  43480. static MODEL_RIGHT_FILENAME: string;
  43481. /**
  43482. * The controller name prefix for this controller type
  43483. */
  43484. static readonly GAMEPAD_ID_PREFIX: string;
  43485. /**
  43486. * The controller id pattern for this controller type
  43487. */
  43488. private static readonly GAMEPAD_ID_PATTERN;
  43489. private _loadedMeshInfo;
  43490. private readonly _mapping;
  43491. /**
  43492. * Fired when the trackpad on this controller is clicked
  43493. */
  43494. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  43495. /**
  43496. * Fired when the trackpad on this controller is modified
  43497. */
  43498. onTrackpadValuesChangedObservable: Observable<StickValues>;
  43499. /**
  43500. * The current x and y values of this controller's trackpad
  43501. */
  43502. trackpad: StickValues;
  43503. /**
  43504. * Creates a new WindowsMotionController from a gamepad
  43505. * @param vrGamepad the gamepad that the controller should be created from
  43506. */
  43507. constructor(vrGamepad: any);
  43508. /**
  43509. * Fired when the trigger on this controller is modified
  43510. */
  43511. readonly onTriggerButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43512. /**
  43513. * Fired when the menu button on this controller is modified
  43514. */
  43515. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43516. /**
  43517. * Fired when the grip button on this controller is modified
  43518. */
  43519. readonly onGripButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43520. /**
  43521. * Fired when the thumbstick button on this controller is modified
  43522. */
  43523. readonly onThumbstickButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43524. /**
  43525. * Fired when the touchpad button on this controller is modified
  43526. */
  43527. readonly onTouchpadButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43528. /**
  43529. * Fired when the touchpad values on this controller are modified
  43530. */
  43531. readonly onTouchpadValuesChangedObservable: Observable<StickValues>;
  43532. private _updateTrackpad;
  43533. /**
  43534. * Called once per frame by the engine.
  43535. */
  43536. update(): void;
  43537. /**
  43538. * Called once for each button that changed state since the last frame
  43539. * @param buttonIdx Which button index changed
  43540. * @param state New state of the button
  43541. * @param changes Which properties on the state changed since last frame
  43542. */
  43543. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43544. /**
  43545. * Moves the buttons on the controller mesh based on their current state
  43546. * @param buttonName the name of the button to move
  43547. * @param buttonValue the value of the button which determines the buttons new position
  43548. */
  43549. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  43550. /**
  43551. * Moves the axis on the controller mesh based on its current state
  43552. * @param axis the index of the axis
  43553. * @param axisValue the value of the axis which determines the meshes new position
  43554. * @hidden
  43555. */
  43556. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  43557. /**
  43558. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43559. * @param scene scene in which to add meshes
  43560. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43561. */
  43562. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  43563. /**
  43564. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  43565. * can be transformed by button presses and axes values, based on this._mapping.
  43566. *
  43567. * @param scene scene in which the meshes exist
  43568. * @param meshes list of meshes that make up the controller model to process
  43569. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  43570. */
  43571. private processModel;
  43572. private createMeshInfo;
  43573. /**
  43574. * Gets the ray of the controller in the direction the controller is pointing
  43575. * @param length the length the resulting ray should be
  43576. * @returns a ray in the direction the controller is pointing
  43577. */
  43578. getForwardRay(length?: number): Ray;
  43579. /**
  43580. * Disposes of the controller
  43581. */
  43582. dispose(): void;
  43583. }
  43584. }
  43585. declare module "babylonjs/Gamepads/Controllers/oculusTouchController" {
  43586. import { Observable } from "babylonjs/Misc/observable";
  43587. import { Scene } from "babylonjs/scene";
  43588. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43589. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  43590. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  43591. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  43592. /**
  43593. * Oculus Touch Controller
  43594. */
  43595. export class OculusTouchController extends WebVRController {
  43596. /**
  43597. * Base Url for the controller model.
  43598. */
  43599. static MODEL_BASE_URL: string;
  43600. /**
  43601. * File name for the left controller model.
  43602. */
  43603. static MODEL_LEFT_FILENAME: string;
  43604. /**
  43605. * File name for the right controller model.
  43606. */
  43607. static MODEL_RIGHT_FILENAME: string;
  43608. /**
  43609. * Base Url for the Quest controller model.
  43610. */
  43611. static QUEST_MODEL_BASE_URL: string;
  43612. /**
  43613. * @hidden
  43614. * If the controllers are running on a device that needs the updated Quest controller models
  43615. */
  43616. static _IsQuest: boolean;
  43617. /**
  43618. * Fired when the secondary trigger on this controller is modified
  43619. */
  43620. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  43621. /**
  43622. * Fired when the thumb rest on this controller is modified
  43623. */
  43624. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  43625. /**
  43626. * Creates a new OculusTouchController from a gamepad
  43627. * @param vrGamepad the gamepad that the controller should be created from
  43628. */
  43629. constructor(vrGamepad: any);
  43630. /**
  43631. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43632. * @param scene scene in which to add meshes
  43633. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43634. */
  43635. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  43636. /**
  43637. * Fired when the A button on this controller is modified
  43638. */
  43639. readonly onAButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43640. /**
  43641. * Fired when the B button on this controller is modified
  43642. */
  43643. readonly onBButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43644. /**
  43645. * Fired when the X button on this controller is modified
  43646. */
  43647. readonly onXButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43648. /**
  43649. * Fired when the Y button on this controller is modified
  43650. */
  43651. readonly onYButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43652. /**
  43653. * Called once for each button that changed state since the last frame
  43654. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  43655. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  43656. * 2) secondary trigger (same)
  43657. * 3) A (right) X (left), touch, pressed = value
  43658. * 4) B / Y
  43659. * 5) thumb rest
  43660. * @param buttonIdx Which button index changed
  43661. * @param state New state of the button
  43662. * @param changes Which properties on the state changed since last frame
  43663. */
  43664. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43665. }
  43666. }
  43667. declare module "babylonjs/Gamepads/Controllers/viveController" {
  43668. import { Scene } from "babylonjs/scene";
  43669. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43670. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  43671. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  43672. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  43673. import { Observable } from "babylonjs/Misc/observable";
  43674. /**
  43675. * Vive Controller
  43676. */
  43677. export class ViveController extends WebVRController {
  43678. /**
  43679. * Base Url for the controller model.
  43680. */
  43681. static MODEL_BASE_URL: string;
  43682. /**
  43683. * File name for the controller model.
  43684. */
  43685. static MODEL_FILENAME: string;
  43686. /**
  43687. * Creates a new ViveController from a gamepad
  43688. * @param vrGamepad the gamepad that the controller should be created from
  43689. */
  43690. constructor(vrGamepad: any);
  43691. /**
  43692. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43693. * @param scene scene in which to add meshes
  43694. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43695. */
  43696. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  43697. /**
  43698. * Fired when the left button on this controller is modified
  43699. */
  43700. readonly onLeftButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43701. /**
  43702. * Fired when the right button on this controller is modified
  43703. */
  43704. readonly onRightButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43705. /**
  43706. * Fired when the menu button on this controller is modified
  43707. */
  43708. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43709. /**
  43710. * Called once for each button that changed state since the last frame
  43711. * Vive mapping:
  43712. * 0: touchpad
  43713. * 1: trigger
  43714. * 2: left AND right buttons
  43715. * 3: menu button
  43716. * @param buttonIdx Which button index changed
  43717. * @param state New state of the button
  43718. * @param changes Which properties on the state changed since last frame
  43719. */
  43720. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43721. }
  43722. }
  43723. declare module "babylonjs/Cameras/XR/webXRControllerModelLoader" {
  43724. import { WebXRInput } from "babylonjs/Cameras/XR/webXRInput";
  43725. /**
  43726. * Loads a controller model and adds it as a child of the WebXRControllers grip when the controller is created
  43727. */
  43728. export class WebXRControllerModelLoader {
  43729. /**
  43730. * Creates the WebXRControllerModelLoader
  43731. * @param input xr input that creates the controllers
  43732. */
  43733. constructor(input: WebXRInput);
  43734. }
  43735. }
  43736. declare module "babylonjs/Cameras/XR/index" {
  43737. export * from "babylonjs/Cameras/XR/webXRCamera";
  43738. export * from "babylonjs/Cameras/XR/webXREnterExitUI";
  43739. export * from "babylonjs/Cameras/XR/webXRExperienceHelper";
  43740. export * from "babylonjs/Cameras/XR/webXRInput";
  43741. export * from "babylonjs/Cameras/XR/webXRControllerTeleportation";
  43742. export * from "babylonjs/Cameras/XR/webXRControllerPointerSelection";
  43743. export * from "babylonjs/Cameras/XR/webXRControllerModelLoader";
  43744. export * from "babylonjs/Cameras/XR/webXRController";
  43745. export * from "babylonjs/Cameras/XR/webXRManagedOutputCanvas";
  43746. export * from "babylonjs/Cameras/XR/webXRSessionManager";
  43747. }
  43748. declare module "babylonjs/Cameras/RigModes/index" {
  43749. export * from "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  43750. export * from "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  43751. export * from "babylonjs/Cameras/RigModes/vrRigMode";
  43752. export * from "babylonjs/Cameras/RigModes/webVRRigMode";
  43753. }
  43754. declare module "babylonjs/Cameras/index" {
  43755. export * from "babylonjs/Cameras/Inputs/index";
  43756. export * from "babylonjs/Cameras/cameraInputsManager";
  43757. export * from "babylonjs/Cameras/camera";
  43758. export * from "babylonjs/Cameras/targetCamera";
  43759. export * from "babylonjs/Cameras/freeCamera";
  43760. export * from "babylonjs/Cameras/freeCameraInputsManager";
  43761. export * from "babylonjs/Cameras/touchCamera";
  43762. export * from "babylonjs/Cameras/arcRotateCamera";
  43763. export * from "babylonjs/Cameras/arcRotateCameraInputsManager";
  43764. export * from "babylonjs/Cameras/deviceOrientationCamera";
  43765. export * from "babylonjs/Cameras/flyCamera";
  43766. export * from "babylonjs/Cameras/flyCameraInputsManager";
  43767. export * from "babylonjs/Cameras/followCamera";
  43768. export * from "babylonjs/Cameras/followCameraInputsManager";
  43769. export * from "babylonjs/Cameras/gamepadCamera";
  43770. export * from "babylonjs/Cameras/Stereoscopic/index";
  43771. export * from "babylonjs/Cameras/universalCamera";
  43772. export * from "babylonjs/Cameras/virtualJoysticksCamera";
  43773. export * from "babylonjs/Cameras/VR/index";
  43774. export * from "babylonjs/Cameras/XR/index";
  43775. export * from "babylonjs/Cameras/RigModes/index";
  43776. }
  43777. declare module "babylonjs/Collisions/index" {
  43778. export * from "babylonjs/Collisions/collider";
  43779. export * from "babylonjs/Collisions/collisionCoordinator";
  43780. export * from "babylonjs/Collisions/pickingInfo";
  43781. export * from "babylonjs/Collisions/intersectionInfo";
  43782. export * from "babylonjs/Collisions/meshCollisionData";
  43783. }
  43784. declare module "babylonjs/Culling/Octrees/octreeBlock" {
  43785. import { SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  43786. import { Vector3 } from "babylonjs/Maths/math.vector";
  43787. import { Ray } from "babylonjs/Culling/ray";
  43788. import { Plane } from "babylonjs/Maths/math.plane";
  43789. /**
  43790. * Contains an array of blocks representing the octree
  43791. */
  43792. export interface IOctreeContainer<T> {
  43793. /**
  43794. * Blocks within the octree
  43795. */
  43796. blocks: Array<OctreeBlock<T>>;
  43797. }
  43798. /**
  43799. * Class used to store a cell in an octree
  43800. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  43801. */
  43802. export class OctreeBlock<T> {
  43803. /**
  43804. * Gets the content of the current block
  43805. */
  43806. entries: T[];
  43807. /**
  43808. * Gets the list of block children
  43809. */
  43810. blocks: Array<OctreeBlock<T>>;
  43811. private _depth;
  43812. private _maxDepth;
  43813. private _capacity;
  43814. private _minPoint;
  43815. private _maxPoint;
  43816. private _boundingVectors;
  43817. private _creationFunc;
  43818. /**
  43819. * Creates a new block
  43820. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  43821. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  43822. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  43823. * @param depth defines the current depth of this block in the octree
  43824. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  43825. * @param creationFunc defines a callback to call when an element is added to the block
  43826. */
  43827. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  43828. /**
  43829. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  43830. */
  43831. readonly capacity: number;
  43832. /**
  43833. * Gets the minimum vector (in world space) of the block's bounding box
  43834. */
  43835. readonly minPoint: Vector3;
  43836. /**
  43837. * Gets the maximum vector (in world space) of the block's bounding box
  43838. */
  43839. readonly maxPoint: Vector3;
  43840. /**
  43841. * Add a new element to this block
  43842. * @param entry defines the element to add
  43843. */
  43844. addEntry(entry: T): void;
  43845. /**
  43846. * Remove an element from this block
  43847. * @param entry defines the element to remove
  43848. */
  43849. removeEntry(entry: T): void;
  43850. /**
  43851. * Add an array of elements to this block
  43852. * @param entries defines the array of elements to add
  43853. */
  43854. addEntries(entries: T[]): void;
  43855. /**
  43856. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  43857. * @param frustumPlanes defines the frustum planes to test
  43858. * @param selection defines the array to store current content if selection is positive
  43859. * @param allowDuplicate defines if the selection array can contains duplicated entries
  43860. */
  43861. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  43862. /**
  43863. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  43864. * @param sphereCenter defines the bounding sphere center
  43865. * @param sphereRadius defines the bounding sphere radius
  43866. * @param selection defines the array to store current content if selection is positive
  43867. * @param allowDuplicate defines if the selection array can contains duplicated entries
  43868. */
  43869. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  43870. /**
  43871. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  43872. * @param ray defines the ray to test with
  43873. * @param selection defines the array to store current content if selection is positive
  43874. */
  43875. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  43876. /**
  43877. * Subdivide the content into child blocks (this block will then be empty)
  43878. */
  43879. createInnerBlocks(): void;
  43880. /**
  43881. * @hidden
  43882. */
  43883. 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;
  43884. }
  43885. }
  43886. declare module "babylonjs/Culling/Octrees/octree" {
  43887. import { SmartArray } from "babylonjs/Misc/smartArray";
  43888. import { Vector3 } from "babylonjs/Maths/math.vector";
  43889. import { SubMesh } from "babylonjs/Meshes/subMesh";
  43890. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43891. import { Ray } from "babylonjs/Culling/ray";
  43892. import { OctreeBlock } from "babylonjs/Culling/Octrees/octreeBlock";
  43893. import { Plane } from "babylonjs/Maths/math.plane";
  43894. /**
  43895. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  43896. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  43897. */
  43898. export class Octree<T> {
  43899. /** 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.) */
  43900. maxDepth: number;
  43901. /**
  43902. * Blocks within the octree containing objects
  43903. */
  43904. blocks: Array<OctreeBlock<T>>;
  43905. /**
  43906. * Content stored in the octree
  43907. */
  43908. dynamicContent: T[];
  43909. private _maxBlockCapacity;
  43910. private _selectionContent;
  43911. private _creationFunc;
  43912. /**
  43913. * Creates a octree
  43914. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  43915. * @param creationFunc function to be used to instatiate the octree
  43916. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  43917. * @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.)
  43918. */
  43919. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  43920. /** 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.) */
  43921. maxDepth?: number);
  43922. /**
  43923. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  43924. * @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);
  43925. * @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);
  43926. * @param entries meshes to be added to the octree blocks
  43927. */
  43928. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  43929. /**
  43930. * Adds a mesh to the octree
  43931. * @param entry Mesh to add to the octree
  43932. */
  43933. addMesh(entry: T): void;
  43934. /**
  43935. * Remove an element from the octree
  43936. * @param entry defines the element to remove
  43937. */
  43938. removeMesh(entry: T): void;
  43939. /**
  43940. * Selects an array of meshes within the frustum
  43941. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  43942. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  43943. * @returns array of meshes within the frustum
  43944. */
  43945. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  43946. /**
  43947. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  43948. * @param sphereCenter defines the bounding sphere center
  43949. * @param sphereRadius defines the bounding sphere radius
  43950. * @param allowDuplicate defines if the selection array can contains duplicated entries
  43951. * @returns an array of objects that intersect the sphere
  43952. */
  43953. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  43954. /**
  43955. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  43956. * @param ray defines the ray to test with
  43957. * @returns array of intersected objects
  43958. */
  43959. intersectsRay(ray: Ray): SmartArray<T>;
  43960. /**
  43961. * Adds a mesh into the octree block if it intersects the block
  43962. */
  43963. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  43964. /**
  43965. * Adds a submesh into the octree block if it intersects the block
  43966. */
  43967. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  43968. }
  43969. }
  43970. declare module "babylonjs/Culling/Octrees/octreeSceneComponent" {
  43971. import { ISmartArrayLike } from "babylonjs/Misc/smartArray";
  43972. import { Scene } from "babylonjs/scene";
  43973. import { SubMesh } from "babylonjs/Meshes/subMesh";
  43974. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43975. import { Ray } from "babylonjs/Culling/ray";
  43976. import { Octree } from "babylonjs/Culling/Octrees/octree";
  43977. import { Collider } from "babylonjs/Collisions/collider";
  43978. module "babylonjs/scene" {
  43979. interface Scene {
  43980. /**
  43981. * @hidden
  43982. * Backing Filed
  43983. */
  43984. _selectionOctree: Octree<AbstractMesh>;
  43985. /**
  43986. * Gets the octree used to boost mesh selection (picking)
  43987. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  43988. */
  43989. selectionOctree: Octree<AbstractMesh>;
  43990. /**
  43991. * Creates or updates the octree used to boost selection (picking)
  43992. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  43993. * @param maxCapacity defines the maximum capacity per leaf
  43994. * @param maxDepth defines the maximum depth of the octree
  43995. * @returns an octree of AbstractMesh
  43996. */
  43997. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  43998. }
  43999. }
  44000. module "babylonjs/Meshes/abstractMesh" {
  44001. interface AbstractMesh {
  44002. /**
  44003. * @hidden
  44004. * Backing Field
  44005. */
  44006. _submeshesOctree: Octree<SubMesh>;
  44007. /**
  44008. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  44009. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  44010. * @param maxCapacity defines the maximum size of each block (64 by default)
  44011. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  44012. * @returns the new octree
  44013. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  44014. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  44015. */
  44016. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  44017. }
  44018. }
  44019. /**
  44020. * Defines the octree scene component responsible to manage any octrees
  44021. * in a given scene.
  44022. */
  44023. export class OctreeSceneComponent {
  44024. /**
  44025. * The component name help to identify the component in the list of scene components.
  44026. */
  44027. readonly name: string;
  44028. /**
  44029. * The scene the component belongs to.
  44030. */
  44031. scene: Scene;
  44032. /**
  44033. * Indicates if the meshes have been checked to make sure they are isEnabled()
  44034. */
  44035. readonly checksIsEnabled: boolean;
  44036. /**
  44037. * Creates a new instance of the component for the given scene
  44038. * @param scene Defines the scene to register the component in
  44039. */
  44040. constructor(scene: Scene);
  44041. /**
  44042. * Registers the component in a given scene
  44043. */
  44044. register(): void;
  44045. /**
  44046. * Return the list of active meshes
  44047. * @returns the list of active meshes
  44048. */
  44049. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  44050. /**
  44051. * Return the list of active sub meshes
  44052. * @param mesh The mesh to get the candidates sub meshes from
  44053. * @returns the list of active sub meshes
  44054. */
  44055. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  44056. private _tempRay;
  44057. /**
  44058. * Return the list of sub meshes intersecting with a given local ray
  44059. * @param mesh defines the mesh to find the submesh for
  44060. * @param localRay defines the ray in local space
  44061. * @returns the list of intersecting sub meshes
  44062. */
  44063. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  44064. /**
  44065. * Return the list of sub meshes colliding with a collider
  44066. * @param mesh defines the mesh to find the submesh for
  44067. * @param collider defines the collider to evaluate the collision against
  44068. * @returns the list of colliding sub meshes
  44069. */
  44070. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  44071. /**
  44072. * Rebuilds the elements related to this component in case of
  44073. * context lost for instance.
  44074. */
  44075. rebuild(): void;
  44076. /**
  44077. * Disposes the component and the associated ressources.
  44078. */
  44079. dispose(): void;
  44080. }
  44081. }
  44082. declare module "babylonjs/Culling/Octrees/index" {
  44083. export * from "babylonjs/Culling/Octrees/octree";
  44084. export * from "babylonjs/Culling/Octrees/octreeBlock";
  44085. export * from "babylonjs/Culling/Octrees/octreeSceneComponent";
  44086. }
  44087. declare module "babylonjs/Culling/index" {
  44088. export * from "babylonjs/Culling/boundingBox";
  44089. export * from "babylonjs/Culling/boundingInfo";
  44090. export * from "babylonjs/Culling/boundingSphere";
  44091. export * from "babylonjs/Culling/Octrees/index";
  44092. export * from "babylonjs/Culling/ray";
  44093. }
  44094. declare module "babylonjs/Rendering/utilityLayerRenderer" {
  44095. import { IDisposable, Scene } from "babylonjs/scene";
  44096. import { Nullable } from "babylonjs/types";
  44097. import { Observable } from "babylonjs/Misc/observable";
  44098. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44099. import { HemisphericLight } from "babylonjs/Lights/hemisphericLight";
  44100. import { Camera } from "babylonjs/Cameras/camera";
  44101. /**
  44102. * Renders a layer on top of an existing scene
  44103. */
  44104. export class UtilityLayerRenderer implements IDisposable {
  44105. /** the original scene that will be rendered on top of */
  44106. originalScene: Scene;
  44107. private _pointerCaptures;
  44108. private _lastPointerEvents;
  44109. private static _DefaultUtilityLayer;
  44110. private static _DefaultKeepDepthUtilityLayer;
  44111. private _sharedGizmoLight;
  44112. private _renderCamera;
  44113. /**
  44114. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  44115. * @returns the camera that is used when rendering the utility layer
  44116. */
  44117. getRenderCamera(): Nullable<Camera>;
  44118. /**
  44119. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  44120. * @param cam the camera that should be used when rendering the utility layer
  44121. */
  44122. setRenderCamera(cam: Nullable<Camera>): void;
  44123. /**
  44124. * @hidden
  44125. * Light which used by gizmos to get light shading
  44126. */
  44127. _getSharedGizmoLight(): HemisphericLight;
  44128. /**
  44129. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  44130. */
  44131. pickUtilitySceneFirst: boolean;
  44132. /**
  44133. * 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)
  44134. */
  44135. static readonly DefaultUtilityLayer: UtilityLayerRenderer;
  44136. /**
  44137. * 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)
  44138. */
  44139. static readonly DefaultKeepDepthUtilityLayer: UtilityLayerRenderer;
  44140. /**
  44141. * The scene that is rendered on top of the original scene
  44142. */
  44143. utilityLayerScene: Scene;
  44144. /**
  44145. * If the utility layer should automatically be rendered on top of existing scene
  44146. */
  44147. shouldRender: boolean;
  44148. /**
  44149. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  44150. */
  44151. onlyCheckPointerDownEvents: boolean;
  44152. /**
  44153. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  44154. */
  44155. processAllEvents: boolean;
  44156. /**
  44157. * Observable raised when the pointer move from the utility layer scene to the main scene
  44158. */
  44159. onPointerOutObservable: Observable<number>;
  44160. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  44161. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  44162. private _afterRenderObserver;
  44163. private _sceneDisposeObserver;
  44164. private _originalPointerObserver;
  44165. /**
  44166. * Instantiates a UtilityLayerRenderer
  44167. * @param originalScene the original scene that will be rendered on top of
  44168. * @param handleEvents boolean indicating if the utility layer should handle events
  44169. */
  44170. constructor(
  44171. /** the original scene that will be rendered on top of */
  44172. originalScene: Scene, handleEvents?: boolean);
  44173. private _notifyObservers;
  44174. /**
  44175. * Renders the utility layers scene on top of the original scene
  44176. */
  44177. render(): void;
  44178. /**
  44179. * Disposes of the renderer
  44180. */
  44181. dispose(): void;
  44182. private _updateCamera;
  44183. }
  44184. }
  44185. declare module "babylonjs/Gizmos/gizmo" {
  44186. import { Nullable } from "babylonjs/types";
  44187. import { IDisposable } from "babylonjs/scene";
  44188. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44189. import { Mesh } from "babylonjs/Meshes/mesh";
  44190. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  44191. /**
  44192. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  44193. */
  44194. export class Gizmo implements IDisposable {
  44195. /** The utility layer the gizmo will be added to */
  44196. gizmoLayer: UtilityLayerRenderer;
  44197. /**
  44198. * The root mesh of the gizmo
  44199. */
  44200. _rootMesh: Mesh;
  44201. private _attachedMesh;
  44202. /**
  44203. * Ratio for the scale of the gizmo (Default: 1)
  44204. */
  44205. scaleRatio: number;
  44206. /**
  44207. * If a custom mesh has been set (Default: false)
  44208. */
  44209. protected _customMeshSet: boolean;
  44210. /**
  44211. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  44212. * * When set, interactions will be enabled
  44213. */
  44214. attachedMesh: Nullable<AbstractMesh>;
  44215. /**
  44216. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  44217. * @param mesh The mesh to replace the default mesh of the gizmo
  44218. */
  44219. setCustomMesh(mesh: Mesh): void;
  44220. /**
  44221. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  44222. */
  44223. updateGizmoRotationToMatchAttachedMesh: boolean;
  44224. /**
  44225. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  44226. */
  44227. updateGizmoPositionToMatchAttachedMesh: boolean;
  44228. /**
  44229. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  44230. */
  44231. updateScale: boolean;
  44232. protected _interactionsEnabled: boolean;
  44233. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  44234. private _beforeRenderObserver;
  44235. private _tempVector;
  44236. /**
  44237. * Creates a gizmo
  44238. * @param gizmoLayer The utility layer the gizmo will be added to
  44239. */
  44240. constructor(
  44241. /** The utility layer the gizmo will be added to */
  44242. gizmoLayer?: UtilityLayerRenderer);
  44243. /**
  44244. * Updates the gizmo to match the attached mesh's position/rotation
  44245. */
  44246. protected _update(): void;
  44247. /**
  44248. * Disposes of the gizmo
  44249. */
  44250. dispose(): void;
  44251. }
  44252. }
  44253. declare module "babylonjs/Gizmos/planeDragGizmo" {
  44254. import { Observable } from "babylonjs/Misc/observable";
  44255. import { Nullable } from "babylonjs/types";
  44256. import { Vector3 } from "babylonjs/Maths/math.vector";
  44257. import { Color3 } from "babylonjs/Maths/math.color";
  44258. import { TransformNode } from "babylonjs/Meshes/transformNode";
  44259. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44260. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  44261. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  44262. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  44263. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  44264. import { Scene } from "babylonjs/scene";
  44265. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  44266. /**
  44267. * Single plane drag gizmo
  44268. */
  44269. export class PlaneDragGizmo extends Gizmo {
  44270. /**
  44271. * Drag behavior responsible for the gizmos dragging interactions
  44272. */
  44273. dragBehavior: PointerDragBehavior;
  44274. private _pointerObserver;
  44275. /**
  44276. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  44277. */
  44278. snapDistance: number;
  44279. /**
  44280. * Event that fires each time the gizmo snaps to a new location.
  44281. * * snapDistance is the the change in distance
  44282. */
  44283. onSnapObservable: Observable<{
  44284. snapDistance: number;
  44285. }>;
  44286. private _plane;
  44287. private _coloredMaterial;
  44288. private _hoverMaterial;
  44289. private _isEnabled;
  44290. private _parent;
  44291. /** @hidden */
  44292. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  44293. /** @hidden */
  44294. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  44295. /**
  44296. * Creates a PlaneDragGizmo
  44297. * @param gizmoLayer The utility layer the gizmo will be added to
  44298. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  44299. * @param color The color of the gizmo
  44300. */
  44301. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  44302. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  44303. /**
  44304. * If the gizmo is enabled
  44305. */
  44306. isEnabled: boolean;
  44307. /**
  44308. * Disposes of the gizmo
  44309. */
  44310. dispose(): void;
  44311. }
  44312. }
  44313. declare module "babylonjs/Gizmos/positionGizmo" {
  44314. import { Observable } from "babylonjs/Misc/observable";
  44315. import { Nullable } from "babylonjs/types";
  44316. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44317. import { Mesh } from "babylonjs/Meshes/mesh";
  44318. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  44319. import { AxisDragGizmo } from "babylonjs/Gizmos/axisDragGizmo";
  44320. import { PlaneDragGizmo } from "babylonjs/Gizmos/planeDragGizmo";
  44321. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  44322. /**
  44323. * Gizmo that enables dragging a mesh along 3 axis
  44324. */
  44325. export class PositionGizmo extends Gizmo {
  44326. /**
  44327. * Internal gizmo used for interactions on the x axis
  44328. */
  44329. xGizmo: AxisDragGizmo;
  44330. /**
  44331. * Internal gizmo used for interactions on the y axis
  44332. */
  44333. yGizmo: AxisDragGizmo;
  44334. /**
  44335. * Internal gizmo used for interactions on the z axis
  44336. */
  44337. zGizmo: AxisDragGizmo;
  44338. /**
  44339. * Internal gizmo used for interactions on the yz plane
  44340. */
  44341. xPlaneGizmo: PlaneDragGizmo;
  44342. /**
  44343. * Internal gizmo used for interactions on the xz plane
  44344. */
  44345. yPlaneGizmo: PlaneDragGizmo;
  44346. /**
  44347. * Internal gizmo used for interactions on the xy plane
  44348. */
  44349. zPlaneGizmo: PlaneDragGizmo;
  44350. /**
  44351. * private variables
  44352. */
  44353. private _meshAttached;
  44354. private _updateGizmoRotationToMatchAttachedMesh;
  44355. private _snapDistance;
  44356. private _scaleRatio;
  44357. /** Fires an event when any of it's sub gizmos are dragged */
  44358. onDragStartObservable: Observable<unknown>;
  44359. /** Fires an event when any of it's sub gizmos are released from dragging */
  44360. onDragEndObservable: Observable<unknown>;
  44361. /**
  44362. * If set to true, planar drag is enabled
  44363. */
  44364. private _planarGizmoEnabled;
  44365. attachedMesh: Nullable<AbstractMesh>;
  44366. /**
  44367. * Creates a PositionGizmo
  44368. * @param gizmoLayer The utility layer the gizmo will be added to
  44369. */
  44370. constructor(gizmoLayer?: UtilityLayerRenderer);
  44371. /**
  44372. * If the planar drag gizmo is enabled
  44373. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  44374. */
  44375. planarGizmoEnabled: boolean;
  44376. updateGizmoRotationToMatchAttachedMesh: boolean;
  44377. /**
  44378. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  44379. */
  44380. snapDistance: number;
  44381. /**
  44382. * Ratio for the scale of the gizmo (Default: 1)
  44383. */
  44384. scaleRatio: number;
  44385. /**
  44386. * Disposes of the gizmo
  44387. */
  44388. dispose(): void;
  44389. /**
  44390. * CustomMeshes are not supported by this gizmo
  44391. * @param mesh The mesh to replace the default mesh of the gizmo
  44392. */
  44393. setCustomMesh(mesh: Mesh): void;
  44394. }
  44395. }
  44396. declare module "babylonjs/Gizmos/axisDragGizmo" {
  44397. import { Observable } from "babylonjs/Misc/observable";
  44398. import { Nullable } from "babylonjs/types";
  44399. import { Vector3 } from "babylonjs/Maths/math.vector";
  44400. import { TransformNode } from "babylonjs/Meshes/transformNode";
  44401. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44402. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  44403. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  44404. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  44405. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  44406. import { Scene } from "babylonjs/scene";
  44407. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  44408. import { Color3 } from "babylonjs/Maths/math.color";
  44409. /**
  44410. * Single axis drag gizmo
  44411. */
  44412. export class AxisDragGizmo extends Gizmo {
  44413. /**
  44414. * Drag behavior responsible for the gizmos dragging interactions
  44415. */
  44416. dragBehavior: PointerDragBehavior;
  44417. private _pointerObserver;
  44418. /**
  44419. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  44420. */
  44421. snapDistance: number;
  44422. /**
  44423. * Event that fires each time the gizmo snaps to a new location.
  44424. * * snapDistance is the the change in distance
  44425. */
  44426. onSnapObservable: Observable<{
  44427. snapDistance: number;
  44428. }>;
  44429. private _isEnabled;
  44430. private _parent;
  44431. private _arrow;
  44432. private _coloredMaterial;
  44433. private _hoverMaterial;
  44434. /** @hidden */
  44435. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  44436. /** @hidden */
  44437. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  44438. /**
  44439. * Creates an AxisDragGizmo
  44440. * @param gizmoLayer The utility layer the gizmo will be added to
  44441. * @param dragAxis The axis which the gizmo will be able to drag on
  44442. * @param color The color of the gizmo
  44443. */
  44444. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  44445. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  44446. /**
  44447. * If the gizmo is enabled
  44448. */
  44449. isEnabled: boolean;
  44450. /**
  44451. * Disposes of the gizmo
  44452. */
  44453. dispose(): void;
  44454. }
  44455. }
  44456. declare module "babylonjs/Debug/axesViewer" {
  44457. import { Vector3 } from "babylonjs/Maths/math.vector";
  44458. import { Nullable } from "babylonjs/types";
  44459. import { Scene } from "babylonjs/scene";
  44460. import { TransformNode } from "babylonjs/Meshes/transformNode";
  44461. /**
  44462. * The Axes viewer will show 3 axes in a specific point in space
  44463. */
  44464. export class AxesViewer {
  44465. private _xAxis;
  44466. private _yAxis;
  44467. private _zAxis;
  44468. private _scaleLinesFactor;
  44469. private _instanced;
  44470. /**
  44471. * Gets the hosting scene
  44472. */
  44473. scene: Scene;
  44474. /**
  44475. * Gets or sets a number used to scale line length
  44476. */
  44477. scaleLines: number;
  44478. /** Gets the node hierarchy used to render x-axis */
  44479. readonly xAxis: TransformNode;
  44480. /** Gets the node hierarchy used to render y-axis */
  44481. readonly yAxis: TransformNode;
  44482. /** Gets the node hierarchy used to render z-axis */
  44483. readonly zAxis: TransformNode;
  44484. /**
  44485. * Creates a new AxesViewer
  44486. * @param scene defines the hosting scene
  44487. * @param scaleLines defines a number used to scale line length (1 by default)
  44488. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  44489. * @param xAxis defines the node hierarchy used to render the x-axis
  44490. * @param yAxis defines the node hierarchy used to render the y-axis
  44491. * @param zAxis defines the node hierarchy used to render the z-axis
  44492. */
  44493. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  44494. /**
  44495. * Force the viewer to update
  44496. * @param position defines the position of the viewer
  44497. * @param xaxis defines the x axis of the viewer
  44498. * @param yaxis defines the y axis of the viewer
  44499. * @param zaxis defines the z axis of the viewer
  44500. */
  44501. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  44502. /**
  44503. * Creates an instance of this axes viewer.
  44504. * @returns a new axes viewer with instanced meshes
  44505. */
  44506. createInstance(): AxesViewer;
  44507. /** Releases resources */
  44508. dispose(): void;
  44509. private static _SetRenderingGroupId;
  44510. }
  44511. }
  44512. declare module "babylonjs/Debug/boneAxesViewer" {
  44513. import { Nullable } from "babylonjs/types";
  44514. import { AxesViewer } from "babylonjs/Debug/axesViewer";
  44515. import { Vector3 } from "babylonjs/Maths/math.vector";
  44516. import { Mesh } from "babylonjs/Meshes/mesh";
  44517. import { Bone } from "babylonjs/Bones/bone";
  44518. import { Scene } from "babylonjs/scene";
  44519. /**
  44520. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  44521. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  44522. */
  44523. export class BoneAxesViewer extends AxesViewer {
  44524. /**
  44525. * Gets or sets the target mesh where to display the axes viewer
  44526. */
  44527. mesh: Nullable<Mesh>;
  44528. /**
  44529. * Gets or sets the target bone where to display the axes viewer
  44530. */
  44531. bone: Nullable<Bone>;
  44532. /** Gets current position */
  44533. pos: Vector3;
  44534. /** Gets direction of X axis */
  44535. xaxis: Vector3;
  44536. /** Gets direction of Y axis */
  44537. yaxis: Vector3;
  44538. /** Gets direction of Z axis */
  44539. zaxis: Vector3;
  44540. /**
  44541. * Creates a new BoneAxesViewer
  44542. * @param scene defines the hosting scene
  44543. * @param bone defines the target bone
  44544. * @param mesh defines the target mesh
  44545. * @param scaleLines defines a scaling factor for line length (1 by default)
  44546. */
  44547. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  44548. /**
  44549. * Force the viewer to update
  44550. */
  44551. update(): void;
  44552. /** Releases resources */
  44553. dispose(): void;
  44554. }
  44555. }
  44556. declare module "babylonjs/Debug/debugLayer" {
  44557. import { Scene } from "babylonjs/scene";
  44558. /**
  44559. * Interface used to define scene explorer extensibility option
  44560. */
  44561. export interface IExplorerExtensibilityOption {
  44562. /**
  44563. * Define the option label
  44564. */
  44565. label: string;
  44566. /**
  44567. * Defines the action to execute on click
  44568. */
  44569. action: (entity: any) => void;
  44570. }
  44571. /**
  44572. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  44573. */
  44574. export interface IExplorerExtensibilityGroup {
  44575. /**
  44576. * Defines a predicate to test if a given type mut be extended
  44577. */
  44578. predicate: (entity: any) => boolean;
  44579. /**
  44580. * Gets the list of options added to a type
  44581. */
  44582. entries: IExplorerExtensibilityOption[];
  44583. }
  44584. /**
  44585. * Interface used to define the options to use to create the Inspector
  44586. */
  44587. export interface IInspectorOptions {
  44588. /**
  44589. * Display in overlay mode (default: false)
  44590. */
  44591. overlay?: boolean;
  44592. /**
  44593. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  44594. */
  44595. globalRoot?: HTMLElement;
  44596. /**
  44597. * Display the Scene explorer
  44598. */
  44599. showExplorer?: boolean;
  44600. /**
  44601. * Display the property inspector
  44602. */
  44603. showInspector?: boolean;
  44604. /**
  44605. * Display in embed mode (both panes on the right)
  44606. */
  44607. embedMode?: boolean;
  44608. /**
  44609. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  44610. */
  44611. handleResize?: boolean;
  44612. /**
  44613. * Allow the panes to popup (default: true)
  44614. */
  44615. enablePopup?: boolean;
  44616. /**
  44617. * Allow the panes to be closed by users (default: true)
  44618. */
  44619. enableClose?: boolean;
  44620. /**
  44621. * Optional list of extensibility entries
  44622. */
  44623. explorerExtensibility?: IExplorerExtensibilityGroup[];
  44624. /**
  44625. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  44626. */
  44627. inspectorURL?: string;
  44628. }
  44629. module "babylonjs/scene" {
  44630. interface Scene {
  44631. /**
  44632. * @hidden
  44633. * Backing field
  44634. */
  44635. _debugLayer: DebugLayer;
  44636. /**
  44637. * Gets the debug layer (aka Inspector) associated with the scene
  44638. * @see http://doc.babylonjs.com/features/playground_debuglayer
  44639. */
  44640. debugLayer: DebugLayer;
  44641. }
  44642. }
  44643. /**
  44644. * The debug layer (aka Inspector) is the go to tool in order to better understand
  44645. * what is happening in your scene
  44646. * @see http://doc.babylonjs.com/features/playground_debuglayer
  44647. */
  44648. export class DebugLayer {
  44649. /**
  44650. * Define the url to get the inspector script from.
  44651. * By default it uses the babylonjs CDN.
  44652. * @ignoreNaming
  44653. */
  44654. static InspectorURL: string;
  44655. private _scene;
  44656. private BJSINSPECTOR;
  44657. private _onPropertyChangedObservable?;
  44658. /**
  44659. * Observable triggered when a property is changed through the inspector.
  44660. */
  44661. readonly onPropertyChangedObservable: any;
  44662. /**
  44663. * Instantiates a new debug layer.
  44664. * The debug layer (aka Inspector) is the go to tool in order to better understand
  44665. * what is happening in your scene
  44666. * @see http://doc.babylonjs.com/features/playground_debuglayer
  44667. * @param scene Defines the scene to inspect
  44668. */
  44669. constructor(scene: Scene);
  44670. /** Creates the inspector window. */
  44671. private _createInspector;
  44672. /**
  44673. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  44674. * @param entity defines the entity to select
  44675. * @param lineContainerTitle defines the specific block to highlight
  44676. */
  44677. select(entity: any, lineContainerTitle?: string): void;
  44678. /** Get the inspector from bundle or global */
  44679. private _getGlobalInspector;
  44680. /**
  44681. * Get if the inspector is visible or not.
  44682. * @returns true if visible otherwise, false
  44683. */
  44684. isVisible(): boolean;
  44685. /**
  44686. * Hide the inspector and close its window.
  44687. */
  44688. hide(): void;
  44689. /**
  44690. * Launch the debugLayer.
  44691. * @param config Define the configuration of the inspector
  44692. * @return a promise fulfilled when the debug layer is visible
  44693. */
  44694. show(config?: IInspectorOptions): Promise<DebugLayer>;
  44695. }
  44696. }
  44697. declare module "babylonjs/Meshes/Builders/boxBuilder" {
  44698. import { Nullable } from "babylonjs/types";
  44699. import { Scene } from "babylonjs/scene";
  44700. import { Vector4 } from "babylonjs/Maths/math.vector";
  44701. import { Color4 } from "babylonjs/Maths/math.color";
  44702. import { Mesh } from "babylonjs/Meshes/mesh";
  44703. /**
  44704. * Class containing static functions to help procedurally build meshes
  44705. */
  44706. export class BoxBuilder {
  44707. /**
  44708. * Creates a box mesh
  44709. * * The parameter `size` sets the size (float) of each box side (default 1)
  44710. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  44711. * * 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)
  44712. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  44713. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  44714. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  44715. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  44716. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  44717. * @param name defines the name of the mesh
  44718. * @param options defines the options used to create the mesh
  44719. * @param scene defines the hosting scene
  44720. * @returns the box mesh
  44721. */
  44722. static CreateBox(name: string, options: {
  44723. size?: number;
  44724. width?: number;
  44725. height?: number;
  44726. depth?: number;
  44727. faceUV?: Vector4[];
  44728. faceColors?: Color4[];
  44729. sideOrientation?: number;
  44730. frontUVs?: Vector4;
  44731. backUVs?: Vector4;
  44732. wrap?: boolean;
  44733. topBaseAt?: number;
  44734. bottomBaseAt?: number;
  44735. updatable?: boolean;
  44736. }, scene?: Nullable<Scene>): Mesh;
  44737. }
  44738. }
  44739. declare module "babylonjs/Meshes/Builders/sphereBuilder" {
  44740. import { Vector4 } from "babylonjs/Maths/math.vector";
  44741. import { Mesh } from "babylonjs/Meshes/mesh";
  44742. import { Scene } from "babylonjs/scene";
  44743. import { Nullable } from "babylonjs/types";
  44744. /**
  44745. * Class containing static functions to help procedurally build meshes
  44746. */
  44747. export class SphereBuilder {
  44748. /**
  44749. * Creates a sphere mesh
  44750. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  44751. * * 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`)
  44752. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  44753. * * 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
  44754. * * 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)
  44755. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  44756. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  44757. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  44758. * @param name defines the name of the mesh
  44759. * @param options defines the options used to create the mesh
  44760. * @param scene defines the hosting scene
  44761. * @returns the sphere mesh
  44762. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  44763. */
  44764. static CreateSphere(name: string, options: {
  44765. segments?: number;
  44766. diameter?: number;
  44767. diameterX?: number;
  44768. diameterY?: number;
  44769. diameterZ?: number;
  44770. arc?: number;
  44771. slice?: number;
  44772. sideOrientation?: number;
  44773. frontUVs?: Vector4;
  44774. backUVs?: Vector4;
  44775. updatable?: boolean;
  44776. }, scene?: Nullable<Scene>): Mesh;
  44777. }
  44778. }
  44779. declare module "babylonjs/Debug/physicsViewer" {
  44780. import { Nullable } from "babylonjs/types";
  44781. import { Scene } from "babylonjs/scene";
  44782. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44783. import { Mesh } from "babylonjs/Meshes/mesh";
  44784. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  44785. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  44786. /**
  44787. * Used to show the physics impostor around the specific mesh
  44788. */
  44789. export class PhysicsViewer {
  44790. /** @hidden */
  44791. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  44792. /** @hidden */
  44793. protected _meshes: Array<Nullable<AbstractMesh>>;
  44794. /** @hidden */
  44795. protected _scene: Nullable<Scene>;
  44796. /** @hidden */
  44797. protected _numMeshes: number;
  44798. /** @hidden */
  44799. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  44800. private _renderFunction;
  44801. private _utilityLayer;
  44802. private _debugBoxMesh;
  44803. private _debugSphereMesh;
  44804. private _debugCylinderMesh;
  44805. private _debugMaterial;
  44806. private _debugMeshMeshes;
  44807. /**
  44808. * Creates a new PhysicsViewer
  44809. * @param scene defines the hosting scene
  44810. */
  44811. constructor(scene: Scene);
  44812. /** @hidden */
  44813. protected _updateDebugMeshes(): void;
  44814. /**
  44815. * Renders a specified physic impostor
  44816. * @param impostor defines the impostor to render
  44817. * @param targetMesh defines the mesh represented by the impostor
  44818. * @returns the new debug mesh used to render the impostor
  44819. */
  44820. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  44821. /**
  44822. * Hides a specified physic impostor
  44823. * @param impostor defines the impostor to hide
  44824. */
  44825. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  44826. private _getDebugMaterial;
  44827. private _getDebugBoxMesh;
  44828. private _getDebugSphereMesh;
  44829. private _getDebugCylinderMesh;
  44830. private _getDebugMeshMesh;
  44831. private _getDebugMesh;
  44832. /** Releases all resources */
  44833. dispose(): void;
  44834. }
  44835. }
  44836. declare module "babylonjs/Meshes/Builders/linesBuilder" {
  44837. import { Vector3 } from "babylonjs/Maths/math.vector";
  44838. import { Color4 } from "babylonjs/Maths/math.color";
  44839. import { Nullable } from "babylonjs/types";
  44840. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  44841. import { Scene } from "babylonjs/scene";
  44842. /**
  44843. * Class containing static functions to help procedurally build meshes
  44844. */
  44845. export class LinesBuilder {
  44846. /**
  44847. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  44848. * * 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
  44849. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  44850. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  44851. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  44852. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  44853. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  44854. * * 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
  44855. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  44856. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  44857. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  44858. * @param name defines the name of the new line system
  44859. * @param options defines the options used to create the line system
  44860. * @param scene defines the hosting scene
  44861. * @returns a new line system mesh
  44862. */
  44863. static CreateLineSystem(name: string, options: {
  44864. lines: Vector3[][];
  44865. updatable?: boolean;
  44866. instance?: Nullable<LinesMesh>;
  44867. colors?: Nullable<Color4[][]>;
  44868. useVertexAlpha?: boolean;
  44869. }, scene: Nullable<Scene>): LinesMesh;
  44870. /**
  44871. * Creates a line mesh
  44872. * 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
  44873. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  44874. * * The parameter `points` is an array successive Vector3
  44875. * * 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
  44876. * * The optional parameter `colors` is an array of successive Color4, one per line point
  44877. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  44878. * * When updating an instance, remember that only point positions can change, not the number of points
  44879. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  44880. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  44881. * @param name defines the name of the new line system
  44882. * @param options defines the options used to create the line system
  44883. * @param scene defines the hosting scene
  44884. * @returns a new line mesh
  44885. */
  44886. static CreateLines(name: string, options: {
  44887. points: Vector3[];
  44888. updatable?: boolean;
  44889. instance?: Nullable<LinesMesh>;
  44890. colors?: Color4[];
  44891. useVertexAlpha?: boolean;
  44892. }, scene?: Nullable<Scene>): LinesMesh;
  44893. /**
  44894. * Creates a dashed line mesh
  44895. * * 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
  44896. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  44897. * * The parameter `points` is an array successive Vector3
  44898. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  44899. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  44900. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  44901. * * 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
  44902. * * When updating an instance, remember that only point positions can change, not the number of points
  44903. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  44904. * @param name defines the name of the mesh
  44905. * @param options defines the options used to create the mesh
  44906. * @param scene defines the hosting scene
  44907. * @returns the dashed line mesh
  44908. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  44909. */
  44910. static CreateDashedLines(name: string, options: {
  44911. points: Vector3[];
  44912. dashSize?: number;
  44913. gapSize?: number;
  44914. dashNb?: number;
  44915. updatable?: boolean;
  44916. instance?: LinesMesh;
  44917. }, scene?: Nullable<Scene>): LinesMesh;
  44918. }
  44919. }
  44920. declare module "babylonjs/Debug/rayHelper" {
  44921. import { Nullable } from "babylonjs/types";
  44922. import { Ray } from "babylonjs/Culling/ray";
  44923. import { Vector3 } from "babylonjs/Maths/math.vector";
  44924. import { Color3 } from "babylonjs/Maths/math.color";
  44925. import { Scene } from "babylonjs/scene";
  44926. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44927. import "babylonjs/Meshes/Builders/linesBuilder";
  44928. /**
  44929. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  44930. * in order to better appreciate the issue one might have.
  44931. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  44932. */
  44933. export class RayHelper {
  44934. /**
  44935. * Defines the ray we are currently tryin to visualize.
  44936. */
  44937. ray: Nullable<Ray>;
  44938. private _renderPoints;
  44939. private _renderLine;
  44940. private _renderFunction;
  44941. private _scene;
  44942. private _updateToMeshFunction;
  44943. private _attachedToMesh;
  44944. private _meshSpaceDirection;
  44945. private _meshSpaceOrigin;
  44946. /**
  44947. * Helper function to create a colored helper in a scene in one line.
  44948. * @param ray Defines the ray we are currently tryin to visualize
  44949. * @param scene Defines the scene the ray is used in
  44950. * @param color Defines the color we want to see the ray in
  44951. * @returns The newly created ray helper.
  44952. */
  44953. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  44954. /**
  44955. * Instantiate a new ray helper.
  44956. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  44957. * in order to better appreciate the issue one might have.
  44958. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  44959. * @param ray Defines the ray we are currently tryin to visualize
  44960. */
  44961. constructor(ray: Ray);
  44962. /**
  44963. * Shows the ray we are willing to debug.
  44964. * @param scene Defines the scene the ray needs to be rendered in
  44965. * @param color Defines the color the ray needs to be rendered in
  44966. */
  44967. show(scene: Scene, color?: Color3): void;
  44968. /**
  44969. * Hides the ray we are debugging.
  44970. */
  44971. hide(): void;
  44972. private _render;
  44973. /**
  44974. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  44975. * @param mesh Defines the mesh we want the helper attached to
  44976. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  44977. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  44978. * @param length Defines the length of the ray
  44979. */
  44980. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  44981. /**
  44982. * Detach the ray helper from the mesh it has previously been attached to.
  44983. */
  44984. detachFromMesh(): void;
  44985. private _updateToMesh;
  44986. /**
  44987. * Dispose the helper and release its associated resources.
  44988. */
  44989. dispose(): void;
  44990. }
  44991. }
  44992. declare module "babylonjs/Debug/skeletonViewer" {
  44993. import { Color3 } from "babylonjs/Maths/math.color";
  44994. import { Scene } from "babylonjs/scene";
  44995. import { Nullable } from "babylonjs/types";
  44996. import { Skeleton } from "babylonjs/Bones/skeleton";
  44997. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44998. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  44999. /**
  45000. * Class used to render a debug view of a given skeleton
  45001. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  45002. */
  45003. export class SkeletonViewer {
  45004. /** defines the skeleton to render */
  45005. skeleton: Skeleton;
  45006. /** defines the mesh attached to the skeleton */
  45007. mesh: AbstractMesh;
  45008. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  45009. autoUpdateBonesMatrices: boolean;
  45010. /** defines the rendering group id to use with the viewer */
  45011. renderingGroupId: number;
  45012. /** Gets or sets the color used to render the skeleton */
  45013. color: Color3;
  45014. private _scene;
  45015. private _debugLines;
  45016. private _debugMesh;
  45017. private _isEnabled;
  45018. private _renderFunction;
  45019. private _utilityLayer;
  45020. /**
  45021. * Returns the mesh used to render the bones
  45022. */
  45023. readonly debugMesh: Nullable<LinesMesh>;
  45024. /**
  45025. * Creates a new SkeletonViewer
  45026. * @param skeleton defines the skeleton to render
  45027. * @param mesh defines the mesh attached to the skeleton
  45028. * @param scene defines the hosting scene
  45029. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  45030. * @param renderingGroupId defines the rendering group id to use with the viewer
  45031. */
  45032. constructor(
  45033. /** defines the skeleton to render */
  45034. skeleton: Skeleton,
  45035. /** defines the mesh attached to the skeleton */
  45036. mesh: AbstractMesh, scene: Scene,
  45037. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  45038. autoUpdateBonesMatrices?: boolean,
  45039. /** defines the rendering group id to use with the viewer */
  45040. renderingGroupId?: number);
  45041. /** Gets or sets a boolean indicating if the viewer is enabled */
  45042. isEnabled: boolean;
  45043. private _getBonePosition;
  45044. private _getLinesForBonesWithLength;
  45045. private _getLinesForBonesNoLength;
  45046. /** Update the viewer to sync with current skeleton state */
  45047. update(): void;
  45048. /** Release associated resources */
  45049. dispose(): void;
  45050. }
  45051. }
  45052. declare module "babylonjs/Debug/index" {
  45053. export * from "babylonjs/Debug/axesViewer";
  45054. export * from "babylonjs/Debug/boneAxesViewer";
  45055. export * from "babylonjs/Debug/debugLayer";
  45056. export * from "babylonjs/Debug/physicsViewer";
  45057. export * from "babylonjs/Debug/rayHelper";
  45058. export * from "babylonjs/Debug/skeletonViewer";
  45059. }
  45060. declare module "babylonjs/Engines/nullEngine" {
  45061. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  45062. import { Scene } from "babylonjs/scene";
  45063. import { Engine } from "babylonjs/Engines/engine";
  45064. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  45065. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  45066. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  45067. import { Effect } from "babylonjs/Materials/effect";
  45068. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  45069. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  45070. import { IColor4Like, IViewportLike } from "babylonjs/Maths/math.like";
  45071. /**
  45072. * Options to create the null engine
  45073. */
  45074. export class NullEngineOptions {
  45075. /**
  45076. * Render width (Default: 512)
  45077. */
  45078. renderWidth: number;
  45079. /**
  45080. * Render height (Default: 256)
  45081. */
  45082. renderHeight: number;
  45083. /**
  45084. * Texture size (Default: 512)
  45085. */
  45086. textureSize: number;
  45087. /**
  45088. * If delta time between frames should be constant
  45089. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  45090. */
  45091. deterministicLockstep: boolean;
  45092. /**
  45093. * Maximum about of steps between frames (Default: 4)
  45094. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  45095. */
  45096. lockstepMaxSteps: number;
  45097. }
  45098. /**
  45099. * The null engine class provides support for headless version of babylon.js.
  45100. * This can be used in server side scenario or for testing purposes
  45101. */
  45102. export class NullEngine extends Engine {
  45103. private _options;
  45104. /**
  45105. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  45106. */
  45107. isDeterministicLockStep(): boolean;
  45108. /** @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep */
  45109. getLockstepMaxSteps(): number;
  45110. /**
  45111. * Sets hardware scaling, used to save performance if needed
  45112. * @see https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  45113. */
  45114. getHardwareScalingLevel(): number;
  45115. constructor(options?: NullEngineOptions);
  45116. createVertexBuffer(vertices: FloatArray): DataBuffer;
  45117. createIndexBuffer(indices: IndicesArray): DataBuffer;
  45118. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  45119. getRenderWidth(useScreen?: boolean): number;
  45120. getRenderHeight(useScreen?: boolean): number;
  45121. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  45122. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  45123. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  45124. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  45125. bindSamplers(effect: Effect): void;
  45126. enableEffect(effect: Effect): void;
  45127. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  45128. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  45129. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  45130. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  45131. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  45132. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  45133. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  45134. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  45135. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  45136. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  45137. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  45138. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  45139. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  45140. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  45141. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  45142. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  45143. setFloat(uniform: WebGLUniformLocation, value: number): void;
  45144. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  45145. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  45146. setBool(uniform: WebGLUniformLocation, bool: number): void;
  45147. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  45148. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  45149. bindBuffers(vertexBuffers: {
  45150. [key: string]: VertexBuffer;
  45151. }, indexBuffer: DataBuffer, effect: Effect): void;
  45152. wipeCaches(bruteForce?: boolean): void;
  45153. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  45154. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  45155. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  45156. /** @hidden */
  45157. _createTexture(): WebGLTexture;
  45158. /** @hidden */
  45159. _releaseTexture(texture: InternalTexture): void;
  45160. 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;
  45161. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  45162. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  45163. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  45164. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  45165. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  45166. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  45167. areAllEffectsReady(): boolean;
  45168. /**
  45169. * @hidden
  45170. * Get the current error code of the webGL context
  45171. * @returns the error code
  45172. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  45173. */
  45174. getError(): number;
  45175. /** @hidden */
  45176. _getUnpackAlignement(): number;
  45177. /** @hidden */
  45178. _unpackFlipY(value: boolean): void;
  45179. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  45180. /**
  45181. * Updates a dynamic vertex buffer.
  45182. * @param vertexBuffer the vertex buffer to update
  45183. * @param data the data used to update the vertex buffer
  45184. * @param byteOffset the byte offset of the data (optional)
  45185. * @param byteLength the byte length of the data (optional)
  45186. */
  45187. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  45188. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  45189. /** @hidden */
  45190. _bindTexture(channel: number, texture: InternalTexture): void;
  45191. protected _deleteBuffer(buffer: WebGLBuffer): void;
  45192. releaseEffects(): void;
  45193. displayLoadingUI(): void;
  45194. hideLoadingUI(): void;
  45195. /** @hidden */
  45196. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  45197. /** @hidden */
  45198. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  45199. /** @hidden */
  45200. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  45201. /** @hidden */
  45202. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  45203. }
  45204. }
  45205. declare module "babylonjs/Engines/Extensions/engine.occlusionQuery" {
  45206. import { Nullable, int } from "babylonjs/types";
  45207. import { _TimeToken } from "babylonjs/Instrumentation/timeToken";
  45208. /** @hidden */
  45209. export class _OcclusionDataStorage {
  45210. /** @hidden */
  45211. occlusionInternalRetryCounter: number;
  45212. /** @hidden */
  45213. isOcclusionQueryInProgress: boolean;
  45214. /** @hidden */
  45215. isOccluded: boolean;
  45216. /** @hidden */
  45217. occlusionRetryCount: number;
  45218. /** @hidden */
  45219. occlusionType: number;
  45220. /** @hidden */
  45221. occlusionQueryAlgorithmType: number;
  45222. }
  45223. module "babylonjs/Engines/engine" {
  45224. interface Engine {
  45225. /**
  45226. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  45227. * @return the new query
  45228. */
  45229. createQuery(): WebGLQuery;
  45230. /**
  45231. * Delete and release a webGL query
  45232. * @param query defines the query to delete
  45233. * @return the current engine
  45234. */
  45235. deleteQuery(query: WebGLQuery): Engine;
  45236. /**
  45237. * Check if a given query has resolved and got its value
  45238. * @param query defines the query to check
  45239. * @returns true if the query got its value
  45240. */
  45241. isQueryResultAvailable(query: WebGLQuery): boolean;
  45242. /**
  45243. * Gets the value of a given query
  45244. * @param query defines the query to check
  45245. * @returns the value of the query
  45246. */
  45247. getQueryResult(query: WebGLQuery): number;
  45248. /**
  45249. * Initiates an occlusion query
  45250. * @param algorithmType defines the algorithm to use
  45251. * @param query defines the query to use
  45252. * @returns the current engine
  45253. * @see http://doc.babylonjs.com/features/occlusionquery
  45254. */
  45255. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  45256. /**
  45257. * Ends an occlusion query
  45258. * @see http://doc.babylonjs.com/features/occlusionquery
  45259. * @param algorithmType defines the algorithm to use
  45260. * @returns the current engine
  45261. */
  45262. endOcclusionQuery(algorithmType: number): Engine;
  45263. /**
  45264. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  45265. * Please note that only one query can be issued at a time
  45266. * @returns a time token used to track the time span
  45267. */
  45268. startTimeQuery(): Nullable<_TimeToken>;
  45269. /**
  45270. * Ends a time query
  45271. * @param token defines the token used to measure the time span
  45272. * @returns the time spent (in ns)
  45273. */
  45274. endTimeQuery(token: _TimeToken): int;
  45275. /** @hidden */
  45276. _currentNonTimestampToken: Nullable<_TimeToken>;
  45277. /** @hidden */
  45278. _createTimeQuery(): WebGLQuery;
  45279. /** @hidden */
  45280. _deleteTimeQuery(query: WebGLQuery): void;
  45281. /** @hidden */
  45282. _getGlAlgorithmType(algorithmType: number): number;
  45283. /** @hidden */
  45284. _getTimeQueryResult(query: WebGLQuery): any;
  45285. /** @hidden */
  45286. _getTimeQueryAvailability(query: WebGLQuery): any;
  45287. }
  45288. }
  45289. module "babylonjs/Meshes/abstractMesh" {
  45290. interface AbstractMesh {
  45291. /**
  45292. * Backing filed
  45293. * @hidden
  45294. */
  45295. __occlusionDataStorage: _OcclusionDataStorage;
  45296. /**
  45297. * Access property
  45298. * @hidden
  45299. */
  45300. _occlusionDataStorage: _OcclusionDataStorage;
  45301. /**
  45302. * 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.
  45303. * The default value is -1 which means don't break the query and wait till the result
  45304. * @see http://doc.babylonjs.com/features/occlusionquery
  45305. */
  45306. occlusionRetryCount: number;
  45307. /**
  45308. * 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:
  45309. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  45310. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  45311. * * 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.
  45312. * @see http://doc.babylonjs.com/features/occlusionquery
  45313. */
  45314. occlusionType: number;
  45315. /**
  45316. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  45317. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  45318. * * 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.
  45319. * @see http://doc.babylonjs.com/features/occlusionquery
  45320. */
  45321. occlusionQueryAlgorithmType: number;
  45322. /**
  45323. * 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
  45324. * @see http://doc.babylonjs.com/features/occlusionquery
  45325. */
  45326. isOccluded: boolean;
  45327. /**
  45328. * Flag to check the progress status of the query
  45329. * @see http://doc.babylonjs.com/features/occlusionquery
  45330. */
  45331. isOcclusionQueryInProgress: boolean;
  45332. }
  45333. }
  45334. }
  45335. declare module "babylonjs/Engines/Extensions/engine.transformFeedback" {
  45336. import { Nullable } from "babylonjs/types";
  45337. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  45338. /** @hidden */
  45339. export var _forceTransformFeedbackToBundle: boolean;
  45340. module "babylonjs/Engines/engine" {
  45341. interface Engine {
  45342. /**
  45343. * Creates a webGL transform feedback object
  45344. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  45345. * @returns the webGL transform feedback object
  45346. */
  45347. createTransformFeedback(): WebGLTransformFeedback;
  45348. /**
  45349. * Delete a webGL transform feedback object
  45350. * @param value defines the webGL transform feedback object to delete
  45351. */
  45352. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  45353. /**
  45354. * Bind a webGL transform feedback object to the webgl context
  45355. * @param value defines the webGL transform feedback object to bind
  45356. */
  45357. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  45358. /**
  45359. * Begins a transform feedback operation
  45360. * @param usePoints defines if points or triangles must be used
  45361. */
  45362. beginTransformFeedback(usePoints: boolean): void;
  45363. /**
  45364. * Ends a transform feedback operation
  45365. */
  45366. endTransformFeedback(): void;
  45367. /**
  45368. * Specify the varyings to use with transform feedback
  45369. * @param program defines the associated webGL program
  45370. * @param value defines the list of strings representing the varying names
  45371. */
  45372. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  45373. /**
  45374. * Bind a webGL buffer for a transform feedback operation
  45375. * @param value defines the webGL buffer to bind
  45376. */
  45377. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  45378. }
  45379. }
  45380. }
  45381. declare module "babylonjs/Materials/Textures/multiRenderTarget" {
  45382. import { Scene } from "babylonjs/scene";
  45383. import { Engine } from "babylonjs/Engines/engine";
  45384. import { Texture } from "babylonjs/Materials/Textures/texture";
  45385. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  45386. import "babylonjs/Engines/Extensions/engine.multiRender";
  45387. /**
  45388. * Creation options of the multi render target texture.
  45389. */
  45390. export interface IMultiRenderTargetOptions {
  45391. /**
  45392. * Define if the texture needs to create mip maps after render.
  45393. */
  45394. generateMipMaps?: boolean;
  45395. /**
  45396. * Define the types of all the draw buffers we want to create
  45397. */
  45398. types?: number[];
  45399. /**
  45400. * Define the sampling modes of all the draw buffers we want to create
  45401. */
  45402. samplingModes?: number[];
  45403. /**
  45404. * Define if a depth buffer is required
  45405. */
  45406. generateDepthBuffer?: boolean;
  45407. /**
  45408. * Define if a stencil buffer is required
  45409. */
  45410. generateStencilBuffer?: boolean;
  45411. /**
  45412. * Define if a depth texture is required instead of a depth buffer
  45413. */
  45414. generateDepthTexture?: boolean;
  45415. /**
  45416. * Define the number of desired draw buffers
  45417. */
  45418. textureCount?: number;
  45419. /**
  45420. * Define if aspect ratio should be adapted to the texture or stay the scene one
  45421. */
  45422. doNotChangeAspectRatio?: boolean;
  45423. /**
  45424. * Define the default type of the buffers we are creating
  45425. */
  45426. defaultType?: number;
  45427. }
  45428. /**
  45429. * A multi render target, like a render target provides the ability to render to a texture.
  45430. * Unlike the render target, it can render to several draw buffers in one draw.
  45431. * This is specially interesting in deferred rendering or for any effects requiring more than
  45432. * just one color from a single pass.
  45433. */
  45434. export class MultiRenderTarget extends RenderTargetTexture {
  45435. private _internalTextures;
  45436. private _textures;
  45437. private _multiRenderTargetOptions;
  45438. /**
  45439. * Get if draw buffers are currently supported by the used hardware and browser.
  45440. */
  45441. readonly isSupported: boolean;
  45442. /**
  45443. * Get the list of textures generated by the multi render target.
  45444. */
  45445. readonly textures: Texture[];
  45446. /**
  45447. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  45448. */
  45449. readonly depthTexture: Texture;
  45450. /**
  45451. * Set the wrapping mode on U of all the textures we are rendering to.
  45452. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  45453. */
  45454. wrapU: number;
  45455. /**
  45456. * Set the wrapping mode on V of all the textures we are rendering to.
  45457. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  45458. */
  45459. wrapV: number;
  45460. /**
  45461. * Instantiate a new multi render target texture.
  45462. * A multi render target, like a render target provides the ability to render to a texture.
  45463. * Unlike the render target, it can render to several draw buffers in one draw.
  45464. * This is specially interesting in deferred rendering or for any effects requiring more than
  45465. * just one color from a single pass.
  45466. * @param name Define the name of the texture
  45467. * @param size Define the size of the buffers to render to
  45468. * @param count Define the number of target we are rendering into
  45469. * @param scene Define the scene the texture belongs to
  45470. * @param options Define the options used to create the multi render target
  45471. */
  45472. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  45473. /** @hidden */
  45474. _rebuild(): void;
  45475. private _createInternalTextures;
  45476. private _createTextures;
  45477. /**
  45478. * Define the number of samples used if MSAA is enabled.
  45479. */
  45480. samples: number;
  45481. /**
  45482. * Resize all the textures in the multi render target.
  45483. * Be carrefull as it will recreate all the data in the new texture.
  45484. * @param size Define the new size
  45485. */
  45486. resize(size: any): void;
  45487. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  45488. /**
  45489. * Dispose the render targets and their associated resources
  45490. */
  45491. dispose(): void;
  45492. /**
  45493. * Release all the underlying texture used as draw buffers.
  45494. */
  45495. releaseInternalTextures(): void;
  45496. }
  45497. }
  45498. declare module "babylonjs/Engines/Extensions/engine.multiRender" {
  45499. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  45500. import { IMultiRenderTargetOptions } from "babylonjs/Materials/Textures/multiRenderTarget";
  45501. import { Nullable } from "babylonjs/types";
  45502. module "babylonjs/Engines/engine" {
  45503. interface Engine {
  45504. /**
  45505. * Unbind a list of render target textures from the webGL context
  45506. * This is used only when drawBuffer extension or webGL2 are active
  45507. * @param textures defines the render target textures to unbind
  45508. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  45509. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  45510. */
  45511. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  45512. /**
  45513. * Create a multi render target texture
  45514. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  45515. * @param size defines the size of the texture
  45516. * @param options defines the creation options
  45517. * @returns the cube texture as an InternalTexture
  45518. */
  45519. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  45520. /**
  45521. * Update the sample count for a given multiple render target texture
  45522. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  45523. * @param textures defines the textures to update
  45524. * @param samples defines the sample count to set
  45525. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  45526. */
  45527. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  45528. }
  45529. }
  45530. }
  45531. declare module "babylonjs/Engines/Extensions/index" {
  45532. export * from "babylonjs/Engines/Extensions/engine.occlusionQuery";
  45533. export * from "babylonjs/Engines/Extensions/engine.transformFeedback";
  45534. export * from "babylonjs/Engines/Extensions/engine.multiview";
  45535. export * from "babylonjs/Engines/Extensions/engine.rawTexture";
  45536. export * from "babylonjs/Engines/Extensions/engine.multiRender";
  45537. export * from "babylonjs/Engines/Extensions/engine.cubeTexture";
  45538. export * from "babylonjs/Engines/Extensions/engine.renderTarget";
  45539. export * from "babylonjs/Engines/Extensions/engine.webVR";
  45540. }
  45541. declare module "babylonjs/Shaders/rgbdEncode.fragment" {
  45542. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  45543. /** @hidden */
  45544. export var rgbdEncodePixelShader: {
  45545. name: string;
  45546. shader: string;
  45547. };
  45548. }
  45549. declare module "babylonjs/Shaders/rgbdDecode.fragment" {
  45550. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  45551. /** @hidden */
  45552. export var rgbdDecodePixelShader: {
  45553. name: string;
  45554. shader: string;
  45555. };
  45556. }
  45557. declare module "babylonjs/Misc/environmentTextureTools" {
  45558. import { Nullable } from "babylonjs/types";
  45559. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  45560. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  45561. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  45562. import "babylonjs/Engines/Extensions/engine.renderTarget";
  45563. import "babylonjs/Shaders/rgbdEncode.fragment";
  45564. import "babylonjs/Shaders/rgbdDecode.fragment";
  45565. /**
  45566. * Raw texture data and descriptor sufficient for WebGL texture upload
  45567. */
  45568. export interface EnvironmentTextureInfo {
  45569. /**
  45570. * Version of the environment map
  45571. */
  45572. version: number;
  45573. /**
  45574. * Width of image
  45575. */
  45576. width: number;
  45577. /**
  45578. * Irradiance information stored in the file.
  45579. */
  45580. irradiance: any;
  45581. /**
  45582. * Specular information stored in the file.
  45583. */
  45584. specular: any;
  45585. }
  45586. /**
  45587. * Defines One Image in the file. It requires only the position in the file
  45588. * as well as the length.
  45589. */
  45590. interface BufferImageData {
  45591. /**
  45592. * Length of the image data.
  45593. */
  45594. length: number;
  45595. /**
  45596. * Position of the data from the null terminator delimiting the end of the JSON.
  45597. */
  45598. position: number;
  45599. }
  45600. /**
  45601. * Defines the specular data enclosed in the file.
  45602. * This corresponds to the version 1 of the data.
  45603. */
  45604. export interface EnvironmentTextureSpecularInfoV1 {
  45605. /**
  45606. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  45607. */
  45608. specularDataPosition?: number;
  45609. /**
  45610. * This contains all the images data needed to reconstruct the cubemap.
  45611. */
  45612. mipmaps: Array<BufferImageData>;
  45613. /**
  45614. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  45615. */
  45616. lodGenerationScale: number;
  45617. }
  45618. /**
  45619. * Sets of helpers addressing the serialization and deserialization of environment texture
  45620. * stored in a BabylonJS env file.
  45621. * Those files are usually stored as .env files.
  45622. */
  45623. export class EnvironmentTextureTools {
  45624. /**
  45625. * Magic number identifying the env file.
  45626. */
  45627. private static _MagicBytes;
  45628. /**
  45629. * Gets the environment info from an env file.
  45630. * @param data The array buffer containing the .env bytes.
  45631. * @returns the environment file info (the json header) if successfully parsed.
  45632. */
  45633. static GetEnvInfo(data: ArrayBuffer): Nullable<EnvironmentTextureInfo>;
  45634. /**
  45635. * Creates an environment texture from a loaded cube texture.
  45636. * @param texture defines the cube texture to convert in env file
  45637. * @return a promise containing the environment data if succesfull.
  45638. */
  45639. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  45640. /**
  45641. * Creates a JSON representation of the spherical data.
  45642. * @param texture defines the texture containing the polynomials
  45643. * @return the JSON representation of the spherical info
  45644. */
  45645. private static _CreateEnvTextureIrradiance;
  45646. /**
  45647. * Creates the ArrayBufferViews used for initializing environment texture image data.
  45648. * @param arrayBuffer the underlying ArrayBuffer to which the views refer
  45649. * @param info parameters that determine what views will be created for accessing the underlying buffer
  45650. * @return the views described by info providing access to the underlying buffer
  45651. */
  45652. static CreateImageDataArrayBufferViews(arrayBuffer: any, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  45653. /**
  45654. * Uploads the texture info contained in the env file to the GPU.
  45655. * @param texture defines the internal texture to upload to
  45656. * @param arrayBuffer defines the buffer cotaining the data to load
  45657. * @param info defines the texture info retrieved through the GetEnvInfo method
  45658. * @returns a promise
  45659. */
  45660. static UploadEnvLevelsAsync(texture: InternalTexture, arrayBuffer: any, info: EnvironmentTextureInfo): Promise<void>;
  45661. /**
  45662. * Uploads the levels of image data to the GPU.
  45663. * @param texture defines the internal texture to upload to
  45664. * @param imageData defines the array buffer views of image data [mipmap][face]
  45665. * @returns a promise
  45666. */
  45667. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  45668. /**
  45669. * Uploads spherical polynomials information to the texture.
  45670. * @param texture defines the texture we are trying to upload the information to
  45671. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  45672. */
  45673. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  45674. /** @hidden */
  45675. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  45676. }
  45677. }
  45678. declare module "babylonjs/Maths/math.vertexFormat" {
  45679. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  45680. /**
  45681. * Contains position and normal vectors for a vertex
  45682. */
  45683. export class PositionNormalVertex {
  45684. /** the position of the vertex (defaut: 0,0,0) */
  45685. position: Vector3;
  45686. /** the normal of the vertex (defaut: 0,1,0) */
  45687. normal: Vector3;
  45688. /**
  45689. * Creates a PositionNormalVertex
  45690. * @param position the position of the vertex (defaut: 0,0,0)
  45691. * @param normal the normal of the vertex (defaut: 0,1,0)
  45692. */
  45693. constructor(
  45694. /** the position of the vertex (defaut: 0,0,0) */
  45695. position?: Vector3,
  45696. /** the normal of the vertex (defaut: 0,1,0) */
  45697. normal?: Vector3);
  45698. /**
  45699. * Clones the PositionNormalVertex
  45700. * @returns the cloned PositionNormalVertex
  45701. */
  45702. clone(): PositionNormalVertex;
  45703. }
  45704. /**
  45705. * Contains position, normal and uv vectors for a vertex
  45706. */
  45707. export class PositionNormalTextureVertex {
  45708. /** the position of the vertex (defaut: 0,0,0) */
  45709. position: Vector3;
  45710. /** the normal of the vertex (defaut: 0,1,0) */
  45711. normal: Vector3;
  45712. /** the uv of the vertex (default: 0,0) */
  45713. uv: Vector2;
  45714. /**
  45715. * Creates a PositionNormalTextureVertex
  45716. * @param position the position of the vertex (defaut: 0,0,0)
  45717. * @param normal the normal of the vertex (defaut: 0,1,0)
  45718. * @param uv the uv of the vertex (default: 0,0)
  45719. */
  45720. constructor(
  45721. /** the position of the vertex (defaut: 0,0,0) */
  45722. position?: Vector3,
  45723. /** the normal of the vertex (defaut: 0,1,0) */
  45724. normal?: Vector3,
  45725. /** the uv of the vertex (default: 0,0) */
  45726. uv?: Vector2);
  45727. /**
  45728. * Clones the PositionNormalTextureVertex
  45729. * @returns the cloned PositionNormalTextureVertex
  45730. */
  45731. clone(): PositionNormalTextureVertex;
  45732. }
  45733. }
  45734. declare module "babylonjs/Maths/math" {
  45735. export * from "babylonjs/Maths/math.axis";
  45736. export * from "babylonjs/Maths/math.color";
  45737. export * from "babylonjs/Maths/math.constants";
  45738. export * from "babylonjs/Maths/math.frustum";
  45739. export * from "babylonjs/Maths/math.path";
  45740. export * from "babylonjs/Maths/math.plane";
  45741. export * from "babylonjs/Maths/math.size";
  45742. export * from "babylonjs/Maths/math.vector";
  45743. export * from "babylonjs/Maths/math.vertexFormat";
  45744. export * from "babylonjs/Maths/math.viewport";
  45745. }
  45746. declare module "babylonjs/Engines/Native/nativeShaderProcessor" {
  45747. import { WebGL2ShaderProcessor } from "babylonjs/Engines/WebGL/webGL2ShaderProcessors";
  45748. /** @hidden */
  45749. export class NativeShaderProcessor extends WebGL2ShaderProcessor {
  45750. private _genericAttributeLocation;
  45751. private _varyingLocationCount;
  45752. private _varyingLocationMap;
  45753. private _replacements;
  45754. private _textureCount;
  45755. private _uniforms;
  45756. lineProcessor(line: string): string;
  45757. attributeProcessor(attribute: string): string;
  45758. varyingProcessor(varying: string, isFragment: boolean): string;
  45759. uniformProcessor(uniform: string): string;
  45760. preProcessor(code: string, defines: string[], isFragment: boolean): string;
  45761. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  45762. }
  45763. }
  45764. declare module "babylonjs/Engines/nativeEngine" {
  45765. import { Nullable, IndicesArray, DataArray } from "babylonjs/types";
  45766. import { Engine } from "babylonjs/Engines/engine";
  45767. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  45768. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  45769. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  45770. import { Effect } from "babylonjs/Materials/effect";
  45771. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  45772. import { Color4, Matrix, Viewport, Color3 } from "babylonjs/Maths/math";
  45773. import { Scene } from "babylonjs/scene";
  45774. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  45775. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  45776. /**
  45777. * Container for accessors for natively-stored mesh data buffers.
  45778. */
  45779. class NativeDataBuffer extends DataBuffer {
  45780. /**
  45781. * Accessor value used to identify/retrieve a natively-stored index buffer.
  45782. */
  45783. nativeIndexBuffer?: any;
  45784. /**
  45785. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  45786. */
  45787. nativeVertexBuffer?: any;
  45788. }
  45789. /** @hidden */
  45790. export class NativeEngine extends Engine {
  45791. private readonly _native;
  45792. getHardwareScalingLevel(): number;
  45793. constructor();
  45794. /**
  45795. * Can be used to override the current requestAnimationFrame requester.
  45796. * @hidden
  45797. */
  45798. protected _queueNewFrame(bindedRenderFunction: any, requester: any): number;
  45799. clear(color: Color4, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  45800. createIndexBuffer(indices: IndicesArray): NativeDataBuffer;
  45801. createVertexBuffer(data: DataArray): NativeDataBuffer;
  45802. recordVertexArrayObject(vertexBuffers: {
  45803. [key: string]: VertexBuffer;
  45804. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  45805. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  45806. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  45807. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  45808. /**
  45809. * Draw a list of indexed primitives
  45810. * @param fillMode defines the primitive to use
  45811. * @param indexStart defines the starting index
  45812. * @param indexCount defines the number of index to draw
  45813. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  45814. */
  45815. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  45816. /**
  45817. * Draw a list of unindexed primitives
  45818. * @param fillMode defines the primitive to use
  45819. * @param verticesStart defines the index of first vertex to draw
  45820. * @param verticesCount defines the count of vertices to draw
  45821. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  45822. */
  45823. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  45824. createPipelineContext(): IPipelineContext;
  45825. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  45826. /** @hidden */
  45827. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  45828. /** @hidden */
  45829. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  45830. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  45831. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  45832. protected _setProgram(program: WebGLProgram): void;
  45833. _releaseEffect(effect: Effect): void;
  45834. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  45835. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  45836. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  45837. bindSamplers(effect: Effect): void;
  45838. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  45839. getRenderWidth(useScreen?: boolean): number;
  45840. getRenderHeight(useScreen?: boolean): number;
  45841. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  45842. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  45843. /**
  45844. * Set the z offset to apply to current rendering
  45845. * @param value defines the offset to apply
  45846. */
  45847. setZOffset(value: number): void;
  45848. /**
  45849. * Gets the current value of the zOffset
  45850. * @returns the current zOffset state
  45851. */
  45852. getZOffset(): number;
  45853. /**
  45854. * Enable or disable depth buffering
  45855. * @param enable defines the state to set
  45856. */
  45857. setDepthBuffer(enable: boolean): void;
  45858. /**
  45859. * Gets a boolean indicating if depth writing is enabled
  45860. * @returns the current depth writing state
  45861. */
  45862. getDepthWrite(): boolean;
  45863. /**
  45864. * Enable or disable depth writing
  45865. * @param enable defines the state to set
  45866. */
  45867. setDepthWrite(enable: boolean): void;
  45868. /**
  45869. * Enable or disable color writing
  45870. * @param enable defines the state to set
  45871. */
  45872. setColorWrite(enable: boolean): void;
  45873. /**
  45874. * Gets a boolean indicating if color writing is enabled
  45875. * @returns the current color writing state
  45876. */
  45877. getColorWrite(): boolean;
  45878. /**
  45879. * Sets alpha constants used by some alpha blending modes
  45880. * @param r defines the red component
  45881. * @param g defines the green component
  45882. * @param b defines the blue component
  45883. * @param a defines the alpha component
  45884. */
  45885. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  45886. /**
  45887. * Sets the current alpha mode
  45888. * @param mode defines the mode to use (one of the BABYLON.Engine.ALPHA_XXX)
  45889. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  45890. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  45891. */
  45892. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  45893. /**
  45894. * Gets the current alpha mode
  45895. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  45896. * @returns the current alpha mode
  45897. */
  45898. getAlphaMode(): number;
  45899. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  45900. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  45901. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  45902. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  45903. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  45904. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  45905. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  45906. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  45907. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  45908. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  45909. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  45910. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  45911. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  45912. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  45913. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  45914. setFloat(uniform: WebGLUniformLocation, value: number): void;
  45915. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  45916. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  45917. setBool(uniform: WebGLUniformLocation, bool: number): void;
  45918. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  45919. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  45920. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  45921. wipeCaches(bruteForce?: boolean): void;
  45922. _createTexture(): WebGLTexture;
  45923. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  45924. /**
  45925. * Usually called from BABYLON.Texture.ts.
  45926. * Passed information to create a WebGLTexture
  45927. * @param urlArg defines a value which contains one of the following:
  45928. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  45929. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  45930. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  45931. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  45932. * @param invertY when true, image is flipped when loaded. You probably want true. Ignored for compressed textures. Must be flipped in the file
  45933. * @param scene needed for loading to the correct scene
  45934. * @param samplingMode mode with should be used sample / access the texture (Default: BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  45935. * @param onLoad optional callback to be called upon successful completion
  45936. * @param onError optional callback to be called upon failure
  45937. * @param buffer a source of a file previously fetched as either a base64 string, an ArrayBuffer (compressed or image format), or a Blob
  45938. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  45939. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  45940. * @param forcedExtension defines the extension to use to pick the right loader
  45941. * @returns a InternalTexture for assignment back into BABYLON.Texture
  45942. */
  45943. 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;
  45944. /**
  45945. * Creates a cube texture
  45946. * @param rootUrl defines the url where the files to load is located
  45947. * @param scene defines the current scene
  45948. * @param files defines the list of files to load (1 per face)
  45949. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  45950. * @param onLoad defines an optional callback raised when the texture is loaded
  45951. * @param onError defines an optional callback raised if there is an issue to load the texture
  45952. * @param format defines the format of the data
  45953. * @param forcedExtension defines the extension to use to pick the right loader
  45954. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  45955. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  45956. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  45957. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  45958. * @returns the cube texture as an InternalTexture
  45959. */
  45960. 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;
  45961. private _getSamplingFilter;
  45962. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  45963. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  45964. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  45965. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  45966. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  45967. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  45968. /**
  45969. * Updates a dynamic vertex buffer.
  45970. * @param vertexBuffer the vertex buffer to update
  45971. * @param data the data used to update the vertex buffer
  45972. * @param byteOffset the byte offset of the data (optional)
  45973. * @param byteLength the byte length of the data (optional)
  45974. */
  45975. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  45976. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  45977. private _updateAnisotropicLevel;
  45978. private _getAddressMode;
  45979. /** @hidden */
  45980. _bindTexture(channel: number, texture: InternalTexture): void;
  45981. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  45982. releaseEffects(): void;
  45983. /** @hidden */
  45984. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  45985. /** @hidden */
  45986. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  45987. /** @hidden */
  45988. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  45989. /** @hidden */
  45990. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  45991. }
  45992. }
  45993. declare module "babylonjs/Engines/index" {
  45994. export * from "babylonjs/Engines/constants";
  45995. export * from "babylonjs/Engines/engine";
  45996. export * from "babylonjs/Engines/engineStore";
  45997. export * from "babylonjs/Engines/nullEngine";
  45998. export * from "babylonjs/Engines/Extensions/index";
  45999. export * from "babylonjs/Engines/IPipelineContext";
  46000. export * from "babylonjs/Engines/WebGL/webGLPipelineContext";
  46001. export * from "babylonjs/Engines/WebGL/webGL2ShaderProcessors";
  46002. export * from "babylonjs/Engines/nativeEngine";
  46003. }
  46004. declare module "babylonjs/Events/clipboardEvents" {
  46005. /**
  46006. * Gather the list of clipboard event types as constants.
  46007. */
  46008. export class ClipboardEventTypes {
  46009. /**
  46010. * The clipboard event is fired when a copy command is active (pressed).
  46011. */
  46012. static readonly COPY: number;
  46013. /**
  46014. * The clipboard event is fired when a cut command is active (pressed).
  46015. */
  46016. static readonly CUT: number;
  46017. /**
  46018. * The clipboard event is fired when a paste command is active (pressed).
  46019. */
  46020. static readonly PASTE: number;
  46021. }
  46022. /**
  46023. * This class is used to store clipboard related info for the onClipboardObservable event.
  46024. */
  46025. export class ClipboardInfo {
  46026. /**
  46027. * Defines the type of event (BABYLON.ClipboardEventTypes)
  46028. */
  46029. type: number;
  46030. /**
  46031. * Defines the related dom event
  46032. */
  46033. event: ClipboardEvent;
  46034. /**
  46035. *Creates an instance of ClipboardInfo.
  46036. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  46037. * @param event Defines the related dom event
  46038. */
  46039. constructor(
  46040. /**
  46041. * Defines the type of event (BABYLON.ClipboardEventTypes)
  46042. */
  46043. type: number,
  46044. /**
  46045. * Defines the related dom event
  46046. */
  46047. event: ClipboardEvent);
  46048. /**
  46049. * Get the clipboard event's type from the keycode.
  46050. * @param keyCode Defines the keyCode for the current keyboard event.
  46051. * @return {number}
  46052. */
  46053. static GetTypeFromCharacter(keyCode: number): number;
  46054. }
  46055. }
  46056. declare module "babylonjs/Events/index" {
  46057. export * from "babylonjs/Events/keyboardEvents";
  46058. export * from "babylonjs/Events/pointerEvents";
  46059. export * from "babylonjs/Events/clipboardEvents";
  46060. }
  46061. declare module "babylonjs/Gamepads/Controllers/daydreamController" {
  46062. import { Scene } from "babylonjs/scene";
  46063. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46064. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  46065. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  46066. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  46067. /**
  46068. * Google Daydream controller
  46069. */
  46070. export class DaydreamController extends WebVRController {
  46071. /**
  46072. * Base Url for the controller model.
  46073. */
  46074. static MODEL_BASE_URL: string;
  46075. /**
  46076. * File name for the controller model.
  46077. */
  46078. static MODEL_FILENAME: string;
  46079. /**
  46080. * Gamepad Id prefix used to identify Daydream Controller.
  46081. */
  46082. static readonly GAMEPAD_ID_PREFIX: string;
  46083. /**
  46084. * Creates a new DaydreamController from a gamepad
  46085. * @param vrGamepad the gamepad that the controller should be created from
  46086. */
  46087. constructor(vrGamepad: any);
  46088. /**
  46089. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  46090. * @param scene scene in which to add meshes
  46091. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  46092. */
  46093. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  46094. /**
  46095. * Called once for each button that changed state since the last frame
  46096. * @param buttonIdx Which button index changed
  46097. * @param state New state of the button
  46098. * @param changes Which properties on the state changed since last frame
  46099. */
  46100. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  46101. }
  46102. }
  46103. declare module "babylonjs/Gamepads/Controllers/gearVRController" {
  46104. import { Scene } from "babylonjs/scene";
  46105. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46106. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  46107. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  46108. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  46109. /**
  46110. * Gear VR Controller
  46111. */
  46112. export class GearVRController extends WebVRController {
  46113. /**
  46114. * Base Url for the controller model.
  46115. */
  46116. static MODEL_BASE_URL: string;
  46117. /**
  46118. * File name for the controller model.
  46119. */
  46120. static MODEL_FILENAME: string;
  46121. /**
  46122. * Gamepad Id prefix used to identify this controller.
  46123. */
  46124. static readonly GAMEPAD_ID_PREFIX: string;
  46125. private readonly _buttonIndexToObservableNameMap;
  46126. /**
  46127. * Creates a new GearVRController from a gamepad
  46128. * @param vrGamepad the gamepad that the controller should be created from
  46129. */
  46130. constructor(vrGamepad: any);
  46131. /**
  46132. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  46133. * @param scene scene in which to add meshes
  46134. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  46135. */
  46136. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  46137. /**
  46138. * Called once for each button that changed state since the last frame
  46139. * @param buttonIdx Which button index changed
  46140. * @param state New state of the button
  46141. * @param changes Which properties on the state changed since last frame
  46142. */
  46143. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  46144. }
  46145. }
  46146. declare module "babylonjs/Gamepads/Controllers/index" {
  46147. export * from "babylonjs/Gamepads/Controllers/daydreamController";
  46148. export * from "babylonjs/Gamepads/Controllers/gearVRController";
  46149. export * from "babylonjs/Gamepads/Controllers/genericController";
  46150. export * from "babylonjs/Gamepads/Controllers/oculusTouchController";
  46151. export * from "babylonjs/Gamepads/Controllers/poseEnabledController";
  46152. export * from "babylonjs/Gamepads/Controllers/viveController";
  46153. export * from "babylonjs/Gamepads/Controllers/webVRController";
  46154. export * from "babylonjs/Gamepads/Controllers/windowsMotionController";
  46155. }
  46156. declare module "babylonjs/Gamepads/index" {
  46157. export * from "babylonjs/Gamepads/Controllers/index";
  46158. export * from "babylonjs/Gamepads/gamepad";
  46159. export * from "babylonjs/Gamepads/gamepadManager";
  46160. export * from "babylonjs/Gamepads/gamepadSceneComponent";
  46161. export * from "babylonjs/Gamepads/xboxGamepad";
  46162. export * from "babylonjs/Gamepads/dualShockGamepad";
  46163. }
  46164. declare module "babylonjs/Meshes/Builders/polyhedronBuilder" {
  46165. import { Scene } from "babylonjs/scene";
  46166. import { Vector4 } from "babylonjs/Maths/math.vector";
  46167. import { Color4 } from "babylonjs/Maths/math.color";
  46168. import { Mesh } from "babylonjs/Meshes/mesh";
  46169. import { Nullable } from "babylonjs/types";
  46170. /**
  46171. * Class containing static functions to help procedurally build meshes
  46172. */
  46173. export class PolyhedronBuilder {
  46174. /**
  46175. * Creates a polyhedron mesh
  46176. * * 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
  46177. * * The parameter `size` (positive float, default 1) sets the polygon size
  46178. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  46179. * * 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`
  46180. * * 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
  46181. * * 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)`)
  46182. * * 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
  46183. * * 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
  46184. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  46185. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  46186. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  46187. * @param name defines the name of the mesh
  46188. * @param options defines the options used to create the mesh
  46189. * @param scene defines the hosting scene
  46190. * @returns the polyhedron mesh
  46191. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  46192. */
  46193. static CreatePolyhedron(name: string, options: {
  46194. type?: number;
  46195. size?: number;
  46196. sizeX?: number;
  46197. sizeY?: number;
  46198. sizeZ?: number;
  46199. custom?: any;
  46200. faceUV?: Vector4[];
  46201. faceColors?: Color4[];
  46202. flat?: boolean;
  46203. updatable?: boolean;
  46204. sideOrientation?: number;
  46205. frontUVs?: Vector4;
  46206. backUVs?: Vector4;
  46207. }, scene?: Nullable<Scene>): Mesh;
  46208. }
  46209. }
  46210. declare module "babylonjs/Gizmos/scaleGizmo" {
  46211. import { Observable } from "babylonjs/Misc/observable";
  46212. import { Nullable } from "babylonjs/types";
  46213. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46214. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  46215. import { AxisScaleGizmo } from "babylonjs/Gizmos/axisScaleGizmo";
  46216. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  46217. /**
  46218. * Gizmo that enables scaling a mesh along 3 axis
  46219. */
  46220. export class ScaleGizmo extends Gizmo {
  46221. /**
  46222. * Internal gizmo used for interactions on the x axis
  46223. */
  46224. xGizmo: AxisScaleGizmo;
  46225. /**
  46226. * Internal gizmo used for interactions on the y axis
  46227. */
  46228. yGizmo: AxisScaleGizmo;
  46229. /**
  46230. * Internal gizmo used for interactions on the z axis
  46231. */
  46232. zGizmo: AxisScaleGizmo;
  46233. /**
  46234. * Internal gizmo used to scale all axis equally
  46235. */
  46236. uniformScaleGizmo: AxisScaleGizmo;
  46237. private _meshAttached;
  46238. private _updateGizmoRotationToMatchAttachedMesh;
  46239. private _snapDistance;
  46240. private _scaleRatio;
  46241. private _uniformScalingMesh;
  46242. private _octahedron;
  46243. /** Fires an event when any of it's sub gizmos are dragged */
  46244. onDragStartObservable: Observable<unknown>;
  46245. /** Fires an event when any of it's sub gizmos are released from dragging */
  46246. onDragEndObservable: Observable<unknown>;
  46247. attachedMesh: Nullable<AbstractMesh>;
  46248. /**
  46249. * Creates a ScaleGizmo
  46250. * @param gizmoLayer The utility layer the gizmo will be added to
  46251. */
  46252. constructor(gizmoLayer?: UtilityLayerRenderer);
  46253. updateGizmoRotationToMatchAttachedMesh: boolean;
  46254. /**
  46255. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  46256. */
  46257. snapDistance: number;
  46258. /**
  46259. * Ratio for the scale of the gizmo (Default: 1)
  46260. */
  46261. scaleRatio: number;
  46262. /**
  46263. * Disposes of the gizmo
  46264. */
  46265. dispose(): void;
  46266. }
  46267. }
  46268. declare module "babylonjs/Gizmos/axisScaleGizmo" {
  46269. import { Observable } from "babylonjs/Misc/observable";
  46270. import { Nullable } from "babylonjs/types";
  46271. import { Vector3 } from "babylonjs/Maths/math.vector";
  46272. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46273. import { Mesh } from "babylonjs/Meshes/mesh";
  46274. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  46275. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  46276. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  46277. import { ScaleGizmo } from "babylonjs/Gizmos/scaleGizmo";
  46278. import { Color3 } from "babylonjs/Maths/math.color";
  46279. /**
  46280. * Single axis scale gizmo
  46281. */
  46282. export class AxisScaleGizmo extends Gizmo {
  46283. /**
  46284. * Drag behavior responsible for the gizmos dragging interactions
  46285. */
  46286. dragBehavior: PointerDragBehavior;
  46287. private _pointerObserver;
  46288. /**
  46289. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  46290. */
  46291. snapDistance: number;
  46292. /**
  46293. * Event that fires each time the gizmo snaps to a new location.
  46294. * * snapDistance is the the change in distance
  46295. */
  46296. onSnapObservable: Observable<{
  46297. snapDistance: number;
  46298. }>;
  46299. /**
  46300. * If the scaling operation should be done on all axis (default: false)
  46301. */
  46302. uniformScaling: boolean;
  46303. private _isEnabled;
  46304. private _parent;
  46305. private _arrow;
  46306. private _coloredMaterial;
  46307. private _hoverMaterial;
  46308. /**
  46309. * Creates an AxisScaleGizmo
  46310. * @param gizmoLayer The utility layer the gizmo will be added to
  46311. * @param dragAxis The axis which the gizmo will be able to scale on
  46312. * @param color The color of the gizmo
  46313. */
  46314. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>);
  46315. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  46316. /**
  46317. * If the gizmo is enabled
  46318. */
  46319. isEnabled: boolean;
  46320. /**
  46321. * Disposes of the gizmo
  46322. */
  46323. dispose(): void;
  46324. /**
  46325. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  46326. * @param mesh The mesh to replace the default mesh of the gizmo
  46327. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  46328. */
  46329. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  46330. }
  46331. }
  46332. declare module "babylonjs/Gizmos/boundingBoxGizmo" {
  46333. import { Observable } from "babylonjs/Misc/observable";
  46334. import { Nullable } from "babylonjs/types";
  46335. import { Vector3 } from "babylonjs/Maths/math.vector";
  46336. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46337. import { Mesh } from "babylonjs/Meshes/mesh";
  46338. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  46339. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  46340. import { Color3 } from "babylonjs/Maths/math.color";
  46341. import "babylonjs/Meshes/Builders/boxBuilder";
  46342. /**
  46343. * Bounding box gizmo
  46344. */
  46345. export class BoundingBoxGizmo extends Gizmo {
  46346. private _lineBoundingBox;
  46347. private _rotateSpheresParent;
  46348. private _scaleBoxesParent;
  46349. private _boundingDimensions;
  46350. private _renderObserver;
  46351. private _pointerObserver;
  46352. private _scaleDragSpeed;
  46353. private _tmpQuaternion;
  46354. private _tmpVector;
  46355. private _tmpRotationMatrix;
  46356. /**
  46357. * 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)
  46358. */
  46359. ignoreChildren: boolean;
  46360. /**
  46361. * 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)
  46362. */
  46363. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  46364. /**
  46365. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  46366. */
  46367. rotationSphereSize: number;
  46368. /**
  46369. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  46370. */
  46371. scaleBoxSize: number;
  46372. /**
  46373. * 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)
  46374. */
  46375. fixedDragMeshScreenSize: boolean;
  46376. /**
  46377. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  46378. */
  46379. fixedDragMeshScreenSizeDistanceFactor: number;
  46380. /**
  46381. * Fired when a rotation sphere or scale box is dragged
  46382. */
  46383. onDragStartObservable: Observable<{}>;
  46384. /**
  46385. * Fired when a scale box is dragged
  46386. */
  46387. onScaleBoxDragObservable: Observable<{}>;
  46388. /**
  46389. * Fired when a scale box drag is ended
  46390. */
  46391. onScaleBoxDragEndObservable: Observable<{}>;
  46392. /**
  46393. * Fired when a rotation sphere is dragged
  46394. */
  46395. onRotationSphereDragObservable: Observable<{}>;
  46396. /**
  46397. * Fired when a rotation sphere drag is ended
  46398. */
  46399. onRotationSphereDragEndObservable: Observable<{}>;
  46400. /**
  46401. * 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)
  46402. */
  46403. scalePivot: Nullable<Vector3>;
  46404. /**
  46405. * Mesh used as a pivot to rotate the attached mesh
  46406. */
  46407. private _anchorMesh;
  46408. private _existingMeshScale;
  46409. private _dragMesh;
  46410. private pointerDragBehavior;
  46411. private coloredMaterial;
  46412. private hoverColoredMaterial;
  46413. /**
  46414. * Sets the color of the bounding box gizmo
  46415. * @param color the color to set
  46416. */
  46417. setColor(color: Color3): void;
  46418. /**
  46419. * Creates an BoundingBoxGizmo
  46420. * @param gizmoLayer The utility layer the gizmo will be added to
  46421. * @param color The color of the gizmo
  46422. */
  46423. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  46424. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  46425. private _selectNode;
  46426. /**
  46427. * Updates the bounding box information for the Gizmo
  46428. */
  46429. updateBoundingBox(): void;
  46430. private _updateRotationSpheres;
  46431. private _updateScaleBoxes;
  46432. /**
  46433. * Enables rotation on the specified axis and disables rotation on the others
  46434. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  46435. */
  46436. setEnabledRotationAxis(axis: string): void;
  46437. /**
  46438. * Enables/disables scaling
  46439. * @param enable if scaling should be enabled
  46440. */
  46441. setEnabledScaling(enable: boolean): void;
  46442. private _updateDummy;
  46443. /**
  46444. * Enables a pointer drag behavior on the bounding box of the gizmo
  46445. */
  46446. enableDragBehavior(): void;
  46447. /**
  46448. * Disposes of the gizmo
  46449. */
  46450. dispose(): void;
  46451. /**
  46452. * 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)
  46453. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  46454. * @returns the bounding box mesh with the passed in mesh as a child
  46455. */
  46456. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  46457. /**
  46458. * CustomMeshes are not supported by this gizmo
  46459. * @param mesh The mesh to replace the default mesh of the gizmo
  46460. */
  46461. setCustomMesh(mesh: Mesh): void;
  46462. }
  46463. }
  46464. declare module "babylonjs/Gizmos/planeRotationGizmo" {
  46465. import { Observable } from "babylonjs/Misc/observable";
  46466. import { Nullable } from "babylonjs/types";
  46467. import { Vector3 } from "babylonjs/Maths/math.vector";
  46468. import { Color3 } from "babylonjs/Maths/math.color";
  46469. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46470. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  46471. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  46472. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  46473. import "babylonjs/Meshes/Builders/linesBuilder";
  46474. import { RotationGizmo } from "babylonjs/Gizmos/rotationGizmo";
  46475. /**
  46476. * Single plane rotation gizmo
  46477. */
  46478. export class PlaneRotationGizmo extends Gizmo {
  46479. /**
  46480. * Drag behavior responsible for the gizmos dragging interactions
  46481. */
  46482. dragBehavior: PointerDragBehavior;
  46483. private _pointerObserver;
  46484. /**
  46485. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  46486. */
  46487. snapDistance: number;
  46488. /**
  46489. * Event that fires each time the gizmo snaps to a new location.
  46490. * * snapDistance is the the change in distance
  46491. */
  46492. onSnapObservable: Observable<{
  46493. snapDistance: number;
  46494. }>;
  46495. private _isEnabled;
  46496. private _parent;
  46497. /**
  46498. * Creates a PlaneRotationGizmo
  46499. * @param gizmoLayer The utility layer the gizmo will be added to
  46500. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  46501. * @param color The color of the gizmo
  46502. * @param tessellation Amount of tessellation to be used when creating rotation circles
  46503. * @param useEulerRotation Use and update Euler angle instead of quaternion
  46504. */
  46505. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean);
  46506. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  46507. /**
  46508. * If the gizmo is enabled
  46509. */
  46510. isEnabled: boolean;
  46511. /**
  46512. * Disposes of the gizmo
  46513. */
  46514. dispose(): void;
  46515. }
  46516. }
  46517. declare module "babylonjs/Gizmos/rotationGizmo" {
  46518. import { Observable } from "babylonjs/Misc/observable";
  46519. import { Nullable } from "babylonjs/types";
  46520. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46521. import { Mesh } from "babylonjs/Meshes/mesh";
  46522. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  46523. import { PlaneRotationGizmo } from "babylonjs/Gizmos/planeRotationGizmo";
  46524. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  46525. /**
  46526. * Gizmo that enables rotating a mesh along 3 axis
  46527. */
  46528. export class RotationGizmo extends Gizmo {
  46529. /**
  46530. * Internal gizmo used for interactions on the x axis
  46531. */
  46532. xGizmo: PlaneRotationGizmo;
  46533. /**
  46534. * Internal gizmo used for interactions on the y axis
  46535. */
  46536. yGizmo: PlaneRotationGizmo;
  46537. /**
  46538. * Internal gizmo used for interactions on the z axis
  46539. */
  46540. zGizmo: PlaneRotationGizmo;
  46541. /** Fires an event when any of it's sub gizmos are dragged */
  46542. onDragStartObservable: Observable<unknown>;
  46543. /** Fires an event when any of it's sub gizmos are released from dragging */
  46544. onDragEndObservable: Observable<unknown>;
  46545. private _meshAttached;
  46546. attachedMesh: Nullable<AbstractMesh>;
  46547. /**
  46548. * Creates a RotationGizmo
  46549. * @param gizmoLayer The utility layer the gizmo will be added to
  46550. * @param tessellation Amount of tessellation to be used when creating rotation circles
  46551. * @param useEulerRotation Use and update Euler angle instead of quaternion
  46552. */
  46553. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean);
  46554. updateGizmoRotationToMatchAttachedMesh: boolean;
  46555. /**
  46556. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  46557. */
  46558. snapDistance: number;
  46559. /**
  46560. * Ratio for the scale of the gizmo (Default: 1)
  46561. */
  46562. scaleRatio: number;
  46563. /**
  46564. * Disposes of the gizmo
  46565. */
  46566. dispose(): void;
  46567. /**
  46568. * CustomMeshes are not supported by this gizmo
  46569. * @param mesh The mesh to replace the default mesh of the gizmo
  46570. */
  46571. setCustomMesh(mesh: Mesh): void;
  46572. }
  46573. }
  46574. declare module "babylonjs/Gizmos/gizmoManager" {
  46575. import { Observable } from "babylonjs/Misc/observable";
  46576. import { Nullable } from "babylonjs/types";
  46577. import { Scene, IDisposable } from "babylonjs/scene";
  46578. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46579. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  46580. import { SixDofDragBehavior } from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  46581. import { RotationGizmo } from "babylonjs/Gizmos/rotationGizmo";
  46582. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  46583. import { ScaleGizmo } from "babylonjs/Gizmos/scaleGizmo";
  46584. import { BoundingBoxGizmo } from "babylonjs/Gizmos/boundingBoxGizmo";
  46585. /**
  46586. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  46587. */
  46588. export class GizmoManager implements IDisposable {
  46589. private scene;
  46590. /**
  46591. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  46592. */
  46593. gizmos: {
  46594. positionGizmo: Nullable<PositionGizmo>;
  46595. rotationGizmo: Nullable<RotationGizmo>;
  46596. scaleGizmo: Nullable<ScaleGizmo>;
  46597. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  46598. };
  46599. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  46600. clearGizmoOnEmptyPointerEvent: boolean;
  46601. /** Fires an event when the manager is attached to a mesh */
  46602. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  46603. private _gizmosEnabled;
  46604. private _pointerObserver;
  46605. private _attachedMesh;
  46606. private _boundingBoxColor;
  46607. private _defaultUtilityLayer;
  46608. private _defaultKeepDepthUtilityLayer;
  46609. /**
  46610. * When bounding box gizmo is enabled, this can be used to track drag/end events
  46611. */
  46612. boundingBoxDragBehavior: SixDofDragBehavior;
  46613. /**
  46614. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  46615. */
  46616. attachableMeshes: Nullable<Array<AbstractMesh>>;
  46617. /**
  46618. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  46619. */
  46620. usePointerToAttachGizmos: boolean;
  46621. /**
  46622. * Utility layer that the bounding box gizmo belongs to
  46623. */
  46624. readonly keepDepthUtilityLayer: UtilityLayerRenderer;
  46625. /**
  46626. * Utility layer that all gizmos besides bounding box belong to
  46627. */
  46628. readonly utilityLayer: UtilityLayerRenderer;
  46629. /**
  46630. * Instatiates a gizmo manager
  46631. * @param scene the scene to overlay the gizmos on top of
  46632. */
  46633. constructor(scene: Scene);
  46634. /**
  46635. * Attaches a set of gizmos to the specified mesh
  46636. * @param mesh The mesh the gizmo's should be attached to
  46637. */
  46638. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  46639. /**
  46640. * If the position gizmo is enabled
  46641. */
  46642. positionGizmoEnabled: boolean;
  46643. /**
  46644. * If the rotation gizmo is enabled
  46645. */
  46646. rotationGizmoEnabled: boolean;
  46647. /**
  46648. * If the scale gizmo is enabled
  46649. */
  46650. scaleGizmoEnabled: boolean;
  46651. /**
  46652. * If the boundingBox gizmo is enabled
  46653. */
  46654. boundingBoxGizmoEnabled: boolean;
  46655. /**
  46656. * Disposes of the gizmo manager
  46657. */
  46658. dispose(): void;
  46659. }
  46660. }
  46661. declare module "babylonjs/Lights/directionalLight" {
  46662. import { Camera } from "babylonjs/Cameras/camera";
  46663. import { Scene } from "babylonjs/scene";
  46664. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  46665. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46666. import { Light } from "babylonjs/Lights/light";
  46667. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  46668. import { Effect } from "babylonjs/Materials/effect";
  46669. /**
  46670. * A directional light is defined by a direction (what a surprise!).
  46671. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  46672. * 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.
  46673. * Documentation: https://doc.babylonjs.com/babylon101/lights
  46674. */
  46675. export class DirectionalLight extends ShadowLight {
  46676. private _shadowFrustumSize;
  46677. /**
  46678. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  46679. */
  46680. /**
  46681. * Specifies a fix frustum size for the shadow generation.
  46682. */
  46683. shadowFrustumSize: number;
  46684. private _shadowOrthoScale;
  46685. /**
  46686. * Gets the shadow projection scale against the optimal computed one.
  46687. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  46688. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  46689. */
  46690. /**
  46691. * Sets the shadow projection scale against the optimal computed one.
  46692. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  46693. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  46694. */
  46695. shadowOrthoScale: number;
  46696. /**
  46697. * Automatically compute the projection matrix to best fit (including all the casters)
  46698. * on each frame.
  46699. */
  46700. autoUpdateExtends: boolean;
  46701. private _orthoLeft;
  46702. private _orthoRight;
  46703. private _orthoTop;
  46704. private _orthoBottom;
  46705. /**
  46706. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  46707. * The directional light is emitted from everywhere in the given direction.
  46708. * It can cast shadows.
  46709. * Documentation : https://doc.babylonjs.com/babylon101/lights
  46710. * @param name The friendly name of the light
  46711. * @param direction The direction of the light
  46712. * @param scene The scene the light belongs to
  46713. */
  46714. constructor(name: string, direction: Vector3, scene: Scene);
  46715. /**
  46716. * Returns the string "DirectionalLight".
  46717. * @return The class name
  46718. */
  46719. getClassName(): string;
  46720. /**
  46721. * Returns the integer 1.
  46722. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  46723. */
  46724. getTypeID(): number;
  46725. /**
  46726. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  46727. * Returns the DirectionalLight Shadow projection matrix.
  46728. */
  46729. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  46730. /**
  46731. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  46732. * Returns the DirectionalLight Shadow projection matrix.
  46733. */
  46734. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  46735. /**
  46736. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  46737. * Returns the DirectionalLight Shadow projection matrix.
  46738. */
  46739. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  46740. protected _buildUniformLayout(): void;
  46741. /**
  46742. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  46743. * @param effect The effect to update
  46744. * @param lightIndex The index of the light in the effect to update
  46745. * @returns The directional light
  46746. */
  46747. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  46748. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  46749. /**
  46750. * Gets the minZ used for shadow according to both the scene and the light.
  46751. *
  46752. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  46753. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  46754. * @param activeCamera The camera we are returning the min for
  46755. * @returns the depth min z
  46756. */
  46757. getDepthMinZ(activeCamera: Camera): number;
  46758. /**
  46759. * Gets the maxZ used for shadow according to both the scene and the light.
  46760. *
  46761. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  46762. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  46763. * @param activeCamera The camera we are returning the max for
  46764. * @returns the depth max z
  46765. */
  46766. getDepthMaxZ(activeCamera: Camera): number;
  46767. /**
  46768. * Prepares the list of defines specific to the light type.
  46769. * @param defines the list of defines
  46770. * @param lightIndex defines the index of the light for the effect
  46771. */
  46772. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  46773. }
  46774. }
  46775. declare module "babylonjs/Meshes/Builders/hemisphereBuilder" {
  46776. import { Mesh } from "babylonjs/Meshes/mesh";
  46777. /**
  46778. * Class containing static functions to help procedurally build meshes
  46779. */
  46780. export class HemisphereBuilder {
  46781. /**
  46782. * Creates a hemisphere mesh
  46783. * @param name defines the name of the mesh
  46784. * @param options defines the options used to create the mesh
  46785. * @param scene defines the hosting scene
  46786. * @returns the hemisphere mesh
  46787. */
  46788. static CreateHemisphere(name: string, options: {
  46789. segments?: number;
  46790. diameter?: number;
  46791. sideOrientation?: number;
  46792. }, scene: any): Mesh;
  46793. }
  46794. }
  46795. declare module "babylonjs/Lights/spotLight" {
  46796. import { Nullable } from "babylonjs/types";
  46797. import { Scene } from "babylonjs/scene";
  46798. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  46799. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46800. import { Effect } from "babylonjs/Materials/effect";
  46801. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  46802. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  46803. /**
  46804. * A spot light is defined by a position, a direction, an angle, and an exponent.
  46805. * These values define a cone of light starting from the position, emitting toward the direction.
  46806. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  46807. * and the exponent defines the speed of the decay of the light with distance (reach).
  46808. * Documentation: https://doc.babylonjs.com/babylon101/lights
  46809. */
  46810. export class SpotLight extends ShadowLight {
  46811. private _angle;
  46812. private _innerAngle;
  46813. private _cosHalfAngle;
  46814. private _lightAngleScale;
  46815. private _lightAngleOffset;
  46816. /**
  46817. * Gets the cone angle of the spot light in Radians.
  46818. */
  46819. /**
  46820. * Sets the cone angle of the spot light in Radians.
  46821. */
  46822. angle: number;
  46823. /**
  46824. * Only used in gltf falloff mode, this defines the angle where
  46825. * the directional falloff will start before cutting at angle which could be seen
  46826. * as outer angle.
  46827. */
  46828. /**
  46829. * Only used in gltf falloff mode, this defines the angle where
  46830. * the directional falloff will start before cutting at angle which could be seen
  46831. * as outer angle.
  46832. */
  46833. innerAngle: number;
  46834. private _shadowAngleScale;
  46835. /**
  46836. * Allows scaling the angle of the light for shadow generation only.
  46837. */
  46838. /**
  46839. * Allows scaling the angle of the light for shadow generation only.
  46840. */
  46841. shadowAngleScale: number;
  46842. /**
  46843. * The light decay speed with the distance from the emission spot.
  46844. */
  46845. exponent: number;
  46846. private _projectionTextureMatrix;
  46847. /**
  46848. * Allows reading the projecton texture
  46849. */
  46850. readonly projectionTextureMatrix: Matrix;
  46851. protected _projectionTextureLightNear: number;
  46852. /**
  46853. * Gets the near clip of the Spotlight for texture projection.
  46854. */
  46855. /**
  46856. * Sets the near clip of the Spotlight for texture projection.
  46857. */
  46858. projectionTextureLightNear: number;
  46859. protected _projectionTextureLightFar: number;
  46860. /**
  46861. * Gets the far clip of the Spotlight for texture projection.
  46862. */
  46863. /**
  46864. * Sets the far clip of the Spotlight for texture projection.
  46865. */
  46866. projectionTextureLightFar: number;
  46867. protected _projectionTextureUpDirection: Vector3;
  46868. /**
  46869. * Gets the Up vector of the Spotlight for texture projection.
  46870. */
  46871. /**
  46872. * Sets the Up vector of the Spotlight for texture projection.
  46873. */
  46874. projectionTextureUpDirection: Vector3;
  46875. private _projectionTexture;
  46876. /**
  46877. * Gets the projection texture of the light.
  46878. */
  46879. /**
  46880. * Sets the projection texture of the light.
  46881. */
  46882. projectionTexture: Nullable<BaseTexture>;
  46883. private _projectionTextureViewLightDirty;
  46884. private _projectionTextureProjectionLightDirty;
  46885. private _projectionTextureDirty;
  46886. private _projectionTextureViewTargetVector;
  46887. private _projectionTextureViewLightMatrix;
  46888. private _projectionTextureProjectionLightMatrix;
  46889. private _projectionTextureScalingMatrix;
  46890. /**
  46891. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  46892. * It can cast shadows.
  46893. * Documentation : https://doc.babylonjs.com/babylon101/lights
  46894. * @param name The light friendly name
  46895. * @param position The position of the spot light in the scene
  46896. * @param direction The direction of the light in the scene
  46897. * @param angle The cone angle of the light in Radians
  46898. * @param exponent The light decay speed with the distance from the emission spot
  46899. * @param scene The scene the lights belongs to
  46900. */
  46901. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  46902. /**
  46903. * Returns the string "SpotLight".
  46904. * @returns the class name
  46905. */
  46906. getClassName(): string;
  46907. /**
  46908. * Returns the integer 2.
  46909. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  46910. */
  46911. getTypeID(): number;
  46912. /**
  46913. * Overrides the direction setter to recompute the projection texture view light Matrix.
  46914. */
  46915. protected _setDirection(value: Vector3): void;
  46916. /**
  46917. * Overrides the position setter to recompute the projection texture view light Matrix.
  46918. */
  46919. protected _setPosition(value: Vector3): void;
  46920. /**
  46921. * 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.
  46922. * Returns the SpotLight.
  46923. */
  46924. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  46925. protected _computeProjectionTextureViewLightMatrix(): void;
  46926. protected _computeProjectionTextureProjectionLightMatrix(): void;
  46927. /**
  46928. * Main function for light texture projection matrix computing.
  46929. */
  46930. protected _computeProjectionTextureMatrix(): void;
  46931. protected _buildUniformLayout(): void;
  46932. private _computeAngleValues;
  46933. /**
  46934. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  46935. * @param effect The effect to update
  46936. * @param lightIndex The index of the light in the effect to update
  46937. * @returns The spot light
  46938. */
  46939. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  46940. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  46941. /**
  46942. * Disposes the light and the associated resources.
  46943. */
  46944. dispose(): void;
  46945. /**
  46946. * Prepares the list of defines specific to the light type.
  46947. * @param defines the list of defines
  46948. * @param lightIndex defines the index of the light for the effect
  46949. */
  46950. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  46951. }
  46952. }
  46953. declare module "babylonjs/Gizmos/lightGizmo" {
  46954. import { Nullable } from "babylonjs/types";
  46955. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  46956. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  46957. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  46958. import { Light } from "babylonjs/Lights/light";
  46959. /**
  46960. * Gizmo that enables viewing a light
  46961. */
  46962. export class LightGizmo extends Gizmo {
  46963. private _lightMesh;
  46964. private _material;
  46965. private cachedPosition;
  46966. private cachedForward;
  46967. /**
  46968. * Creates a LightGizmo
  46969. * @param gizmoLayer The utility layer the gizmo will be added to
  46970. */
  46971. constructor(gizmoLayer?: UtilityLayerRenderer);
  46972. private _light;
  46973. /**
  46974. * The light that the gizmo is attached to
  46975. */
  46976. light: Nullable<Light>;
  46977. /**
  46978. * Gets the material used to render the light gizmo
  46979. */
  46980. readonly material: StandardMaterial;
  46981. /**
  46982. * @hidden
  46983. * Updates the gizmo to match the attached mesh's position/rotation
  46984. */
  46985. protected _update(): void;
  46986. private static _Scale;
  46987. /**
  46988. * Creates the lines for a light mesh
  46989. */
  46990. private static _createLightLines;
  46991. /**
  46992. * Disposes of the light gizmo
  46993. */
  46994. dispose(): void;
  46995. private static _CreateHemisphericLightMesh;
  46996. private static _CreatePointLightMesh;
  46997. private static _CreateSpotLightMesh;
  46998. private static _CreateDirectionalLightMesh;
  46999. }
  47000. }
  47001. declare module "babylonjs/Gizmos/index" {
  47002. export * from "babylonjs/Gizmos/axisDragGizmo";
  47003. export * from "babylonjs/Gizmos/axisScaleGizmo";
  47004. export * from "babylonjs/Gizmos/boundingBoxGizmo";
  47005. export * from "babylonjs/Gizmos/gizmo";
  47006. export * from "babylonjs/Gizmos/gizmoManager";
  47007. export * from "babylonjs/Gizmos/planeRotationGizmo";
  47008. export * from "babylonjs/Gizmos/positionGizmo";
  47009. export * from "babylonjs/Gizmos/rotationGizmo";
  47010. export * from "babylonjs/Gizmos/scaleGizmo";
  47011. export * from "babylonjs/Gizmos/lightGizmo";
  47012. export * from "babylonjs/Gizmos/planeDragGizmo";
  47013. }
  47014. declare module "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration" {
  47015. /** @hidden */
  47016. export var backgroundFragmentDeclaration: {
  47017. name: string;
  47018. shader: string;
  47019. };
  47020. }
  47021. declare module "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration" {
  47022. /** @hidden */
  47023. export var backgroundUboDeclaration: {
  47024. name: string;
  47025. shader: string;
  47026. };
  47027. }
  47028. declare module "babylonjs/Shaders/background.fragment" {
  47029. import "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration";
  47030. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  47031. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  47032. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  47033. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  47034. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  47035. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  47036. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  47037. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  47038. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  47039. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  47040. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  47041. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  47042. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  47043. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  47044. /** @hidden */
  47045. export var backgroundPixelShader: {
  47046. name: string;
  47047. shader: string;
  47048. };
  47049. }
  47050. declare module "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration" {
  47051. /** @hidden */
  47052. export var backgroundVertexDeclaration: {
  47053. name: string;
  47054. shader: string;
  47055. };
  47056. }
  47057. declare module "babylonjs/Shaders/background.vertex" {
  47058. import "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration";
  47059. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  47060. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  47061. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  47062. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  47063. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  47064. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  47065. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  47066. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  47067. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  47068. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  47069. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  47070. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  47071. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  47072. /** @hidden */
  47073. export var backgroundVertexShader: {
  47074. name: string;
  47075. shader: string;
  47076. };
  47077. }
  47078. declare module "babylonjs/Materials/Background/backgroundMaterial" {
  47079. import { Nullable, int, float } from "babylonjs/types";
  47080. import { Scene } from "babylonjs/scene";
  47081. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  47082. import { SubMesh } from "babylonjs/Meshes/subMesh";
  47083. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47084. import { Mesh } from "babylonjs/Meshes/mesh";
  47085. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  47086. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  47087. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  47088. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  47089. import { IShadowLight } from "babylonjs/Lights/shadowLight";
  47090. import { Color3 } from "babylonjs/Maths/math.color";
  47091. import "babylonjs/Shaders/background.fragment";
  47092. import "babylonjs/Shaders/background.vertex";
  47093. /**
  47094. * Background material used to create an efficient environement around your scene.
  47095. */
  47096. export class BackgroundMaterial extends PushMaterial {
  47097. /**
  47098. * Standard reflectance value at parallel view angle.
  47099. */
  47100. static StandardReflectance0: number;
  47101. /**
  47102. * Standard reflectance value at grazing angle.
  47103. */
  47104. static StandardReflectance90: number;
  47105. protected _primaryColor: Color3;
  47106. /**
  47107. * Key light Color (multiply against the environement texture)
  47108. */
  47109. primaryColor: Color3;
  47110. protected __perceptualColor: Nullable<Color3>;
  47111. /**
  47112. * Experimental Internal Use Only.
  47113. *
  47114. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  47115. * This acts as a helper to set the primary color to a more "human friendly" value.
  47116. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  47117. * output color as close as possible from the chosen value.
  47118. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  47119. * part of lighting setup.)
  47120. */
  47121. _perceptualColor: Nullable<Color3>;
  47122. protected _primaryColorShadowLevel: float;
  47123. /**
  47124. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  47125. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  47126. */
  47127. primaryColorShadowLevel: float;
  47128. protected _primaryColorHighlightLevel: float;
  47129. /**
  47130. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  47131. * The primary color is used at the level chosen to define what the white area would look.
  47132. */
  47133. primaryColorHighlightLevel: float;
  47134. protected _reflectionTexture: Nullable<BaseTexture>;
  47135. /**
  47136. * Reflection Texture used in the material.
  47137. * Should be author in a specific way for the best result (refer to the documentation).
  47138. */
  47139. reflectionTexture: Nullable<BaseTexture>;
  47140. protected _reflectionBlur: float;
  47141. /**
  47142. * Reflection Texture level of blur.
  47143. *
  47144. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  47145. * texture twice.
  47146. */
  47147. reflectionBlur: float;
  47148. protected _diffuseTexture: Nullable<BaseTexture>;
  47149. /**
  47150. * Diffuse Texture used in the material.
  47151. * Should be author in a specific way for the best result (refer to the documentation).
  47152. */
  47153. diffuseTexture: Nullable<BaseTexture>;
  47154. protected _shadowLights: Nullable<IShadowLight[]>;
  47155. /**
  47156. * Specify the list of lights casting shadow on the material.
  47157. * All scene shadow lights will be included if null.
  47158. */
  47159. shadowLights: Nullable<IShadowLight[]>;
  47160. protected _shadowLevel: float;
  47161. /**
  47162. * Helps adjusting the shadow to a softer level if required.
  47163. * 0 means black shadows and 1 means no shadows.
  47164. */
  47165. shadowLevel: float;
  47166. protected _sceneCenter: Vector3;
  47167. /**
  47168. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  47169. * It is usually zero but might be interesting to modify according to your setup.
  47170. */
  47171. sceneCenter: Vector3;
  47172. protected _opacityFresnel: boolean;
  47173. /**
  47174. * This helps specifying that the material is falling off to the sky box at grazing angle.
  47175. * This helps ensuring a nice transition when the camera goes under the ground.
  47176. */
  47177. opacityFresnel: boolean;
  47178. protected _reflectionFresnel: boolean;
  47179. /**
  47180. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  47181. * This helps adding a mirror texture on the ground.
  47182. */
  47183. reflectionFresnel: boolean;
  47184. protected _reflectionFalloffDistance: number;
  47185. /**
  47186. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  47187. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  47188. */
  47189. reflectionFalloffDistance: number;
  47190. protected _reflectionAmount: number;
  47191. /**
  47192. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  47193. */
  47194. reflectionAmount: number;
  47195. protected _reflectionReflectance0: number;
  47196. /**
  47197. * This specifies the weight of the reflection at grazing angle.
  47198. */
  47199. reflectionReflectance0: number;
  47200. protected _reflectionReflectance90: number;
  47201. /**
  47202. * This specifies the weight of the reflection at a perpendicular point of view.
  47203. */
  47204. reflectionReflectance90: number;
  47205. /**
  47206. * Sets the reflection reflectance fresnel values according to the default standard
  47207. * empirically know to work well :-)
  47208. */
  47209. reflectionStandardFresnelWeight: number;
  47210. protected _useRGBColor: boolean;
  47211. /**
  47212. * Helps to directly use the maps channels instead of their level.
  47213. */
  47214. useRGBColor: boolean;
  47215. protected _enableNoise: boolean;
  47216. /**
  47217. * This helps reducing the banding effect that could occur on the background.
  47218. */
  47219. enableNoise: boolean;
  47220. /**
  47221. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  47222. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  47223. * Recommended to be keep at 1.0 except for special cases.
  47224. */
  47225. fovMultiplier: number;
  47226. private _fovMultiplier;
  47227. /**
  47228. * Enable the FOV adjustment feature controlled by fovMultiplier.
  47229. */
  47230. useEquirectangularFOV: boolean;
  47231. private _maxSimultaneousLights;
  47232. /**
  47233. * Number of Simultaneous lights allowed on the material.
  47234. */
  47235. maxSimultaneousLights: int;
  47236. /**
  47237. * Default configuration related to image processing available in the Background Material.
  47238. */
  47239. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  47240. /**
  47241. * Keep track of the image processing observer to allow dispose and replace.
  47242. */
  47243. private _imageProcessingObserver;
  47244. /**
  47245. * Attaches a new image processing configuration to the PBR Material.
  47246. * @param configuration (if null the scene configuration will be use)
  47247. */
  47248. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  47249. /**
  47250. * Gets the image processing configuration used either in this material.
  47251. */
  47252. /**
  47253. * Sets the Default image processing configuration used either in the this material.
  47254. *
  47255. * If sets to null, the scene one is in use.
  47256. */
  47257. imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  47258. /**
  47259. * Gets wether the color curves effect is enabled.
  47260. */
  47261. /**
  47262. * Sets wether the color curves effect is enabled.
  47263. */
  47264. cameraColorCurvesEnabled: boolean;
  47265. /**
  47266. * Gets wether the color grading effect is enabled.
  47267. */
  47268. /**
  47269. * Gets wether the color grading effect is enabled.
  47270. */
  47271. cameraColorGradingEnabled: boolean;
  47272. /**
  47273. * Gets wether tonemapping is enabled or not.
  47274. */
  47275. /**
  47276. * Sets wether tonemapping is enabled or not
  47277. */
  47278. cameraToneMappingEnabled: boolean;
  47279. /**
  47280. * The camera exposure used on this material.
  47281. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  47282. * This corresponds to a photographic exposure.
  47283. */
  47284. /**
  47285. * The camera exposure used on this material.
  47286. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  47287. * This corresponds to a photographic exposure.
  47288. */
  47289. cameraExposure: float;
  47290. /**
  47291. * Gets The camera contrast used on this material.
  47292. */
  47293. /**
  47294. * Sets The camera contrast used on this material.
  47295. */
  47296. cameraContrast: float;
  47297. /**
  47298. * Gets the Color Grading 2D Lookup Texture.
  47299. */
  47300. /**
  47301. * Sets the Color Grading 2D Lookup Texture.
  47302. */
  47303. cameraColorGradingTexture: Nullable<BaseTexture>;
  47304. /**
  47305. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  47306. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  47307. * 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;
  47308. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  47309. */
  47310. /**
  47311. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  47312. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  47313. * 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;
  47314. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  47315. */
  47316. cameraColorCurves: Nullable<ColorCurves>;
  47317. /**
  47318. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  47319. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  47320. */
  47321. switchToBGR: boolean;
  47322. private _renderTargets;
  47323. private _reflectionControls;
  47324. private _white;
  47325. private _primaryShadowColor;
  47326. private _primaryHighlightColor;
  47327. /**
  47328. * Instantiates a Background Material in the given scene
  47329. * @param name The friendly name of the material
  47330. * @param scene The scene to add the material to
  47331. */
  47332. constructor(name: string, scene: Scene);
  47333. /**
  47334. * Gets a boolean indicating that current material needs to register RTT
  47335. */
  47336. readonly hasRenderTargetTextures: boolean;
  47337. /**
  47338. * The entire material has been created in order to prevent overdraw.
  47339. * @returns false
  47340. */
  47341. needAlphaTesting(): boolean;
  47342. /**
  47343. * The entire material has been created in order to prevent overdraw.
  47344. * @returns true if blending is enable
  47345. */
  47346. needAlphaBlending(): boolean;
  47347. /**
  47348. * Checks wether the material is ready to be rendered for a given mesh.
  47349. * @param mesh The mesh to render
  47350. * @param subMesh The submesh to check against
  47351. * @param useInstances Specify wether or not the material is used with instances
  47352. * @returns true if all the dependencies are ready (Textures, Effects...)
  47353. */
  47354. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  47355. /**
  47356. * Compute the primary color according to the chosen perceptual color.
  47357. */
  47358. private _computePrimaryColorFromPerceptualColor;
  47359. /**
  47360. * Compute the highlights and shadow colors according to their chosen levels.
  47361. */
  47362. private _computePrimaryColors;
  47363. /**
  47364. * Build the uniform buffer used in the material.
  47365. */
  47366. buildUniformLayout(): void;
  47367. /**
  47368. * Unbind the material.
  47369. */
  47370. unbind(): void;
  47371. /**
  47372. * Bind only the world matrix to the material.
  47373. * @param world The world matrix to bind.
  47374. */
  47375. bindOnlyWorldMatrix(world: Matrix): void;
  47376. /**
  47377. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  47378. * @param world The world matrix to bind.
  47379. * @param subMesh The submesh to bind for.
  47380. */
  47381. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  47382. /**
  47383. * Checks to see if a texture is used in the material.
  47384. * @param texture - Base texture to use.
  47385. * @returns - Boolean specifying if a texture is used in the material.
  47386. */
  47387. hasTexture(texture: BaseTexture): boolean;
  47388. /**
  47389. * Dispose the material.
  47390. * @param forceDisposeEffect Force disposal of the associated effect.
  47391. * @param forceDisposeTextures Force disposal of the associated textures.
  47392. */
  47393. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  47394. /**
  47395. * Clones the material.
  47396. * @param name The cloned name.
  47397. * @returns The cloned material.
  47398. */
  47399. clone(name: string): BackgroundMaterial;
  47400. /**
  47401. * Serializes the current material to its JSON representation.
  47402. * @returns The JSON representation.
  47403. */
  47404. serialize(): any;
  47405. /**
  47406. * Gets the class name of the material
  47407. * @returns "BackgroundMaterial"
  47408. */
  47409. getClassName(): string;
  47410. /**
  47411. * Parse a JSON input to create back a background material.
  47412. * @param source The JSON data to parse
  47413. * @param scene The scene to create the parsed material in
  47414. * @param rootUrl The root url of the assets the material depends upon
  47415. * @returns the instantiated BackgroundMaterial.
  47416. */
  47417. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  47418. }
  47419. }
  47420. declare module "babylonjs/Helpers/environmentHelper" {
  47421. import { Observable } from "babylonjs/Misc/observable";
  47422. import { Nullable } from "babylonjs/types";
  47423. import { Scene } from "babylonjs/scene";
  47424. import { Vector3 } from "babylonjs/Maths/math.vector";
  47425. import { Color3 } from "babylonjs/Maths/math.color";
  47426. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47427. import { Mesh } from "babylonjs/Meshes/mesh";
  47428. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  47429. import { MirrorTexture } from "babylonjs/Materials/Textures/mirrorTexture";
  47430. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  47431. import "babylonjs/Meshes/Builders/planeBuilder";
  47432. import "babylonjs/Meshes/Builders/boxBuilder";
  47433. /**
  47434. * Represents the different options available during the creation of
  47435. * a Environment helper.
  47436. *
  47437. * This can control the default ground, skybox and image processing setup of your scene.
  47438. */
  47439. export interface IEnvironmentHelperOptions {
  47440. /**
  47441. * Specifies wether or not to create a ground.
  47442. * True by default.
  47443. */
  47444. createGround: boolean;
  47445. /**
  47446. * Specifies the ground size.
  47447. * 15 by default.
  47448. */
  47449. groundSize: number;
  47450. /**
  47451. * The texture used on the ground for the main color.
  47452. * Comes from the BabylonJS CDN by default.
  47453. *
  47454. * Remarks: Can be either a texture or a url.
  47455. */
  47456. groundTexture: string | BaseTexture;
  47457. /**
  47458. * The color mixed in the ground texture by default.
  47459. * BabylonJS clearColor by default.
  47460. */
  47461. groundColor: Color3;
  47462. /**
  47463. * Specifies the ground opacity.
  47464. * 1 by default.
  47465. */
  47466. groundOpacity: number;
  47467. /**
  47468. * Enables the ground to receive shadows.
  47469. * True by default.
  47470. */
  47471. enableGroundShadow: boolean;
  47472. /**
  47473. * Helps preventing the shadow to be fully black on the ground.
  47474. * 0.5 by default.
  47475. */
  47476. groundShadowLevel: number;
  47477. /**
  47478. * Creates a mirror texture attach to the ground.
  47479. * false by default.
  47480. */
  47481. enableGroundMirror: boolean;
  47482. /**
  47483. * Specifies the ground mirror size ratio.
  47484. * 0.3 by default as the default kernel is 64.
  47485. */
  47486. groundMirrorSizeRatio: number;
  47487. /**
  47488. * Specifies the ground mirror blur kernel size.
  47489. * 64 by default.
  47490. */
  47491. groundMirrorBlurKernel: number;
  47492. /**
  47493. * Specifies the ground mirror visibility amount.
  47494. * 1 by default
  47495. */
  47496. groundMirrorAmount: number;
  47497. /**
  47498. * Specifies the ground mirror reflectance weight.
  47499. * This uses the standard weight of the background material to setup the fresnel effect
  47500. * of the mirror.
  47501. * 1 by default.
  47502. */
  47503. groundMirrorFresnelWeight: number;
  47504. /**
  47505. * Specifies the ground mirror Falloff distance.
  47506. * This can helps reducing the size of the reflection.
  47507. * 0 by Default.
  47508. */
  47509. groundMirrorFallOffDistance: number;
  47510. /**
  47511. * Specifies the ground mirror texture type.
  47512. * Unsigned Int by Default.
  47513. */
  47514. groundMirrorTextureType: number;
  47515. /**
  47516. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  47517. * the shown objects.
  47518. */
  47519. groundYBias: number;
  47520. /**
  47521. * Specifies wether or not to create a skybox.
  47522. * True by default.
  47523. */
  47524. createSkybox: boolean;
  47525. /**
  47526. * Specifies the skybox size.
  47527. * 20 by default.
  47528. */
  47529. skyboxSize: number;
  47530. /**
  47531. * The texture used on the skybox for the main color.
  47532. * Comes from the BabylonJS CDN by default.
  47533. *
  47534. * Remarks: Can be either a texture or a url.
  47535. */
  47536. skyboxTexture: string | BaseTexture;
  47537. /**
  47538. * The color mixed in the skybox texture by default.
  47539. * BabylonJS clearColor by default.
  47540. */
  47541. skyboxColor: Color3;
  47542. /**
  47543. * The background rotation around the Y axis of the scene.
  47544. * This helps aligning the key lights of your scene with the background.
  47545. * 0 by default.
  47546. */
  47547. backgroundYRotation: number;
  47548. /**
  47549. * Compute automatically the size of the elements to best fit with the scene.
  47550. */
  47551. sizeAuto: boolean;
  47552. /**
  47553. * Default position of the rootMesh if autoSize is not true.
  47554. */
  47555. rootPosition: Vector3;
  47556. /**
  47557. * Sets up the image processing in the scene.
  47558. * true by default.
  47559. */
  47560. setupImageProcessing: boolean;
  47561. /**
  47562. * The texture used as your environment texture in the scene.
  47563. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  47564. *
  47565. * Remarks: Can be either a texture or a url.
  47566. */
  47567. environmentTexture: string | BaseTexture;
  47568. /**
  47569. * The value of the exposure to apply to the scene.
  47570. * 0.6 by default if setupImageProcessing is true.
  47571. */
  47572. cameraExposure: number;
  47573. /**
  47574. * The value of the contrast to apply to the scene.
  47575. * 1.6 by default if setupImageProcessing is true.
  47576. */
  47577. cameraContrast: number;
  47578. /**
  47579. * Specifies wether or not tonemapping should be enabled in the scene.
  47580. * true by default if setupImageProcessing is true.
  47581. */
  47582. toneMappingEnabled: boolean;
  47583. }
  47584. /**
  47585. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  47586. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  47587. * It also helps with the default setup of your imageProcessing configuration.
  47588. */
  47589. export class EnvironmentHelper {
  47590. /**
  47591. * Default ground texture URL.
  47592. */
  47593. private static _groundTextureCDNUrl;
  47594. /**
  47595. * Default skybox texture URL.
  47596. */
  47597. private static _skyboxTextureCDNUrl;
  47598. /**
  47599. * Default environment texture URL.
  47600. */
  47601. private static _environmentTextureCDNUrl;
  47602. /**
  47603. * Creates the default options for the helper.
  47604. */
  47605. private static _getDefaultOptions;
  47606. private _rootMesh;
  47607. /**
  47608. * Gets the root mesh created by the helper.
  47609. */
  47610. readonly rootMesh: Mesh;
  47611. private _skybox;
  47612. /**
  47613. * Gets the skybox created by the helper.
  47614. */
  47615. readonly skybox: Nullable<Mesh>;
  47616. private _skyboxTexture;
  47617. /**
  47618. * Gets the skybox texture created by the helper.
  47619. */
  47620. readonly skyboxTexture: Nullable<BaseTexture>;
  47621. private _skyboxMaterial;
  47622. /**
  47623. * Gets the skybox material created by the helper.
  47624. */
  47625. readonly skyboxMaterial: Nullable<BackgroundMaterial>;
  47626. private _ground;
  47627. /**
  47628. * Gets the ground mesh created by the helper.
  47629. */
  47630. readonly ground: Nullable<Mesh>;
  47631. private _groundTexture;
  47632. /**
  47633. * Gets the ground texture created by the helper.
  47634. */
  47635. readonly groundTexture: Nullable<BaseTexture>;
  47636. private _groundMirror;
  47637. /**
  47638. * Gets the ground mirror created by the helper.
  47639. */
  47640. readonly groundMirror: Nullable<MirrorTexture>;
  47641. /**
  47642. * Gets the ground mirror render list to helps pushing the meshes
  47643. * you wish in the ground reflection.
  47644. */
  47645. readonly groundMirrorRenderList: Nullable<AbstractMesh[]>;
  47646. private _groundMaterial;
  47647. /**
  47648. * Gets the ground material created by the helper.
  47649. */
  47650. readonly groundMaterial: Nullable<BackgroundMaterial>;
  47651. /**
  47652. * Stores the creation options.
  47653. */
  47654. private readonly _scene;
  47655. private _options;
  47656. /**
  47657. * This observable will be notified with any error during the creation of the environment,
  47658. * mainly texture creation errors.
  47659. */
  47660. onErrorObservable: Observable<{
  47661. message?: string;
  47662. exception?: any;
  47663. }>;
  47664. /**
  47665. * constructor
  47666. * @param options Defines the options we want to customize the helper
  47667. * @param scene The scene to add the material to
  47668. */
  47669. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  47670. /**
  47671. * Updates the background according to the new options
  47672. * @param options
  47673. */
  47674. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  47675. /**
  47676. * Sets the primary color of all the available elements.
  47677. * @param color the main color to affect to the ground and the background
  47678. */
  47679. setMainColor(color: Color3): void;
  47680. /**
  47681. * Setup the image processing according to the specified options.
  47682. */
  47683. private _setupImageProcessing;
  47684. /**
  47685. * Setup the environment texture according to the specified options.
  47686. */
  47687. private _setupEnvironmentTexture;
  47688. /**
  47689. * Setup the background according to the specified options.
  47690. */
  47691. private _setupBackground;
  47692. /**
  47693. * Get the scene sizes according to the setup.
  47694. */
  47695. private _getSceneSize;
  47696. /**
  47697. * Setup the ground according to the specified options.
  47698. */
  47699. private _setupGround;
  47700. /**
  47701. * Setup the ground material according to the specified options.
  47702. */
  47703. private _setupGroundMaterial;
  47704. /**
  47705. * Setup the ground diffuse texture according to the specified options.
  47706. */
  47707. private _setupGroundDiffuseTexture;
  47708. /**
  47709. * Setup the ground mirror texture according to the specified options.
  47710. */
  47711. private _setupGroundMirrorTexture;
  47712. /**
  47713. * Setup the ground to receive the mirror texture.
  47714. */
  47715. private _setupMirrorInGroundMaterial;
  47716. /**
  47717. * Setup the skybox according to the specified options.
  47718. */
  47719. private _setupSkybox;
  47720. /**
  47721. * Setup the skybox material according to the specified options.
  47722. */
  47723. private _setupSkyboxMaterial;
  47724. /**
  47725. * Setup the skybox reflection texture according to the specified options.
  47726. */
  47727. private _setupSkyboxReflectionTexture;
  47728. private _errorHandler;
  47729. /**
  47730. * Dispose all the elements created by the Helper.
  47731. */
  47732. dispose(): void;
  47733. }
  47734. }
  47735. declare module "babylonjs/Helpers/photoDome" {
  47736. import { Observable } from "babylonjs/Misc/observable";
  47737. import { Nullable } from "babylonjs/types";
  47738. import { Scene } from "babylonjs/scene";
  47739. import { TransformNode } from "babylonjs/Meshes/transformNode";
  47740. import { Mesh } from "babylonjs/Meshes/mesh";
  47741. import { Texture } from "babylonjs/Materials/Textures/texture";
  47742. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  47743. import "babylonjs/Meshes/Builders/sphereBuilder";
  47744. /**
  47745. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  47746. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  47747. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  47748. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  47749. */
  47750. export class PhotoDome extends TransformNode {
  47751. /**
  47752. * Define the image as a Monoscopic panoramic 360 image.
  47753. */
  47754. static readonly MODE_MONOSCOPIC: number;
  47755. /**
  47756. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  47757. */
  47758. static readonly MODE_TOPBOTTOM: number;
  47759. /**
  47760. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  47761. */
  47762. static readonly MODE_SIDEBYSIDE: number;
  47763. private _useDirectMapping;
  47764. /**
  47765. * The texture being displayed on the sphere
  47766. */
  47767. protected _photoTexture: Texture;
  47768. /**
  47769. * Gets or sets the texture being displayed on the sphere
  47770. */
  47771. photoTexture: Texture;
  47772. /**
  47773. * Observable raised when an error occured while loading the 360 image
  47774. */
  47775. onLoadErrorObservable: Observable<string>;
  47776. /**
  47777. * The skybox material
  47778. */
  47779. protected _material: BackgroundMaterial;
  47780. /**
  47781. * The surface used for the skybox
  47782. */
  47783. protected _mesh: Mesh;
  47784. /**
  47785. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  47786. * Also see the options.resolution property.
  47787. */
  47788. fovMultiplier: number;
  47789. private _imageMode;
  47790. /**
  47791. * Gets or set the current video mode for the video. It can be:
  47792. * * PhotoDome.MODE_MONOSCOPIC : Define the image as a Monoscopic panoramic 360 image.
  47793. * * PhotoDome.MODE_TOPBOTTOM : Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  47794. * * PhotoDome.MODE_SIDEBYSIDE : Define the image as a Stereoscopic Side by Side panoramic 360 image.
  47795. */
  47796. imageMode: number;
  47797. /**
  47798. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  47799. * @param name Element's name, child elements will append suffixes for their own names.
  47800. * @param urlsOfPhoto defines the url of the photo to display
  47801. * @param options defines an object containing optional or exposed sub element properties
  47802. * @param onError defines a callback called when an error occured while loading the texture
  47803. */
  47804. constructor(name: string, urlOfPhoto: string, options: {
  47805. resolution?: number;
  47806. size?: number;
  47807. useDirectMapping?: boolean;
  47808. faceForward?: boolean;
  47809. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  47810. private _onBeforeCameraRenderObserver;
  47811. private _changeImageMode;
  47812. /**
  47813. * Releases resources associated with this node.
  47814. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  47815. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  47816. */
  47817. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  47818. }
  47819. }
  47820. declare module "babylonjs/Misc/brdfTextureTools" {
  47821. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  47822. import { Scene } from "babylonjs/scene";
  47823. import "babylonjs/Shaders/rgbdDecode.fragment";
  47824. /**
  47825. * Class used to host texture specific utilities
  47826. */
  47827. export class BRDFTextureTools {
  47828. /**
  47829. * Expand the BRDF Texture from RGBD to Half Float if necessary.
  47830. * @param texture the texture to expand.
  47831. */
  47832. private static _ExpandDefaultBRDFTexture;
  47833. /**
  47834. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  47835. * @param scene defines the hosting scene
  47836. * @returns the environment BRDF texture
  47837. */
  47838. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  47839. private static _environmentBRDFBase64Texture;
  47840. }
  47841. }
  47842. declare module "babylonjs/Materials/PBR/pbrClearCoatConfiguration" {
  47843. import { Nullable } from "babylonjs/types";
  47844. import { Color3 } from "babylonjs/Maths/math.color";
  47845. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  47846. import { EffectFallbacks } from "babylonjs/Materials/effect";
  47847. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  47848. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  47849. import { Engine } from "babylonjs/Engines/engine";
  47850. import { Scene } from "babylonjs/scene";
  47851. /**
  47852. * @hidden
  47853. */
  47854. export interface IMaterialClearCoatDefines {
  47855. CLEARCOAT: boolean;
  47856. CLEARCOAT_DEFAULTIOR: boolean;
  47857. CLEARCOAT_TEXTURE: boolean;
  47858. CLEARCOAT_TEXTUREDIRECTUV: number;
  47859. CLEARCOAT_BUMP: boolean;
  47860. CLEARCOAT_BUMPDIRECTUV: number;
  47861. CLEARCOAT_TINT: boolean;
  47862. CLEARCOAT_TINT_TEXTURE: boolean;
  47863. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  47864. /** @hidden */
  47865. _areTexturesDirty: boolean;
  47866. }
  47867. /**
  47868. * Define the code related to the clear coat parameters of the pbr material.
  47869. */
  47870. export class PBRClearCoatConfiguration {
  47871. /**
  47872. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  47873. * The default fits with a polyurethane material.
  47874. */
  47875. private static readonly _DefaultIndexOfRefraction;
  47876. private _isEnabled;
  47877. /**
  47878. * Defines if the clear coat is enabled in the material.
  47879. */
  47880. isEnabled: boolean;
  47881. /**
  47882. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  47883. */
  47884. intensity: number;
  47885. /**
  47886. * Defines the clear coat layer roughness.
  47887. */
  47888. roughness: number;
  47889. private _indexOfRefraction;
  47890. /**
  47891. * Defines the index of refraction of the clear coat.
  47892. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  47893. * The default fits with a polyurethane material.
  47894. * Changing the default value is more performance intensive.
  47895. */
  47896. indexOfRefraction: number;
  47897. private _texture;
  47898. /**
  47899. * Stores the clear coat values in a texture.
  47900. */
  47901. texture: Nullable<BaseTexture>;
  47902. private _bumpTexture;
  47903. /**
  47904. * Define the clear coat specific bump texture.
  47905. */
  47906. bumpTexture: Nullable<BaseTexture>;
  47907. private _isTintEnabled;
  47908. /**
  47909. * Defines if the clear coat tint is enabled in the material.
  47910. */
  47911. isTintEnabled: boolean;
  47912. /**
  47913. * Defines the clear coat tint of the material.
  47914. * This is only use if tint is enabled
  47915. */
  47916. tintColor: Color3;
  47917. /**
  47918. * Defines the distance at which the tint color should be found in the
  47919. * clear coat media.
  47920. * This is only use if tint is enabled
  47921. */
  47922. tintColorAtDistance: number;
  47923. /**
  47924. * Defines the clear coat layer thickness.
  47925. * This is only use if tint is enabled
  47926. */
  47927. tintThickness: number;
  47928. private _tintTexture;
  47929. /**
  47930. * Stores the clear tint values in a texture.
  47931. * rgb is tint
  47932. * a is a thickness factor
  47933. */
  47934. tintTexture: Nullable<BaseTexture>;
  47935. /** @hidden */
  47936. private _internalMarkAllSubMeshesAsTexturesDirty;
  47937. /** @hidden */
  47938. _markAllSubMeshesAsTexturesDirty(): void;
  47939. /**
  47940. * Instantiate a new istance of clear coat configuration.
  47941. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  47942. */
  47943. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  47944. /**
  47945. * Gets wehter the submesh is ready to be used or not.
  47946. * @param defines the list of "defines" to update.
  47947. * @param scene defines the scene the material belongs to.
  47948. * @param engine defines the engine the material belongs to.
  47949. * @param disableBumpMap defines wether the material disables bump or not.
  47950. * @returns - boolean indicating that the submesh is ready or not.
  47951. */
  47952. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  47953. /**
  47954. * Checks to see if a texture is used in the material.
  47955. * @param defines the list of "defines" to update.
  47956. * @param scene defines the scene to the material belongs to.
  47957. */
  47958. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  47959. /**
  47960. * Binds the material data.
  47961. * @param uniformBuffer defines the Uniform buffer to fill in.
  47962. * @param scene defines the scene the material belongs to.
  47963. * @param engine defines the engine the material belongs to.
  47964. * @param disableBumpMap defines wether the material disables bump or not.
  47965. * @param isFrozen defines wether the material is frozen or not.
  47966. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  47967. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  47968. */
  47969. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  47970. /**
  47971. * Checks to see if a texture is used in the material.
  47972. * @param texture - Base texture to use.
  47973. * @returns - Boolean specifying if a texture is used in the material.
  47974. */
  47975. hasTexture(texture: BaseTexture): boolean;
  47976. /**
  47977. * Returns an array of the actively used textures.
  47978. * @param activeTextures Array of BaseTextures
  47979. */
  47980. getActiveTextures(activeTextures: BaseTexture[]): void;
  47981. /**
  47982. * Returns the animatable textures.
  47983. * @param animatables Array of animatable textures.
  47984. */
  47985. getAnimatables(animatables: IAnimatable[]): void;
  47986. /**
  47987. * Disposes the resources of the material.
  47988. * @param forceDisposeTextures - Forces the disposal of all textures.
  47989. */
  47990. dispose(forceDisposeTextures?: boolean): void;
  47991. /**
  47992. * Get the current class name of the texture useful for serialization or dynamic coding.
  47993. * @returns "PBRClearCoatConfiguration"
  47994. */
  47995. getClassName(): string;
  47996. /**
  47997. * Add fallbacks to the effect fallbacks list.
  47998. * @param defines defines the Base texture to use.
  47999. * @param fallbacks defines the current fallback list.
  48000. * @param currentRank defines the current fallback rank.
  48001. * @returns the new fallback rank.
  48002. */
  48003. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  48004. /**
  48005. * Add the required uniforms to the current list.
  48006. * @param uniforms defines the current uniform list.
  48007. */
  48008. static AddUniforms(uniforms: string[]): void;
  48009. /**
  48010. * Add the required samplers to the current list.
  48011. * @param samplers defines the current sampler list.
  48012. */
  48013. static AddSamplers(samplers: string[]): void;
  48014. /**
  48015. * Add the required uniforms to the current buffer.
  48016. * @param uniformBuffer defines the current uniform buffer.
  48017. */
  48018. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  48019. /**
  48020. * Makes a duplicate of the current configuration into another one.
  48021. * @param clearCoatConfiguration define the config where to copy the info
  48022. */
  48023. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  48024. /**
  48025. * Serializes this clear coat configuration.
  48026. * @returns - An object with the serialized config.
  48027. */
  48028. serialize(): any;
  48029. /**
  48030. * Parses a anisotropy Configuration from a serialized object.
  48031. * @param source - Serialized object.
  48032. * @param scene Defines the scene we are parsing for
  48033. * @param rootUrl Defines the rootUrl to load from
  48034. */
  48035. parse(source: any, scene: Scene, rootUrl: string): void;
  48036. }
  48037. }
  48038. declare module "babylonjs/Materials/PBR/pbrAnisotropicConfiguration" {
  48039. import { EffectFallbacks } from "babylonjs/Materials/effect";
  48040. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  48041. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48042. import { Vector2 } from "babylonjs/Maths/math.vector";
  48043. import { Scene } from "babylonjs/scene";
  48044. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  48045. import { Nullable } from "babylonjs/types";
  48046. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  48047. /**
  48048. * @hidden
  48049. */
  48050. export interface IMaterialAnisotropicDefines {
  48051. ANISOTROPIC: boolean;
  48052. ANISOTROPIC_TEXTURE: boolean;
  48053. ANISOTROPIC_TEXTUREDIRECTUV: number;
  48054. MAINUV1: boolean;
  48055. _areTexturesDirty: boolean;
  48056. _needUVs: boolean;
  48057. }
  48058. /**
  48059. * Define the code related to the anisotropic parameters of the pbr material.
  48060. */
  48061. export class PBRAnisotropicConfiguration {
  48062. private _isEnabled;
  48063. /**
  48064. * Defines if the anisotropy is enabled in the material.
  48065. */
  48066. isEnabled: boolean;
  48067. /**
  48068. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  48069. */
  48070. intensity: number;
  48071. /**
  48072. * Defines if the effect is along the tangents, bitangents or in between.
  48073. * By default, the effect is "strectching" the highlights along the tangents.
  48074. */
  48075. direction: Vector2;
  48076. private _texture;
  48077. /**
  48078. * Stores the anisotropy values in a texture.
  48079. * rg is direction (like normal from -1 to 1)
  48080. * b is a intensity
  48081. */
  48082. texture: Nullable<BaseTexture>;
  48083. /** @hidden */
  48084. private _internalMarkAllSubMeshesAsTexturesDirty;
  48085. /** @hidden */
  48086. _markAllSubMeshesAsTexturesDirty(): void;
  48087. /**
  48088. * Instantiate a new istance of anisotropy configuration.
  48089. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  48090. */
  48091. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  48092. /**
  48093. * Specifies that the submesh is ready to be used.
  48094. * @param defines the list of "defines" to update.
  48095. * @param scene defines the scene the material belongs to.
  48096. * @returns - boolean indicating that the submesh is ready or not.
  48097. */
  48098. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  48099. /**
  48100. * Checks to see if a texture is used in the material.
  48101. * @param defines the list of "defines" to update.
  48102. * @param mesh the mesh we are preparing the defines for.
  48103. * @param scene defines the scene the material belongs to.
  48104. */
  48105. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  48106. /**
  48107. * Binds the material data.
  48108. * @param uniformBuffer defines the Uniform buffer to fill in.
  48109. * @param scene defines the scene the material belongs to.
  48110. * @param isFrozen defines wether the material is frozen or not.
  48111. */
  48112. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  48113. /**
  48114. * Checks to see if a texture is used in the material.
  48115. * @param texture - Base texture to use.
  48116. * @returns - Boolean specifying if a texture is used in the material.
  48117. */
  48118. hasTexture(texture: BaseTexture): boolean;
  48119. /**
  48120. * Returns an array of the actively used textures.
  48121. * @param activeTextures Array of BaseTextures
  48122. */
  48123. getActiveTextures(activeTextures: BaseTexture[]): void;
  48124. /**
  48125. * Returns the animatable textures.
  48126. * @param animatables Array of animatable textures.
  48127. */
  48128. getAnimatables(animatables: IAnimatable[]): void;
  48129. /**
  48130. * Disposes the resources of the material.
  48131. * @param forceDisposeTextures - Forces the disposal of all textures.
  48132. */
  48133. dispose(forceDisposeTextures?: boolean): void;
  48134. /**
  48135. * Get the current class name of the texture useful for serialization or dynamic coding.
  48136. * @returns "PBRAnisotropicConfiguration"
  48137. */
  48138. getClassName(): string;
  48139. /**
  48140. * Add fallbacks to the effect fallbacks list.
  48141. * @param defines defines the Base texture to use.
  48142. * @param fallbacks defines the current fallback list.
  48143. * @param currentRank defines the current fallback rank.
  48144. * @returns the new fallback rank.
  48145. */
  48146. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  48147. /**
  48148. * Add the required uniforms to the current list.
  48149. * @param uniforms defines the current uniform list.
  48150. */
  48151. static AddUniforms(uniforms: string[]): void;
  48152. /**
  48153. * Add the required uniforms to the current buffer.
  48154. * @param uniformBuffer defines the current uniform buffer.
  48155. */
  48156. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  48157. /**
  48158. * Add the required samplers to the current list.
  48159. * @param samplers defines the current sampler list.
  48160. */
  48161. static AddSamplers(samplers: string[]): void;
  48162. /**
  48163. * Makes a duplicate of the current configuration into another one.
  48164. * @param anisotropicConfiguration define the config where to copy the info
  48165. */
  48166. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  48167. /**
  48168. * Serializes this anisotropy configuration.
  48169. * @returns - An object with the serialized config.
  48170. */
  48171. serialize(): any;
  48172. /**
  48173. * Parses a anisotropy Configuration from a serialized object.
  48174. * @param source - Serialized object.
  48175. * @param scene Defines the scene we are parsing for
  48176. * @param rootUrl Defines the rootUrl to load from
  48177. */
  48178. parse(source: any, scene: Scene, rootUrl: string): void;
  48179. }
  48180. }
  48181. declare module "babylonjs/Materials/PBR/pbrBRDFConfiguration" {
  48182. import { Scene } from "babylonjs/scene";
  48183. /**
  48184. * @hidden
  48185. */
  48186. export interface IMaterialBRDFDefines {
  48187. BRDF_V_HEIGHT_CORRELATED: boolean;
  48188. MS_BRDF_ENERGY_CONSERVATION: boolean;
  48189. SPHERICAL_HARMONICS: boolean;
  48190. /** @hidden */
  48191. _areMiscDirty: boolean;
  48192. }
  48193. /**
  48194. * Define the code related to the BRDF parameters of the pbr material.
  48195. */
  48196. export class PBRBRDFConfiguration {
  48197. /**
  48198. * Default value used for the energy conservation.
  48199. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  48200. */
  48201. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  48202. /**
  48203. * Default value used for the Smith Visibility Height Correlated mode.
  48204. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  48205. */
  48206. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  48207. /**
  48208. * Default value used for the IBL diffuse part.
  48209. * This can help switching back to the polynomials mode globally which is a tiny bit
  48210. * less GPU intensive at the drawback of a lower quality.
  48211. */
  48212. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  48213. private _useEnergyConservation;
  48214. /**
  48215. * Defines if the material uses energy conservation.
  48216. */
  48217. useEnergyConservation: boolean;
  48218. private _useSmithVisibilityHeightCorrelated;
  48219. /**
  48220. * LEGACY Mode set to false
  48221. * Defines if the material uses height smith correlated visibility term.
  48222. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  48223. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  48224. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  48225. * Not relying on height correlated will also disable energy conservation.
  48226. */
  48227. useSmithVisibilityHeightCorrelated: boolean;
  48228. private _useSphericalHarmonics;
  48229. /**
  48230. * LEGACY Mode set to false
  48231. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  48232. * diffuse part of the IBL.
  48233. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  48234. * to the ground truth.
  48235. */
  48236. useSphericalHarmonics: boolean;
  48237. /** @hidden */
  48238. private _internalMarkAllSubMeshesAsMiscDirty;
  48239. /** @hidden */
  48240. _markAllSubMeshesAsMiscDirty(): void;
  48241. /**
  48242. * Instantiate a new istance of clear coat configuration.
  48243. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  48244. */
  48245. constructor(markAllSubMeshesAsMiscDirty: () => void);
  48246. /**
  48247. * Checks to see if a texture is used in the material.
  48248. * @param defines the list of "defines" to update.
  48249. */
  48250. prepareDefines(defines: IMaterialBRDFDefines): void;
  48251. /**
  48252. * Get the current class name of the texture useful for serialization or dynamic coding.
  48253. * @returns "PBRClearCoatConfiguration"
  48254. */
  48255. getClassName(): string;
  48256. /**
  48257. * Makes a duplicate of the current configuration into another one.
  48258. * @param brdfConfiguration define the config where to copy the info
  48259. */
  48260. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  48261. /**
  48262. * Serializes this BRDF configuration.
  48263. * @returns - An object with the serialized config.
  48264. */
  48265. serialize(): any;
  48266. /**
  48267. * Parses a anisotropy Configuration from a serialized object.
  48268. * @param source - Serialized object.
  48269. * @param scene Defines the scene we are parsing for
  48270. * @param rootUrl Defines the rootUrl to load from
  48271. */
  48272. parse(source: any, scene: Scene, rootUrl: string): void;
  48273. }
  48274. }
  48275. declare module "babylonjs/Materials/PBR/pbrSheenConfiguration" {
  48276. import { EffectFallbacks } from "babylonjs/Materials/effect";
  48277. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  48278. import { Color3 } from "babylonjs/Maths/math.color";
  48279. import { Scene } from "babylonjs/scene";
  48280. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  48281. import { Nullable } from "babylonjs/types";
  48282. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  48283. /**
  48284. * @hidden
  48285. */
  48286. export interface IMaterialSheenDefines {
  48287. SHEEN: boolean;
  48288. SHEEN_TEXTURE: boolean;
  48289. SHEEN_TEXTUREDIRECTUV: number;
  48290. SHEEN_LINKWITHALBEDO: boolean;
  48291. /** @hidden */
  48292. _areTexturesDirty: boolean;
  48293. }
  48294. /**
  48295. * Define the code related to the Sheen parameters of the pbr material.
  48296. */
  48297. export class PBRSheenConfiguration {
  48298. private _isEnabled;
  48299. /**
  48300. * Defines if the material uses sheen.
  48301. */
  48302. isEnabled: boolean;
  48303. private _linkSheenWithAlbedo;
  48304. /**
  48305. * Defines if the sheen is linked to the sheen color.
  48306. */
  48307. linkSheenWithAlbedo: boolean;
  48308. /**
  48309. * Defines the sheen intensity.
  48310. */
  48311. intensity: number;
  48312. /**
  48313. * Defines the sheen color.
  48314. */
  48315. color: Color3;
  48316. private _texture;
  48317. /**
  48318. * Stores the sheen tint values in a texture.
  48319. * rgb is tint
  48320. * a is a intensity
  48321. */
  48322. texture: Nullable<BaseTexture>;
  48323. /** @hidden */
  48324. private _internalMarkAllSubMeshesAsTexturesDirty;
  48325. /** @hidden */
  48326. _markAllSubMeshesAsTexturesDirty(): void;
  48327. /**
  48328. * Instantiate a new istance of clear coat configuration.
  48329. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  48330. */
  48331. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  48332. /**
  48333. * Specifies that the submesh is ready to be used.
  48334. * @param defines the list of "defines" to update.
  48335. * @param scene defines the scene the material belongs to.
  48336. * @returns - boolean indicating that the submesh is ready or not.
  48337. */
  48338. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  48339. /**
  48340. * Checks to see if a texture is used in the material.
  48341. * @param defines the list of "defines" to update.
  48342. * @param scene defines the scene the material belongs to.
  48343. */
  48344. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  48345. /**
  48346. * Binds the material data.
  48347. * @param uniformBuffer defines the Uniform buffer to fill in.
  48348. * @param scene defines the scene the material belongs to.
  48349. * @param isFrozen defines wether the material is frozen or not.
  48350. */
  48351. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  48352. /**
  48353. * Checks to see if a texture is used in the material.
  48354. * @param texture - Base texture to use.
  48355. * @returns - Boolean specifying if a texture is used in the material.
  48356. */
  48357. hasTexture(texture: BaseTexture): boolean;
  48358. /**
  48359. * Returns an array of the actively used textures.
  48360. * @param activeTextures Array of BaseTextures
  48361. */
  48362. getActiveTextures(activeTextures: BaseTexture[]): void;
  48363. /**
  48364. * Returns the animatable textures.
  48365. * @param animatables Array of animatable textures.
  48366. */
  48367. getAnimatables(animatables: IAnimatable[]): void;
  48368. /**
  48369. * Disposes the resources of the material.
  48370. * @param forceDisposeTextures - Forces the disposal of all textures.
  48371. */
  48372. dispose(forceDisposeTextures?: boolean): void;
  48373. /**
  48374. * Get the current class name of the texture useful for serialization or dynamic coding.
  48375. * @returns "PBRSheenConfiguration"
  48376. */
  48377. getClassName(): string;
  48378. /**
  48379. * Add fallbacks to the effect fallbacks list.
  48380. * @param defines defines the Base texture to use.
  48381. * @param fallbacks defines the current fallback list.
  48382. * @param currentRank defines the current fallback rank.
  48383. * @returns the new fallback rank.
  48384. */
  48385. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  48386. /**
  48387. * Add the required uniforms to the current list.
  48388. * @param uniforms defines the current uniform list.
  48389. */
  48390. static AddUniforms(uniforms: string[]): void;
  48391. /**
  48392. * Add the required uniforms to the current buffer.
  48393. * @param uniformBuffer defines the current uniform buffer.
  48394. */
  48395. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  48396. /**
  48397. * Add the required samplers to the current list.
  48398. * @param samplers defines the current sampler list.
  48399. */
  48400. static AddSamplers(samplers: string[]): void;
  48401. /**
  48402. * Makes a duplicate of the current configuration into another one.
  48403. * @param sheenConfiguration define the config where to copy the info
  48404. */
  48405. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  48406. /**
  48407. * Serializes this BRDF configuration.
  48408. * @returns - An object with the serialized config.
  48409. */
  48410. serialize(): any;
  48411. /**
  48412. * Parses a anisotropy Configuration from a serialized object.
  48413. * @param source - Serialized object.
  48414. * @param scene Defines the scene we are parsing for
  48415. * @param rootUrl Defines the rootUrl to load from
  48416. */
  48417. parse(source: any, scene: Scene, rootUrl: string): void;
  48418. }
  48419. }
  48420. declare module "babylonjs/Materials/PBR/pbrSubSurfaceConfiguration" {
  48421. import { Nullable } from "babylonjs/types";
  48422. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  48423. import { Color3 } from "babylonjs/Maths/math.color";
  48424. import { SmartArray } from "babylonjs/Misc/smartArray";
  48425. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  48426. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  48427. import { Effect, EffectFallbacks } from "babylonjs/Materials/effect";
  48428. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  48429. import { Engine } from "babylonjs/Engines/engine";
  48430. import { Scene } from "babylonjs/scene";
  48431. /**
  48432. * @hidden
  48433. */
  48434. export interface IMaterialSubSurfaceDefines {
  48435. SUBSURFACE: boolean;
  48436. SS_REFRACTION: boolean;
  48437. SS_TRANSLUCENCY: boolean;
  48438. SS_SCATERRING: boolean;
  48439. SS_THICKNESSANDMASK_TEXTURE: boolean;
  48440. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  48441. SS_REFRACTIONMAP_3D: boolean;
  48442. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  48443. SS_LODINREFRACTIONALPHA: boolean;
  48444. SS_GAMMAREFRACTION: boolean;
  48445. SS_RGBDREFRACTION: boolean;
  48446. SS_LINEARSPECULARREFRACTION: boolean;
  48447. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  48448. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  48449. /** @hidden */
  48450. _areTexturesDirty: boolean;
  48451. }
  48452. /**
  48453. * Define the code related to the sub surface parameters of the pbr material.
  48454. */
  48455. export class PBRSubSurfaceConfiguration {
  48456. private _isRefractionEnabled;
  48457. /**
  48458. * Defines if the refraction is enabled in the material.
  48459. */
  48460. isRefractionEnabled: boolean;
  48461. private _isTranslucencyEnabled;
  48462. /**
  48463. * Defines if the translucency is enabled in the material.
  48464. */
  48465. isTranslucencyEnabled: boolean;
  48466. private _isScatteringEnabled;
  48467. /**
  48468. * Defines the refraction intensity of the material.
  48469. * The refraction when enabled replaces the Diffuse part of the material.
  48470. * The intensity helps transitionning between diffuse and refraction.
  48471. */
  48472. refractionIntensity: number;
  48473. /**
  48474. * Defines the translucency intensity of the material.
  48475. * When translucency has been enabled, this defines how much of the "translucency"
  48476. * is addded to the diffuse part of the material.
  48477. */
  48478. translucencyIntensity: number;
  48479. /**
  48480. * Defines the scattering intensity of the material.
  48481. * When scattering has been enabled, this defines how much of the "scattered light"
  48482. * is addded to the diffuse part of the material.
  48483. */
  48484. scatteringIntensity: number;
  48485. private _thicknessTexture;
  48486. /**
  48487. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  48488. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  48489. * 0 would mean minimumThickness
  48490. * 1 would mean maximumThickness
  48491. * The other channels might be use as a mask to vary the different effects intensity.
  48492. */
  48493. thicknessTexture: Nullable<BaseTexture>;
  48494. private _refractionTexture;
  48495. /**
  48496. * Defines the texture to use for refraction.
  48497. */
  48498. refractionTexture: Nullable<BaseTexture>;
  48499. private _indexOfRefraction;
  48500. /**
  48501. * Defines the index of refraction used in the material.
  48502. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  48503. */
  48504. indexOfRefraction: number;
  48505. private _invertRefractionY;
  48506. /**
  48507. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  48508. */
  48509. invertRefractionY: boolean;
  48510. private _linkRefractionWithTransparency;
  48511. /**
  48512. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  48513. * Materials half opaque for instance using refraction could benefit from this control.
  48514. */
  48515. linkRefractionWithTransparency: boolean;
  48516. /**
  48517. * Defines the minimum thickness stored in the thickness map.
  48518. * If no thickness map is defined, this value will be used to simulate thickness.
  48519. */
  48520. minimumThickness: number;
  48521. /**
  48522. * Defines the maximum thickness stored in the thickness map.
  48523. */
  48524. maximumThickness: number;
  48525. /**
  48526. * Defines the volume tint of the material.
  48527. * This is used for both translucency and scattering.
  48528. */
  48529. tintColor: Color3;
  48530. /**
  48531. * Defines the distance at which the tint color should be found in the media.
  48532. * This is used for refraction only.
  48533. */
  48534. tintColorAtDistance: number;
  48535. /**
  48536. * Defines how far each channel transmit through the media.
  48537. * It is defined as a color to simplify it selection.
  48538. */
  48539. diffusionDistance: Color3;
  48540. private _useMaskFromThicknessTexture;
  48541. /**
  48542. * Stores the intensity of the different subsurface effects in the thickness texture.
  48543. * * the green channel is the translucency intensity.
  48544. * * the blue channel is the scattering intensity.
  48545. * * the alpha channel is the refraction intensity.
  48546. */
  48547. useMaskFromThicknessTexture: boolean;
  48548. /** @hidden */
  48549. private _internalMarkAllSubMeshesAsTexturesDirty;
  48550. /** @hidden */
  48551. _markAllSubMeshesAsTexturesDirty(): void;
  48552. /**
  48553. * Instantiate a new istance of sub surface configuration.
  48554. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  48555. */
  48556. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  48557. /**
  48558. * Gets wehter the submesh is ready to be used or not.
  48559. * @param defines the list of "defines" to update.
  48560. * @param scene defines the scene the material belongs to.
  48561. * @returns - boolean indicating that the submesh is ready or not.
  48562. */
  48563. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  48564. /**
  48565. * Checks to see if a texture is used in the material.
  48566. * @param defines the list of "defines" to update.
  48567. * @param scene defines the scene to the material belongs to.
  48568. */
  48569. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  48570. /**
  48571. * Binds the material data.
  48572. * @param uniformBuffer defines the Uniform buffer to fill in.
  48573. * @param scene defines the scene the material belongs to.
  48574. * @param engine defines the engine the material belongs to.
  48575. * @param isFrozen defines wether the material is frozen or not.
  48576. * @param lodBasedMicrosurface defines wether the material relies on lod based microsurface or not.
  48577. */
  48578. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean): void;
  48579. /**
  48580. * Unbinds the material from the mesh.
  48581. * @param activeEffect defines the effect that should be unbound from.
  48582. * @returns true if unbound, otherwise false
  48583. */
  48584. unbind(activeEffect: Effect): boolean;
  48585. /**
  48586. * Returns the texture used for refraction or null if none is used.
  48587. * @param scene defines the scene the material belongs to.
  48588. * @returns - Refraction texture if present. If no refraction texture and refraction
  48589. * is linked with transparency, returns environment texture. Otherwise, returns null.
  48590. */
  48591. private _getRefractionTexture;
  48592. /**
  48593. * Returns true if alpha blending should be disabled.
  48594. */
  48595. readonly disableAlphaBlending: boolean;
  48596. /**
  48597. * Fills the list of render target textures.
  48598. * @param renderTargets the list of render targets to update
  48599. */
  48600. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  48601. /**
  48602. * Checks to see if a texture is used in the material.
  48603. * @param texture - Base texture to use.
  48604. * @returns - Boolean specifying if a texture is used in the material.
  48605. */
  48606. hasTexture(texture: BaseTexture): boolean;
  48607. /**
  48608. * Gets a boolean indicating that current material needs to register RTT
  48609. * @returns true if this uses a render target otherwise false.
  48610. */
  48611. hasRenderTargetTextures(): boolean;
  48612. /**
  48613. * Returns an array of the actively used textures.
  48614. * @param activeTextures Array of BaseTextures
  48615. */
  48616. getActiveTextures(activeTextures: BaseTexture[]): void;
  48617. /**
  48618. * Returns the animatable textures.
  48619. * @param animatables Array of animatable textures.
  48620. */
  48621. getAnimatables(animatables: IAnimatable[]): void;
  48622. /**
  48623. * Disposes the resources of the material.
  48624. * @param forceDisposeTextures - Forces the disposal of all textures.
  48625. */
  48626. dispose(forceDisposeTextures?: boolean): void;
  48627. /**
  48628. * Get the current class name of the texture useful for serialization or dynamic coding.
  48629. * @returns "PBRSubSurfaceConfiguration"
  48630. */
  48631. getClassName(): string;
  48632. /**
  48633. * Add fallbacks to the effect fallbacks list.
  48634. * @param defines defines the Base texture to use.
  48635. * @param fallbacks defines the current fallback list.
  48636. * @param currentRank defines the current fallback rank.
  48637. * @returns the new fallback rank.
  48638. */
  48639. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  48640. /**
  48641. * Add the required uniforms to the current list.
  48642. * @param uniforms defines the current uniform list.
  48643. */
  48644. static AddUniforms(uniforms: string[]): void;
  48645. /**
  48646. * Add the required samplers to the current list.
  48647. * @param samplers defines the current sampler list.
  48648. */
  48649. static AddSamplers(samplers: string[]): void;
  48650. /**
  48651. * Add the required uniforms to the current buffer.
  48652. * @param uniformBuffer defines the current uniform buffer.
  48653. */
  48654. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  48655. /**
  48656. * Makes a duplicate of the current configuration into another one.
  48657. * @param configuration define the config where to copy the info
  48658. */
  48659. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  48660. /**
  48661. * Serializes this Sub Surface configuration.
  48662. * @returns - An object with the serialized config.
  48663. */
  48664. serialize(): any;
  48665. /**
  48666. * Parses a anisotropy Configuration from a serialized object.
  48667. * @param source - Serialized object.
  48668. * @param scene Defines the scene we are parsing for
  48669. * @param rootUrl Defines the rootUrl to load from
  48670. */
  48671. parse(source: any, scene: Scene, rootUrl: string): void;
  48672. }
  48673. }
  48674. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration" {
  48675. /** @hidden */
  48676. export var pbrFragmentDeclaration: {
  48677. name: string;
  48678. shader: string;
  48679. };
  48680. }
  48681. declare module "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration" {
  48682. /** @hidden */
  48683. export var pbrUboDeclaration: {
  48684. name: string;
  48685. shader: string;
  48686. };
  48687. }
  48688. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentExtraDeclaration" {
  48689. /** @hidden */
  48690. export var pbrFragmentExtraDeclaration: {
  48691. name: string;
  48692. shader: string;
  48693. };
  48694. }
  48695. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration" {
  48696. /** @hidden */
  48697. export var pbrFragmentSamplersDeclaration: {
  48698. name: string;
  48699. shader: string;
  48700. };
  48701. }
  48702. declare module "babylonjs/Shaders/ShadersInclude/pbrHelperFunctions" {
  48703. /** @hidden */
  48704. export var pbrHelperFunctions: {
  48705. name: string;
  48706. shader: string;
  48707. };
  48708. }
  48709. declare module "babylonjs/Shaders/ShadersInclude/harmonicsFunctions" {
  48710. /** @hidden */
  48711. export var harmonicsFunctions: {
  48712. name: string;
  48713. shader: string;
  48714. };
  48715. }
  48716. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingSetupFunctions" {
  48717. /** @hidden */
  48718. export var pbrDirectLightingSetupFunctions: {
  48719. name: string;
  48720. shader: string;
  48721. };
  48722. }
  48723. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFalloffFunctions" {
  48724. /** @hidden */
  48725. export var pbrDirectLightingFalloffFunctions: {
  48726. name: string;
  48727. shader: string;
  48728. };
  48729. }
  48730. declare module "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions" {
  48731. /** @hidden */
  48732. export var pbrBRDFFunctions: {
  48733. name: string;
  48734. shader: string;
  48735. };
  48736. }
  48737. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFunctions" {
  48738. /** @hidden */
  48739. export var pbrDirectLightingFunctions: {
  48740. name: string;
  48741. shader: string;
  48742. };
  48743. }
  48744. declare module "babylonjs/Shaders/ShadersInclude/pbrIBLFunctions" {
  48745. /** @hidden */
  48746. export var pbrIBLFunctions: {
  48747. name: string;
  48748. shader: string;
  48749. };
  48750. }
  48751. declare module "babylonjs/Shaders/ShadersInclude/pbrDebug" {
  48752. /** @hidden */
  48753. export var pbrDebug: {
  48754. name: string;
  48755. shader: string;
  48756. };
  48757. }
  48758. declare module "babylonjs/Shaders/pbr.fragment" {
  48759. import "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration";
  48760. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  48761. import "babylonjs/Shaders/ShadersInclude/pbrFragmentExtraDeclaration";
  48762. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  48763. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  48764. import "babylonjs/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration";
  48765. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  48766. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  48767. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  48768. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  48769. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  48770. import "babylonjs/Shaders/ShadersInclude/pbrHelperFunctions";
  48771. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  48772. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  48773. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  48774. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingSetupFunctions";
  48775. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFalloffFunctions";
  48776. import "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions";
  48777. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFunctions";
  48778. import "babylonjs/Shaders/ShadersInclude/pbrIBLFunctions";
  48779. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  48780. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  48781. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  48782. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  48783. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  48784. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  48785. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  48786. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  48787. import "babylonjs/Shaders/ShadersInclude/pbrDebug";
  48788. /** @hidden */
  48789. export var pbrPixelShader: {
  48790. name: string;
  48791. shader: string;
  48792. };
  48793. }
  48794. declare module "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration" {
  48795. /** @hidden */
  48796. export var pbrVertexDeclaration: {
  48797. name: string;
  48798. shader: string;
  48799. };
  48800. }
  48801. declare module "babylonjs/Shaders/pbr.vertex" {
  48802. import "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration";
  48803. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  48804. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  48805. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  48806. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  48807. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  48808. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  48809. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  48810. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  48811. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  48812. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  48813. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  48814. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  48815. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  48816. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  48817. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  48818. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  48819. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  48820. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  48821. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  48822. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  48823. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  48824. /** @hidden */
  48825. export var pbrVertexShader: {
  48826. name: string;
  48827. shader: string;
  48828. };
  48829. }
  48830. declare module "babylonjs/Materials/PBR/pbrBaseMaterial" {
  48831. import { Nullable } from "babylonjs/types";
  48832. import { Scene } from "babylonjs/scene";
  48833. import { Matrix } from "babylonjs/Maths/math.vector";
  48834. import { SubMesh } from "babylonjs/Meshes/subMesh";
  48835. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48836. import { Mesh } from "babylonjs/Meshes/mesh";
  48837. import { IMaterialClearCoatDefines, PBRClearCoatConfiguration } from "babylonjs/Materials/PBR/pbrClearCoatConfiguration";
  48838. import { IMaterialAnisotropicDefines, PBRAnisotropicConfiguration } from "babylonjs/Materials/PBR/pbrAnisotropicConfiguration";
  48839. import { IMaterialBRDFDefines, PBRBRDFConfiguration } from "babylonjs/Materials/PBR/pbrBRDFConfiguration";
  48840. import { IMaterialSheenDefines, PBRSheenConfiguration } from "babylonjs/Materials/PBR/pbrSheenConfiguration";
  48841. import { IMaterialSubSurfaceDefines, PBRSubSurfaceConfiguration } from "babylonjs/Materials/PBR/pbrSubSurfaceConfiguration";
  48842. import { Color3 } from "babylonjs/Maths/math.color";
  48843. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  48844. import { Material } from "babylonjs/Materials/material";
  48845. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  48846. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  48847. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  48848. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  48849. import "babylonjs/Shaders/pbr.fragment";
  48850. import "babylonjs/Shaders/pbr.vertex";
  48851. /**
  48852. * Manages the defines for the PBR Material.
  48853. * @hidden
  48854. */
  48855. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines {
  48856. PBR: boolean;
  48857. MAINUV1: boolean;
  48858. MAINUV2: boolean;
  48859. UV1: boolean;
  48860. UV2: boolean;
  48861. ALBEDO: boolean;
  48862. ALBEDODIRECTUV: number;
  48863. VERTEXCOLOR: boolean;
  48864. AMBIENT: boolean;
  48865. AMBIENTDIRECTUV: number;
  48866. AMBIENTINGRAYSCALE: boolean;
  48867. OPACITY: boolean;
  48868. VERTEXALPHA: boolean;
  48869. OPACITYDIRECTUV: number;
  48870. OPACITYRGB: boolean;
  48871. ALPHATEST: boolean;
  48872. DEPTHPREPASS: boolean;
  48873. ALPHABLEND: boolean;
  48874. ALPHAFROMALBEDO: boolean;
  48875. ALPHATESTVALUE: string;
  48876. SPECULAROVERALPHA: boolean;
  48877. RADIANCEOVERALPHA: boolean;
  48878. ALPHAFRESNEL: boolean;
  48879. LINEARALPHAFRESNEL: boolean;
  48880. PREMULTIPLYALPHA: boolean;
  48881. EMISSIVE: boolean;
  48882. EMISSIVEDIRECTUV: number;
  48883. REFLECTIVITY: boolean;
  48884. REFLECTIVITYDIRECTUV: number;
  48885. SPECULARTERM: boolean;
  48886. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  48887. MICROSURFACEAUTOMATIC: boolean;
  48888. LODBASEDMICROSFURACE: boolean;
  48889. MICROSURFACEMAP: boolean;
  48890. MICROSURFACEMAPDIRECTUV: number;
  48891. METALLICWORKFLOW: boolean;
  48892. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  48893. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  48894. METALLNESSSTOREINMETALMAPBLUE: boolean;
  48895. AOSTOREINMETALMAPRED: boolean;
  48896. ENVIRONMENTBRDF: boolean;
  48897. ENVIRONMENTBRDF_RGBD: boolean;
  48898. NORMAL: boolean;
  48899. TANGENT: boolean;
  48900. BUMP: boolean;
  48901. BUMPDIRECTUV: number;
  48902. OBJECTSPACE_NORMALMAP: boolean;
  48903. PARALLAX: boolean;
  48904. PARALLAXOCCLUSION: boolean;
  48905. NORMALXYSCALE: boolean;
  48906. LIGHTMAP: boolean;
  48907. LIGHTMAPDIRECTUV: number;
  48908. USELIGHTMAPASSHADOWMAP: boolean;
  48909. GAMMALIGHTMAP: boolean;
  48910. REFLECTION: boolean;
  48911. REFLECTIONMAP_3D: boolean;
  48912. REFLECTIONMAP_SPHERICAL: boolean;
  48913. REFLECTIONMAP_PLANAR: boolean;
  48914. REFLECTIONMAP_CUBIC: boolean;
  48915. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  48916. REFLECTIONMAP_PROJECTION: boolean;
  48917. REFLECTIONMAP_SKYBOX: boolean;
  48918. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  48919. REFLECTIONMAP_EXPLICIT: boolean;
  48920. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  48921. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  48922. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  48923. INVERTCUBICMAP: boolean;
  48924. USESPHERICALFROMREFLECTIONMAP: boolean;
  48925. USEIRRADIANCEMAP: boolean;
  48926. SPHERICAL_HARMONICS: boolean;
  48927. USESPHERICALINVERTEX: boolean;
  48928. REFLECTIONMAP_OPPOSITEZ: boolean;
  48929. LODINREFLECTIONALPHA: boolean;
  48930. GAMMAREFLECTION: boolean;
  48931. RGBDREFLECTION: boolean;
  48932. LINEARSPECULARREFLECTION: boolean;
  48933. RADIANCEOCCLUSION: boolean;
  48934. HORIZONOCCLUSION: boolean;
  48935. INSTANCES: boolean;
  48936. NUM_BONE_INFLUENCERS: number;
  48937. BonesPerMesh: number;
  48938. BONETEXTURE: boolean;
  48939. NONUNIFORMSCALING: boolean;
  48940. MORPHTARGETS: boolean;
  48941. MORPHTARGETS_NORMAL: boolean;
  48942. MORPHTARGETS_TANGENT: boolean;
  48943. MORPHTARGETS_UV: boolean;
  48944. NUM_MORPH_INFLUENCERS: number;
  48945. IMAGEPROCESSING: boolean;
  48946. VIGNETTE: boolean;
  48947. VIGNETTEBLENDMODEMULTIPLY: boolean;
  48948. VIGNETTEBLENDMODEOPAQUE: boolean;
  48949. TONEMAPPING: boolean;
  48950. TONEMAPPING_ACES: boolean;
  48951. CONTRAST: boolean;
  48952. COLORCURVES: boolean;
  48953. COLORGRADING: boolean;
  48954. COLORGRADING3D: boolean;
  48955. SAMPLER3DGREENDEPTH: boolean;
  48956. SAMPLER3DBGRMAP: boolean;
  48957. IMAGEPROCESSINGPOSTPROCESS: boolean;
  48958. EXPOSURE: boolean;
  48959. MULTIVIEW: boolean;
  48960. USEPHYSICALLIGHTFALLOFF: boolean;
  48961. USEGLTFLIGHTFALLOFF: boolean;
  48962. TWOSIDEDLIGHTING: boolean;
  48963. SHADOWFLOAT: boolean;
  48964. CLIPPLANE: boolean;
  48965. CLIPPLANE2: boolean;
  48966. CLIPPLANE3: boolean;
  48967. CLIPPLANE4: boolean;
  48968. POINTSIZE: boolean;
  48969. FOG: boolean;
  48970. LOGARITHMICDEPTH: boolean;
  48971. FORCENORMALFORWARD: boolean;
  48972. SPECULARAA: boolean;
  48973. CLEARCOAT: boolean;
  48974. CLEARCOAT_DEFAULTIOR: boolean;
  48975. CLEARCOAT_TEXTURE: boolean;
  48976. CLEARCOAT_TEXTUREDIRECTUV: number;
  48977. CLEARCOAT_BUMP: boolean;
  48978. CLEARCOAT_BUMPDIRECTUV: number;
  48979. CLEARCOAT_TINT: boolean;
  48980. CLEARCOAT_TINT_TEXTURE: boolean;
  48981. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  48982. ANISOTROPIC: boolean;
  48983. ANISOTROPIC_TEXTURE: boolean;
  48984. ANISOTROPIC_TEXTUREDIRECTUV: number;
  48985. BRDF_V_HEIGHT_CORRELATED: boolean;
  48986. MS_BRDF_ENERGY_CONSERVATION: boolean;
  48987. SHEEN: boolean;
  48988. SHEEN_TEXTURE: boolean;
  48989. SHEEN_TEXTUREDIRECTUV: number;
  48990. SHEEN_LINKWITHALBEDO: boolean;
  48991. SUBSURFACE: boolean;
  48992. SS_REFRACTION: boolean;
  48993. SS_TRANSLUCENCY: boolean;
  48994. SS_SCATERRING: boolean;
  48995. SS_THICKNESSANDMASK_TEXTURE: boolean;
  48996. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  48997. SS_REFRACTIONMAP_3D: boolean;
  48998. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  48999. SS_LODINREFRACTIONALPHA: boolean;
  49000. SS_GAMMAREFRACTION: boolean;
  49001. SS_RGBDREFRACTION: boolean;
  49002. SS_LINEARSPECULARREFRACTION: boolean;
  49003. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  49004. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  49005. UNLIT: boolean;
  49006. DEBUGMODE: number;
  49007. /**
  49008. * Initializes the PBR Material defines.
  49009. */
  49010. constructor();
  49011. /**
  49012. * Resets the PBR Material defines.
  49013. */
  49014. reset(): void;
  49015. }
  49016. /**
  49017. * The Physically based material base class of BJS.
  49018. *
  49019. * This offers the main features of a standard PBR material.
  49020. * For more information, please refer to the documentation :
  49021. * https://doc.babylonjs.com/how_to/physically_based_rendering
  49022. */
  49023. export abstract class PBRBaseMaterial extends PushMaterial {
  49024. /**
  49025. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  49026. */
  49027. static readonly PBRMATERIAL_OPAQUE: number;
  49028. /**
  49029. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  49030. */
  49031. static readonly PBRMATERIAL_ALPHATEST: number;
  49032. /**
  49033. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  49034. */
  49035. static readonly PBRMATERIAL_ALPHABLEND: number;
  49036. /**
  49037. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  49038. * They are also discarded below the alpha cutoff threshold to improve performances.
  49039. */
  49040. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  49041. /**
  49042. * Defines the default value of how much AO map is occluding the analytical lights
  49043. * (point spot...).
  49044. */
  49045. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  49046. /**
  49047. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  49048. */
  49049. static readonly LIGHTFALLOFF_PHYSICAL: number;
  49050. /**
  49051. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  49052. * to enhance interoperability with other engines.
  49053. */
  49054. static readonly LIGHTFALLOFF_GLTF: number;
  49055. /**
  49056. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  49057. * to enhance interoperability with other materials.
  49058. */
  49059. static readonly LIGHTFALLOFF_STANDARD: number;
  49060. /**
  49061. * Intensity of the direct lights e.g. the four lights available in your scene.
  49062. * This impacts both the direct diffuse and specular highlights.
  49063. */
  49064. protected _directIntensity: number;
  49065. /**
  49066. * Intensity of the emissive part of the material.
  49067. * This helps controlling the emissive effect without modifying the emissive color.
  49068. */
  49069. protected _emissiveIntensity: number;
  49070. /**
  49071. * Intensity of the environment e.g. how much the environment will light the object
  49072. * either through harmonics for rough material or through the refelction for shiny ones.
  49073. */
  49074. protected _environmentIntensity: number;
  49075. /**
  49076. * This is a special control allowing the reduction of the specular highlights coming from the
  49077. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  49078. */
  49079. protected _specularIntensity: number;
  49080. /**
  49081. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  49082. */
  49083. private _lightingInfos;
  49084. /**
  49085. * Debug Control allowing disabling the bump map on this material.
  49086. */
  49087. protected _disableBumpMap: boolean;
  49088. /**
  49089. * AKA Diffuse Texture in standard nomenclature.
  49090. */
  49091. protected _albedoTexture: Nullable<BaseTexture>;
  49092. /**
  49093. * AKA Occlusion Texture in other nomenclature.
  49094. */
  49095. protected _ambientTexture: Nullable<BaseTexture>;
  49096. /**
  49097. * AKA Occlusion Texture Intensity in other nomenclature.
  49098. */
  49099. protected _ambientTextureStrength: number;
  49100. /**
  49101. * Defines how much the AO map is occluding the analytical lights (point spot...).
  49102. * 1 means it completely occludes it
  49103. * 0 mean it has no impact
  49104. */
  49105. protected _ambientTextureImpactOnAnalyticalLights: number;
  49106. /**
  49107. * Stores the alpha values in a texture.
  49108. */
  49109. protected _opacityTexture: Nullable<BaseTexture>;
  49110. /**
  49111. * Stores the reflection values in a texture.
  49112. */
  49113. protected _reflectionTexture: Nullable<BaseTexture>;
  49114. /**
  49115. * Stores the emissive values in a texture.
  49116. */
  49117. protected _emissiveTexture: Nullable<BaseTexture>;
  49118. /**
  49119. * AKA Specular texture in other nomenclature.
  49120. */
  49121. protected _reflectivityTexture: Nullable<BaseTexture>;
  49122. /**
  49123. * Used to switch from specular/glossiness to metallic/roughness workflow.
  49124. */
  49125. protected _metallicTexture: Nullable<BaseTexture>;
  49126. /**
  49127. * Specifies the metallic scalar of the metallic/roughness workflow.
  49128. * Can also be used to scale the metalness values of the metallic texture.
  49129. */
  49130. protected _metallic: Nullable<number>;
  49131. /**
  49132. * Specifies the roughness scalar of the metallic/roughness workflow.
  49133. * Can also be used to scale the roughness values of the metallic texture.
  49134. */
  49135. protected _roughness: Nullable<number>;
  49136. /**
  49137. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  49138. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  49139. */
  49140. protected _microSurfaceTexture: Nullable<BaseTexture>;
  49141. /**
  49142. * Stores surface normal data used to displace a mesh in a texture.
  49143. */
  49144. protected _bumpTexture: Nullable<BaseTexture>;
  49145. /**
  49146. * Stores the pre-calculated light information of a mesh in a texture.
  49147. */
  49148. protected _lightmapTexture: Nullable<BaseTexture>;
  49149. /**
  49150. * The color of a material in ambient lighting.
  49151. */
  49152. protected _ambientColor: Color3;
  49153. /**
  49154. * AKA Diffuse Color in other nomenclature.
  49155. */
  49156. protected _albedoColor: Color3;
  49157. /**
  49158. * AKA Specular Color in other nomenclature.
  49159. */
  49160. protected _reflectivityColor: Color3;
  49161. /**
  49162. * The color applied when light is reflected from a material.
  49163. */
  49164. protected _reflectionColor: Color3;
  49165. /**
  49166. * The color applied when light is emitted from a material.
  49167. */
  49168. protected _emissiveColor: Color3;
  49169. /**
  49170. * AKA Glossiness in other nomenclature.
  49171. */
  49172. protected _microSurface: number;
  49173. /**
  49174. * Specifies that the material will use the light map as a show map.
  49175. */
  49176. protected _useLightmapAsShadowmap: boolean;
  49177. /**
  49178. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  49179. * makes the reflect vector face the model (under horizon).
  49180. */
  49181. protected _useHorizonOcclusion: boolean;
  49182. /**
  49183. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  49184. * too much the area relying on ambient texture to define their ambient occlusion.
  49185. */
  49186. protected _useRadianceOcclusion: boolean;
  49187. /**
  49188. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  49189. */
  49190. protected _useAlphaFromAlbedoTexture: boolean;
  49191. /**
  49192. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  49193. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  49194. */
  49195. protected _useSpecularOverAlpha: boolean;
  49196. /**
  49197. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  49198. */
  49199. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  49200. /**
  49201. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  49202. */
  49203. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  49204. /**
  49205. * Specifies if the metallic texture contains the roughness information in its green channel.
  49206. */
  49207. protected _useRoughnessFromMetallicTextureGreen: boolean;
  49208. /**
  49209. * Specifies if the metallic texture contains the metallness information in its blue channel.
  49210. */
  49211. protected _useMetallnessFromMetallicTextureBlue: boolean;
  49212. /**
  49213. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  49214. */
  49215. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  49216. /**
  49217. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  49218. */
  49219. protected _useAmbientInGrayScale: boolean;
  49220. /**
  49221. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  49222. * The material will try to infer what glossiness each pixel should be.
  49223. */
  49224. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  49225. /**
  49226. * Defines the falloff type used in this material.
  49227. * It by default is Physical.
  49228. */
  49229. protected _lightFalloff: number;
  49230. /**
  49231. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  49232. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  49233. */
  49234. protected _useRadianceOverAlpha: boolean;
  49235. /**
  49236. * Allows using an object space normal map (instead of tangent space).
  49237. */
  49238. protected _useObjectSpaceNormalMap: boolean;
  49239. /**
  49240. * Allows using the bump map in parallax mode.
  49241. */
  49242. protected _useParallax: boolean;
  49243. /**
  49244. * Allows using the bump map in parallax occlusion mode.
  49245. */
  49246. protected _useParallaxOcclusion: boolean;
  49247. /**
  49248. * Controls the scale bias of the parallax mode.
  49249. */
  49250. protected _parallaxScaleBias: number;
  49251. /**
  49252. * If sets to true, disables all the lights affecting the material.
  49253. */
  49254. protected _disableLighting: boolean;
  49255. /**
  49256. * Number of Simultaneous lights allowed on the material.
  49257. */
  49258. protected _maxSimultaneousLights: number;
  49259. /**
  49260. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  49261. */
  49262. protected _invertNormalMapX: boolean;
  49263. /**
  49264. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  49265. */
  49266. protected _invertNormalMapY: boolean;
  49267. /**
  49268. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  49269. */
  49270. protected _twoSidedLighting: boolean;
  49271. /**
  49272. * Defines the alpha limits in alpha test mode.
  49273. */
  49274. protected _alphaCutOff: number;
  49275. /**
  49276. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  49277. */
  49278. protected _forceAlphaTest: boolean;
  49279. /**
  49280. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  49281. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  49282. */
  49283. protected _useAlphaFresnel: boolean;
  49284. /**
  49285. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  49286. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  49287. */
  49288. protected _useLinearAlphaFresnel: boolean;
  49289. /**
  49290. * The transparency mode of the material.
  49291. */
  49292. protected _transparencyMode: Nullable<number>;
  49293. /**
  49294. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  49295. * from cos thetav and roughness:
  49296. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  49297. */
  49298. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  49299. /**
  49300. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  49301. */
  49302. protected _forceIrradianceInFragment: boolean;
  49303. /**
  49304. * Force normal to face away from face.
  49305. */
  49306. protected _forceNormalForward: boolean;
  49307. /**
  49308. * Enables specular anti aliasing in the PBR shader.
  49309. * It will both interacts on the Geometry for analytical and IBL lighting.
  49310. * It also prefilter the roughness map based on the bump values.
  49311. */
  49312. protected _enableSpecularAntiAliasing: boolean;
  49313. /**
  49314. * Default configuration related to image processing available in the PBR Material.
  49315. */
  49316. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  49317. /**
  49318. * Keep track of the image processing observer to allow dispose and replace.
  49319. */
  49320. private _imageProcessingObserver;
  49321. /**
  49322. * Attaches a new image processing configuration to the PBR Material.
  49323. * @param configuration
  49324. */
  49325. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  49326. /**
  49327. * Stores the available render targets.
  49328. */
  49329. private _renderTargets;
  49330. /**
  49331. * Sets the global ambient color for the material used in lighting calculations.
  49332. */
  49333. private _globalAmbientColor;
  49334. /**
  49335. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  49336. */
  49337. private _useLogarithmicDepth;
  49338. /**
  49339. * If set to true, no lighting calculations will be applied.
  49340. */
  49341. private _unlit;
  49342. private _debugMode;
  49343. /**
  49344. * @hidden
  49345. * This is reserved for the inspector.
  49346. * Defines the material debug mode.
  49347. * It helps seeing only some components of the material while troubleshooting.
  49348. */
  49349. debugMode: number;
  49350. /**
  49351. * @hidden
  49352. * This is reserved for the inspector.
  49353. * Specify from where on screen the debug mode should start.
  49354. * The value goes from -1 (full screen) to 1 (not visible)
  49355. * It helps with side by side comparison against the final render
  49356. * This defaults to -1
  49357. */
  49358. private debugLimit;
  49359. /**
  49360. * @hidden
  49361. * This is reserved for the inspector.
  49362. * As the default viewing range might not be enough (if the ambient is really small for instance)
  49363. * You can use the factor to better multiply the final value.
  49364. */
  49365. private debugFactor;
  49366. /**
  49367. * Defines the clear coat layer parameters for the material.
  49368. */
  49369. readonly clearCoat: PBRClearCoatConfiguration;
  49370. /**
  49371. * Defines the anisotropic parameters for the material.
  49372. */
  49373. readonly anisotropy: PBRAnisotropicConfiguration;
  49374. /**
  49375. * Defines the BRDF parameters for the material.
  49376. */
  49377. readonly brdf: PBRBRDFConfiguration;
  49378. /**
  49379. * Defines the Sheen parameters for the material.
  49380. */
  49381. readonly sheen: PBRSheenConfiguration;
  49382. /**
  49383. * Defines the SubSurface parameters for the material.
  49384. */
  49385. readonly subSurface: PBRSubSurfaceConfiguration;
  49386. /**
  49387. * Custom callback helping to override the default shader used in the material.
  49388. */
  49389. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: PBRMaterialDefines) => string;
  49390. protected _rebuildInParallel: boolean;
  49391. /**
  49392. * Instantiates a new PBRMaterial instance.
  49393. *
  49394. * @param name The material name
  49395. * @param scene The scene the material will be use in.
  49396. */
  49397. constructor(name: string, scene: Scene);
  49398. /**
  49399. * Gets a boolean indicating that current material needs to register RTT
  49400. */
  49401. readonly hasRenderTargetTextures: boolean;
  49402. /**
  49403. * Gets the name of the material class.
  49404. */
  49405. getClassName(): string;
  49406. /**
  49407. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  49408. */
  49409. /**
  49410. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  49411. */
  49412. useLogarithmicDepth: boolean;
  49413. /**
  49414. * Gets the current transparency mode.
  49415. */
  49416. /**
  49417. * Sets the transparency mode of the material.
  49418. *
  49419. * | Value | Type | Description |
  49420. * | ----- | ----------------------------------- | ----------- |
  49421. * | 0 | OPAQUE | |
  49422. * | 1 | ALPHATEST | |
  49423. * | 2 | ALPHABLEND | |
  49424. * | 3 | ALPHATESTANDBLEND | |
  49425. *
  49426. */
  49427. transparencyMode: Nullable<number>;
  49428. /**
  49429. * Returns true if alpha blending should be disabled.
  49430. */
  49431. private readonly _disableAlphaBlending;
  49432. /**
  49433. * Specifies whether or not this material should be rendered in alpha blend mode.
  49434. */
  49435. needAlphaBlending(): boolean;
  49436. /**
  49437. * Specifies if the mesh will require alpha blending.
  49438. * @param mesh - BJS mesh.
  49439. */
  49440. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  49441. /**
  49442. * Specifies whether or not this material should be rendered in alpha test mode.
  49443. */
  49444. needAlphaTesting(): boolean;
  49445. /**
  49446. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  49447. */
  49448. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  49449. /**
  49450. * Gets the texture used for the alpha test.
  49451. */
  49452. getAlphaTestTexture(): Nullable<BaseTexture>;
  49453. /**
  49454. * Specifies that the submesh is ready to be used.
  49455. * @param mesh - BJS mesh.
  49456. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  49457. * @param useInstances - Specifies that instances should be used.
  49458. * @returns - boolean indicating that the submesh is ready or not.
  49459. */
  49460. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  49461. /**
  49462. * Specifies if the material uses metallic roughness workflow.
  49463. * @returns boolean specifiying if the material uses metallic roughness workflow.
  49464. */
  49465. isMetallicWorkflow(): boolean;
  49466. private _prepareEffect;
  49467. private _prepareDefines;
  49468. /**
  49469. * Force shader compilation
  49470. */
  49471. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  49472. clipPlane: boolean;
  49473. }>): void;
  49474. /**
  49475. * Initializes the uniform buffer layout for the shader.
  49476. */
  49477. buildUniformLayout(): void;
  49478. /**
  49479. * Unbinds the material from the mesh
  49480. */
  49481. unbind(): void;
  49482. /**
  49483. * Binds the submesh data.
  49484. * @param world - The world matrix.
  49485. * @param mesh - The BJS mesh.
  49486. * @param subMesh - A submesh of the BJS mesh.
  49487. */
  49488. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  49489. /**
  49490. * Returns the animatable textures.
  49491. * @returns - Array of animatable textures.
  49492. */
  49493. getAnimatables(): IAnimatable[];
  49494. /**
  49495. * Returns the texture used for reflections.
  49496. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  49497. */
  49498. private _getReflectionTexture;
  49499. /**
  49500. * Returns an array of the actively used textures.
  49501. * @returns - Array of BaseTextures
  49502. */
  49503. getActiveTextures(): BaseTexture[];
  49504. /**
  49505. * Checks to see if a texture is used in the material.
  49506. * @param texture - Base texture to use.
  49507. * @returns - Boolean specifying if a texture is used in the material.
  49508. */
  49509. hasTexture(texture: BaseTexture): boolean;
  49510. /**
  49511. * Disposes the resources of the material.
  49512. * @param forceDisposeEffect - Forces the disposal of effects.
  49513. * @param forceDisposeTextures - Forces the disposal of all textures.
  49514. */
  49515. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  49516. }
  49517. }
  49518. declare module "babylonjs/Materials/PBR/pbrMaterial" {
  49519. import { Nullable } from "babylonjs/types";
  49520. import { Scene } from "babylonjs/scene";
  49521. import { Color3 } from "babylonjs/Maths/math.color";
  49522. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  49523. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  49524. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  49525. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  49526. /**
  49527. * The Physically based material of BJS.
  49528. *
  49529. * This offers the main features of a standard PBR material.
  49530. * For more information, please refer to the documentation :
  49531. * https://doc.babylonjs.com/how_to/physically_based_rendering
  49532. */
  49533. export class PBRMaterial extends PBRBaseMaterial {
  49534. /**
  49535. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  49536. */
  49537. static readonly PBRMATERIAL_OPAQUE: number;
  49538. /**
  49539. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  49540. */
  49541. static readonly PBRMATERIAL_ALPHATEST: number;
  49542. /**
  49543. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  49544. */
  49545. static readonly PBRMATERIAL_ALPHABLEND: number;
  49546. /**
  49547. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  49548. * They are also discarded below the alpha cutoff threshold to improve performances.
  49549. */
  49550. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  49551. /**
  49552. * Defines the default value of how much AO map is occluding the analytical lights
  49553. * (point spot...).
  49554. */
  49555. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  49556. /**
  49557. * Intensity of the direct lights e.g. the four lights available in your scene.
  49558. * This impacts both the direct diffuse and specular highlights.
  49559. */
  49560. directIntensity: number;
  49561. /**
  49562. * Intensity of the emissive part of the material.
  49563. * This helps controlling the emissive effect without modifying the emissive color.
  49564. */
  49565. emissiveIntensity: number;
  49566. /**
  49567. * Intensity of the environment e.g. how much the environment will light the object
  49568. * either through harmonics for rough material or through the refelction for shiny ones.
  49569. */
  49570. environmentIntensity: number;
  49571. /**
  49572. * This is a special control allowing the reduction of the specular highlights coming from the
  49573. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  49574. */
  49575. specularIntensity: number;
  49576. /**
  49577. * Debug Control allowing disabling the bump map on this material.
  49578. */
  49579. disableBumpMap: boolean;
  49580. /**
  49581. * AKA Diffuse Texture in standard nomenclature.
  49582. */
  49583. albedoTexture: BaseTexture;
  49584. /**
  49585. * AKA Occlusion Texture in other nomenclature.
  49586. */
  49587. ambientTexture: BaseTexture;
  49588. /**
  49589. * AKA Occlusion Texture Intensity in other nomenclature.
  49590. */
  49591. ambientTextureStrength: number;
  49592. /**
  49593. * Defines how much the AO map is occluding the analytical lights (point spot...).
  49594. * 1 means it completely occludes it
  49595. * 0 mean it has no impact
  49596. */
  49597. ambientTextureImpactOnAnalyticalLights: number;
  49598. /**
  49599. * Stores the alpha values in a texture.
  49600. */
  49601. opacityTexture: BaseTexture;
  49602. /**
  49603. * Stores the reflection values in a texture.
  49604. */
  49605. reflectionTexture: Nullable<BaseTexture>;
  49606. /**
  49607. * Stores the emissive values in a texture.
  49608. */
  49609. emissiveTexture: BaseTexture;
  49610. /**
  49611. * AKA Specular texture in other nomenclature.
  49612. */
  49613. reflectivityTexture: BaseTexture;
  49614. /**
  49615. * Used to switch from specular/glossiness to metallic/roughness workflow.
  49616. */
  49617. metallicTexture: BaseTexture;
  49618. /**
  49619. * Specifies the metallic scalar of the metallic/roughness workflow.
  49620. * Can also be used to scale the metalness values of the metallic texture.
  49621. */
  49622. metallic: Nullable<number>;
  49623. /**
  49624. * Specifies the roughness scalar of the metallic/roughness workflow.
  49625. * Can also be used to scale the roughness values of the metallic texture.
  49626. */
  49627. roughness: Nullable<number>;
  49628. /**
  49629. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  49630. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  49631. */
  49632. microSurfaceTexture: BaseTexture;
  49633. /**
  49634. * Stores surface normal data used to displace a mesh in a texture.
  49635. */
  49636. bumpTexture: BaseTexture;
  49637. /**
  49638. * Stores the pre-calculated light information of a mesh in a texture.
  49639. */
  49640. lightmapTexture: BaseTexture;
  49641. /**
  49642. * Stores the refracted light information in a texture.
  49643. */
  49644. refractionTexture: Nullable<BaseTexture>;
  49645. /**
  49646. * The color of a material in ambient lighting.
  49647. */
  49648. ambientColor: Color3;
  49649. /**
  49650. * AKA Diffuse Color in other nomenclature.
  49651. */
  49652. albedoColor: Color3;
  49653. /**
  49654. * AKA Specular Color in other nomenclature.
  49655. */
  49656. reflectivityColor: Color3;
  49657. /**
  49658. * The color reflected from the material.
  49659. */
  49660. reflectionColor: Color3;
  49661. /**
  49662. * The color emitted from the material.
  49663. */
  49664. emissiveColor: Color3;
  49665. /**
  49666. * AKA Glossiness in other nomenclature.
  49667. */
  49668. microSurface: number;
  49669. /**
  49670. * source material index of refraction (IOR)' / 'destination material IOR.
  49671. */
  49672. indexOfRefraction: number;
  49673. /**
  49674. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  49675. */
  49676. invertRefractionY: boolean;
  49677. /**
  49678. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  49679. * Materials half opaque for instance using refraction could benefit from this control.
  49680. */
  49681. linkRefractionWithTransparency: boolean;
  49682. /**
  49683. * If true, the light map contains occlusion information instead of lighting info.
  49684. */
  49685. useLightmapAsShadowmap: boolean;
  49686. /**
  49687. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  49688. */
  49689. useAlphaFromAlbedoTexture: boolean;
  49690. /**
  49691. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  49692. */
  49693. forceAlphaTest: boolean;
  49694. /**
  49695. * Defines the alpha limits in alpha test mode.
  49696. */
  49697. alphaCutOff: number;
  49698. /**
  49699. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  49700. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  49701. */
  49702. useSpecularOverAlpha: boolean;
  49703. /**
  49704. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  49705. */
  49706. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  49707. /**
  49708. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  49709. */
  49710. useRoughnessFromMetallicTextureAlpha: boolean;
  49711. /**
  49712. * Specifies if the metallic texture contains the roughness information in its green channel.
  49713. */
  49714. useRoughnessFromMetallicTextureGreen: boolean;
  49715. /**
  49716. * Specifies if the metallic texture contains the metallness information in its blue channel.
  49717. */
  49718. useMetallnessFromMetallicTextureBlue: boolean;
  49719. /**
  49720. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  49721. */
  49722. useAmbientOcclusionFromMetallicTextureRed: boolean;
  49723. /**
  49724. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  49725. */
  49726. useAmbientInGrayScale: boolean;
  49727. /**
  49728. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  49729. * The material will try to infer what glossiness each pixel should be.
  49730. */
  49731. useAutoMicroSurfaceFromReflectivityMap: boolean;
  49732. /**
  49733. * BJS is using an harcoded light falloff based on a manually sets up range.
  49734. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  49735. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  49736. */
  49737. /**
  49738. * BJS is using an harcoded light falloff based on a manually sets up range.
  49739. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  49740. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  49741. */
  49742. usePhysicalLightFalloff: boolean;
  49743. /**
  49744. * In order to support the falloff compatibility with gltf, a special mode has been added
  49745. * to reproduce the gltf light falloff.
  49746. */
  49747. /**
  49748. * In order to support the falloff compatibility with gltf, a special mode has been added
  49749. * to reproduce the gltf light falloff.
  49750. */
  49751. useGLTFLightFalloff: boolean;
  49752. /**
  49753. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  49754. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  49755. */
  49756. useRadianceOverAlpha: boolean;
  49757. /**
  49758. * Allows using an object space normal map (instead of tangent space).
  49759. */
  49760. useObjectSpaceNormalMap: boolean;
  49761. /**
  49762. * Allows using the bump map in parallax mode.
  49763. */
  49764. useParallax: boolean;
  49765. /**
  49766. * Allows using the bump map in parallax occlusion mode.
  49767. */
  49768. useParallaxOcclusion: boolean;
  49769. /**
  49770. * Controls the scale bias of the parallax mode.
  49771. */
  49772. parallaxScaleBias: number;
  49773. /**
  49774. * If sets to true, disables all the lights affecting the material.
  49775. */
  49776. disableLighting: boolean;
  49777. /**
  49778. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  49779. */
  49780. forceIrradianceInFragment: boolean;
  49781. /**
  49782. * Number of Simultaneous lights allowed on the material.
  49783. */
  49784. maxSimultaneousLights: number;
  49785. /**
  49786. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  49787. */
  49788. invertNormalMapX: boolean;
  49789. /**
  49790. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  49791. */
  49792. invertNormalMapY: boolean;
  49793. /**
  49794. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  49795. */
  49796. twoSidedLighting: boolean;
  49797. /**
  49798. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  49799. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  49800. */
  49801. useAlphaFresnel: boolean;
  49802. /**
  49803. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  49804. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  49805. */
  49806. useLinearAlphaFresnel: boolean;
  49807. /**
  49808. * Let user defines the brdf lookup texture used for IBL.
  49809. * A default 8bit version is embedded but you could point at :
  49810. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  49811. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  49812. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  49813. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  49814. */
  49815. environmentBRDFTexture: Nullable<BaseTexture>;
  49816. /**
  49817. * Force normal to face away from face.
  49818. */
  49819. forceNormalForward: boolean;
  49820. /**
  49821. * Enables specular anti aliasing in the PBR shader.
  49822. * It will both interacts on the Geometry for analytical and IBL lighting.
  49823. * It also prefilter the roughness map based on the bump values.
  49824. */
  49825. enableSpecularAntiAliasing: boolean;
  49826. /**
  49827. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  49828. * makes the reflect vector face the model (under horizon).
  49829. */
  49830. useHorizonOcclusion: boolean;
  49831. /**
  49832. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  49833. * too much the area relying on ambient texture to define their ambient occlusion.
  49834. */
  49835. useRadianceOcclusion: boolean;
  49836. /**
  49837. * If set to true, no lighting calculations will be applied.
  49838. */
  49839. unlit: boolean;
  49840. /**
  49841. * Gets the image processing configuration used either in this material.
  49842. */
  49843. /**
  49844. * Sets the Default image processing configuration used either in the this material.
  49845. *
  49846. * If sets to null, the scene one is in use.
  49847. */
  49848. imageProcessingConfiguration: ImageProcessingConfiguration;
  49849. /**
  49850. * Gets wether the color curves effect is enabled.
  49851. */
  49852. /**
  49853. * Sets wether the color curves effect is enabled.
  49854. */
  49855. cameraColorCurvesEnabled: boolean;
  49856. /**
  49857. * Gets wether the color grading effect is enabled.
  49858. */
  49859. /**
  49860. * Gets wether the color grading effect is enabled.
  49861. */
  49862. cameraColorGradingEnabled: boolean;
  49863. /**
  49864. * Gets wether tonemapping is enabled or not.
  49865. */
  49866. /**
  49867. * Sets wether tonemapping is enabled or not
  49868. */
  49869. cameraToneMappingEnabled: boolean;
  49870. /**
  49871. * The camera exposure used on this material.
  49872. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  49873. * This corresponds to a photographic exposure.
  49874. */
  49875. /**
  49876. * The camera exposure used on this material.
  49877. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  49878. * This corresponds to a photographic exposure.
  49879. */
  49880. cameraExposure: number;
  49881. /**
  49882. * Gets The camera contrast used on this material.
  49883. */
  49884. /**
  49885. * Sets The camera contrast used on this material.
  49886. */
  49887. cameraContrast: number;
  49888. /**
  49889. * Gets the Color Grading 2D Lookup Texture.
  49890. */
  49891. /**
  49892. * Sets the Color Grading 2D Lookup Texture.
  49893. */
  49894. cameraColorGradingTexture: Nullable<BaseTexture>;
  49895. /**
  49896. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  49897. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  49898. * 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;
  49899. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  49900. */
  49901. /**
  49902. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  49903. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  49904. * 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;
  49905. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  49906. */
  49907. cameraColorCurves: Nullable<ColorCurves>;
  49908. /**
  49909. * Instantiates a new PBRMaterial instance.
  49910. *
  49911. * @param name The material name
  49912. * @param scene The scene the material will be use in.
  49913. */
  49914. constructor(name: string, scene: Scene);
  49915. /**
  49916. * Returns the name of this material class.
  49917. */
  49918. getClassName(): string;
  49919. /**
  49920. * Makes a duplicate of the current material.
  49921. * @param name - name to use for the new material.
  49922. */
  49923. clone(name: string): PBRMaterial;
  49924. /**
  49925. * Serializes this PBR Material.
  49926. * @returns - An object with the serialized material.
  49927. */
  49928. serialize(): any;
  49929. /**
  49930. * Parses a PBR Material from a serialized object.
  49931. * @param source - Serialized object.
  49932. * @param scene - BJS scene instance.
  49933. * @param rootUrl - url for the scene object
  49934. * @returns - PBRMaterial
  49935. */
  49936. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  49937. }
  49938. }
  49939. declare module "babylonjs/Misc/dds" {
  49940. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  49941. import { Engine } from "babylonjs/Engines/engine";
  49942. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  49943. import { Nullable } from "babylonjs/types";
  49944. import { Scene } from "babylonjs/scene";
  49945. import "babylonjs/Engines/Extensions/engine.cubeTexture";
  49946. /**
  49947. * Direct draw surface info
  49948. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  49949. */
  49950. export interface DDSInfo {
  49951. /**
  49952. * Width of the texture
  49953. */
  49954. width: number;
  49955. /**
  49956. * Width of the texture
  49957. */
  49958. height: number;
  49959. /**
  49960. * Number of Mipmaps for the texture
  49961. * @see https://en.wikipedia.org/wiki/Mipmap
  49962. */
  49963. mipmapCount: number;
  49964. /**
  49965. * If the textures format is a known fourCC format
  49966. * @see https://www.fourcc.org/
  49967. */
  49968. isFourCC: boolean;
  49969. /**
  49970. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  49971. */
  49972. isRGB: boolean;
  49973. /**
  49974. * If the texture is a lumincance format
  49975. */
  49976. isLuminance: boolean;
  49977. /**
  49978. * If this is a cube texture
  49979. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  49980. */
  49981. isCube: boolean;
  49982. /**
  49983. * If the texture is a compressed format eg. FOURCC_DXT1
  49984. */
  49985. isCompressed: boolean;
  49986. /**
  49987. * The dxgiFormat of the texture
  49988. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  49989. */
  49990. dxgiFormat: number;
  49991. /**
  49992. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  49993. */
  49994. textureType: number;
  49995. /**
  49996. * Sphericle polynomial created for the dds texture
  49997. */
  49998. sphericalPolynomial?: SphericalPolynomial;
  49999. }
  50000. /**
  50001. * Class used to provide DDS decompression tools
  50002. */
  50003. export class DDSTools {
  50004. /**
  50005. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  50006. */
  50007. static StoreLODInAlphaChannel: boolean;
  50008. /**
  50009. * Gets DDS information from an array buffer
  50010. * @param arrayBuffer defines the array buffer to read data from
  50011. * @returns the DDS information
  50012. */
  50013. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  50014. private static _FloatView;
  50015. private static _Int32View;
  50016. private static _ToHalfFloat;
  50017. private static _FromHalfFloat;
  50018. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  50019. private static _GetHalfFloatRGBAArrayBuffer;
  50020. private static _GetFloatRGBAArrayBuffer;
  50021. private static _GetFloatAsUIntRGBAArrayBuffer;
  50022. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  50023. private static _GetRGBAArrayBuffer;
  50024. private static _ExtractLongWordOrder;
  50025. private static _GetRGBArrayBuffer;
  50026. private static _GetLuminanceArrayBuffer;
  50027. /**
  50028. * Uploads DDS Levels to a Babylon Texture
  50029. * @hidden
  50030. */
  50031. static UploadDDSLevels(engine: Engine, texture: InternalTexture, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  50032. }
  50033. module "babylonjs/Engines/engine" {
  50034. interface Engine {
  50035. /**
  50036. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  50037. * @param rootUrl defines the url where the file to load is located
  50038. * @param scene defines the current scene
  50039. * @param lodScale defines scale to apply to the mip map selection
  50040. * @param lodOffset defines offset to apply to the mip map selection
  50041. * @param onLoad defines an optional callback raised when the texture is loaded
  50042. * @param onError defines an optional callback raised if there is an issue to load the texture
  50043. * @param format defines the format of the data
  50044. * @param forcedExtension defines the extension to use to pick the right loader
  50045. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  50046. * @returns the cube texture as an InternalTexture
  50047. */
  50048. 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;
  50049. }
  50050. }
  50051. }
  50052. declare module "babylonjs/Materials/Textures/Loaders/ddsTextureLoader" {
  50053. import { Nullable } from "babylonjs/types";
  50054. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  50055. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  50056. /**
  50057. * Implementation of the DDS Texture Loader.
  50058. * @hidden
  50059. */
  50060. export class _DDSTextureLoader implements IInternalTextureLoader {
  50061. /**
  50062. * Defines wether the loader supports cascade loading the different faces.
  50063. */
  50064. readonly supportCascades: boolean;
  50065. /**
  50066. * This returns if the loader support the current file information.
  50067. * @param extension defines the file extension of the file being loaded
  50068. * @param textureFormatInUse defines the current compressed format in use iun the engine
  50069. * @param fallback defines the fallback internal texture if any
  50070. * @param isBase64 defines whether the texture is encoded as a base64
  50071. * @param isBuffer defines whether the texture data are stored as a buffer
  50072. * @returns true if the loader can load the specified file
  50073. */
  50074. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  50075. /**
  50076. * Transform the url before loading if required.
  50077. * @param rootUrl the url of the texture
  50078. * @param textureFormatInUse defines the current compressed format in use iun the engine
  50079. * @returns the transformed texture
  50080. */
  50081. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  50082. /**
  50083. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  50084. * @param rootUrl the url of the texture
  50085. * @param textureFormatInUse defines the current compressed format in use iun the engine
  50086. * @returns the fallback texture
  50087. */
  50088. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  50089. /**
  50090. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  50091. * @param data contains the texture data
  50092. * @param texture defines the BabylonJS internal texture
  50093. * @param createPolynomials will be true if polynomials have been requested
  50094. * @param onLoad defines the callback to trigger once the texture is ready
  50095. * @param onError defines the callback to trigger in case of error
  50096. */
  50097. loadCubeData(imgs: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  50098. /**
  50099. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  50100. * @param data contains the texture data
  50101. * @param texture defines the BabylonJS internal texture
  50102. * @param callback defines the method to call once ready to upload
  50103. */
  50104. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  50105. }
  50106. }
  50107. declare module "babylonjs/Materials/Textures/Loaders/envTextureLoader" {
  50108. import { Nullable } from "babylonjs/types";
  50109. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  50110. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  50111. /**
  50112. * Implementation of the ENV Texture Loader.
  50113. * @hidden
  50114. */
  50115. export class _ENVTextureLoader implements IInternalTextureLoader {
  50116. /**
  50117. * Defines wether the loader supports cascade loading the different faces.
  50118. */
  50119. readonly supportCascades: boolean;
  50120. /**
  50121. * This returns if the loader support the current file information.
  50122. * @param extension defines the file extension of the file being loaded
  50123. * @param textureFormatInUse defines the current compressed format in use iun the engine
  50124. * @param fallback defines the fallback internal texture if any
  50125. * @param isBase64 defines whether the texture is encoded as a base64
  50126. * @param isBuffer defines whether the texture data are stored as a buffer
  50127. * @returns true if the loader can load the specified file
  50128. */
  50129. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  50130. /**
  50131. * Transform the url before loading if required.
  50132. * @param rootUrl the url of the texture
  50133. * @param textureFormatInUse defines the current compressed format in use iun the engine
  50134. * @returns the transformed texture
  50135. */
  50136. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  50137. /**
  50138. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  50139. * @param rootUrl the url of the texture
  50140. * @param textureFormatInUse defines the current compressed format in use iun the engine
  50141. * @returns the fallback texture
  50142. */
  50143. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  50144. /**
  50145. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  50146. * @param data contains the texture data
  50147. * @param texture defines the BabylonJS internal texture
  50148. * @param createPolynomials will be true if polynomials have been requested
  50149. * @param onLoad defines the callback to trigger once the texture is ready
  50150. * @param onError defines the callback to trigger in case of error
  50151. */
  50152. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  50153. /**
  50154. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  50155. * @param data contains the texture data
  50156. * @param texture defines the BabylonJS internal texture
  50157. * @param callback defines the method to call once ready to upload
  50158. */
  50159. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  50160. }
  50161. }
  50162. declare module "babylonjs/Misc/khronosTextureContainer" {
  50163. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  50164. /**
  50165. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  50166. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  50167. */
  50168. export class KhronosTextureContainer {
  50169. /** contents of the KTX container file */
  50170. arrayBuffer: any;
  50171. private static HEADER_LEN;
  50172. private static COMPRESSED_2D;
  50173. private static COMPRESSED_3D;
  50174. private static TEX_2D;
  50175. private static TEX_3D;
  50176. /**
  50177. * Gets the openGL type
  50178. */
  50179. glType: number;
  50180. /**
  50181. * Gets the openGL type size
  50182. */
  50183. glTypeSize: number;
  50184. /**
  50185. * Gets the openGL format
  50186. */
  50187. glFormat: number;
  50188. /**
  50189. * Gets the openGL internal format
  50190. */
  50191. glInternalFormat: number;
  50192. /**
  50193. * Gets the base internal format
  50194. */
  50195. glBaseInternalFormat: number;
  50196. /**
  50197. * Gets image width in pixel
  50198. */
  50199. pixelWidth: number;
  50200. /**
  50201. * Gets image height in pixel
  50202. */
  50203. pixelHeight: number;
  50204. /**
  50205. * Gets image depth in pixels
  50206. */
  50207. pixelDepth: number;
  50208. /**
  50209. * Gets the number of array elements
  50210. */
  50211. numberOfArrayElements: number;
  50212. /**
  50213. * Gets the number of faces
  50214. */
  50215. numberOfFaces: number;
  50216. /**
  50217. * Gets the number of mipmap levels
  50218. */
  50219. numberOfMipmapLevels: number;
  50220. /**
  50221. * Gets the bytes of key value data
  50222. */
  50223. bytesOfKeyValueData: number;
  50224. /**
  50225. * Gets the load type
  50226. */
  50227. loadType: number;
  50228. /**
  50229. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  50230. */
  50231. isInvalid: boolean;
  50232. /**
  50233. * Creates a new KhronosTextureContainer
  50234. * @param arrayBuffer contents of the KTX container file
  50235. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  50236. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  50237. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  50238. */
  50239. constructor(
  50240. /** contents of the KTX container file */
  50241. arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  50242. /**
  50243. * Uploads KTX content to a Babylon Texture.
  50244. * It is assumed that the texture has already been created & is currently bound
  50245. * @hidden
  50246. */
  50247. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  50248. private _upload2DCompressedLevels;
  50249. }
  50250. }
  50251. declare module "babylonjs/Materials/Textures/Loaders/ktxTextureLoader" {
  50252. import { Nullable } from "babylonjs/types";
  50253. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  50254. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  50255. /**
  50256. * Implementation of the KTX Texture Loader.
  50257. * @hidden
  50258. */
  50259. export class _KTXTextureLoader implements IInternalTextureLoader {
  50260. /**
  50261. * Defines wether the loader supports cascade loading the different faces.
  50262. */
  50263. readonly supportCascades: boolean;
  50264. /**
  50265. * This returns if the loader support the current file information.
  50266. * @param extension defines the file extension of the file being loaded
  50267. * @param textureFormatInUse defines the current compressed format in use iun the engine
  50268. * @param fallback defines the fallback internal texture if any
  50269. * @param isBase64 defines whether the texture is encoded as a base64
  50270. * @param isBuffer defines whether the texture data are stored as a buffer
  50271. * @returns true if the loader can load the specified file
  50272. */
  50273. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  50274. /**
  50275. * Transform the url before loading if required.
  50276. * @param rootUrl the url of the texture
  50277. * @param textureFormatInUse defines the current compressed format in use iun the engine
  50278. * @returns the transformed texture
  50279. */
  50280. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  50281. /**
  50282. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  50283. * @param rootUrl the url of the texture
  50284. * @param textureFormatInUse defines the current compressed format in use iun the engine
  50285. * @returns the fallback texture
  50286. */
  50287. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  50288. /**
  50289. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  50290. * @param data contains the texture data
  50291. * @param texture defines the BabylonJS internal texture
  50292. * @param createPolynomials will be true if polynomials have been requested
  50293. * @param onLoad defines the callback to trigger once the texture is ready
  50294. * @param onError defines the callback to trigger in case of error
  50295. */
  50296. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  50297. /**
  50298. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  50299. * @param data contains the texture data
  50300. * @param texture defines the BabylonJS internal texture
  50301. * @param callback defines the method to call once ready to upload
  50302. */
  50303. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  50304. }
  50305. }
  50306. declare module "babylonjs/Cameras/XR/webXRDefaultExperience" {
  50307. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  50308. import { Scene } from "babylonjs/scene";
  50309. import { WebXRInput } from "babylonjs/Cameras/XR/webXRInput";
  50310. import { WebXRControllerModelLoader } from "babylonjs/Cameras/XR/webXRControllerModelLoader";
  50311. import { WebXRControllerPointerSelection } from "babylonjs/Cameras/XR/webXRControllerPointerSelection";
  50312. import { WebXRControllerTeleportation } from "babylonjs/Cameras/XR/webXRControllerTeleportation";
  50313. import { WebXRManagedOutputCanvas } from "babylonjs/Cameras/XR/webXRManagedOutputCanvas";
  50314. import { WebXREnterExitUI } from "babylonjs/Cameras/XR/webXREnterExitUI";
  50315. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50316. /**
  50317. * Options for the default xr helper
  50318. */
  50319. export class WebXRDefaultExperienceOptions {
  50320. /**
  50321. * Floor meshes that should be used for teleporting
  50322. */
  50323. floorMeshes: Array<AbstractMesh>;
  50324. }
  50325. /**
  50326. * Default experience which provides a similar setup to the previous webVRExperience
  50327. */
  50328. export class WebXRDefaultExperience {
  50329. /**
  50330. * Base experience
  50331. */
  50332. baseExperience: WebXRExperienceHelper;
  50333. /**
  50334. * Input experience extension
  50335. */
  50336. input: WebXRInput;
  50337. /**
  50338. * Loads the controller models
  50339. */
  50340. controllerModelLoader: WebXRControllerModelLoader;
  50341. /**
  50342. * Enables laser pointer and selection
  50343. */
  50344. pointerSelection: WebXRControllerPointerSelection;
  50345. /**
  50346. * Enables teleportation
  50347. */
  50348. teleportation: WebXRControllerTeleportation;
  50349. /**
  50350. * Enables ui for enetering/exiting xr
  50351. */
  50352. enterExitUI: WebXREnterExitUI;
  50353. /**
  50354. * Default output canvas xr should render to
  50355. */
  50356. outputCanvas: WebXRManagedOutputCanvas;
  50357. /**
  50358. * Creates the default xr experience
  50359. * @param scene scene
  50360. * @param options options for basic configuration
  50361. * @returns resulting WebXRDefaultExperience
  50362. */
  50363. static CreateAsync(scene: Scene, options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  50364. private constructor();
  50365. /**
  50366. * DIsposes of the experience helper
  50367. */
  50368. dispose(): void;
  50369. }
  50370. }
  50371. declare module "babylonjs/Helpers/sceneHelpers" {
  50372. import { Nullable } from "babylonjs/types";
  50373. import { Mesh } from "babylonjs/Meshes/mesh";
  50374. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  50375. import { IEnvironmentHelperOptions, EnvironmentHelper } from "babylonjs/Helpers/environmentHelper";
  50376. import { VRExperienceHelperOptions, VRExperienceHelper } from "babylonjs/Cameras/VR/vrExperienceHelper";
  50377. import "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  50378. import "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  50379. import "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  50380. import "babylonjs/Meshes/Builders/boxBuilder";
  50381. import { WebXRDefaultExperience, WebXRDefaultExperienceOptions } from "babylonjs/Cameras/XR/webXRDefaultExperience";
  50382. /** @hidden */
  50383. export var _forceSceneHelpersToBundle: boolean;
  50384. module "babylonjs/scene" {
  50385. interface Scene {
  50386. /**
  50387. * Creates a default light for the scene.
  50388. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  50389. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  50390. */
  50391. createDefaultLight(replace?: boolean): void;
  50392. /**
  50393. * Creates a default camera for the scene.
  50394. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  50395. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  50396. * @param replace has default false, when true replaces the active camera in the scene
  50397. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  50398. */
  50399. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  50400. /**
  50401. * Creates a default camera and a default light.
  50402. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  50403. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  50404. * @param replace has the default false, when true replaces the active camera/light in the scene
  50405. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  50406. */
  50407. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  50408. /**
  50409. * Creates a new sky box
  50410. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  50411. * @param environmentTexture defines the texture to use as environment texture
  50412. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  50413. * @param scale defines the overall scale of the skybox
  50414. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  50415. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  50416. * @returns a new mesh holding the sky box
  50417. */
  50418. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  50419. /**
  50420. * Creates a new environment
  50421. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  50422. * @param options defines the options you can use to configure the environment
  50423. * @returns the new EnvironmentHelper
  50424. */
  50425. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  50426. /**
  50427. * Creates a new VREXperienceHelper
  50428. * @see http://doc.babylonjs.com/how_to/webvr_helper
  50429. * @param webVROptions defines the options used to create the new VREXperienceHelper
  50430. * @returns a new VREXperienceHelper
  50431. */
  50432. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  50433. /**
  50434. * Creates a new WebXRDefaultExperience
  50435. * @see http://doc.babylonjs.com/how_to/webxr
  50436. * @param options experience options
  50437. * @returns a promise for a new WebXRDefaultExperience
  50438. */
  50439. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  50440. }
  50441. }
  50442. }
  50443. declare module "babylonjs/Helpers/videoDome" {
  50444. import { Scene } from "babylonjs/scene";
  50445. import { TransformNode } from "babylonjs/Meshes/transformNode";
  50446. import { Mesh } from "babylonjs/Meshes/mesh";
  50447. import { VideoTexture } from "babylonjs/Materials/Textures/videoTexture";
  50448. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  50449. import "babylonjs/Meshes/Builders/sphereBuilder";
  50450. /**
  50451. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  50452. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  50453. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  50454. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  50455. */
  50456. export class VideoDome extends TransformNode {
  50457. /**
  50458. * Define the video source as a Monoscopic panoramic 360 video.
  50459. */
  50460. static readonly MODE_MONOSCOPIC: number;
  50461. /**
  50462. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  50463. */
  50464. static readonly MODE_TOPBOTTOM: number;
  50465. /**
  50466. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  50467. */
  50468. static readonly MODE_SIDEBYSIDE: number;
  50469. private _halfDome;
  50470. private _useDirectMapping;
  50471. /**
  50472. * The video texture being displayed on the sphere
  50473. */
  50474. protected _videoTexture: VideoTexture;
  50475. /**
  50476. * Gets the video texture being displayed on the sphere
  50477. */
  50478. readonly videoTexture: VideoTexture;
  50479. /**
  50480. * The skybox material
  50481. */
  50482. protected _material: BackgroundMaterial;
  50483. /**
  50484. * The surface used for the skybox
  50485. */
  50486. protected _mesh: Mesh;
  50487. /**
  50488. * A mesh that will be used to mask the back of the video dome in case it is a 180 degree movie.
  50489. */
  50490. private _halfDomeMask;
  50491. /**
  50492. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  50493. * Also see the options.resolution property.
  50494. */
  50495. fovMultiplier: number;
  50496. private _videoMode;
  50497. /**
  50498. * Gets or set the current video mode for the video. It can be:
  50499. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  50500. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  50501. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  50502. */
  50503. videoMode: number;
  50504. /**
  50505. * Is the video a 180 degrees video (half dome) or 360 video (full dome)
  50506. *
  50507. */
  50508. /**
  50509. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  50510. */
  50511. halfDome: boolean;
  50512. /**
  50513. * Oberserver used in Stereoscopic VR Mode.
  50514. */
  50515. private _onBeforeCameraRenderObserver;
  50516. /**
  50517. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  50518. * @param name Element's name, child elements will append suffixes for their own names.
  50519. * @param urlsOrVideo defines the url(s) or the video element to use
  50520. * @param options An object containing optional or exposed sub element properties
  50521. */
  50522. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  50523. resolution?: number;
  50524. clickToPlay?: boolean;
  50525. autoPlay?: boolean;
  50526. loop?: boolean;
  50527. size?: number;
  50528. poster?: string;
  50529. faceForward?: boolean;
  50530. useDirectMapping?: boolean;
  50531. halfDomeMode?: boolean;
  50532. }, scene: Scene);
  50533. private _changeVideoMode;
  50534. /**
  50535. * Releases resources associated with this node.
  50536. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  50537. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  50538. */
  50539. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  50540. }
  50541. }
  50542. declare module "babylonjs/Helpers/index" {
  50543. export * from "babylonjs/Helpers/environmentHelper";
  50544. export * from "babylonjs/Helpers/photoDome";
  50545. export * from "babylonjs/Helpers/sceneHelpers";
  50546. export * from "babylonjs/Helpers/videoDome";
  50547. }
  50548. declare module "babylonjs/Instrumentation/engineInstrumentation" {
  50549. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  50550. import { IDisposable } from "babylonjs/scene";
  50551. import { Engine } from "babylonjs/Engines/engine";
  50552. /**
  50553. * This class can be used to get instrumentation data from a Babylon engine
  50554. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  50555. */
  50556. export class EngineInstrumentation implements IDisposable {
  50557. /**
  50558. * Define the instrumented engine.
  50559. */
  50560. engine: Engine;
  50561. private _captureGPUFrameTime;
  50562. private _gpuFrameTimeToken;
  50563. private _gpuFrameTime;
  50564. private _captureShaderCompilationTime;
  50565. private _shaderCompilationTime;
  50566. private _onBeginFrameObserver;
  50567. private _onEndFrameObserver;
  50568. private _onBeforeShaderCompilationObserver;
  50569. private _onAfterShaderCompilationObserver;
  50570. /**
  50571. * Gets the perf counter used for GPU frame time
  50572. */
  50573. readonly gpuFrameTimeCounter: PerfCounter;
  50574. /**
  50575. * Gets the GPU frame time capture status
  50576. */
  50577. /**
  50578. * Enable or disable the GPU frame time capture
  50579. */
  50580. captureGPUFrameTime: boolean;
  50581. /**
  50582. * Gets the perf counter used for shader compilation time
  50583. */
  50584. readonly shaderCompilationTimeCounter: PerfCounter;
  50585. /**
  50586. * Gets the shader compilation time capture status
  50587. */
  50588. /**
  50589. * Enable or disable the shader compilation time capture
  50590. */
  50591. captureShaderCompilationTime: boolean;
  50592. /**
  50593. * Instantiates a new engine instrumentation.
  50594. * This class can be used to get instrumentation data from a Babylon engine
  50595. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  50596. * @param engine Defines the engine to instrument
  50597. */
  50598. constructor(
  50599. /**
  50600. * Define the instrumented engine.
  50601. */
  50602. engine: Engine);
  50603. /**
  50604. * Dispose and release associated resources.
  50605. */
  50606. dispose(): void;
  50607. }
  50608. }
  50609. declare module "babylonjs/Instrumentation/sceneInstrumentation" {
  50610. import { Scene, IDisposable } from "babylonjs/scene";
  50611. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  50612. /**
  50613. * This class can be used to get instrumentation data from a Babylon engine
  50614. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  50615. */
  50616. export class SceneInstrumentation implements IDisposable {
  50617. /**
  50618. * Defines the scene to instrument
  50619. */
  50620. scene: Scene;
  50621. private _captureActiveMeshesEvaluationTime;
  50622. private _activeMeshesEvaluationTime;
  50623. private _captureRenderTargetsRenderTime;
  50624. private _renderTargetsRenderTime;
  50625. private _captureFrameTime;
  50626. private _frameTime;
  50627. private _captureRenderTime;
  50628. private _renderTime;
  50629. private _captureInterFrameTime;
  50630. private _interFrameTime;
  50631. private _captureParticlesRenderTime;
  50632. private _particlesRenderTime;
  50633. private _captureSpritesRenderTime;
  50634. private _spritesRenderTime;
  50635. private _capturePhysicsTime;
  50636. private _physicsTime;
  50637. private _captureAnimationsTime;
  50638. private _animationsTime;
  50639. private _captureCameraRenderTime;
  50640. private _cameraRenderTime;
  50641. private _onBeforeActiveMeshesEvaluationObserver;
  50642. private _onAfterActiveMeshesEvaluationObserver;
  50643. private _onBeforeRenderTargetsRenderObserver;
  50644. private _onAfterRenderTargetsRenderObserver;
  50645. private _onAfterRenderObserver;
  50646. private _onBeforeDrawPhaseObserver;
  50647. private _onAfterDrawPhaseObserver;
  50648. private _onBeforeAnimationsObserver;
  50649. private _onBeforeParticlesRenderingObserver;
  50650. private _onAfterParticlesRenderingObserver;
  50651. private _onBeforeSpritesRenderingObserver;
  50652. private _onAfterSpritesRenderingObserver;
  50653. private _onBeforePhysicsObserver;
  50654. private _onAfterPhysicsObserver;
  50655. private _onAfterAnimationsObserver;
  50656. private _onBeforeCameraRenderObserver;
  50657. private _onAfterCameraRenderObserver;
  50658. /**
  50659. * Gets the perf counter used for active meshes evaluation time
  50660. */
  50661. readonly activeMeshesEvaluationTimeCounter: PerfCounter;
  50662. /**
  50663. * Gets the active meshes evaluation time capture status
  50664. */
  50665. /**
  50666. * Enable or disable the active meshes evaluation time capture
  50667. */
  50668. captureActiveMeshesEvaluationTime: boolean;
  50669. /**
  50670. * Gets the perf counter used for render targets render time
  50671. */
  50672. readonly renderTargetsRenderTimeCounter: PerfCounter;
  50673. /**
  50674. * Gets the render targets render time capture status
  50675. */
  50676. /**
  50677. * Enable or disable the render targets render time capture
  50678. */
  50679. captureRenderTargetsRenderTime: boolean;
  50680. /**
  50681. * Gets the perf counter used for particles render time
  50682. */
  50683. readonly particlesRenderTimeCounter: PerfCounter;
  50684. /**
  50685. * Gets the particles render time capture status
  50686. */
  50687. /**
  50688. * Enable or disable the particles render time capture
  50689. */
  50690. captureParticlesRenderTime: boolean;
  50691. /**
  50692. * Gets the perf counter used for sprites render time
  50693. */
  50694. readonly spritesRenderTimeCounter: PerfCounter;
  50695. /**
  50696. * Gets the sprites render time capture status
  50697. */
  50698. /**
  50699. * Enable or disable the sprites render time capture
  50700. */
  50701. captureSpritesRenderTime: boolean;
  50702. /**
  50703. * Gets the perf counter used for physics time
  50704. */
  50705. readonly physicsTimeCounter: PerfCounter;
  50706. /**
  50707. * Gets the physics time capture status
  50708. */
  50709. /**
  50710. * Enable or disable the physics time capture
  50711. */
  50712. capturePhysicsTime: boolean;
  50713. /**
  50714. * Gets the perf counter used for animations time
  50715. */
  50716. readonly animationsTimeCounter: PerfCounter;
  50717. /**
  50718. * Gets the animations time capture status
  50719. */
  50720. /**
  50721. * Enable or disable the animations time capture
  50722. */
  50723. captureAnimationsTime: boolean;
  50724. /**
  50725. * Gets the perf counter used for frame time capture
  50726. */
  50727. readonly frameTimeCounter: PerfCounter;
  50728. /**
  50729. * Gets the frame time capture status
  50730. */
  50731. /**
  50732. * Enable or disable the frame time capture
  50733. */
  50734. captureFrameTime: boolean;
  50735. /**
  50736. * Gets the perf counter used for inter-frames time capture
  50737. */
  50738. readonly interFrameTimeCounter: PerfCounter;
  50739. /**
  50740. * Gets the inter-frames time capture status
  50741. */
  50742. /**
  50743. * Enable or disable the inter-frames time capture
  50744. */
  50745. captureInterFrameTime: boolean;
  50746. /**
  50747. * Gets the perf counter used for render time capture
  50748. */
  50749. readonly renderTimeCounter: PerfCounter;
  50750. /**
  50751. * Gets the render time capture status
  50752. */
  50753. /**
  50754. * Enable or disable the render time capture
  50755. */
  50756. captureRenderTime: boolean;
  50757. /**
  50758. * Gets the perf counter used for camera render time capture
  50759. */
  50760. readonly cameraRenderTimeCounter: PerfCounter;
  50761. /**
  50762. * Gets the camera render time capture status
  50763. */
  50764. /**
  50765. * Enable or disable the camera render time capture
  50766. */
  50767. captureCameraRenderTime: boolean;
  50768. /**
  50769. * Gets the perf counter used for draw calls
  50770. */
  50771. readonly drawCallsCounter: PerfCounter;
  50772. /**
  50773. * Instantiates a new scene instrumentation.
  50774. * This class can be used to get instrumentation data from a Babylon engine
  50775. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  50776. * @param scene Defines the scene to instrument
  50777. */
  50778. constructor(
  50779. /**
  50780. * Defines the scene to instrument
  50781. */
  50782. scene: Scene);
  50783. /**
  50784. * Dispose and release associated resources.
  50785. */
  50786. dispose(): void;
  50787. }
  50788. }
  50789. declare module "babylonjs/Instrumentation/index" {
  50790. export * from "babylonjs/Instrumentation/engineInstrumentation";
  50791. export * from "babylonjs/Instrumentation/sceneInstrumentation";
  50792. export * from "babylonjs/Instrumentation/timeToken";
  50793. }
  50794. declare module "babylonjs/Shaders/glowMapGeneration.fragment" {
  50795. /** @hidden */
  50796. export var glowMapGenerationPixelShader: {
  50797. name: string;
  50798. shader: string;
  50799. };
  50800. }
  50801. declare module "babylonjs/Shaders/glowMapGeneration.vertex" {
  50802. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  50803. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  50804. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  50805. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  50806. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  50807. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  50808. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  50809. /** @hidden */
  50810. export var glowMapGenerationVertexShader: {
  50811. name: string;
  50812. shader: string;
  50813. };
  50814. }
  50815. declare module "babylonjs/Layers/effectLayer" {
  50816. import { Observable } from "babylonjs/Misc/observable";
  50817. import { Nullable } from "babylonjs/types";
  50818. import { Camera } from "babylonjs/Cameras/camera";
  50819. import { Scene } from "babylonjs/scene";
  50820. import { ISize } from "babylonjs/Maths/math.size";
  50821. import { Color4 } from "babylonjs/Maths/math.color";
  50822. import { Engine } from "babylonjs/Engines/engine";
  50823. import { SubMesh } from "babylonjs/Meshes/subMesh";
  50824. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50825. import { Mesh } from "babylonjs/Meshes/mesh";
  50826. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  50827. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  50828. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  50829. import { Effect } from "babylonjs/Materials/effect";
  50830. import { Material } from "babylonjs/Materials/material";
  50831. import "babylonjs/Shaders/glowMapGeneration.fragment";
  50832. import "babylonjs/Shaders/glowMapGeneration.vertex";
  50833. /**
  50834. * Effect layer options. This helps customizing the behaviour
  50835. * of the effect layer.
  50836. */
  50837. export interface IEffectLayerOptions {
  50838. /**
  50839. * Multiplication factor apply to the canvas size to compute the render target size
  50840. * used to generated the objects (the smaller the faster).
  50841. */
  50842. mainTextureRatio: number;
  50843. /**
  50844. * Enforces a fixed size texture to ensure effect stability across devices.
  50845. */
  50846. mainTextureFixedSize?: number;
  50847. /**
  50848. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  50849. */
  50850. alphaBlendingMode: number;
  50851. /**
  50852. * The camera attached to the layer.
  50853. */
  50854. camera: Nullable<Camera>;
  50855. /**
  50856. * The rendering group to draw the layer in.
  50857. */
  50858. renderingGroupId: number;
  50859. }
  50860. /**
  50861. * The effect layer Helps adding post process effect blended with the main pass.
  50862. *
  50863. * This can be for instance use to generate glow or higlight effects on the scene.
  50864. *
  50865. * The effect layer class can not be used directly and is intented to inherited from to be
  50866. * customized per effects.
  50867. */
  50868. export abstract class EffectLayer {
  50869. private _vertexBuffers;
  50870. private _indexBuffer;
  50871. private _cachedDefines;
  50872. private _effectLayerMapGenerationEffect;
  50873. private _effectLayerOptions;
  50874. private _mergeEffect;
  50875. protected _scene: Scene;
  50876. protected _engine: Engine;
  50877. protected _maxSize: number;
  50878. protected _mainTextureDesiredSize: ISize;
  50879. protected _mainTexture: RenderTargetTexture;
  50880. protected _shouldRender: boolean;
  50881. protected _postProcesses: PostProcess[];
  50882. protected _textures: BaseTexture[];
  50883. protected _emissiveTextureAndColor: {
  50884. texture: Nullable<BaseTexture>;
  50885. color: Color4;
  50886. };
  50887. /**
  50888. * The name of the layer
  50889. */
  50890. name: string;
  50891. /**
  50892. * The clear color of the texture used to generate the glow map.
  50893. */
  50894. neutralColor: Color4;
  50895. /**
  50896. * Specifies wether the highlight layer is enabled or not.
  50897. */
  50898. isEnabled: boolean;
  50899. /**
  50900. * Gets the camera attached to the layer.
  50901. */
  50902. readonly camera: Nullable<Camera>;
  50903. /**
  50904. * Gets the rendering group id the layer should render in.
  50905. */
  50906. renderingGroupId: number;
  50907. /**
  50908. * An event triggered when the effect layer has been disposed.
  50909. */
  50910. onDisposeObservable: Observable<EffectLayer>;
  50911. /**
  50912. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  50913. */
  50914. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  50915. /**
  50916. * An event triggered when the generated texture is being merged in the scene.
  50917. */
  50918. onBeforeComposeObservable: Observable<EffectLayer>;
  50919. /**
  50920. * An event triggered when the generated texture has been merged in the scene.
  50921. */
  50922. onAfterComposeObservable: Observable<EffectLayer>;
  50923. /**
  50924. * An event triggered when the efffect layer changes its size.
  50925. */
  50926. onSizeChangedObservable: Observable<EffectLayer>;
  50927. /** @hidden */
  50928. static _SceneComponentInitialization: (scene: Scene) => void;
  50929. /**
  50930. * Instantiates a new effect Layer and references it in the scene.
  50931. * @param name The name of the layer
  50932. * @param scene The scene to use the layer in
  50933. */
  50934. constructor(
  50935. /** The Friendly of the effect in the scene */
  50936. name: string, scene: Scene);
  50937. /**
  50938. * Get the effect name of the layer.
  50939. * @return The effect name
  50940. */
  50941. abstract getEffectName(): string;
  50942. /**
  50943. * Checks for the readiness of the element composing the layer.
  50944. * @param subMesh the mesh to check for
  50945. * @param useInstances specify wether or not to use instances to render the mesh
  50946. * @return true if ready otherwise, false
  50947. */
  50948. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  50949. /**
  50950. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  50951. * @returns true if the effect requires stencil during the main canvas render pass.
  50952. */
  50953. abstract needStencil(): boolean;
  50954. /**
  50955. * Create the merge effect. This is the shader use to blit the information back
  50956. * to the main canvas at the end of the scene rendering.
  50957. * @returns The effect containing the shader used to merge the effect on the main canvas
  50958. */
  50959. protected abstract _createMergeEffect(): Effect;
  50960. /**
  50961. * Creates the render target textures and post processes used in the effect layer.
  50962. */
  50963. protected abstract _createTextureAndPostProcesses(): void;
  50964. /**
  50965. * Implementation specific of rendering the generating effect on the main canvas.
  50966. * @param effect The effect used to render through
  50967. */
  50968. protected abstract _internalRender(effect: Effect): void;
  50969. /**
  50970. * Sets the required values for both the emissive texture and and the main color.
  50971. */
  50972. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  50973. /**
  50974. * Free any resources and references associated to a mesh.
  50975. * Internal use
  50976. * @param mesh The mesh to free.
  50977. */
  50978. abstract _disposeMesh(mesh: Mesh): void;
  50979. /**
  50980. * Serializes this layer (Glow or Highlight for example)
  50981. * @returns a serialized layer object
  50982. */
  50983. abstract serialize?(): any;
  50984. /**
  50985. * Initializes the effect layer with the required options.
  50986. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  50987. */
  50988. protected _init(options: Partial<IEffectLayerOptions>): void;
  50989. /**
  50990. * Generates the index buffer of the full screen quad blending to the main canvas.
  50991. */
  50992. private _generateIndexBuffer;
  50993. /**
  50994. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  50995. */
  50996. private _generateVertexBuffer;
  50997. /**
  50998. * Sets the main texture desired size which is the closest power of two
  50999. * of the engine canvas size.
  51000. */
  51001. private _setMainTextureSize;
  51002. /**
  51003. * Creates the main texture for the effect layer.
  51004. */
  51005. protected _createMainTexture(): void;
  51006. /**
  51007. * Adds specific effects defines.
  51008. * @param defines The defines to add specifics to.
  51009. */
  51010. protected _addCustomEffectDefines(defines: string[]): void;
  51011. /**
  51012. * Checks for the readiness of the element composing the layer.
  51013. * @param subMesh the mesh to check for
  51014. * @param useInstances specify wether or not to use instances to render the mesh
  51015. * @param emissiveTexture the associated emissive texture used to generate the glow
  51016. * @return true if ready otherwise, false
  51017. */
  51018. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  51019. /**
  51020. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  51021. */
  51022. render(): void;
  51023. /**
  51024. * Determine if a given mesh will be used in the current effect.
  51025. * @param mesh mesh to test
  51026. * @returns true if the mesh will be used
  51027. */
  51028. hasMesh(mesh: AbstractMesh): boolean;
  51029. /**
  51030. * Returns true if the layer contains information to display, otherwise false.
  51031. * @returns true if the glow layer should be rendered
  51032. */
  51033. shouldRender(): boolean;
  51034. /**
  51035. * Returns true if the mesh should render, otherwise false.
  51036. * @param mesh The mesh to render
  51037. * @returns true if it should render otherwise false
  51038. */
  51039. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  51040. /**
  51041. * Returns true if the mesh can be rendered, otherwise false.
  51042. * @param mesh The mesh to render
  51043. * @param material The material used on the mesh
  51044. * @returns true if it can be rendered otherwise false
  51045. */
  51046. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  51047. /**
  51048. * Returns true if the mesh should render, otherwise false.
  51049. * @param mesh The mesh to render
  51050. * @returns true if it should render otherwise false
  51051. */
  51052. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  51053. /**
  51054. * Renders the submesh passed in parameter to the generation map.
  51055. */
  51056. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  51057. /**
  51058. * Rebuild the required buffers.
  51059. * @hidden Internal use only.
  51060. */
  51061. _rebuild(): void;
  51062. /**
  51063. * Dispose only the render target textures and post process.
  51064. */
  51065. private _disposeTextureAndPostProcesses;
  51066. /**
  51067. * Dispose the highlight layer and free resources.
  51068. */
  51069. dispose(): void;
  51070. /**
  51071. * Gets the class name of the effect layer
  51072. * @returns the string with the class name of the effect layer
  51073. */
  51074. getClassName(): string;
  51075. /**
  51076. * Creates an effect layer from parsed effect layer data
  51077. * @param parsedEffectLayer defines effect layer data
  51078. * @param scene defines the current scene
  51079. * @param rootUrl defines the root URL containing the effect layer information
  51080. * @returns a parsed effect Layer
  51081. */
  51082. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  51083. }
  51084. }
  51085. declare module "babylonjs/Layers/effectLayerSceneComponent" {
  51086. import { Scene } from "babylonjs/scene";
  51087. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  51088. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  51089. import { AbstractScene } from "babylonjs/abstractScene";
  51090. module "babylonjs/abstractScene" {
  51091. interface AbstractScene {
  51092. /**
  51093. * The list of effect layers (highlights/glow) added to the scene
  51094. * @see http://doc.babylonjs.com/how_to/highlight_layer
  51095. * @see http://doc.babylonjs.com/how_to/glow_layer
  51096. */
  51097. effectLayers: Array<EffectLayer>;
  51098. /**
  51099. * Removes the given effect layer from this scene.
  51100. * @param toRemove defines the effect layer to remove
  51101. * @returns the index of the removed effect layer
  51102. */
  51103. removeEffectLayer(toRemove: EffectLayer): number;
  51104. /**
  51105. * Adds the given effect layer to this scene
  51106. * @param newEffectLayer defines the effect layer to add
  51107. */
  51108. addEffectLayer(newEffectLayer: EffectLayer): void;
  51109. }
  51110. }
  51111. /**
  51112. * Defines the layer scene component responsible to manage any effect layers
  51113. * in a given scene.
  51114. */
  51115. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  51116. /**
  51117. * The component name helpfull to identify the component in the list of scene components.
  51118. */
  51119. readonly name: string;
  51120. /**
  51121. * The scene the component belongs to.
  51122. */
  51123. scene: Scene;
  51124. private _engine;
  51125. private _renderEffects;
  51126. private _needStencil;
  51127. private _previousStencilState;
  51128. /**
  51129. * Creates a new instance of the component for the given scene
  51130. * @param scene Defines the scene to register the component in
  51131. */
  51132. constructor(scene: Scene);
  51133. /**
  51134. * Registers the component in a given scene
  51135. */
  51136. register(): void;
  51137. /**
  51138. * Rebuilds the elements related to this component in case of
  51139. * context lost for instance.
  51140. */
  51141. rebuild(): void;
  51142. /**
  51143. * Serializes the component data to the specified json object
  51144. * @param serializationObject The object to serialize to
  51145. */
  51146. serialize(serializationObject: any): void;
  51147. /**
  51148. * Adds all the elements from the container to the scene
  51149. * @param container the container holding the elements
  51150. */
  51151. addFromContainer(container: AbstractScene): void;
  51152. /**
  51153. * Removes all the elements in the container from the scene
  51154. * @param container contains the elements to remove
  51155. * @param dispose if the removed element should be disposed (default: false)
  51156. */
  51157. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  51158. /**
  51159. * Disposes the component and the associated ressources.
  51160. */
  51161. dispose(): void;
  51162. private _isReadyForMesh;
  51163. private _renderMainTexture;
  51164. private _setStencil;
  51165. private _setStencilBack;
  51166. private _draw;
  51167. private _drawCamera;
  51168. private _drawRenderingGroup;
  51169. }
  51170. }
  51171. declare module "babylonjs/Shaders/glowMapMerge.fragment" {
  51172. /** @hidden */
  51173. export var glowMapMergePixelShader: {
  51174. name: string;
  51175. shader: string;
  51176. };
  51177. }
  51178. declare module "babylonjs/Shaders/glowMapMerge.vertex" {
  51179. /** @hidden */
  51180. export var glowMapMergeVertexShader: {
  51181. name: string;
  51182. shader: string;
  51183. };
  51184. }
  51185. declare module "babylonjs/Layers/glowLayer" {
  51186. import { Nullable } from "babylonjs/types";
  51187. import { Camera } from "babylonjs/Cameras/camera";
  51188. import { Scene } from "babylonjs/scene";
  51189. import { SubMesh } from "babylonjs/Meshes/subMesh";
  51190. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51191. import { Mesh } from "babylonjs/Meshes/mesh";
  51192. import { Texture } from "babylonjs/Materials/Textures/texture";
  51193. import { Effect } from "babylonjs/Materials/effect";
  51194. import { Material } from "babylonjs/Materials/material";
  51195. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  51196. import { Color4 } from "babylonjs/Maths/math.color";
  51197. import "babylonjs/Shaders/glowMapMerge.fragment";
  51198. import "babylonjs/Shaders/glowMapMerge.vertex";
  51199. import "babylonjs/Layers/effectLayerSceneComponent";
  51200. module "babylonjs/abstractScene" {
  51201. interface AbstractScene {
  51202. /**
  51203. * Return a the first highlight layer of the scene with a given name.
  51204. * @param name The name of the highlight layer to look for.
  51205. * @return The highlight layer if found otherwise null.
  51206. */
  51207. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  51208. }
  51209. }
  51210. /**
  51211. * Glow layer options. This helps customizing the behaviour
  51212. * of the glow layer.
  51213. */
  51214. export interface IGlowLayerOptions {
  51215. /**
  51216. * Multiplication factor apply to the canvas size to compute the render target size
  51217. * used to generated the glowing objects (the smaller the faster).
  51218. */
  51219. mainTextureRatio: number;
  51220. /**
  51221. * Enforces a fixed size texture to ensure resize independant blur.
  51222. */
  51223. mainTextureFixedSize?: number;
  51224. /**
  51225. * How big is the kernel of the blur texture.
  51226. */
  51227. blurKernelSize: number;
  51228. /**
  51229. * The camera attached to the layer.
  51230. */
  51231. camera: Nullable<Camera>;
  51232. /**
  51233. * Enable MSAA by chosing the number of samples.
  51234. */
  51235. mainTextureSamples?: number;
  51236. /**
  51237. * The rendering group to draw the layer in.
  51238. */
  51239. renderingGroupId: number;
  51240. }
  51241. /**
  51242. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  51243. *
  51244. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  51245. * glowy meshes to your scene.
  51246. *
  51247. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  51248. */
  51249. export class GlowLayer extends EffectLayer {
  51250. /**
  51251. * Effect Name of the layer.
  51252. */
  51253. static readonly EffectName: string;
  51254. /**
  51255. * The default blur kernel size used for the glow.
  51256. */
  51257. static DefaultBlurKernelSize: number;
  51258. /**
  51259. * The default texture size ratio used for the glow.
  51260. */
  51261. static DefaultTextureRatio: number;
  51262. /**
  51263. * Sets the kernel size of the blur.
  51264. */
  51265. /**
  51266. * Gets the kernel size of the blur.
  51267. */
  51268. blurKernelSize: number;
  51269. /**
  51270. * Sets the glow intensity.
  51271. */
  51272. /**
  51273. * Gets the glow intensity.
  51274. */
  51275. intensity: number;
  51276. private _options;
  51277. private _intensity;
  51278. private _horizontalBlurPostprocess1;
  51279. private _verticalBlurPostprocess1;
  51280. private _horizontalBlurPostprocess2;
  51281. private _verticalBlurPostprocess2;
  51282. private _blurTexture1;
  51283. private _blurTexture2;
  51284. private _postProcesses1;
  51285. private _postProcesses2;
  51286. private _includedOnlyMeshes;
  51287. private _excludedMeshes;
  51288. /**
  51289. * Callback used to let the user override the color selection on a per mesh basis
  51290. */
  51291. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  51292. /**
  51293. * Callback used to let the user override the texture selection on a per mesh basis
  51294. */
  51295. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  51296. /**
  51297. * Instantiates a new glow Layer and references it to the scene.
  51298. * @param name The name of the layer
  51299. * @param scene The scene to use the layer in
  51300. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  51301. */
  51302. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  51303. /**
  51304. * Get the effect name of the layer.
  51305. * @return The effect name
  51306. */
  51307. getEffectName(): string;
  51308. /**
  51309. * Create the merge effect. This is the shader use to blit the information back
  51310. * to the main canvas at the end of the scene rendering.
  51311. */
  51312. protected _createMergeEffect(): Effect;
  51313. /**
  51314. * Creates the render target textures and post processes used in the glow layer.
  51315. */
  51316. protected _createTextureAndPostProcesses(): void;
  51317. /**
  51318. * Checks for the readiness of the element composing the layer.
  51319. * @param subMesh the mesh to check for
  51320. * @param useInstances specify wether or not to use instances to render the mesh
  51321. * @param emissiveTexture the associated emissive texture used to generate the glow
  51322. * @return true if ready otherwise, false
  51323. */
  51324. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  51325. /**
  51326. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  51327. */
  51328. needStencil(): boolean;
  51329. /**
  51330. * Returns true if the mesh can be rendered, otherwise false.
  51331. * @param mesh The mesh to render
  51332. * @param material The material used on the mesh
  51333. * @returns true if it can be rendered otherwise false
  51334. */
  51335. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  51336. /**
  51337. * Implementation specific of rendering the generating effect on the main canvas.
  51338. * @param effect The effect used to render through
  51339. */
  51340. protected _internalRender(effect: Effect): void;
  51341. /**
  51342. * Sets the required values for both the emissive texture and and the main color.
  51343. */
  51344. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  51345. /**
  51346. * Returns true if the mesh should render, otherwise false.
  51347. * @param mesh The mesh to render
  51348. * @returns true if it should render otherwise false
  51349. */
  51350. protected _shouldRenderMesh(mesh: Mesh): boolean;
  51351. /**
  51352. * Adds specific effects defines.
  51353. * @param defines The defines to add specifics to.
  51354. */
  51355. protected _addCustomEffectDefines(defines: string[]): void;
  51356. /**
  51357. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  51358. * @param mesh The mesh to exclude from the glow layer
  51359. */
  51360. addExcludedMesh(mesh: Mesh): void;
  51361. /**
  51362. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  51363. * @param mesh The mesh to remove
  51364. */
  51365. removeExcludedMesh(mesh: Mesh): void;
  51366. /**
  51367. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  51368. * @param mesh The mesh to include in the glow layer
  51369. */
  51370. addIncludedOnlyMesh(mesh: Mesh): void;
  51371. /**
  51372. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  51373. * @param mesh The mesh to remove
  51374. */
  51375. removeIncludedOnlyMesh(mesh: Mesh): void;
  51376. /**
  51377. * Determine if a given mesh will be used in the glow layer
  51378. * @param mesh The mesh to test
  51379. * @returns true if the mesh will be highlighted by the current glow layer
  51380. */
  51381. hasMesh(mesh: AbstractMesh): boolean;
  51382. /**
  51383. * Free any resources and references associated to a mesh.
  51384. * Internal use
  51385. * @param mesh The mesh to free.
  51386. * @hidden
  51387. */
  51388. _disposeMesh(mesh: Mesh): void;
  51389. /**
  51390. * Gets the class name of the effect layer
  51391. * @returns the string with the class name of the effect layer
  51392. */
  51393. getClassName(): string;
  51394. /**
  51395. * Serializes this glow layer
  51396. * @returns a serialized glow layer object
  51397. */
  51398. serialize(): any;
  51399. /**
  51400. * Creates a Glow Layer from parsed glow layer data
  51401. * @param parsedGlowLayer defines glow layer data
  51402. * @param scene defines the current scene
  51403. * @param rootUrl defines the root URL containing the glow layer information
  51404. * @returns a parsed Glow Layer
  51405. */
  51406. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  51407. }
  51408. }
  51409. declare module "babylonjs/Shaders/glowBlurPostProcess.fragment" {
  51410. /** @hidden */
  51411. export var glowBlurPostProcessPixelShader: {
  51412. name: string;
  51413. shader: string;
  51414. };
  51415. }
  51416. declare module "babylonjs/Layers/highlightLayer" {
  51417. import { Observable } from "babylonjs/Misc/observable";
  51418. import { Nullable } from "babylonjs/types";
  51419. import { Camera } from "babylonjs/Cameras/camera";
  51420. import { Scene } from "babylonjs/scene";
  51421. import { SubMesh } from "babylonjs/Meshes/subMesh";
  51422. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51423. import { Mesh } from "babylonjs/Meshes/mesh";
  51424. import { Effect } from "babylonjs/Materials/effect";
  51425. import { Material } from "babylonjs/Materials/material";
  51426. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  51427. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  51428. import "babylonjs/Shaders/glowMapMerge.fragment";
  51429. import "babylonjs/Shaders/glowMapMerge.vertex";
  51430. import "babylonjs/Shaders/glowBlurPostProcess.fragment";
  51431. module "babylonjs/abstractScene" {
  51432. interface AbstractScene {
  51433. /**
  51434. * Return a the first highlight layer of the scene with a given name.
  51435. * @param name The name of the highlight layer to look for.
  51436. * @return The highlight layer if found otherwise null.
  51437. */
  51438. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  51439. }
  51440. }
  51441. /**
  51442. * Highlight layer options. This helps customizing the behaviour
  51443. * of the highlight layer.
  51444. */
  51445. export interface IHighlightLayerOptions {
  51446. /**
  51447. * Multiplication factor apply to the canvas size to compute the render target size
  51448. * used to generated the glowing objects (the smaller the faster).
  51449. */
  51450. mainTextureRatio: number;
  51451. /**
  51452. * Enforces a fixed size texture to ensure resize independant blur.
  51453. */
  51454. mainTextureFixedSize?: number;
  51455. /**
  51456. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  51457. * of the picture to blur (the smaller the faster).
  51458. */
  51459. blurTextureSizeRatio: number;
  51460. /**
  51461. * How big in texel of the blur texture is the vertical blur.
  51462. */
  51463. blurVerticalSize: number;
  51464. /**
  51465. * How big in texel of the blur texture is the horizontal blur.
  51466. */
  51467. blurHorizontalSize: number;
  51468. /**
  51469. * Alpha blending mode used to apply the blur. Default is combine.
  51470. */
  51471. alphaBlendingMode: number;
  51472. /**
  51473. * The camera attached to the layer.
  51474. */
  51475. camera: Nullable<Camera>;
  51476. /**
  51477. * Should we display highlight as a solid stroke?
  51478. */
  51479. isStroke?: boolean;
  51480. /**
  51481. * The rendering group to draw the layer in.
  51482. */
  51483. renderingGroupId: number;
  51484. }
  51485. /**
  51486. * The highlight layer Helps adding a glow effect around a mesh.
  51487. *
  51488. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  51489. * glowy meshes to your scene.
  51490. *
  51491. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  51492. */
  51493. export class HighlightLayer extends EffectLayer {
  51494. name: string;
  51495. /**
  51496. * Effect Name of the highlight layer.
  51497. */
  51498. static readonly EffectName: string;
  51499. /**
  51500. * The neutral color used during the preparation of the glow effect.
  51501. * This is black by default as the blend operation is a blend operation.
  51502. */
  51503. static NeutralColor: Color4;
  51504. /**
  51505. * Stencil value used for glowing meshes.
  51506. */
  51507. static GlowingMeshStencilReference: number;
  51508. /**
  51509. * Stencil value used for the other meshes in the scene.
  51510. */
  51511. static NormalMeshStencilReference: number;
  51512. /**
  51513. * Specifies whether or not the inner glow is ACTIVE in the layer.
  51514. */
  51515. innerGlow: boolean;
  51516. /**
  51517. * Specifies whether or not the outer glow is ACTIVE in the layer.
  51518. */
  51519. outerGlow: boolean;
  51520. /**
  51521. * Specifies the horizontal size of the blur.
  51522. */
  51523. /**
  51524. * Gets the horizontal size of the blur.
  51525. */
  51526. blurHorizontalSize: number;
  51527. /**
  51528. * Specifies the vertical size of the blur.
  51529. */
  51530. /**
  51531. * Gets the vertical size of the blur.
  51532. */
  51533. blurVerticalSize: number;
  51534. /**
  51535. * An event triggered when the highlight layer is being blurred.
  51536. */
  51537. onBeforeBlurObservable: Observable<HighlightLayer>;
  51538. /**
  51539. * An event triggered when the highlight layer has been blurred.
  51540. */
  51541. onAfterBlurObservable: Observable<HighlightLayer>;
  51542. private _instanceGlowingMeshStencilReference;
  51543. private _options;
  51544. private _downSamplePostprocess;
  51545. private _horizontalBlurPostprocess;
  51546. private _verticalBlurPostprocess;
  51547. private _blurTexture;
  51548. private _meshes;
  51549. private _excludedMeshes;
  51550. /**
  51551. * Instantiates a new highlight Layer and references it to the scene..
  51552. * @param name The name of the layer
  51553. * @param scene The scene to use the layer in
  51554. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  51555. */
  51556. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  51557. /**
  51558. * Get the effect name of the layer.
  51559. * @return The effect name
  51560. */
  51561. getEffectName(): string;
  51562. /**
  51563. * Create the merge effect. This is the shader use to blit the information back
  51564. * to the main canvas at the end of the scene rendering.
  51565. */
  51566. protected _createMergeEffect(): Effect;
  51567. /**
  51568. * Creates the render target textures and post processes used in the highlight layer.
  51569. */
  51570. protected _createTextureAndPostProcesses(): void;
  51571. /**
  51572. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  51573. */
  51574. needStencil(): boolean;
  51575. /**
  51576. * Checks for the readiness of the element composing the layer.
  51577. * @param subMesh the mesh to check for
  51578. * @param useInstances specify wether or not to use instances to render the mesh
  51579. * @param emissiveTexture the associated emissive texture used to generate the glow
  51580. * @return true if ready otherwise, false
  51581. */
  51582. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  51583. /**
  51584. * Implementation specific of rendering the generating effect on the main canvas.
  51585. * @param effect The effect used to render through
  51586. */
  51587. protected _internalRender(effect: Effect): void;
  51588. /**
  51589. * Returns true if the layer contains information to display, otherwise false.
  51590. */
  51591. shouldRender(): boolean;
  51592. /**
  51593. * Returns true if the mesh should render, otherwise false.
  51594. * @param mesh The mesh to render
  51595. * @returns true if it should render otherwise false
  51596. */
  51597. protected _shouldRenderMesh(mesh: Mesh): boolean;
  51598. /**
  51599. * Sets the required values for both the emissive texture and and the main color.
  51600. */
  51601. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  51602. /**
  51603. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  51604. * @param mesh The mesh to exclude from the highlight layer
  51605. */
  51606. addExcludedMesh(mesh: Mesh): void;
  51607. /**
  51608. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  51609. * @param mesh The mesh to highlight
  51610. */
  51611. removeExcludedMesh(mesh: Mesh): void;
  51612. /**
  51613. * Determine if a given mesh will be highlighted by the current HighlightLayer
  51614. * @param mesh mesh to test
  51615. * @returns true if the mesh will be highlighted by the current HighlightLayer
  51616. */
  51617. hasMesh(mesh: AbstractMesh): boolean;
  51618. /**
  51619. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  51620. * @param mesh The mesh to highlight
  51621. * @param color The color of the highlight
  51622. * @param glowEmissiveOnly Extract the glow from the emissive texture
  51623. */
  51624. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  51625. /**
  51626. * Remove a mesh from the highlight layer in order to make it stop glowing.
  51627. * @param mesh The mesh to highlight
  51628. */
  51629. removeMesh(mesh: Mesh): void;
  51630. /**
  51631. * Force the stencil to the normal expected value for none glowing parts
  51632. */
  51633. private _defaultStencilReference;
  51634. /**
  51635. * Free any resources and references associated to a mesh.
  51636. * Internal use
  51637. * @param mesh The mesh to free.
  51638. * @hidden
  51639. */
  51640. _disposeMesh(mesh: Mesh): void;
  51641. /**
  51642. * Dispose the highlight layer and free resources.
  51643. */
  51644. dispose(): void;
  51645. /**
  51646. * Gets the class name of the effect layer
  51647. * @returns the string with the class name of the effect layer
  51648. */
  51649. getClassName(): string;
  51650. /**
  51651. * Serializes this Highlight layer
  51652. * @returns a serialized Highlight layer object
  51653. */
  51654. serialize(): any;
  51655. /**
  51656. * Creates a Highlight layer from parsed Highlight layer data
  51657. * @param parsedHightlightLayer defines the Highlight layer data
  51658. * @param scene defines the current scene
  51659. * @param rootUrl defines the root URL containing the Highlight layer information
  51660. * @returns a parsed Highlight layer
  51661. */
  51662. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  51663. }
  51664. }
  51665. declare module "babylonjs/Layers/layerSceneComponent" {
  51666. import { Scene } from "babylonjs/scene";
  51667. import { ISceneComponent } from "babylonjs/sceneComponent";
  51668. import { Layer } from "babylonjs/Layers/layer";
  51669. import { AbstractScene } from "babylonjs/abstractScene";
  51670. module "babylonjs/abstractScene" {
  51671. interface AbstractScene {
  51672. /**
  51673. * The list of layers (background and foreground) of the scene
  51674. */
  51675. layers: Array<Layer>;
  51676. }
  51677. }
  51678. /**
  51679. * Defines the layer scene component responsible to manage any layers
  51680. * in a given scene.
  51681. */
  51682. export class LayerSceneComponent implements ISceneComponent {
  51683. /**
  51684. * The component name helpfull to identify the component in the list of scene components.
  51685. */
  51686. readonly name: string;
  51687. /**
  51688. * The scene the component belongs to.
  51689. */
  51690. scene: Scene;
  51691. private _engine;
  51692. /**
  51693. * Creates a new instance of the component for the given scene
  51694. * @param scene Defines the scene to register the component in
  51695. */
  51696. constructor(scene: Scene);
  51697. /**
  51698. * Registers the component in a given scene
  51699. */
  51700. register(): void;
  51701. /**
  51702. * Rebuilds the elements related to this component in case of
  51703. * context lost for instance.
  51704. */
  51705. rebuild(): void;
  51706. /**
  51707. * Disposes the component and the associated ressources.
  51708. */
  51709. dispose(): void;
  51710. private _draw;
  51711. private _drawCameraPredicate;
  51712. private _drawCameraBackground;
  51713. private _drawCameraForeground;
  51714. private _drawRenderTargetPredicate;
  51715. private _drawRenderTargetBackground;
  51716. private _drawRenderTargetForeground;
  51717. /**
  51718. * Adds all the elements from the container to the scene
  51719. * @param container the container holding the elements
  51720. */
  51721. addFromContainer(container: AbstractScene): void;
  51722. /**
  51723. * Removes all the elements in the container from the scene
  51724. * @param container contains the elements to remove
  51725. * @param dispose if the removed element should be disposed (default: false)
  51726. */
  51727. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  51728. }
  51729. }
  51730. declare module "babylonjs/Shaders/layer.fragment" {
  51731. /** @hidden */
  51732. export var layerPixelShader: {
  51733. name: string;
  51734. shader: string;
  51735. };
  51736. }
  51737. declare module "babylonjs/Shaders/layer.vertex" {
  51738. /** @hidden */
  51739. export var layerVertexShader: {
  51740. name: string;
  51741. shader: string;
  51742. };
  51743. }
  51744. declare module "babylonjs/Layers/layer" {
  51745. import { Observable } from "babylonjs/Misc/observable";
  51746. import { Nullable } from "babylonjs/types";
  51747. import { Scene } from "babylonjs/scene";
  51748. import { Vector2 } from "babylonjs/Maths/math.vector";
  51749. import { Color4 } from "babylonjs/Maths/math.color";
  51750. import { Texture } from "babylonjs/Materials/Textures/texture";
  51751. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  51752. import "babylonjs/Shaders/layer.fragment";
  51753. import "babylonjs/Shaders/layer.vertex";
  51754. /**
  51755. * This represents a full screen 2d layer.
  51756. * This can be useful to display a picture in the background of your scene for instance.
  51757. * @see https://www.babylonjs-playground.com/#08A2BS#1
  51758. */
  51759. export class Layer {
  51760. /**
  51761. * Define the name of the layer.
  51762. */
  51763. name: string;
  51764. /**
  51765. * Define the texture the layer should display.
  51766. */
  51767. texture: Nullable<Texture>;
  51768. /**
  51769. * Is the layer in background or foreground.
  51770. */
  51771. isBackground: boolean;
  51772. /**
  51773. * Define the color of the layer (instead of texture).
  51774. */
  51775. color: Color4;
  51776. /**
  51777. * Define the scale of the layer in order to zoom in out of the texture.
  51778. */
  51779. scale: Vector2;
  51780. /**
  51781. * Define an offset for the layer in order to shift the texture.
  51782. */
  51783. offset: Vector2;
  51784. /**
  51785. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  51786. */
  51787. alphaBlendingMode: number;
  51788. /**
  51789. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  51790. * Alpha test will not mix with the background color in case of transparency.
  51791. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  51792. */
  51793. alphaTest: boolean;
  51794. /**
  51795. * Define a mask to restrict the layer to only some of the scene cameras.
  51796. */
  51797. layerMask: number;
  51798. /**
  51799. * Define the list of render target the layer is visible into.
  51800. */
  51801. renderTargetTextures: RenderTargetTexture[];
  51802. /**
  51803. * Define if the layer is only used in renderTarget or if it also
  51804. * renders in the main frame buffer of the canvas.
  51805. */
  51806. renderOnlyInRenderTargetTextures: boolean;
  51807. private _scene;
  51808. private _vertexBuffers;
  51809. private _indexBuffer;
  51810. private _effect;
  51811. private _alphaTestEffect;
  51812. /**
  51813. * An event triggered when the layer is disposed.
  51814. */
  51815. onDisposeObservable: Observable<Layer>;
  51816. private _onDisposeObserver;
  51817. /**
  51818. * Back compatibility with callback before the onDisposeObservable existed.
  51819. * The set callback will be triggered when the layer has been disposed.
  51820. */
  51821. onDispose: () => void;
  51822. /**
  51823. * An event triggered before rendering the scene
  51824. */
  51825. onBeforeRenderObservable: Observable<Layer>;
  51826. private _onBeforeRenderObserver;
  51827. /**
  51828. * Back compatibility with callback before the onBeforeRenderObservable existed.
  51829. * The set callback will be triggered just before rendering the layer.
  51830. */
  51831. onBeforeRender: () => void;
  51832. /**
  51833. * An event triggered after rendering the scene
  51834. */
  51835. onAfterRenderObservable: Observable<Layer>;
  51836. private _onAfterRenderObserver;
  51837. /**
  51838. * Back compatibility with callback before the onAfterRenderObservable existed.
  51839. * The set callback will be triggered just after rendering the layer.
  51840. */
  51841. onAfterRender: () => void;
  51842. /**
  51843. * Instantiates a new layer.
  51844. * This represents a full screen 2d layer.
  51845. * This can be useful to display a picture in the background of your scene for instance.
  51846. * @see https://www.babylonjs-playground.com/#08A2BS#1
  51847. * @param name Define the name of the layer in the scene
  51848. * @param imgUrl Define the url of the texture to display in the layer
  51849. * @param scene Define the scene the layer belongs to
  51850. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  51851. * @param color Defines a color for the layer
  51852. */
  51853. constructor(
  51854. /**
  51855. * Define the name of the layer.
  51856. */
  51857. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  51858. private _createIndexBuffer;
  51859. /** @hidden */
  51860. _rebuild(): void;
  51861. /**
  51862. * Renders the layer in the scene.
  51863. */
  51864. render(): void;
  51865. /**
  51866. * Disposes and releases the associated ressources.
  51867. */
  51868. dispose(): void;
  51869. }
  51870. }
  51871. declare module "babylonjs/Layers/index" {
  51872. export * from "babylonjs/Layers/effectLayer";
  51873. export * from "babylonjs/Layers/effectLayerSceneComponent";
  51874. export * from "babylonjs/Layers/glowLayer";
  51875. export * from "babylonjs/Layers/highlightLayer";
  51876. export * from "babylonjs/Layers/layer";
  51877. export * from "babylonjs/Layers/layerSceneComponent";
  51878. }
  51879. declare module "babylonjs/Shaders/lensFlare.fragment" {
  51880. /** @hidden */
  51881. export var lensFlarePixelShader: {
  51882. name: string;
  51883. shader: string;
  51884. };
  51885. }
  51886. declare module "babylonjs/Shaders/lensFlare.vertex" {
  51887. /** @hidden */
  51888. export var lensFlareVertexShader: {
  51889. name: string;
  51890. shader: string;
  51891. };
  51892. }
  51893. declare module "babylonjs/LensFlares/lensFlareSystem" {
  51894. import { Scene } from "babylonjs/scene";
  51895. import { Vector3 } from "babylonjs/Maths/math.vector";
  51896. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51897. import { LensFlare } from "babylonjs/LensFlares/lensFlare";
  51898. import "babylonjs/Shaders/lensFlare.fragment";
  51899. import "babylonjs/Shaders/lensFlare.vertex";
  51900. import { Viewport } from "babylonjs/Maths/math.viewport";
  51901. /**
  51902. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  51903. * It is usually composed of several `lensFlare`.
  51904. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  51905. */
  51906. export class LensFlareSystem {
  51907. /**
  51908. * Define the name of the lens flare system
  51909. */
  51910. name: string;
  51911. /**
  51912. * List of lens flares used in this system.
  51913. */
  51914. lensFlares: LensFlare[];
  51915. /**
  51916. * Define a limit from the border the lens flare can be visible.
  51917. */
  51918. borderLimit: number;
  51919. /**
  51920. * Define a viewport border we do not want to see the lens flare in.
  51921. */
  51922. viewportBorder: number;
  51923. /**
  51924. * Define a predicate which could limit the list of meshes able to occlude the effect.
  51925. */
  51926. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  51927. /**
  51928. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  51929. */
  51930. layerMask: number;
  51931. /**
  51932. * Define the id of the lens flare system in the scene.
  51933. * (equal to name by default)
  51934. */
  51935. id: string;
  51936. private _scene;
  51937. private _emitter;
  51938. private _vertexBuffers;
  51939. private _indexBuffer;
  51940. private _effect;
  51941. private _positionX;
  51942. private _positionY;
  51943. private _isEnabled;
  51944. /** @hidden */
  51945. static _SceneComponentInitialization: (scene: Scene) => void;
  51946. /**
  51947. * Instantiates a lens flare system.
  51948. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  51949. * It is usually composed of several `lensFlare`.
  51950. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  51951. * @param name Define the name of the lens flare system in the scene
  51952. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  51953. * @param scene Define the scene the lens flare system belongs to
  51954. */
  51955. constructor(
  51956. /**
  51957. * Define the name of the lens flare system
  51958. */
  51959. name: string, emitter: any, scene: Scene);
  51960. /**
  51961. * Define if the lens flare system is enabled.
  51962. */
  51963. isEnabled: boolean;
  51964. /**
  51965. * Get the scene the effects belongs to.
  51966. * @returns the scene holding the lens flare system
  51967. */
  51968. getScene(): Scene;
  51969. /**
  51970. * Get the emitter of the lens flare system.
  51971. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  51972. * @returns the emitter of the lens flare system
  51973. */
  51974. getEmitter(): any;
  51975. /**
  51976. * Set the emitter of the lens flare system.
  51977. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  51978. * @param newEmitter Define the new emitter of the system
  51979. */
  51980. setEmitter(newEmitter: any): void;
  51981. /**
  51982. * Get the lens flare system emitter position.
  51983. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  51984. * @returns the position
  51985. */
  51986. getEmitterPosition(): Vector3;
  51987. /**
  51988. * @hidden
  51989. */
  51990. computeEffectivePosition(globalViewport: Viewport): boolean;
  51991. /** @hidden */
  51992. _isVisible(): boolean;
  51993. /**
  51994. * @hidden
  51995. */
  51996. render(): boolean;
  51997. /**
  51998. * Dispose and release the lens flare with its associated resources.
  51999. */
  52000. dispose(): void;
  52001. /**
  52002. * Parse a lens flare system from a JSON repressentation
  52003. * @param parsedLensFlareSystem Define the JSON to parse
  52004. * @param scene Define the scene the parsed system should be instantiated in
  52005. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  52006. * @returns the parsed system
  52007. */
  52008. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  52009. /**
  52010. * Serialize the current Lens Flare System into a JSON representation.
  52011. * @returns the serialized JSON
  52012. */
  52013. serialize(): any;
  52014. }
  52015. }
  52016. declare module "babylonjs/LensFlares/lensFlare" {
  52017. import { Nullable } from "babylonjs/types";
  52018. import { Color3 } from "babylonjs/Maths/math.color";
  52019. import { Texture } from "babylonjs/Materials/Textures/texture";
  52020. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  52021. /**
  52022. * This represents one of the lens effect in a `lensFlareSystem`.
  52023. * It controls one of the indiviual texture used in the effect.
  52024. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  52025. */
  52026. export class LensFlare {
  52027. /**
  52028. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  52029. */
  52030. size: number;
  52031. /**
  52032. * 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.
  52033. */
  52034. position: number;
  52035. /**
  52036. * Define the lens color.
  52037. */
  52038. color: Color3;
  52039. /**
  52040. * Define the lens texture.
  52041. */
  52042. texture: Nullable<Texture>;
  52043. /**
  52044. * Define the alpha mode to render this particular lens.
  52045. */
  52046. alphaMode: number;
  52047. private _system;
  52048. /**
  52049. * Creates a new Lens Flare.
  52050. * This represents one of the lens effect in a `lensFlareSystem`.
  52051. * It controls one of the indiviual texture used in the effect.
  52052. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  52053. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  52054. * @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.
  52055. * @param color Define the lens color
  52056. * @param imgUrl Define the lens texture url
  52057. * @param system Define the `lensFlareSystem` this flare is part of
  52058. * @returns The newly created Lens Flare
  52059. */
  52060. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  52061. /**
  52062. * Instantiates a new Lens Flare.
  52063. * This represents one of the lens effect in a `lensFlareSystem`.
  52064. * It controls one of the indiviual texture used in the effect.
  52065. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  52066. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  52067. * @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.
  52068. * @param color Define the lens color
  52069. * @param imgUrl Define the lens texture url
  52070. * @param system Define the `lensFlareSystem` this flare is part of
  52071. */
  52072. constructor(
  52073. /**
  52074. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  52075. */
  52076. size: number,
  52077. /**
  52078. * 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.
  52079. */
  52080. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  52081. /**
  52082. * Dispose and release the lens flare with its associated resources.
  52083. */
  52084. dispose(): void;
  52085. }
  52086. }
  52087. declare module "babylonjs/LensFlares/lensFlareSystemSceneComponent" {
  52088. import { Nullable } from "babylonjs/types";
  52089. import { Scene } from "babylonjs/scene";
  52090. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  52091. import { AbstractScene } from "babylonjs/abstractScene";
  52092. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  52093. module "babylonjs/abstractScene" {
  52094. interface AbstractScene {
  52095. /**
  52096. * The list of lens flare system added to the scene
  52097. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  52098. */
  52099. lensFlareSystems: Array<LensFlareSystem>;
  52100. /**
  52101. * Removes the given lens flare system from this scene.
  52102. * @param toRemove The lens flare system to remove
  52103. * @returns The index of the removed lens flare system
  52104. */
  52105. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  52106. /**
  52107. * Adds the given lens flare system to this scene
  52108. * @param newLensFlareSystem The lens flare system to add
  52109. */
  52110. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  52111. /**
  52112. * Gets a lens flare system using its name
  52113. * @param name defines the name to look for
  52114. * @returns the lens flare system or null if not found
  52115. */
  52116. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  52117. /**
  52118. * Gets a lens flare system using its id
  52119. * @param id defines the id to look for
  52120. * @returns the lens flare system or null if not found
  52121. */
  52122. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  52123. }
  52124. }
  52125. /**
  52126. * Defines the lens flare scene component responsible to manage any lens flares
  52127. * in a given scene.
  52128. */
  52129. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  52130. /**
  52131. * The component name helpfull to identify the component in the list of scene components.
  52132. */
  52133. readonly name: string;
  52134. /**
  52135. * The scene the component belongs to.
  52136. */
  52137. scene: Scene;
  52138. /**
  52139. * Creates a new instance of the component for the given scene
  52140. * @param scene Defines the scene to register the component in
  52141. */
  52142. constructor(scene: Scene);
  52143. /**
  52144. * Registers the component in a given scene
  52145. */
  52146. register(): void;
  52147. /**
  52148. * Rebuilds the elements related to this component in case of
  52149. * context lost for instance.
  52150. */
  52151. rebuild(): void;
  52152. /**
  52153. * Adds all the elements from the container to the scene
  52154. * @param container the container holding the elements
  52155. */
  52156. addFromContainer(container: AbstractScene): void;
  52157. /**
  52158. * Removes all the elements in the container from the scene
  52159. * @param container contains the elements to remove
  52160. * @param dispose if the removed element should be disposed (default: false)
  52161. */
  52162. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  52163. /**
  52164. * Serializes the component data to the specified json object
  52165. * @param serializationObject The object to serialize to
  52166. */
  52167. serialize(serializationObject: any): void;
  52168. /**
  52169. * Disposes the component and the associated ressources.
  52170. */
  52171. dispose(): void;
  52172. private _draw;
  52173. }
  52174. }
  52175. declare module "babylonjs/LensFlares/index" {
  52176. export * from "babylonjs/LensFlares/lensFlare";
  52177. export * from "babylonjs/LensFlares/lensFlareSystem";
  52178. export * from "babylonjs/LensFlares/lensFlareSystemSceneComponent";
  52179. }
  52180. declare module "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent" {
  52181. import { Scene } from "babylonjs/scene";
  52182. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  52183. import { AbstractScene } from "babylonjs/abstractScene";
  52184. /**
  52185. * Defines the shadow generator component responsible to manage any shadow generators
  52186. * in a given scene.
  52187. */
  52188. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  52189. /**
  52190. * The component name helpfull to identify the component in the list of scene components.
  52191. */
  52192. readonly name: string;
  52193. /**
  52194. * The scene the component belongs to.
  52195. */
  52196. scene: Scene;
  52197. /**
  52198. * Creates a new instance of the component for the given scene
  52199. * @param scene Defines the scene to register the component in
  52200. */
  52201. constructor(scene: Scene);
  52202. /**
  52203. * Registers the component in a given scene
  52204. */
  52205. register(): void;
  52206. /**
  52207. * Rebuilds the elements related to this component in case of
  52208. * context lost for instance.
  52209. */
  52210. rebuild(): void;
  52211. /**
  52212. * Serializes the component data to the specified json object
  52213. * @param serializationObject The object to serialize to
  52214. */
  52215. serialize(serializationObject: any): void;
  52216. /**
  52217. * Adds all the elements from the container to the scene
  52218. * @param container the container holding the elements
  52219. */
  52220. addFromContainer(container: AbstractScene): void;
  52221. /**
  52222. * Removes all the elements in the container from the scene
  52223. * @param container contains the elements to remove
  52224. * @param dispose if the removed element should be disposed (default: false)
  52225. */
  52226. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  52227. /**
  52228. * Rebuilds the elements related to this component in case of
  52229. * context lost for instance.
  52230. */
  52231. dispose(): void;
  52232. private _gatherRenderTargets;
  52233. }
  52234. }
  52235. declare module "babylonjs/Lights/Shadows/index" {
  52236. export * from "babylonjs/Lights/Shadows/shadowGenerator";
  52237. export * from "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent";
  52238. }
  52239. declare module "babylonjs/Lights/pointLight" {
  52240. import { Scene } from "babylonjs/scene";
  52241. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  52242. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52243. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  52244. import { Effect } from "babylonjs/Materials/effect";
  52245. /**
  52246. * A point light is a light defined by an unique point in world space.
  52247. * The light is emitted in every direction from this point.
  52248. * A good example of a point light is a standard light bulb.
  52249. * Documentation: https://doc.babylonjs.com/babylon101/lights
  52250. */
  52251. export class PointLight extends ShadowLight {
  52252. private _shadowAngle;
  52253. /**
  52254. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  52255. * This specifies what angle the shadow will use to be created.
  52256. *
  52257. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  52258. */
  52259. /**
  52260. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  52261. * This specifies what angle the shadow will use to be created.
  52262. *
  52263. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  52264. */
  52265. shadowAngle: number;
  52266. /**
  52267. * Gets the direction if it has been set.
  52268. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  52269. */
  52270. /**
  52271. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  52272. */
  52273. direction: Vector3;
  52274. /**
  52275. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  52276. * A PointLight emits the light in every direction.
  52277. * It can cast shadows.
  52278. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  52279. * ```javascript
  52280. * var pointLight = new PointLight("pl", camera.position, scene);
  52281. * ```
  52282. * Documentation : https://doc.babylonjs.com/babylon101/lights
  52283. * @param name The light friendly name
  52284. * @param position The position of the point light in the scene
  52285. * @param scene The scene the lights belongs to
  52286. */
  52287. constructor(name: string, position: Vector3, scene: Scene);
  52288. /**
  52289. * Returns the string "PointLight"
  52290. * @returns the class name
  52291. */
  52292. getClassName(): string;
  52293. /**
  52294. * Returns the integer 0.
  52295. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  52296. */
  52297. getTypeID(): number;
  52298. /**
  52299. * Specifies wether or not the shadowmap should be a cube texture.
  52300. * @returns true if the shadowmap needs to be a cube texture.
  52301. */
  52302. needCube(): boolean;
  52303. /**
  52304. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  52305. * @param faceIndex The index of the face we are computed the direction to generate shadow
  52306. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  52307. */
  52308. getShadowDirection(faceIndex?: number): Vector3;
  52309. /**
  52310. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  52311. * - fov = PI / 2
  52312. * - aspect ratio : 1.0
  52313. * - z-near and far equal to the active camera minZ and maxZ.
  52314. * Returns the PointLight.
  52315. */
  52316. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  52317. protected _buildUniformLayout(): void;
  52318. /**
  52319. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  52320. * @param effect The effect to update
  52321. * @param lightIndex The index of the light in the effect to update
  52322. * @returns The point light
  52323. */
  52324. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  52325. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  52326. /**
  52327. * Prepares the list of defines specific to the light type.
  52328. * @param defines the list of defines
  52329. * @param lightIndex defines the index of the light for the effect
  52330. */
  52331. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  52332. }
  52333. }
  52334. declare module "babylonjs/Lights/index" {
  52335. export * from "babylonjs/Lights/light";
  52336. export * from "babylonjs/Lights/shadowLight";
  52337. export * from "babylonjs/Lights/Shadows/index";
  52338. export * from "babylonjs/Lights/directionalLight";
  52339. export * from "babylonjs/Lights/hemisphericLight";
  52340. export * from "babylonjs/Lights/pointLight";
  52341. export * from "babylonjs/Lights/spotLight";
  52342. }
  52343. declare module "babylonjs/Misc/HighDynamicRange/hdr" {
  52344. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  52345. /**
  52346. * Header information of HDR texture files.
  52347. */
  52348. export interface HDRInfo {
  52349. /**
  52350. * The height of the texture in pixels.
  52351. */
  52352. height: number;
  52353. /**
  52354. * The width of the texture in pixels.
  52355. */
  52356. width: number;
  52357. /**
  52358. * The index of the beginning of the data in the binary file.
  52359. */
  52360. dataPosition: number;
  52361. }
  52362. /**
  52363. * This groups tools to convert HDR texture to native colors array.
  52364. */
  52365. export class HDRTools {
  52366. private static Ldexp;
  52367. private static Rgbe2float;
  52368. private static readStringLine;
  52369. /**
  52370. * Reads header information from an RGBE texture stored in a native array.
  52371. * More information on this format are available here:
  52372. * https://en.wikipedia.org/wiki/RGBE_image_format
  52373. *
  52374. * @param uint8array The binary file stored in native array.
  52375. * @return The header information.
  52376. */
  52377. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  52378. /**
  52379. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  52380. * This RGBE texture needs to store the information as a panorama.
  52381. *
  52382. * More information on this format are available here:
  52383. * https://en.wikipedia.org/wiki/RGBE_image_format
  52384. *
  52385. * @param buffer The binary file stored in an array buffer.
  52386. * @param size The expected size of the extracted cubemap.
  52387. * @return The Cube Map information.
  52388. */
  52389. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  52390. /**
  52391. * Returns the pixels data extracted from an RGBE texture.
  52392. * This pixels will be stored left to right up to down in the R G B order in one array.
  52393. *
  52394. * More information on this format are available here:
  52395. * https://en.wikipedia.org/wiki/RGBE_image_format
  52396. *
  52397. * @param uint8array The binary file stored in an array buffer.
  52398. * @param hdrInfo The header information of the file.
  52399. * @return The pixels data in RGB right to left up to down order.
  52400. */
  52401. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  52402. private static RGBE_ReadPixels_RLE;
  52403. }
  52404. }
  52405. declare module "babylonjs/Materials/Textures/hdrCubeTexture" {
  52406. import { Nullable } from "babylonjs/types";
  52407. import { Scene } from "babylonjs/scene";
  52408. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  52409. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  52410. import "babylonjs/Engines/Extensions/engine.rawTexture";
  52411. /**
  52412. * This represents a texture coming from an HDR input.
  52413. *
  52414. * The only supported format is currently panorama picture stored in RGBE format.
  52415. * Example of such files can be found on HDRLib: http://hdrlib.com/
  52416. */
  52417. export class HDRCubeTexture extends BaseTexture {
  52418. private static _facesMapping;
  52419. private _generateHarmonics;
  52420. private _noMipmap;
  52421. private _textureMatrix;
  52422. private _size;
  52423. private _onLoad;
  52424. private _onError;
  52425. /**
  52426. * The texture URL.
  52427. */
  52428. url: string;
  52429. /**
  52430. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  52431. */
  52432. coordinatesMode: number;
  52433. protected _isBlocking: boolean;
  52434. /**
  52435. * Sets wether or not the texture is blocking during loading.
  52436. */
  52437. /**
  52438. * Gets wether or not the texture is blocking during loading.
  52439. */
  52440. isBlocking: boolean;
  52441. protected _rotationY: number;
  52442. /**
  52443. * Sets texture matrix rotation angle around Y axis in radians.
  52444. */
  52445. /**
  52446. * Gets texture matrix rotation angle around Y axis radians.
  52447. */
  52448. rotationY: number;
  52449. /**
  52450. * Gets or sets the center of the bounding box associated with the cube texture
  52451. * It must define where the camera used to render the texture was set
  52452. */
  52453. boundingBoxPosition: Vector3;
  52454. private _boundingBoxSize;
  52455. /**
  52456. * Gets or sets the size of the bounding box associated with the cube texture
  52457. * When defined, the cubemap will switch to local mode
  52458. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  52459. * @example https://www.babylonjs-playground.com/#RNASML
  52460. */
  52461. boundingBoxSize: Vector3;
  52462. /**
  52463. * Instantiates an HDRTexture from the following parameters.
  52464. *
  52465. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  52466. * @param scene The scene the texture will be used in
  52467. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  52468. * @param noMipmap Forces to not generate the mipmap if true
  52469. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  52470. * @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)
  52471. * @param reserved Reserved flag for internal use.
  52472. */
  52473. 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>);
  52474. /**
  52475. * Get the current class name of the texture useful for serialization or dynamic coding.
  52476. * @returns "HDRCubeTexture"
  52477. */
  52478. getClassName(): string;
  52479. /**
  52480. * Occurs when the file is raw .hdr file.
  52481. */
  52482. private loadTexture;
  52483. clone(): HDRCubeTexture;
  52484. delayLoad(): void;
  52485. /**
  52486. * Get the texture reflection matrix used to rotate/transform the reflection.
  52487. * @returns the reflection matrix
  52488. */
  52489. getReflectionTextureMatrix(): Matrix;
  52490. /**
  52491. * Set the texture reflection matrix used to rotate/transform the reflection.
  52492. * @param value Define the reflection matrix to set
  52493. */
  52494. setReflectionTextureMatrix(value: Matrix): void;
  52495. /**
  52496. * Parses a JSON representation of an HDR Texture in order to create the texture
  52497. * @param parsedTexture Define the JSON representation
  52498. * @param scene Define the scene the texture should be created in
  52499. * @param rootUrl Define the root url in case we need to load relative dependencies
  52500. * @returns the newly created texture after parsing
  52501. */
  52502. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  52503. serialize(): any;
  52504. }
  52505. }
  52506. declare module "babylonjs/Physics/physicsEngine" {
  52507. import { Nullable } from "babylonjs/types";
  52508. import { Vector3 } from "babylonjs/Maths/math.vector";
  52509. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  52510. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  52511. import { PhysicsJoint } from "babylonjs/Physics/physicsJoint";
  52512. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  52513. /**
  52514. * Class used to control physics engine
  52515. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  52516. */
  52517. export class PhysicsEngine implements IPhysicsEngine {
  52518. private _physicsPlugin;
  52519. /**
  52520. * Global value used to control the smallest number supported by the simulation
  52521. */
  52522. static Epsilon: number;
  52523. private _impostors;
  52524. private _joints;
  52525. /**
  52526. * Gets the gravity vector used by the simulation
  52527. */
  52528. gravity: Vector3;
  52529. /**
  52530. * Factory used to create the default physics plugin.
  52531. * @returns The default physics plugin
  52532. */
  52533. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  52534. /**
  52535. * Creates a new Physics Engine
  52536. * @param gravity defines the gravity vector used by the simulation
  52537. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  52538. */
  52539. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  52540. /**
  52541. * Sets the gravity vector used by the simulation
  52542. * @param gravity defines the gravity vector to use
  52543. */
  52544. setGravity(gravity: Vector3): void;
  52545. /**
  52546. * Set the time step of the physics engine.
  52547. * Default is 1/60.
  52548. * To slow it down, enter 1/600 for example.
  52549. * To speed it up, 1/30
  52550. * @param newTimeStep defines the new timestep to apply to this world.
  52551. */
  52552. setTimeStep(newTimeStep?: number): void;
  52553. /**
  52554. * Get the time step of the physics engine.
  52555. * @returns the current time step
  52556. */
  52557. getTimeStep(): number;
  52558. /**
  52559. * Release all resources
  52560. */
  52561. dispose(): void;
  52562. /**
  52563. * Gets the name of the current physics plugin
  52564. * @returns the name of the plugin
  52565. */
  52566. getPhysicsPluginName(): string;
  52567. /**
  52568. * Adding a new impostor for the impostor tracking.
  52569. * This will be done by the impostor itself.
  52570. * @param impostor the impostor to add
  52571. */
  52572. addImpostor(impostor: PhysicsImpostor): void;
  52573. /**
  52574. * Remove an impostor from the engine.
  52575. * This impostor and its mesh will not longer be updated by the physics engine.
  52576. * @param impostor the impostor to remove
  52577. */
  52578. removeImpostor(impostor: PhysicsImpostor): void;
  52579. /**
  52580. * Add a joint to the physics engine
  52581. * @param mainImpostor defines the main impostor to which the joint is added.
  52582. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  52583. * @param joint defines the joint that will connect both impostors.
  52584. */
  52585. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  52586. /**
  52587. * Removes a joint from the simulation
  52588. * @param mainImpostor defines the impostor used with the joint
  52589. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  52590. * @param joint defines the joint to remove
  52591. */
  52592. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  52593. /**
  52594. * Called by the scene. No need to call it.
  52595. * @param delta defines the timespam between frames
  52596. */
  52597. _step(delta: number): void;
  52598. /**
  52599. * Gets the current plugin used to run the simulation
  52600. * @returns current plugin
  52601. */
  52602. getPhysicsPlugin(): IPhysicsEnginePlugin;
  52603. /**
  52604. * Gets the list of physic impostors
  52605. * @returns an array of PhysicsImpostor
  52606. */
  52607. getImpostors(): Array<PhysicsImpostor>;
  52608. /**
  52609. * Gets the impostor for a physics enabled object
  52610. * @param object defines the object impersonated by the impostor
  52611. * @returns the PhysicsImpostor or null if not found
  52612. */
  52613. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  52614. /**
  52615. * Gets the impostor for a physics body object
  52616. * @param body defines physics body used by the impostor
  52617. * @returns the PhysicsImpostor or null if not found
  52618. */
  52619. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  52620. /**
  52621. * Does a raycast in the physics world
  52622. * @param from when should the ray start?
  52623. * @param to when should the ray end?
  52624. * @returns PhysicsRaycastResult
  52625. */
  52626. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  52627. }
  52628. }
  52629. declare module "babylonjs/Physics/Plugins/cannonJSPlugin" {
  52630. import { Nullable } from "babylonjs/types";
  52631. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  52632. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52633. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  52634. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  52635. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  52636. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  52637. /** @hidden */
  52638. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  52639. private _useDeltaForWorldStep;
  52640. world: any;
  52641. name: string;
  52642. private _physicsMaterials;
  52643. private _fixedTimeStep;
  52644. private _cannonRaycastResult;
  52645. private _raycastResult;
  52646. private _physicsBodysToRemoveAfterStep;
  52647. BJSCANNON: any;
  52648. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  52649. setGravity(gravity: Vector3): void;
  52650. setTimeStep(timeStep: number): void;
  52651. getTimeStep(): number;
  52652. executeStep(delta: number): void;
  52653. private _removeMarkedPhysicsBodiesFromWorld;
  52654. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  52655. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  52656. generatePhysicsBody(impostor: PhysicsImpostor): void;
  52657. private _processChildMeshes;
  52658. removePhysicsBody(impostor: PhysicsImpostor): void;
  52659. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  52660. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  52661. private _addMaterial;
  52662. private _checkWithEpsilon;
  52663. private _createShape;
  52664. private _createHeightmap;
  52665. private _minus90X;
  52666. private _plus90X;
  52667. private _tmpPosition;
  52668. private _tmpDeltaPosition;
  52669. private _tmpUnityRotation;
  52670. private _updatePhysicsBodyTransformation;
  52671. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  52672. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  52673. isSupported(): boolean;
  52674. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  52675. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  52676. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  52677. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  52678. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  52679. getBodyMass(impostor: PhysicsImpostor): number;
  52680. getBodyFriction(impostor: PhysicsImpostor): number;
  52681. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  52682. getBodyRestitution(impostor: PhysicsImpostor): number;
  52683. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  52684. sleepBody(impostor: PhysicsImpostor): void;
  52685. wakeUpBody(impostor: PhysicsImpostor): void;
  52686. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  52687. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  52688. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  52689. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  52690. getRadius(impostor: PhysicsImpostor): number;
  52691. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  52692. dispose(): void;
  52693. private _extendNamespace;
  52694. /**
  52695. * Does a raycast in the physics world
  52696. * @param from when should the ray start?
  52697. * @param to when should the ray end?
  52698. * @returns PhysicsRaycastResult
  52699. */
  52700. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  52701. }
  52702. }
  52703. declare module "babylonjs/Physics/Plugins/oimoJSPlugin" {
  52704. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  52705. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  52706. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  52707. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52708. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  52709. import { Nullable } from "babylonjs/types";
  52710. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  52711. /** @hidden */
  52712. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  52713. world: any;
  52714. name: string;
  52715. BJSOIMO: any;
  52716. private _raycastResult;
  52717. constructor(iterations?: number, oimoInjection?: any);
  52718. setGravity(gravity: Vector3): void;
  52719. setTimeStep(timeStep: number): void;
  52720. getTimeStep(): number;
  52721. private _tmpImpostorsArray;
  52722. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  52723. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  52724. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  52725. generatePhysicsBody(impostor: PhysicsImpostor): void;
  52726. private _tmpPositionVector;
  52727. removePhysicsBody(impostor: PhysicsImpostor): void;
  52728. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  52729. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  52730. isSupported(): boolean;
  52731. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  52732. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  52733. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  52734. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  52735. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  52736. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  52737. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  52738. getBodyMass(impostor: PhysicsImpostor): number;
  52739. getBodyFriction(impostor: PhysicsImpostor): number;
  52740. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  52741. getBodyRestitution(impostor: PhysicsImpostor): number;
  52742. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  52743. sleepBody(impostor: PhysicsImpostor): void;
  52744. wakeUpBody(impostor: PhysicsImpostor): void;
  52745. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  52746. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  52747. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  52748. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  52749. getRadius(impostor: PhysicsImpostor): number;
  52750. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  52751. dispose(): void;
  52752. /**
  52753. * Does a raycast in the physics world
  52754. * @param from when should the ray start?
  52755. * @param to when should the ray end?
  52756. * @returns PhysicsRaycastResult
  52757. */
  52758. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  52759. }
  52760. }
  52761. declare module "babylonjs/Meshes/Builders/ribbonBuilder" {
  52762. import { Nullable } from "babylonjs/types";
  52763. import { Scene } from "babylonjs/scene";
  52764. import { Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  52765. import { Color4 } from "babylonjs/Maths/math.color";
  52766. import { Mesh } from "babylonjs/Meshes/mesh";
  52767. /**
  52768. * Class containing static functions to help procedurally build meshes
  52769. */
  52770. export class RibbonBuilder {
  52771. /**
  52772. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  52773. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  52774. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  52775. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  52776. * * 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
  52777. * * 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
  52778. * * 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
  52779. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52780. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  52781. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  52782. * * 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
  52783. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  52784. * * 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
  52785. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  52786. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52787. * @param name defines the name of the mesh
  52788. * @param options defines the options used to create the mesh
  52789. * @param scene defines the hosting scene
  52790. * @returns the ribbon mesh
  52791. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  52792. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  52793. */
  52794. static CreateRibbon(name: string, options: {
  52795. pathArray: Vector3[][];
  52796. closeArray?: boolean;
  52797. closePath?: boolean;
  52798. offset?: number;
  52799. updatable?: boolean;
  52800. sideOrientation?: number;
  52801. frontUVs?: Vector4;
  52802. backUVs?: Vector4;
  52803. instance?: Mesh;
  52804. invertUV?: boolean;
  52805. uvs?: Vector2[];
  52806. colors?: Color4[];
  52807. }, scene?: Nullable<Scene>): Mesh;
  52808. }
  52809. }
  52810. declare module "babylonjs/Meshes/Builders/shapeBuilder" {
  52811. import { Nullable } from "babylonjs/types";
  52812. import { Scene } from "babylonjs/scene";
  52813. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  52814. import { Mesh } from "babylonjs/Meshes/mesh";
  52815. /**
  52816. * Class containing static functions to help procedurally build meshes
  52817. */
  52818. export class ShapeBuilder {
  52819. /**
  52820. * 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.
  52821. * * 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.
  52822. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  52823. * * 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.
  52824. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  52825. * * 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
  52826. * * 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
  52827. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  52828. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52829. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  52830. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  52831. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  52832. * @param name defines the name of the mesh
  52833. * @param options defines the options used to create the mesh
  52834. * @param scene defines the hosting scene
  52835. * @returns the extruded shape mesh
  52836. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  52837. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  52838. */
  52839. static ExtrudeShape(name: string, options: {
  52840. shape: Vector3[];
  52841. path: Vector3[];
  52842. scale?: number;
  52843. rotation?: number;
  52844. cap?: number;
  52845. updatable?: boolean;
  52846. sideOrientation?: number;
  52847. frontUVs?: Vector4;
  52848. backUVs?: Vector4;
  52849. instance?: Mesh;
  52850. invertUV?: boolean;
  52851. }, scene?: Nullable<Scene>): Mesh;
  52852. /**
  52853. * Creates an custom extruded shape mesh.
  52854. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  52855. * * 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.
  52856. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  52857. * * 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
  52858. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  52859. * * 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
  52860. * * It must returns a float value that will be the scale value applied to the shape on each path point
  52861. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  52862. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  52863. * * 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
  52864. * * 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
  52865. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  52866. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52867. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  52868. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  52869. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52870. * @param name defines the name of the mesh
  52871. * @param options defines the options used to create the mesh
  52872. * @param scene defines the hosting scene
  52873. * @returns the custom extruded shape mesh
  52874. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  52875. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  52876. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  52877. */
  52878. static ExtrudeShapeCustom(name: string, options: {
  52879. shape: Vector3[];
  52880. path: Vector3[];
  52881. scaleFunction?: any;
  52882. rotationFunction?: any;
  52883. ribbonCloseArray?: boolean;
  52884. ribbonClosePath?: boolean;
  52885. cap?: number;
  52886. updatable?: boolean;
  52887. sideOrientation?: number;
  52888. frontUVs?: Vector4;
  52889. backUVs?: Vector4;
  52890. instance?: Mesh;
  52891. invertUV?: boolean;
  52892. }, scene?: Nullable<Scene>): Mesh;
  52893. private static _ExtrudeShapeGeneric;
  52894. }
  52895. }
  52896. declare module "babylonjs/Physics/Plugins/ammoJSPlugin" {
  52897. import { Quaternion, Vector3 } from "babylonjs/Maths/math.vector";
  52898. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  52899. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  52900. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  52901. import { Nullable } from "babylonjs/types";
  52902. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52903. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  52904. /**
  52905. * AmmoJS Physics plugin
  52906. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  52907. * @see https://github.com/kripken/ammo.js/
  52908. */
  52909. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  52910. private _useDeltaForWorldStep;
  52911. /**
  52912. * Reference to the Ammo library
  52913. */
  52914. bjsAMMO: any;
  52915. /**
  52916. * Created ammoJS world which physics bodies are added to
  52917. */
  52918. world: any;
  52919. /**
  52920. * Name of the plugin
  52921. */
  52922. name: string;
  52923. private _timeStep;
  52924. private _fixedTimeStep;
  52925. private _maxSteps;
  52926. private _tmpQuaternion;
  52927. private _tmpAmmoTransform;
  52928. private _tmpAmmoQuaternion;
  52929. private _tmpAmmoConcreteContactResultCallback;
  52930. private _collisionConfiguration;
  52931. private _dispatcher;
  52932. private _overlappingPairCache;
  52933. private _solver;
  52934. private _softBodySolver;
  52935. private _tmpAmmoVectorA;
  52936. private _tmpAmmoVectorB;
  52937. private _tmpAmmoVectorC;
  52938. private _tmpAmmoVectorD;
  52939. private _tmpContactCallbackResult;
  52940. private _tmpAmmoVectorRCA;
  52941. private _tmpAmmoVectorRCB;
  52942. private _raycastResult;
  52943. private static readonly DISABLE_COLLISION_FLAG;
  52944. private static readonly KINEMATIC_FLAG;
  52945. private static readonly DISABLE_DEACTIVATION_FLAG;
  52946. /**
  52947. * Initializes the ammoJS plugin
  52948. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  52949. * @param ammoInjection can be used to inject your own ammo reference
  52950. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  52951. */
  52952. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  52953. /**
  52954. * Sets the gravity of the physics world (m/(s^2))
  52955. * @param gravity Gravity to set
  52956. */
  52957. setGravity(gravity: Vector3): void;
  52958. /**
  52959. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  52960. * @param timeStep timestep to use in seconds
  52961. */
  52962. setTimeStep(timeStep: number): void;
  52963. /**
  52964. * 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)
  52965. * @param fixedTimeStep fixedTimeStep to use in seconds
  52966. */
  52967. setFixedTimeStep(fixedTimeStep: number): void;
  52968. /**
  52969. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  52970. * @param maxSteps the maximum number of steps by the physics engine per frame
  52971. */
  52972. setMaxSteps(maxSteps: number): void;
  52973. /**
  52974. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  52975. * @returns the current timestep in seconds
  52976. */
  52977. getTimeStep(): number;
  52978. private _isImpostorInContact;
  52979. private _isImpostorPairInContact;
  52980. private _stepSimulation;
  52981. /**
  52982. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  52983. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  52984. * After the step the babylon meshes are set to the position of the physics imposters
  52985. * @param delta amount of time to step forward
  52986. * @param impostors array of imposters to update before/after the step
  52987. */
  52988. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  52989. /**
  52990. * Update babylon mesh to match physics world object
  52991. * @param impostor imposter to match
  52992. */
  52993. private _afterSoftStep;
  52994. /**
  52995. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  52996. * @param impostor imposter to match
  52997. */
  52998. private _ropeStep;
  52999. /**
  53000. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  53001. * @param impostor imposter to match
  53002. */
  53003. private _softbodyOrClothStep;
  53004. private _tmpVector;
  53005. private _tmpMatrix;
  53006. /**
  53007. * Applies an impulse on the imposter
  53008. * @param impostor imposter to apply impulse to
  53009. * @param force amount of force to be applied to the imposter
  53010. * @param contactPoint the location to apply the impulse on the imposter
  53011. */
  53012. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  53013. /**
  53014. * Applies a force on the imposter
  53015. * @param impostor imposter to apply force
  53016. * @param force amount of force to be applied to the imposter
  53017. * @param contactPoint the location to apply the force on the imposter
  53018. */
  53019. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  53020. /**
  53021. * Creates a physics body using the plugin
  53022. * @param impostor the imposter to create the physics body on
  53023. */
  53024. generatePhysicsBody(impostor: PhysicsImpostor): void;
  53025. /**
  53026. * Removes the physics body from the imposter and disposes of the body's memory
  53027. * @param impostor imposter to remove the physics body from
  53028. */
  53029. removePhysicsBody(impostor: PhysicsImpostor): void;
  53030. /**
  53031. * Generates a joint
  53032. * @param impostorJoint the imposter joint to create the joint with
  53033. */
  53034. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  53035. /**
  53036. * Removes a joint
  53037. * @param impostorJoint the imposter joint to remove the joint from
  53038. */
  53039. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  53040. private _addMeshVerts;
  53041. /**
  53042. * Initialise the soft body vertices to match its object's (mesh) vertices
  53043. * Softbody vertices (nodes) are in world space and to match this
  53044. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  53045. * @param impostor to create the softbody for
  53046. */
  53047. private _softVertexData;
  53048. /**
  53049. * Create an impostor's soft body
  53050. * @param impostor to create the softbody for
  53051. */
  53052. private _createSoftbody;
  53053. /**
  53054. * Create cloth for an impostor
  53055. * @param impostor to create the softbody for
  53056. */
  53057. private _createCloth;
  53058. /**
  53059. * Create rope for an impostor
  53060. * @param impostor to create the softbody for
  53061. */
  53062. private _createRope;
  53063. private _addHullVerts;
  53064. private _createShape;
  53065. /**
  53066. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  53067. * @param impostor imposter containing the physics body and babylon object
  53068. */
  53069. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  53070. /**
  53071. * Sets the babylon object's position/rotation from the physics body's position/rotation
  53072. * @param impostor imposter containing the physics body and babylon object
  53073. * @param newPosition new position
  53074. * @param newRotation new rotation
  53075. */
  53076. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  53077. /**
  53078. * If this plugin is supported
  53079. * @returns true if its supported
  53080. */
  53081. isSupported(): boolean;
  53082. /**
  53083. * Sets the linear velocity of the physics body
  53084. * @param impostor imposter to set the velocity on
  53085. * @param velocity velocity to set
  53086. */
  53087. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  53088. /**
  53089. * Sets the angular velocity of the physics body
  53090. * @param impostor imposter to set the velocity on
  53091. * @param velocity velocity to set
  53092. */
  53093. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  53094. /**
  53095. * gets the linear velocity
  53096. * @param impostor imposter to get linear velocity from
  53097. * @returns linear velocity
  53098. */
  53099. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  53100. /**
  53101. * gets the angular velocity
  53102. * @param impostor imposter to get angular velocity from
  53103. * @returns angular velocity
  53104. */
  53105. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  53106. /**
  53107. * Sets the mass of physics body
  53108. * @param impostor imposter to set the mass on
  53109. * @param mass mass to set
  53110. */
  53111. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  53112. /**
  53113. * Gets the mass of the physics body
  53114. * @param impostor imposter to get the mass from
  53115. * @returns mass
  53116. */
  53117. getBodyMass(impostor: PhysicsImpostor): number;
  53118. /**
  53119. * Gets friction of the impostor
  53120. * @param impostor impostor to get friction from
  53121. * @returns friction value
  53122. */
  53123. getBodyFriction(impostor: PhysicsImpostor): number;
  53124. /**
  53125. * Sets friction of the impostor
  53126. * @param impostor impostor to set friction on
  53127. * @param friction friction value
  53128. */
  53129. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  53130. /**
  53131. * Gets restitution of the impostor
  53132. * @param impostor impostor to get restitution from
  53133. * @returns restitution value
  53134. */
  53135. getBodyRestitution(impostor: PhysicsImpostor): number;
  53136. /**
  53137. * Sets resitution of the impostor
  53138. * @param impostor impostor to set resitution on
  53139. * @param restitution resitution value
  53140. */
  53141. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  53142. /**
  53143. * Gets pressure inside the impostor
  53144. * @param impostor impostor to get pressure from
  53145. * @returns pressure value
  53146. */
  53147. getBodyPressure(impostor: PhysicsImpostor): number;
  53148. /**
  53149. * Sets pressure inside a soft body impostor
  53150. * Cloth and rope must remain 0 pressure
  53151. * @param impostor impostor to set pressure on
  53152. * @param pressure pressure value
  53153. */
  53154. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  53155. /**
  53156. * Gets stiffness of the impostor
  53157. * @param impostor impostor to get stiffness from
  53158. * @returns pressure value
  53159. */
  53160. getBodyStiffness(impostor: PhysicsImpostor): number;
  53161. /**
  53162. * Sets stiffness of the impostor
  53163. * @param impostor impostor to set stiffness on
  53164. * @param stiffness stiffness value from 0 to 1
  53165. */
  53166. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  53167. /**
  53168. * Gets velocityIterations of the impostor
  53169. * @param impostor impostor to get velocity iterations from
  53170. * @returns velocityIterations value
  53171. */
  53172. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  53173. /**
  53174. * Sets velocityIterations of the impostor
  53175. * @param impostor impostor to set velocity iterations on
  53176. * @param velocityIterations velocityIterations value
  53177. */
  53178. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  53179. /**
  53180. * Gets positionIterations of the impostor
  53181. * @param impostor impostor to get position iterations from
  53182. * @returns positionIterations value
  53183. */
  53184. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  53185. /**
  53186. * Sets positionIterations of the impostor
  53187. * @param impostor impostor to set position on
  53188. * @param positionIterations positionIterations value
  53189. */
  53190. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  53191. /**
  53192. * Append an anchor to a cloth object
  53193. * @param impostor is the cloth impostor to add anchor to
  53194. * @param otherImpostor is the rigid impostor to anchor to
  53195. * @param width ratio across width from 0 to 1
  53196. * @param height ratio up height from 0 to 1
  53197. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  53198. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  53199. */
  53200. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  53201. /**
  53202. * Append an hook to a rope object
  53203. * @param impostor is the rope impostor to add hook to
  53204. * @param otherImpostor is the rigid impostor to hook to
  53205. * @param length ratio along the rope from 0 to 1
  53206. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  53207. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  53208. */
  53209. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  53210. /**
  53211. * Sleeps the physics body and stops it from being active
  53212. * @param impostor impostor to sleep
  53213. */
  53214. sleepBody(impostor: PhysicsImpostor): void;
  53215. /**
  53216. * Activates the physics body
  53217. * @param impostor impostor to activate
  53218. */
  53219. wakeUpBody(impostor: PhysicsImpostor): void;
  53220. /**
  53221. * Updates the distance parameters of the joint
  53222. * @param joint joint to update
  53223. * @param maxDistance maximum distance of the joint
  53224. * @param minDistance minimum distance of the joint
  53225. */
  53226. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  53227. /**
  53228. * Sets a motor on the joint
  53229. * @param joint joint to set motor on
  53230. * @param speed speed of the motor
  53231. * @param maxForce maximum force of the motor
  53232. * @param motorIndex index of the motor
  53233. */
  53234. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  53235. /**
  53236. * Sets the motors limit
  53237. * @param joint joint to set limit on
  53238. * @param upperLimit upper limit
  53239. * @param lowerLimit lower limit
  53240. */
  53241. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  53242. /**
  53243. * Syncs the position and rotation of a mesh with the impostor
  53244. * @param mesh mesh to sync
  53245. * @param impostor impostor to update the mesh with
  53246. */
  53247. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  53248. /**
  53249. * Gets the radius of the impostor
  53250. * @param impostor impostor to get radius from
  53251. * @returns the radius
  53252. */
  53253. getRadius(impostor: PhysicsImpostor): number;
  53254. /**
  53255. * Gets the box size of the impostor
  53256. * @param impostor impostor to get box size from
  53257. * @param result the resulting box size
  53258. */
  53259. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  53260. /**
  53261. * Disposes of the impostor
  53262. */
  53263. dispose(): void;
  53264. /**
  53265. * Does a raycast in the physics world
  53266. * @param from when should the ray start?
  53267. * @param to when should the ray end?
  53268. * @returns PhysicsRaycastResult
  53269. */
  53270. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  53271. }
  53272. }
  53273. declare module "babylonjs/Probes/reflectionProbe" {
  53274. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  53275. import { Vector3 } from "babylonjs/Maths/math.vector";
  53276. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53277. import { Nullable } from "babylonjs/types";
  53278. import { Scene } from "babylonjs/scene";
  53279. module "babylonjs/abstractScene" {
  53280. interface AbstractScene {
  53281. /**
  53282. * The list of reflection probes added to the scene
  53283. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  53284. */
  53285. reflectionProbes: Array<ReflectionProbe>;
  53286. /**
  53287. * Removes the given reflection probe from this scene.
  53288. * @param toRemove The reflection probe to remove
  53289. * @returns The index of the removed reflection probe
  53290. */
  53291. removeReflectionProbe(toRemove: ReflectionProbe): number;
  53292. /**
  53293. * Adds the given reflection probe to this scene.
  53294. * @param newReflectionProbe The reflection probe to add
  53295. */
  53296. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  53297. }
  53298. }
  53299. /**
  53300. * Class used to generate realtime reflection / refraction cube textures
  53301. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  53302. */
  53303. export class ReflectionProbe {
  53304. /** defines the name of the probe */
  53305. name: string;
  53306. private _scene;
  53307. private _renderTargetTexture;
  53308. private _projectionMatrix;
  53309. private _viewMatrix;
  53310. private _target;
  53311. private _add;
  53312. private _attachedMesh;
  53313. private _invertYAxis;
  53314. /** Gets or sets probe position (center of the cube map) */
  53315. position: Vector3;
  53316. /**
  53317. * Creates a new reflection probe
  53318. * @param name defines the name of the probe
  53319. * @param size defines the texture resolution (for each face)
  53320. * @param scene defines the hosting scene
  53321. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  53322. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  53323. */
  53324. constructor(
  53325. /** defines the name of the probe */
  53326. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  53327. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  53328. samples: number;
  53329. /** Gets or sets the refresh rate to use (on every frame by default) */
  53330. refreshRate: number;
  53331. /**
  53332. * Gets the hosting scene
  53333. * @returns a Scene
  53334. */
  53335. getScene(): Scene;
  53336. /** Gets the internal CubeTexture used to render to */
  53337. readonly cubeTexture: RenderTargetTexture;
  53338. /** Gets the list of meshes to render */
  53339. readonly renderList: Nullable<AbstractMesh[]>;
  53340. /**
  53341. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  53342. * @param mesh defines the mesh to attach to
  53343. */
  53344. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  53345. /**
  53346. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  53347. * @param renderingGroupId The rendering group id corresponding to its index
  53348. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  53349. */
  53350. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  53351. /**
  53352. * Clean all associated resources
  53353. */
  53354. dispose(): void;
  53355. /**
  53356. * Converts the reflection probe information to a readable string for debug purpose.
  53357. * @param fullDetails Supports for multiple levels of logging within scene loading
  53358. * @returns the human readable reflection probe info
  53359. */
  53360. toString(fullDetails?: boolean): string;
  53361. /**
  53362. * Get the class name of the relfection probe.
  53363. * @returns "ReflectionProbe"
  53364. */
  53365. getClassName(): string;
  53366. /**
  53367. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  53368. * @returns The JSON representation of the texture
  53369. */
  53370. serialize(): any;
  53371. /**
  53372. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  53373. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  53374. * @param scene Define the scene the parsed reflection probe should be instantiated in
  53375. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  53376. * @returns The parsed reflection probe if successful
  53377. */
  53378. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  53379. }
  53380. }
  53381. declare module "babylonjs/Loading/Plugins/babylonFileLoader" {
  53382. /** @hidden */
  53383. export var _BabylonLoaderRegistered: boolean;
  53384. }
  53385. declare module "babylonjs/Loading/Plugins/index" {
  53386. export * from "babylonjs/Loading/Plugins/babylonFileLoader";
  53387. }
  53388. declare module "babylonjs/Loading/index" {
  53389. export * from "babylonjs/Loading/loadingScreen";
  53390. export * from "babylonjs/Loading/Plugins/index";
  53391. export * from "babylonjs/Loading/sceneLoader";
  53392. export * from "babylonjs/Loading/sceneLoaderFlags";
  53393. }
  53394. declare module "babylonjs/Materials/Background/index" {
  53395. export * from "babylonjs/Materials/Background/backgroundMaterial";
  53396. }
  53397. declare module "babylonjs/Materials/PBR/pbrBaseSimpleMaterial" {
  53398. import { Scene } from "babylonjs/scene";
  53399. import { Color3 } from "babylonjs/Maths/math.color";
  53400. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  53401. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  53402. /**
  53403. * The Physically based simple base material of BJS.
  53404. *
  53405. * This enables better naming and convention enforcements on top of the pbrMaterial.
  53406. * It is used as the base class for both the specGloss and metalRough conventions.
  53407. */
  53408. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  53409. /**
  53410. * Number of Simultaneous lights allowed on the material.
  53411. */
  53412. maxSimultaneousLights: number;
  53413. /**
  53414. * If sets to true, disables all the lights affecting the material.
  53415. */
  53416. disableLighting: boolean;
  53417. /**
  53418. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  53419. */
  53420. environmentTexture: BaseTexture;
  53421. /**
  53422. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  53423. */
  53424. invertNormalMapX: boolean;
  53425. /**
  53426. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  53427. */
  53428. invertNormalMapY: boolean;
  53429. /**
  53430. * Normal map used in the model.
  53431. */
  53432. normalTexture: BaseTexture;
  53433. /**
  53434. * Emissivie color used to self-illuminate the model.
  53435. */
  53436. emissiveColor: Color3;
  53437. /**
  53438. * Emissivie texture used to self-illuminate the model.
  53439. */
  53440. emissiveTexture: BaseTexture;
  53441. /**
  53442. * Occlusion Channel Strenght.
  53443. */
  53444. occlusionStrength: number;
  53445. /**
  53446. * Occlusion Texture of the material (adding extra occlusion effects).
  53447. */
  53448. occlusionTexture: BaseTexture;
  53449. /**
  53450. * Defines the alpha limits in alpha test mode.
  53451. */
  53452. alphaCutOff: number;
  53453. /**
  53454. * Gets the current double sided mode.
  53455. */
  53456. /**
  53457. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  53458. */
  53459. doubleSided: boolean;
  53460. /**
  53461. * Stores the pre-calculated light information of a mesh in a texture.
  53462. */
  53463. lightmapTexture: BaseTexture;
  53464. /**
  53465. * If true, the light map contains occlusion information instead of lighting info.
  53466. */
  53467. useLightmapAsShadowmap: boolean;
  53468. /**
  53469. * Instantiates a new PBRMaterial instance.
  53470. *
  53471. * @param name The material name
  53472. * @param scene The scene the material will be use in.
  53473. */
  53474. constructor(name: string, scene: Scene);
  53475. getClassName(): string;
  53476. }
  53477. }
  53478. declare module "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial" {
  53479. import { Scene } from "babylonjs/scene";
  53480. import { Color3 } from "babylonjs/Maths/math.color";
  53481. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  53482. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  53483. /**
  53484. * The PBR material of BJS following the metal roughness convention.
  53485. *
  53486. * This fits to the PBR convention in the GLTF definition:
  53487. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  53488. */
  53489. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  53490. /**
  53491. * The base color has two different interpretations depending on the value of metalness.
  53492. * When the material is a metal, the base color is the specific measured reflectance value
  53493. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  53494. * of the material.
  53495. */
  53496. baseColor: Color3;
  53497. /**
  53498. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  53499. * well as opacity information in the alpha channel.
  53500. */
  53501. baseTexture: BaseTexture;
  53502. /**
  53503. * Specifies the metallic scalar value of the material.
  53504. * Can also be used to scale the metalness values of the metallic texture.
  53505. */
  53506. metallic: number;
  53507. /**
  53508. * Specifies the roughness scalar value of the material.
  53509. * Can also be used to scale the roughness values of the metallic texture.
  53510. */
  53511. roughness: number;
  53512. /**
  53513. * Texture containing both the metallic value in the B channel and the
  53514. * roughness value in the G channel to keep better precision.
  53515. */
  53516. metallicRoughnessTexture: BaseTexture;
  53517. /**
  53518. * Instantiates a new PBRMetalRoughnessMaterial instance.
  53519. *
  53520. * @param name The material name
  53521. * @param scene The scene the material will be use in.
  53522. */
  53523. constructor(name: string, scene: Scene);
  53524. /**
  53525. * Return the currrent class name of the material.
  53526. */
  53527. getClassName(): string;
  53528. /**
  53529. * Makes a duplicate of the current material.
  53530. * @param name - name to use for the new material.
  53531. */
  53532. clone(name: string): PBRMetallicRoughnessMaterial;
  53533. /**
  53534. * Serialize the material to a parsable JSON object.
  53535. */
  53536. serialize(): any;
  53537. /**
  53538. * Parses a JSON object correponding to the serialize function.
  53539. */
  53540. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  53541. }
  53542. }
  53543. declare module "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial" {
  53544. import { Scene } from "babylonjs/scene";
  53545. import { Color3 } from "babylonjs/Maths/math.color";
  53546. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  53547. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  53548. /**
  53549. * The PBR material of BJS following the specular glossiness convention.
  53550. *
  53551. * This fits to the PBR convention in the GLTF definition:
  53552. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  53553. */
  53554. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  53555. /**
  53556. * Specifies the diffuse color of the material.
  53557. */
  53558. diffuseColor: Color3;
  53559. /**
  53560. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  53561. * channel.
  53562. */
  53563. diffuseTexture: BaseTexture;
  53564. /**
  53565. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  53566. */
  53567. specularColor: Color3;
  53568. /**
  53569. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  53570. */
  53571. glossiness: number;
  53572. /**
  53573. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  53574. */
  53575. specularGlossinessTexture: BaseTexture;
  53576. /**
  53577. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  53578. *
  53579. * @param name The material name
  53580. * @param scene The scene the material will be use in.
  53581. */
  53582. constructor(name: string, scene: Scene);
  53583. /**
  53584. * Return the currrent class name of the material.
  53585. */
  53586. getClassName(): string;
  53587. /**
  53588. * Makes a duplicate of the current material.
  53589. * @param name - name to use for the new material.
  53590. */
  53591. clone(name: string): PBRSpecularGlossinessMaterial;
  53592. /**
  53593. * Serialize the material to a parsable JSON object.
  53594. */
  53595. serialize(): any;
  53596. /**
  53597. * Parses a JSON object correponding to the serialize function.
  53598. */
  53599. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  53600. }
  53601. }
  53602. declare module "babylonjs/Materials/PBR/index" {
  53603. export * from "babylonjs/Materials/PBR/pbrBaseMaterial";
  53604. export * from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  53605. export * from "babylonjs/Materials/PBR/pbrMaterial";
  53606. export * from "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial";
  53607. export * from "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial";
  53608. }
  53609. declare module "babylonjs/Materials/Textures/colorGradingTexture" {
  53610. import { Nullable } from "babylonjs/types";
  53611. import { Scene } from "babylonjs/scene";
  53612. import { Matrix } from "babylonjs/Maths/math.vector";
  53613. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  53614. /**
  53615. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  53616. * It can help converting any input color in a desired output one. This can then be used to create effects
  53617. * from sepia, black and white to sixties or futuristic rendering...
  53618. *
  53619. * The only supported format is currently 3dl.
  53620. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  53621. */
  53622. export class ColorGradingTexture extends BaseTexture {
  53623. /**
  53624. * The current texture matrix. (will always be identity in color grading texture)
  53625. */
  53626. private _textureMatrix;
  53627. /**
  53628. * The texture URL.
  53629. */
  53630. url: string;
  53631. /**
  53632. * Empty line regex stored for GC.
  53633. */
  53634. private static _noneEmptyLineRegex;
  53635. private _engine;
  53636. /**
  53637. * Instantiates a ColorGradingTexture from the following parameters.
  53638. *
  53639. * @param url The location of the color gradind data (currently only supporting 3dl)
  53640. * @param scene The scene the texture will be used in
  53641. */
  53642. constructor(url: string, scene: Scene);
  53643. /**
  53644. * Returns the texture matrix used in most of the material.
  53645. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  53646. */
  53647. getTextureMatrix(): Matrix;
  53648. /**
  53649. * Occurs when the file being loaded is a .3dl LUT file.
  53650. */
  53651. private load3dlTexture;
  53652. /**
  53653. * Starts the loading process of the texture.
  53654. */
  53655. private loadTexture;
  53656. /**
  53657. * Clones the color gradind texture.
  53658. */
  53659. clone(): ColorGradingTexture;
  53660. /**
  53661. * Called during delayed load for textures.
  53662. */
  53663. delayLoad(): void;
  53664. /**
  53665. * Parses a color grading texture serialized by Babylon.
  53666. * @param parsedTexture The texture information being parsedTexture
  53667. * @param scene The scene to load the texture in
  53668. * @param rootUrl The root url of the data assets to load
  53669. * @return A color gradind texture
  53670. */
  53671. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  53672. /**
  53673. * Serializes the LUT texture to json format.
  53674. */
  53675. serialize(): any;
  53676. }
  53677. }
  53678. declare module "babylonjs/Materials/Textures/equiRectangularCubeTexture" {
  53679. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  53680. import { Scene } from "babylonjs/scene";
  53681. import { Nullable } from "babylonjs/types";
  53682. import "babylonjs/Engines/Extensions/engine.rawTexture";
  53683. /**
  53684. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  53685. */
  53686. export class EquiRectangularCubeTexture extends BaseTexture {
  53687. /** The six faces of the cube. */
  53688. private static _FacesMapping;
  53689. private _noMipmap;
  53690. private _onLoad;
  53691. private _onError;
  53692. /** The size of the cubemap. */
  53693. private _size;
  53694. /** The buffer of the image. */
  53695. private _buffer;
  53696. /** The width of the input image. */
  53697. private _width;
  53698. /** The height of the input image. */
  53699. private _height;
  53700. /** The URL to the image. */
  53701. url: string;
  53702. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  53703. coordinatesMode: number;
  53704. /**
  53705. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  53706. * @param url The location of the image
  53707. * @param scene The scene the texture will be used in
  53708. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  53709. * @param noMipmap Forces to not generate the mipmap if true
  53710. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  53711. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  53712. * @param onLoad — defines a callback called when texture is loaded
  53713. * @param onError — defines a callback called if there is an error
  53714. */
  53715. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  53716. /**
  53717. * Load the image data, by putting the image on a canvas and extracting its buffer.
  53718. */
  53719. private loadImage;
  53720. /**
  53721. * Convert the image buffer into a cubemap and create a CubeTexture.
  53722. */
  53723. private loadTexture;
  53724. /**
  53725. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  53726. * @param buffer The ArrayBuffer that should be converted.
  53727. * @returns The buffer as Float32Array.
  53728. */
  53729. private getFloat32ArrayFromArrayBuffer;
  53730. /**
  53731. * Get the current class name of the texture useful for serialization or dynamic coding.
  53732. * @returns "EquiRectangularCubeTexture"
  53733. */
  53734. getClassName(): string;
  53735. /**
  53736. * Create a clone of the current EquiRectangularCubeTexture and return it.
  53737. * @returns A clone of the current EquiRectangularCubeTexture.
  53738. */
  53739. clone(): EquiRectangularCubeTexture;
  53740. }
  53741. }
  53742. declare module "babylonjs/Misc/tga" {
  53743. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  53744. /**
  53745. * Based on jsTGALoader - Javascript loader for TGA file
  53746. * By Vincent Thibault
  53747. * @see http://blog.robrowser.com/javascript-tga-loader.html
  53748. */
  53749. export class TGATools {
  53750. private static _TYPE_INDEXED;
  53751. private static _TYPE_RGB;
  53752. private static _TYPE_GREY;
  53753. private static _TYPE_RLE_INDEXED;
  53754. private static _TYPE_RLE_RGB;
  53755. private static _TYPE_RLE_GREY;
  53756. private static _ORIGIN_MASK;
  53757. private static _ORIGIN_SHIFT;
  53758. private static _ORIGIN_BL;
  53759. private static _ORIGIN_BR;
  53760. private static _ORIGIN_UL;
  53761. private static _ORIGIN_UR;
  53762. /**
  53763. * Gets the header of a TGA file
  53764. * @param data defines the TGA data
  53765. * @returns the header
  53766. */
  53767. static GetTGAHeader(data: Uint8Array): any;
  53768. /**
  53769. * Uploads TGA content to a Babylon Texture
  53770. * @hidden
  53771. */
  53772. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  53773. /** @hidden */
  53774. 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;
  53775. /** @hidden */
  53776. 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;
  53777. /** @hidden */
  53778. 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;
  53779. /** @hidden */
  53780. 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;
  53781. /** @hidden */
  53782. 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;
  53783. /** @hidden */
  53784. 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;
  53785. }
  53786. }
  53787. declare module "babylonjs/Materials/Textures/Loaders/tgaTextureLoader" {
  53788. import { Nullable } from "babylonjs/types";
  53789. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  53790. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  53791. /**
  53792. * Implementation of the TGA Texture Loader.
  53793. * @hidden
  53794. */
  53795. export class _TGATextureLoader implements IInternalTextureLoader {
  53796. /**
  53797. * Defines wether the loader supports cascade loading the different faces.
  53798. */
  53799. readonly supportCascades: boolean;
  53800. /**
  53801. * This returns if the loader support the current file information.
  53802. * @param extension defines the file extension of the file being loaded
  53803. * @param textureFormatInUse defines the current compressed format in use iun the engine
  53804. * @param fallback defines the fallback internal texture if any
  53805. * @param isBase64 defines whether the texture is encoded as a base64
  53806. * @param isBuffer defines whether the texture data are stored as a buffer
  53807. * @returns true if the loader can load the specified file
  53808. */
  53809. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  53810. /**
  53811. * Transform the url before loading if required.
  53812. * @param rootUrl the url of the texture
  53813. * @param textureFormatInUse defines the current compressed format in use iun the engine
  53814. * @returns the transformed texture
  53815. */
  53816. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  53817. /**
  53818. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  53819. * @param rootUrl the url of the texture
  53820. * @param textureFormatInUse defines the current compressed format in use iun the engine
  53821. * @returns the fallback texture
  53822. */
  53823. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  53824. /**
  53825. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  53826. * @param data contains the texture data
  53827. * @param texture defines the BabylonJS internal texture
  53828. * @param createPolynomials will be true if polynomials have been requested
  53829. * @param onLoad defines the callback to trigger once the texture is ready
  53830. * @param onError defines the callback to trigger in case of error
  53831. */
  53832. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  53833. /**
  53834. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  53835. * @param data contains the texture data
  53836. * @param texture defines the BabylonJS internal texture
  53837. * @param callback defines the method to call once ready to upload
  53838. */
  53839. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  53840. }
  53841. }
  53842. declare module "babylonjs/Misc/basis" {
  53843. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  53844. /**
  53845. * Info about the .basis files
  53846. */
  53847. class BasisFileInfo {
  53848. /**
  53849. * If the file has alpha
  53850. */
  53851. hasAlpha: boolean;
  53852. /**
  53853. * Info about each image of the basis file
  53854. */
  53855. images: Array<{
  53856. levels: Array<{
  53857. width: number;
  53858. height: number;
  53859. transcodedPixels: ArrayBufferView;
  53860. }>;
  53861. }>;
  53862. }
  53863. /**
  53864. * Result of transcoding a basis file
  53865. */
  53866. class TranscodeResult {
  53867. /**
  53868. * Info about the .basis file
  53869. */
  53870. fileInfo: BasisFileInfo;
  53871. /**
  53872. * Format to use when loading the file
  53873. */
  53874. format: number;
  53875. }
  53876. /**
  53877. * Configuration options for the Basis transcoder
  53878. */
  53879. export class BasisTranscodeConfiguration {
  53880. /**
  53881. * Supported compression formats used to determine the supported output format of the transcoder
  53882. */
  53883. supportedCompressionFormats?: {
  53884. /**
  53885. * etc1 compression format
  53886. */
  53887. etc1?: boolean;
  53888. /**
  53889. * s3tc compression format
  53890. */
  53891. s3tc?: boolean;
  53892. /**
  53893. * pvrtc compression format
  53894. */
  53895. pvrtc?: boolean;
  53896. /**
  53897. * etc2 compression format
  53898. */
  53899. etc2?: boolean;
  53900. };
  53901. /**
  53902. * If mipmap levels should be loaded for transcoded images (Default: true)
  53903. */
  53904. loadMipmapLevels?: boolean;
  53905. /**
  53906. * Index of a single image to load (Default: all images)
  53907. */
  53908. loadSingleImage?: number;
  53909. }
  53910. /**
  53911. * Used to load .Basis files
  53912. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  53913. */
  53914. export class BasisTools {
  53915. private static _IgnoreSupportedFormats;
  53916. /**
  53917. * URL to use when loading the basis transcoder
  53918. */
  53919. static JSModuleURL: string;
  53920. /**
  53921. * URL to use when loading the wasm module for the transcoder
  53922. */
  53923. static WasmModuleURL: string;
  53924. /**
  53925. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  53926. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  53927. * @returns internal format corresponding to the Basis format
  53928. */
  53929. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  53930. private static _WorkerPromise;
  53931. private static _Worker;
  53932. private static _actionId;
  53933. private static _CreateWorkerAsync;
  53934. /**
  53935. * Transcodes a loaded image file to compressed pixel data
  53936. * @param imageData image data to transcode
  53937. * @param config configuration options for the transcoding
  53938. * @returns a promise resulting in the transcoded image
  53939. */
  53940. static TranscodeAsync(imageData: ArrayBuffer, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  53941. /**
  53942. * Loads a texture from the transcode result
  53943. * @param texture texture load to
  53944. * @param transcodeResult the result of transcoding the basis file to load from
  53945. */
  53946. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  53947. }
  53948. }
  53949. declare module "babylonjs/Materials/Textures/Loaders/basisTextureLoader" {
  53950. import { Nullable } from "babylonjs/types";
  53951. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  53952. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  53953. /**
  53954. * Loader for .basis file format
  53955. */
  53956. export class _BasisTextureLoader implements IInternalTextureLoader {
  53957. /**
  53958. * Defines whether the loader supports cascade loading the different faces.
  53959. */
  53960. readonly supportCascades: boolean;
  53961. /**
  53962. * This returns if the loader support the current file information.
  53963. * @param extension defines the file extension of the file being loaded
  53964. * @param textureFormatInUse defines the current compressed format in use iun the engine
  53965. * @param fallback defines the fallback internal texture if any
  53966. * @param isBase64 defines whether the texture is encoded as a base64
  53967. * @param isBuffer defines whether the texture data are stored as a buffer
  53968. * @returns true if the loader can load the specified file
  53969. */
  53970. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  53971. /**
  53972. * Transform the url before loading if required.
  53973. * @param rootUrl the url of the texture
  53974. * @param textureFormatInUse defines the current compressed format in use iun the engine
  53975. * @returns the transformed texture
  53976. */
  53977. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  53978. /**
  53979. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  53980. * @param rootUrl the url of the texture
  53981. * @param textureFormatInUse defines the current compressed format in use iun the engine
  53982. * @returns the fallback texture
  53983. */
  53984. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  53985. /**
  53986. * Uploads the cube texture data to the WebGl Texture. It has already been bound.
  53987. * @param data contains the texture data
  53988. * @param texture defines the BabylonJS internal texture
  53989. * @param createPolynomials will be true if polynomials have been requested
  53990. * @param onLoad defines the callback to trigger once the texture is ready
  53991. * @param onError defines the callback to trigger in case of error
  53992. */
  53993. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  53994. /**
  53995. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  53996. * @param data contains the texture data
  53997. * @param texture defines the BabylonJS internal texture
  53998. * @param callback defines the method to call once ready to upload
  53999. */
  54000. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  54001. }
  54002. }
  54003. declare module "babylonjs/Materials/Textures/Loaders/index" {
  54004. export * from "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  54005. export * from "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  54006. export * from "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  54007. export * from "babylonjs/Materials/Textures/Loaders/tgaTextureLoader";
  54008. export * from "babylonjs/Materials/Textures/Loaders/basisTextureLoader";
  54009. }
  54010. declare module "babylonjs/Materials/Textures/Procedurals/customProceduralTexture" {
  54011. import { Scene } from "babylonjs/scene";
  54012. import { Texture } from "babylonjs/Materials/Textures/texture";
  54013. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  54014. /**
  54015. * 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.
  54016. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  54017. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  54018. */
  54019. export class CustomProceduralTexture extends ProceduralTexture {
  54020. private _animate;
  54021. private _time;
  54022. private _config;
  54023. private _texturePath;
  54024. /**
  54025. * Instantiates a new Custom Procedural Texture.
  54026. * 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.
  54027. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  54028. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  54029. * @param name Define the name of the texture
  54030. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  54031. * @param size Define the size of the texture to create
  54032. * @param scene Define the scene the texture belongs to
  54033. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  54034. * @param generateMipMaps Define if the texture should creates mip maps or not
  54035. */
  54036. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  54037. private _loadJson;
  54038. /**
  54039. * Is the texture ready to be used ? (rendered at least once)
  54040. * @returns true if ready, otherwise, false.
  54041. */
  54042. isReady(): boolean;
  54043. /**
  54044. * Render the texture to its associated render target.
  54045. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  54046. */
  54047. render(useCameraPostProcess?: boolean): void;
  54048. /**
  54049. * Update the list of dependant textures samplers in the shader.
  54050. */
  54051. updateTextures(): void;
  54052. /**
  54053. * Update the uniform values of the procedural texture in the shader.
  54054. */
  54055. updateShaderUniforms(): void;
  54056. /**
  54057. * Define if the texture animates or not.
  54058. */
  54059. animate: boolean;
  54060. }
  54061. }
  54062. declare module "babylonjs/Shaders/noise.fragment" {
  54063. /** @hidden */
  54064. export var noisePixelShader: {
  54065. name: string;
  54066. shader: string;
  54067. };
  54068. }
  54069. declare module "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture" {
  54070. import { Nullable } from "babylonjs/types";
  54071. import { Scene } from "babylonjs/scene";
  54072. import { Texture } from "babylonjs/Materials/Textures/texture";
  54073. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  54074. import "babylonjs/Shaders/noise.fragment";
  54075. /**
  54076. * Class used to generate noise procedural textures
  54077. */
  54078. export class NoiseProceduralTexture extends ProceduralTexture {
  54079. private _time;
  54080. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  54081. brightness: number;
  54082. /** Defines the number of octaves to process */
  54083. octaves: number;
  54084. /** Defines the level of persistence (0.8 by default) */
  54085. persistence: number;
  54086. /** Gets or sets animation speed factor (default is 1) */
  54087. animationSpeedFactor: number;
  54088. /**
  54089. * Creates a new NoiseProceduralTexture
  54090. * @param name defines the name fo the texture
  54091. * @param size defines the size of the texture (default is 256)
  54092. * @param scene defines the hosting scene
  54093. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  54094. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  54095. */
  54096. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  54097. private _updateShaderUniforms;
  54098. protected _getDefines(): string;
  54099. /** Generate the current state of the procedural texture */
  54100. render(useCameraPostProcess?: boolean): void;
  54101. /**
  54102. * Serializes this noise procedural texture
  54103. * @returns a serialized noise procedural texture object
  54104. */
  54105. serialize(): any;
  54106. /**
  54107. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  54108. * @param parsedTexture defines parsed texture data
  54109. * @param scene defines the current scene
  54110. * @param rootUrl defines the root URL containing noise procedural texture information
  54111. * @returns a parsed NoiseProceduralTexture
  54112. */
  54113. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  54114. }
  54115. }
  54116. declare module "babylonjs/Materials/Textures/Procedurals/index" {
  54117. export * from "babylonjs/Materials/Textures/Procedurals/customProceduralTexture";
  54118. export * from "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture";
  54119. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  54120. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTextureSceneComponent";
  54121. }
  54122. declare module "babylonjs/Materials/Textures/rawCubeTexture" {
  54123. import { Nullable } from "babylonjs/types";
  54124. import { Scene } from "babylonjs/scene";
  54125. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  54126. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  54127. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  54128. import "babylonjs/Engines/Extensions/engine.rawTexture";
  54129. /**
  54130. * Raw cube texture where the raw buffers are passed in
  54131. */
  54132. export class RawCubeTexture extends CubeTexture {
  54133. /**
  54134. * Creates a cube texture where the raw buffers are passed in.
  54135. * @param scene defines the scene the texture is attached to
  54136. * @param data defines the array of data to use to create each face
  54137. * @param size defines the size of the textures
  54138. * @param format defines the format of the data
  54139. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  54140. * @param generateMipMaps defines if the engine should generate the mip levels
  54141. * @param invertY defines if data must be stored with Y axis inverted
  54142. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  54143. * @param compression defines the compression used (null by default)
  54144. */
  54145. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  54146. /**
  54147. * Updates the raw cube texture.
  54148. * @param data defines the data to store
  54149. * @param format defines the data format
  54150. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  54151. * @param invertY defines if data must be stored with Y axis inverted
  54152. * @param compression defines the compression used (null by default)
  54153. * @param level defines which level of the texture to update
  54154. */
  54155. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  54156. /**
  54157. * Updates a raw cube texture with RGBD encoded data.
  54158. * @param data defines the array of data [mipmap][face] to use to create each face
  54159. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  54160. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  54161. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  54162. * @returns a promsie that resolves when the operation is complete
  54163. */
  54164. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  54165. /**
  54166. * Clones the raw cube texture.
  54167. * @return a new cube texture
  54168. */
  54169. clone(): CubeTexture;
  54170. /** @hidden */
  54171. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  54172. }
  54173. }
  54174. declare module "babylonjs/Materials/Textures/rawTexture3D" {
  54175. import { Scene } from "babylonjs/scene";
  54176. import { Texture } from "babylonjs/Materials/Textures/texture";
  54177. import "babylonjs/Engines/Extensions/engine.rawTexture";
  54178. /**
  54179. * Class used to store 3D textures containing user data
  54180. */
  54181. export class RawTexture3D extends Texture {
  54182. /** Gets or sets the texture format to use */
  54183. format: number;
  54184. private _engine;
  54185. /**
  54186. * Create a new RawTexture3D
  54187. * @param data defines the data of the texture
  54188. * @param width defines the width of the texture
  54189. * @param height defines the height of the texture
  54190. * @param depth defines the depth of the texture
  54191. * @param format defines the texture format to use
  54192. * @param scene defines the hosting scene
  54193. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  54194. * @param invertY defines if texture must be stored with Y axis inverted
  54195. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  54196. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  54197. */
  54198. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  54199. /** Gets or sets the texture format to use */
  54200. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  54201. /**
  54202. * Update the texture with new data
  54203. * @param data defines the data to store in the texture
  54204. */
  54205. update(data: ArrayBufferView): void;
  54206. }
  54207. }
  54208. declare module "babylonjs/Materials/Textures/refractionTexture" {
  54209. import { Scene } from "babylonjs/scene";
  54210. import { Plane } from "babylonjs/Maths/math.plane";
  54211. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  54212. /**
  54213. * Creates a refraction texture used by refraction channel of the standard material.
  54214. * It is like a mirror but to see through a material.
  54215. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  54216. */
  54217. export class RefractionTexture extends RenderTargetTexture {
  54218. /**
  54219. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  54220. * 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.
  54221. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  54222. */
  54223. refractionPlane: Plane;
  54224. /**
  54225. * Define how deep under the surface we should see.
  54226. */
  54227. depth: number;
  54228. /**
  54229. * Creates a refraction texture used by refraction channel of the standard material.
  54230. * It is like a mirror but to see through a material.
  54231. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  54232. * @param name Define the texture name
  54233. * @param size Define the size of the underlying texture
  54234. * @param scene Define the scene the refraction belongs to
  54235. * @param generateMipMaps Define if we need to generate mips level for the refraction
  54236. */
  54237. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  54238. /**
  54239. * Clone the refraction texture.
  54240. * @returns the cloned texture
  54241. */
  54242. clone(): RefractionTexture;
  54243. /**
  54244. * Serialize the texture to a JSON representation you could use in Parse later on
  54245. * @returns the serialized JSON representation
  54246. */
  54247. serialize(): any;
  54248. }
  54249. }
  54250. declare module "babylonjs/Materials/Textures/htmlElementTexture" {
  54251. import { Nullable } from "babylonjs/types";
  54252. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  54253. import { Matrix } from "babylonjs/Maths/math.vector";
  54254. import { Engine } from "babylonjs/Engines/engine";
  54255. import { Scene } from "babylonjs/scene";
  54256. /**
  54257. * Defines the options related to the creation of an HtmlElementTexture
  54258. */
  54259. export interface IHtmlElementTextureOptions {
  54260. /**
  54261. * Defines wether mip maps should be created or not.
  54262. */
  54263. generateMipMaps?: boolean;
  54264. /**
  54265. * Defines the sampling mode of the texture.
  54266. */
  54267. samplingMode?: number;
  54268. /**
  54269. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  54270. */
  54271. engine: Nullable<Engine>;
  54272. /**
  54273. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  54274. */
  54275. scene: Nullable<Scene>;
  54276. }
  54277. /**
  54278. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  54279. * To be as efficient as possible depending on your constraints nothing aside the first upload
  54280. * is automatically managed.
  54281. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  54282. * in your application.
  54283. *
  54284. * As the update is not automatic, you need to call them manually.
  54285. */
  54286. export class HtmlElementTexture extends BaseTexture {
  54287. /**
  54288. * The texture URL.
  54289. */
  54290. element: HTMLVideoElement | HTMLCanvasElement;
  54291. private static readonly DefaultOptions;
  54292. private _textureMatrix;
  54293. private _engine;
  54294. private _isVideo;
  54295. private _generateMipMaps;
  54296. private _samplingMode;
  54297. /**
  54298. * Instantiates a HtmlElementTexture from the following parameters.
  54299. *
  54300. * @param name Defines the name of the texture
  54301. * @param element Defines the video or canvas the texture is filled with
  54302. * @param options Defines the other none mandatory texture creation options
  54303. */
  54304. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  54305. private _createInternalTexture;
  54306. /**
  54307. * Returns the texture matrix used in most of the material.
  54308. */
  54309. getTextureMatrix(): Matrix;
  54310. /**
  54311. * Updates the content of the texture.
  54312. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  54313. */
  54314. update(invertY?: Nullable<boolean>): void;
  54315. }
  54316. }
  54317. declare module "babylonjs/Materials/Textures/index" {
  54318. export * from "babylonjs/Materials/Textures/baseTexture";
  54319. export * from "babylonjs/Materials/Textures/colorGradingTexture";
  54320. export * from "babylonjs/Materials/Textures/cubeTexture";
  54321. export * from "babylonjs/Materials/Textures/dynamicTexture";
  54322. export * from "babylonjs/Materials/Textures/equiRectangularCubeTexture";
  54323. export * from "babylonjs/Materials/Textures/hdrCubeTexture";
  54324. export * from "babylonjs/Materials/Textures/internalTexture";
  54325. export * from "babylonjs/Materials/Textures/internalTextureLoader";
  54326. export * from "babylonjs/Materials/Textures/Loaders/index";
  54327. export * from "babylonjs/Materials/Textures/mirrorTexture";
  54328. export * from "babylonjs/Materials/Textures/multiRenderTarget";
  54329. export * from "babylonjs/Materials/Textures/Procedurals/index";
  54330. export * from "babylonjs/Materials/Textures/rawCubeTexture";
  54331. export * from "babylonjs/Materials/Textures/rawTexture";
  54332. export * from "babylonjs/Materials/Textures/rawTexture3D";
  54333. export * from "babylonjs/Materials/Textures/refractionTexture";
  54334. export * from "babylonjs/Materials/Textures/renderTargetTexture";
  54335. export * from "babylonjs/Materials/Textures/texture";
  54336. export * from "babylonjs/Materials/Textures/videoTexture";
  54337. export * from "babylonjs/Materials/Textures/htmlElementTexture";
  54338. }
  54339. declare module "babylonjs/Materials/Node/nodeMaterialBlockTargets" {
  54340. /**
  54341. * Enum used to define the target of a block
  54342. */
  54343. export enum NodeMaterialBlockTargets {
  54344. /** Vertex shader */
  54345. Vertex = 1,
  54346. /** Fragment shader */
  54347. Fragment = 2,
  54348. /** Neutral */
  54349. Neutral = 4,
  54350. /** Vertex and Fragment */
  54351. VertexAndFragment = 3
  54352. }
  54353. }
  54354. declare module "babylonjs/Materials/Node/nodeMaterialBlockConnectionPointTypes" {
  54355. /**
  54356. * Defines the kind of connection point for node based material
  54357. */
  54358. export enum NodeMaterialBlockConnectionPointTypes {
  54359. /** Float */
  54360. Float = 1,
  54361. /** Int */
  54362. Int = 2,
  54363. /** Vector2 */
  54364. Vector2 = 4,
  54365. /** Vector3 */
  54366. Vector3 = 8,
  54367. /** Vector4 */
  54368. Vector4 = 16,
  54369. /** Color3 */
  54370. Color3 = 32,
  54371. /** Color4 */
  54372. Color4 = 64,
  54373. /** Matrix */
  54374. Matrix = 128,
  54375. /** Detect type based on connection */
  54376. AutoDetect = 1024,
  54377. /** Output type that will be defined by input type */
  54378. BasedOnInput = 2048
  54379. }
  54380. }
  54381. declare module "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer" {
  54382. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  54383. /**
  54384. * Root class for all node material optimizers
  54385. */
  54386. export class NodeMaterialOptimizer {
  54387. /**
  54388. * Function used to optimize a NodeMaterial graph
  54389. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  54390. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  54391. */
  54392. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  54393. }
  54394. }
  54395. declare module "babylonjs/Materials/Node/Blocks/transformBlock" {
  54396. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  54397. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  54398. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  54399. import { Scene } from "babylonjs/scene";
  54400. /**
  54401. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  54402. */
  54403. export class TransformBlock extends NodeMaterialBlock {
  54404. /**
  54405. * Defines the value to use to complement W value to transform it to a Vector4
  54406. */
  54407. complementW: number;
  54408. /**
  54409. * Defines the value to use to complement z value to transform it to a Vector4
  54410. */
  54411. complementZ: number;
  54412. /**
  54413. * Creates a new TransformBlock
  54414. * @param name defines the block name
  54415. */
  54416. constructor(name: string);
  54417. /**
  54418. * Gets the current class name
  54419. * @returns the class name
  54420. */
  54421. getClassName(): string;
  54422. /**
  54423. * Gets the vector input
  54424. */
  54425. readonly vector: NodeMaterialConnectionPoint;
  54426. /**
  54427. * Gets the output component
  54428. */
  54429. readonly output: NodeMaterialConnectionPoint;
  54430. /**
  54431. * Gets the matrix transform input
  54432. */
  54433. readonly transform: NodeMaterialConnectionPoint;
  54434. protected _buildBlock(state: NodeMaterialBuildState): this;
  54435. serialize(): any;
  54436. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  54437. protected _dumpPropertiesCode(): string;
  54438. }
  54439. }
  54440. declare module "babylonjs/Materials/Node/Blocks/Vertex/vertexOutputBlock" {
  54441. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  54442. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  54443. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  54444. /**
  54445. * Block used to output the vertex position
  54446. */
  54447. export class VertexOutputBlock extends NodeMaterialBlock {
  54448. /**
  54449. * Creates a new VertexOutputBlock
  54450. * @param name defines the block name
  54451. */
  54452. constructor(name: string);
  54453. /**
  54454. * Gets the current class name
  54455. * @returns the class name
  54456. */
  54457. getClassName(): string;
  54458. /**
  54459. * Gets the vector input component
  54460. */
  54461. readonly vector: NodeMaterialConnectionPoint;
  54462. protected _buildBlock(state: NodeMaterialBuildState): this;
  54463. }
  54464. }
  54465. declare module "babylonjs/Materials/Node/Blocks/Fragment/fragmentOutputBlock" {
  54466. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  54467. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  54468. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  54469. /**
  54470. * Block used to output the final color
  54471. */
  54472. export class FragmentOutputBlock extends NodeMaterialBlock {
  54473. /**
  54474. * Create a new FragmentOutputBlock
  54475. * @param name defines the block name
  54476. */
  54477. constructor(name: string);
  54478. /**
  54479. * Gets the current class name
  54480. * @returns the class name
  54481. */
  54482. getClassName(): string;
  54483. /**
  54484. * Gets the rgba input component
  54485. */
  54486. readonly rgba: NodeMaterialConnectionPoint;
  54487. /**
  54488. * Gets the rgb input component
  54489. */
  54490. readonly rgb: NodeMaterialConnectionPoint;
  54491. /**
  54492. * Gets the a input component
  54493. */
  54494. readonly a: NodeMaterialConnectionPoint;
  54495. protected _buildBlock(state: NodeMaterialBuildState): this;
  54496. }
  54497. }
  54498. declare module "babylonjs/Materials/Node/nodeMaterialSystemValues" {
  54499. /**
  54500. * Enum used to define system values e.g. values automatically provided by the system
  54501. */
  54502. export enum NodeMaterialSystemValues {
  54503. /** World */
  54504. World = 1,
  54505. /** View */
  54506. View = 2,
  54507. /** Projection */
  54508. Projection = 3,
  54509. /** ViewProjection */
  54510. ViewProjection = 4,
  54511. /** WorldView */
  54512. WorldView = 5,
  54513. /** WorldViewProjection */
  54514. WorldViewProjection = 6,
  54515. /** CameraPosition */
  54516. CameraPosition = 7,
  54517. /** Fog Color */
  54518. FogColor = 8
  54519. }
  54520. }
  54521. declare module "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock" {
  54522. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  54523. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  54524. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  54525. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  54526. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54527. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  54528. import { Effect } from "babylonjs/Materials/effect";
  54529. import { Mesh } from "babylonjs/Meshes/mesh";
  54530. import { Nullable } from "babylonjs/types";
  54531. import { Scene } from "babylonjs/scene";
  54532. /**
  54533. * Block used to read a reflection texture from a sampler
  54534. */
  54535. export class ReflectionTextureBlock extends NodeMaterialBlock {
  54536. private _define3DName;
  54537. private _defineCubicName;
  54538. private _defineExplicitName;
  54539. private _defineProjectionName;
  54540. private _defineLocalCubicName;
  54541. private _defineSphericalName;
  54542. private _definePlanarName;
  54543. private _defineEquirectangularName;
  54544. private _defineMirroredEquirectangularFixedName;
  54545. private _defineEquirectangularFixedName;
  54546. private _defineSkyboxName;
  54547. private _cubeSamplerName;
  54548. private _2DSamplerName;
  54549. private _positionUVWName;
  54550. private _directionWName;
  54551. private _reflectionCoordsName;
  54552. private _reflection2DCoordsName;
  54553. private _reflectionColorName;
  54554. private _reflectionMatrixName;
  54555. /**
  54556. * Gets or sets the texture associated with the node
  54557. */
  54558. texture: Nullable<BaseTexture>;
  54559. /**
  54560. * Create a new TextureBlock
  54561. * @param name defines the block name
  54562. */
  54563. constructor(name: string);
  54564. /**
  54565. * Gets the current class name
  54566. * @returns the class name
  54567. */
  54568. getClassName(): string;
  54569. /**
  54570. * Gets the world position input component
  54571. */
  54572. readonly position: NodeMaterialConnectionPoint;
  54573. /**
  54574. * Gets the world position input component
  54575. */
  54576. readonly worldPosition: NodeMaterialConnectionPoint;
  54577. /**
  54578. * Gets the world normal input component
  54579. */
  54580. readonly worldNormal: NodeMaterialConnectionPoint;
  54581. /**
  54582. * Gets the world input component
  54583. */
  54584. readonly world: NodeMaterialConnectionPoint;
  54585. /**
  54586. * Gets the camera (or eye) position component
  54587. */
  54588. readonly cameraPosition: NodeMaterialConnectionPoint;
  54589. /**
  54590. * Gets the view input component
  54591. */
  54592. readonly view: NodeMaterialConnectionPoint;
  54593. /**
  54594. * Gets the rgb output component
  54595. */
  54596. readonly rgb: NodeMaterialConnectionPoint;
  54597. /**
  54598. * Gets the r output component
  54599. */
  54600. readonly r: NodeMaterialConnectionPoint;
  54601. /**
  54602. * Gets the g output component
  54603. */
  54604. readonly g: NodeMaterialConnectionPoint;
  54605. /**
  54606. * Gets the b output component
  54607. */
  54608. readonly b: NodeMaterialConnectionPoint;
  54609. autoConfigure(material: NodeMaterial): void;
  54610. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  54611. isReady(): boolean;
  54612. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  54613. private _injectVertexCode;
  54614. private _writeOutput;
  54615. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  54616. serialize(): any;
  54617. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  54618. }
  54619. }
  54620. declare module "babylonjs/Materials/Node/nodeMaterial" {
  54621. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  54622. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  54623. import { Scene } from "babylonjs/scene";
  54624. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54625. import { Matrix } from "babylonjs/Maths/math.vector";
  54626. import { Mesh } from "babylonjs/Meshes/mesh";
  54627. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  54628. import { Observable } from "babylonjs/Misc/observable";
  54629. import { SubMesh } from "babylonjs/Meshes/subMesh";
  54630. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  54631. import { NodeMaterialOptimizer } from "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer";
  54632. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  54633. import { Nullable } from "babylonjs/types";
  54634. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  54635. import { TextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  54636. import { ReflectionTextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock";
  54637. /**
  54638. * Interface used to configure the node material editor
  54639. */
  54640. export interface INodeMaterialEditorOptions {
  54641. /** Define the URl to load node editor script */
  54642. editorURL?: string;
  54643. }
  54644. /** @hidden */
  54645. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  54646. /** BONES */
  54647. NUM_BONE_INFLUENCERS: number;
  54648. BonesPerMesh: number;
  54649. BONETEXTURE: boolean;
  54650. /** MORPH TARGETS */
  54651. MORPHTARGETS: boolean;
  54652. MORPHTARGETS_NORMAL: boolean;
  54653. MORPHTARGETS_TANGENT: boolean;
  54654. MORPHTARGETS_UV: boolean;
  54655. NUM_MORPH_INFLUENCERS: number;
  54656. /** IMAGE PROCESSING */
  54657. IMAGEPROCESSING: boolean;
  54658. VIGNETTE: boolean;
  54659. VIGNETTEBLENDMODEMULTIPLY: boolean;
  54660. VIGNETTEBLENDMODEOPAQUE: boolean;
  54661. TONEMAPPING: boolean;
  54662. TONEMAPPING_ACES: boolean;
  54663. CONTRAST: boolean;
  54664. EXPOSURE: boolean;
  54665. COLORCURVES: boolean;
  54666. COLORGRADING: boolean;
  54667. COLORGRADING3D: boolean;
  54668. SAMPLER3DGREENDEPTH: boolean;
  54669. SAMPLER3DBGRMAP: boolean;
  54670. IMAGEPROCESSINGPOSTPROCESS: boolean;
  54671. constructor();
  54672. setValue(name: string, value: boolean): void;
  54673. }
  54674. /**
  54675. * Class used to configure NodeMaterial
  54676. */
  54677. export interface INodeMaterialOptions {
  54678. /**
  54679. * Defines if blocks should emit comments
  54680. */
  54681. emitComments: boolean;
  54682. }
  54683. /**
  54684. * Class used to create a node based material built by assembling shader blocks
  54685. */
  54686. export class NodeMaterial extends PushMaterial {
  54687. private static _BuildIdGenerator;
  54688. private _options;
  54689. private _vertexCompilationState;
  54690. private _fragmentCompilationState;
  54691. private _sharedData;
  54692. private _buildId;
  54693. private _buildWasSuccessful;
  54694. private _cachedWorldViewMatrix;
  54695. private _cachedWorldViewProjectionMatrix;
  54696. private _optimizers;
  54697. private _animationFrame;
  54698. /** Define the URl to load node editor script */
  54699. static EditorURL: string;
  54700. private BJSNODEMATERIALEDITOR;
  54701. /** Get the inspector from bundle or global */
  54702. private _getGlobalNodeMaterialEditor;
  54703. /**
  54704. * 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)
  54705. */
  54706. ignoreAlpha: boolean;
  54707. /**
  54708. * Defines the maximum number of lights that can be used in the material
  54709. */
  54710. maxSimultaneousLights: number;
  54711. /**
  54712. * Observable raised when the material is built
  54713. */
  54714. onBuildObservable: Observable<NodeMaterial>;
  54715. /**
  54716. * Gets or sets the root nodes of the material vertex shader
  54717. */
  54718. _vertexOutputNodes: NodeMaterialBlock[];
  54719. /**
  54720. * Gets or sets the root nodes of the material fragment (pixel) shader
  54721. */
  54722. _fragmentOutputNodes: NodeMaterialBlock[];
  54723. /** Gets or sets options to control the node material overall behavior */
  54724. options: INodeMaterialOptions;
  54725. /**
  54726. * Default configuration related to image processing available in the standard Material.
  54727. */
  54728. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  54729. /**
  54730. * Gets the image processing configuration used either in this material.
  54731. */
  54732. /**
  54733. * Sets the Default image processing configuration used either in the this material.
  54734. *
  54735. * If sets to null, the scene one is in use.
  54736. */
  54737. imageProcessingConfiguration: ImageProcessingConfiguration;
  54738. /**
  54739. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  54740. */
  54741. attachedBlocks: NodeMaterialBlock[];
  54742. /**
  54743. * Create a new node based material
  54744. * @param name defines the material name
  54745. * @param scene defines the hosting scene
  54746. * @param options defines creation option
  54747. */
  54748. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  54749. /**
  54750. * Gets the current class name of the material e.g. "NodeMaterial"
  54751. * @returns the class name
  54752. */
  54753. getClassName(): string;
  54754. /**
  54755. * Keep track of the image processing observer to allow dispose and replace.
  54756. */
  54757. private _imageProcessingObserver;
  54758. /**
  54759. * Attaches a new image processing configuration to the Standard Material.
  54760. * @param configuration
  54761. */
  54762. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  54763. /**
  54764. * Get a block by its name
  54765. * @param name defines the name of the block to retrieve
  54766. * @returns the required block or null if not found
  54767. */
  54768. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  54769. /**
  54770. * Get a block by its name
  54771. * @param predicate defines the predicate used to find the good candidate
  54772. * @returns the required block or null if not found
  54773. */
  54774. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  54775. /**
  54776. * Get an input block by its name
  54777. * @param predicate defines the predicate used to find the good candidate
  54778. * @returns the required input block or null if not found
  54779. */
  54780. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  54781. /**
  54782. * Gets the list of input blocks attached to this material
  54783. * @returns an array of InputBlocks
  54784. */
  54785. getInputBlocks(): InputBlock[];
  54786. /**
  54787. * Adds a new optimizer to the list of optimizers
  54788. * @param optimizer defines the optimizers to add
  54789. * @returns the current material
  54790. */
  54791. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  54792. /**
  54793. * Remove an optimizer from the list of optimizers
  54794. * @param optimizer defines the optimizers to remove
  54795. * @returns the current material
  54796. */
  54797. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  54798. /**
  54799. * Add a new block to the list of output nodes
  54800. * @param node defines the node to add
  54801. * @returns the current material
  54802. */
  54803. addOutputNode(node: NodeMaterialBlock): this;
  54804. /**
  54805. * Remove a block from the list of root nodes
  54806. * @param node defines the node to remove
  54807. * @returns the current material
  54808. */
  54809. removeOutputNode(node: NodeMaterialBlock): this;
  54810. private _addVertexOutputNode;
  54811. private _removeVertexOutputNode;
  54812. private _addFragmentOutputNode;
  54813. private _removeFragmentOutputNode;
  54814. /**
  54815. * Specifies if the material will require alpha blending
  54816. * @returns a boolean specifying if alpha blending is needed
  54817. */
  54818. needAlphaBlending(): boolean;
  54819. /**
  54820. * Specifies if this material should be rendered in alpha test mode
  54821. * @returns a boolean specifying if an alpha test is needed.
  54822. */
  54823. needAlphaTesting(): boolean;
  54824. private _initializeBlock;
  54825. private _resetDualBlocks;
  54826. /**
  54827. * Build the material and generates the inner effect
  54828. * @param verbose defines if the build should log activity
  54829. */
  54830. build(verbose?: boolean): void;
  54831. /**
  54832. * Runs an otpimization phase to try to improve the shader code
  54833. */
  54834. optimize(): void;
  54835. private _prepareDefinesForAttributes;
  54836. /**
  54837. * Get if the submesh is ready to be used and all its information available.
  54838. * Child classes can use it to update shaders
  54839. * @param mesh defines the mesh to check
  54840. * @param subMesh defines which submesh to check
  54841. * @param useInstances specifies that instances should be used
  54842. * @returns a boolean indicating that the submesh is ready or not
  54843. */
  54844. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  54845. /**
  54846. * Get a string representing the shaders built by the current node graph
  54847. */
  54848. readonly compiledShaders: string;
  54849. /**
  54850. * Binds the world matrix to the material
  54851. * @param world defines the world transformation matrix
  54852. */
  54853. bindOnlyWorldMatrix(world: Matrix): void;
  54854. /**
  54855. * Binds the submesh to this material by preparing the effect and shader to draw
  54856. * @param world defines the world transformation matrix
  54857. * @param mesh defines the mesh containing the submesh
  54858. * @param subMesh defines the submesh to bind the material to
  54859. */
  54860. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  54861. /**
  54862. * Gets the active textures from the material
  54863. * @returns an array of textures
  54864. */
  54865. getActiveTextures(): BaseTexture[];
  54866. /**
  54867. * Gets the list of texture blocks
  54868. * @returns an array of texture blocks
  54869. */
  54870. getTextureBlocks(): (TextureBlock | ReflectionTextureBlock)[];
  54871. /**
  54872. * Specifies if the material uses a texture
  54873. * @param texture defines the texture to check against the material
  54874. * @returns a boolean specifying if the material uses the texture
  54875. */
  54876. hasTexture(texture: BaseTexture): boolean;
  54877. /**
  54878. * Disposes the material
  54879. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  54880. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  54881. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  54882. */
  54883. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  54884. /** Creates the node editor window. */
  54885. private _createNodeEditor;
  54886. /**
  54887. * Launch the node material editor
  54888. * @param config Define the configuration of the editor
  54889. * @return a promise fulfilled when the node editor is visible
  54890. */
  54891. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  54892. /**
  54893. * Clear the current material
  54894. */
  54895. clear(): void;
  54896. /**
  54897. * Clear the current material and set it to a default state
  54898. */
  54899. setToDefault(): void;
  54900. /**
  54901. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  54902. * @param url defines the url to load from
  54903. * @returns a promise that will fullfil when the material is fully loaded
  54904. */
  54905. loadAsync(url: string): Promise<unknown>;
  54906. private _gatherBlocks;
  54907. /**
  54908. * Generate a string containing the code declaration required to create an equivalent of this material
  54909. * @returns a string
  54910. */
  54911. generateCode(): string;
  54912. /**
  54913. * Serializes this material in a JSON representation
  54914. * @returns the serialized material object
  54915. */
  54916. serialize(): any;
  54917. private _restoreConnections;
  54918. /**
  54919. * Clear the current graph and load a new one from a serialization object
  54920. * @param source defines the JSON representation of the material
  54921. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  54922. */
  54923. loadFromSerialization(source: any, rootUrl?: string): void;
  54924. /**
  54925. * Creates a node material from parsed material data
  54926. * @param source defines the JSON representation of the material
  54927. * @param scene defines the hosting scene
  54928. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  54929. * @returns a new node material
  54930. */
  54931. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  54932. /**
  54933. * Creates a new node material set to default basic configuration
  54934. * @param name defines the name of the material
  54935. * @param scene defines the hosting scene
  54936. * @returns a new NodeMaterial
  54937. */
  54938. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  54939. }
  54940. }
  54941. declare module "babylonjs/Materials/Node/Blocks/Dual/textureBlock" {
  54942. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  54943. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  54944. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/nodeMaterialBlockTargets";
  54945. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  54946. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  54947. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54948. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  54949. import { Effect } from "babylonjs/Materials/effect";
  54950. import { Mesh } from "babylonjs/Meshes/mesh";
  54951. import { Nullable } from "babylonjs/types";
  54952. import { Scene } from "babylonjs/scene";
  54953. /**
  54954. * Block used to read a texture from a sampler
  54955. */
  54956. export class TextureBlock extends NodeMaterialBlock {
  54957. private _defineName;
  54958. private _samplerName;
  54959. private _transformedUVName;
  54960. private _textureTransformName;
  54961. private _textureInfoName;
  54962. private _mainUVName;
  54963. private _mainUVDefineName;
  54964. /**
  54965. * Gets or sets the texture associated with the node
  54966. */
  54967. texture: Nullable<BaseTexture>;
  54968. /**
  54969. * Create a new TextureBlock
  54970. * @param name defines the block name
  54971. */
  54972. constructor(name: string);
  54973. /**
  54974. * Gets the current class name
  54975. * @returns the class name
  54976. */
  54977. getClassName(): string;
  54978. /**
  54979. * Gets the uv input component
  54980. */
  54981. readonly uv: NodeMaterialConnectionPoint;
  54982. /**
  54983. * Gets the rgba output component
  54984. */
  54985. readonly rgba: NodeMaterialConnectionPoint;
  54986. /**
  54987. * Gets the rgb output component
  54988. */
  54989. readonly rgb: NodeMaterialConnectionPoint;
  54990. /**
  54991. * Gets the r output component
  54992. */
  54993. readonly r: NodeMaterialConnectionPoint;
  54994. /**
  54995. * Gets the g output component
  54996. */
  54997. readonly g: NodeMaterialConnectionPoint;
  54998. /**
  54999. * Gets the b output component
  55000. */
  55001. readonly b: NodeMaterialConnectionPoint;
  55002. /**
  55003. * Gets the a output component
  55004. */
  55005. readonly a: NodeMaterialConnectionPoint;
  55006. readonly target: NodeMaterialBlockTargets;
  55007. autoConfigure(material: NodeMaterial): void;
  55008. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  55009. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  55010. isReady(): boolean;
  55011. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  55012. private readonly _isMixed;
  55013. private _injectVertexCode;
  55014. private _writeOutput;
  55015. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  55016. protected _dumpPropertiesCode(): string;
  55017. serialize(): any;
  55018. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  55019. }
  55020. }
  55021. declare module "babylonjs/Materials/Node/nodeMaterialBuildStateSharedData" {
  55022. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55023. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55024. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  55025. import { TextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  55026. import { ReflectionTextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock";
  55027. /**
  55028. * Class used to store shared data between 2 NodeMaterialBuildState
  55029. */
  55030. export class NodeMaterialBuildStateSharedData {
  55031. /**
  55032. * Gets the list of emitted varyings
  55033. */
  55034. temps: string[];
  55035. /**
  55036. * Gets the list of emitted varyings
  55037. */
  55038. varyings: string[];
  55039. /**
  55040. * Gets the varying declaration string
  55041. */
  55042. varyingDeclaration: string;
  55043. /**
  55044. * Input blocks
  55045. */
  55046. inputBlocks: InputBlock[];
  55047. /**
  55048. * Input blocks
  55049. */
  55050. textureBlocks: (ReflectionTextureBlock | TextureBlock)[];
  55051. /**
  55052. * Bindable blocks (Blocks that need to set data to the effect)
  55053. */
  55054. bindableBlocks: NodeMaterialBlock[];
  55055. /**
  55056. * List of blocks that can provide a compilation fallback
  55057. */
  55058. blocksWithFallbacks: NodeMaterialBlock[];
  55059. /**
  55060. * List of blocks that can provide a define update
  55061. */
  55062. blocksWithDefines: NodeMaterialBlock[];
  55063. /**
  55064. * List of blocks that can provide a repeatable content
  55065. */
  55066. repeatableContentBlocks: NodeMaterialBlock[];
  55067. /**
  55068. * List of blocks that can provide a dynamic list of uniforms
  55069. */
  55070. dynamicUniformBlocks: NodeMaterialBlock[];
  55071. /**
  55072. * List of blocks that can block the isReady function for the material
  55073. */
  55074. blockingBlocks: NodeMaterialBlock[];
  55075. /**
  55076. * Gets the list of animated inputs
  55077. */
  55078. animatedInputs: InputBlock[];
  55079. /**
  55080. * Build Id used to avoid multiple recompilations
  55081. */
  55082. buildId: number;
  55083. /** List of emitted variables */
  55084. variableNames: {
  55085. [key: string]: number;
  55086. };
  55087. /** List of emitted defines */
  55088. defineNames: {
  55089. [key: string]: number;
  55090. };
  55091. /** Should emit comments? */
  55092. emitComments: boolean;
  55093. /** Emit build activity */
  55094. verbose: boolean;
  55095. /**
  55096. * Gets the compilation hints emitted at compilation time
  55097. */
  55098. hints: {
  55099. needWorldViewMatrix: boolean;
  55100. needWorldViewProjectionMatrix: boolean;
  55101. needAlphaBlending: boolean;
  55102. needAlphaTesting: boolean;
  55103. };
  55104. /**
  55105. * List of compilation checks
  55106. */
  55107. checks: {
  55108. emitVertex: boolean;
  55109. emitFragment: boolean;
  55110. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  55111. };
  55112. /** Creates a new shared data */
  55113. constructor();
  55114. /**
  55115. * Emits console errors and exceptions if there is a failing check
  55116. */
  55117. emitErrors(): void;
  55118. }
  55119. }
  55120. declare module "babylonjs/Materials/Node/nodeMaterialBuildState" {
  55121. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPointTypes";
  55122. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/nodeMaterialBlockTargets";
  55123. import { NodeMaterialBuildStateSharedData } from "babylonjs/Materials/Node/nodeMaterialBuildStateSharedData";
  55124. /**
  55125. * Class used to store node based material build state
  55126. */
  55127. export class NodeMaterialBuildState {
  55128. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  55129. supportUniformBuffers: boolean;
  55130. /**
  55131. * Gets the list of emitted attributes
  55132. */
  55133. attributes: string[];
  55134. /**
  55135. * Gets the list of emitted uniforms
  55136. */
  55137. uniforms: string[];
  55138. /**
  55139. * Gets the list of emitted uniform buffers
  55140. */
  55141. uniformBuffers: string[];
  55142. /**
  55143. * Gets the list of emitted samplers
  55144. */
  55145. samplers: string[];
  55146. /**
  55147. * Gets the list of emitted functions
  55148. */
  55149. functions: {
  55150. [key: string]: string;
  55151. };
  55152. /**
  55153. * Gets the target of the compilation state
  55154. */
  55155. target: NodeMaterialBlockTargets;
  55156. /**
  55157. * Gets the list of emitted counters
  55158. */
  55159. counters: {
  55160. [key: string]: number;
  55161. };
  55162. /**
  55163. * Shared data between multiple NodeMaterialBuildState instances
  55164. */
  55165. sharedData: NodeMaterialBuildStateSharedData;
  55166. /** @hidden */
  55167. _vertexState: NodeMaterialBuildState;
  55168. /** @hidden */
  55169. _attributeDeclaration: string;
  55170. /** @hidden */
  55171. _uniformDeclaration: string;
  55172. /** @hidden */
  55173. _samplerDeclaration: string;
  55174. /** @hidden */
  55175. _varyingTransfer: string;
  55176. private _repeatableContentAnchorIndex;
  55177. /** @hidden */
  55178. _builtCompilationString: string;
  55179. /**
  55180. * Gets the emitted compilation strings
  55181. */
  55182. compilationString: string;
  55183. /**
  55184. * Finalize the compilation strings
  55185. * @param state defines the current compilation state
  55186. */
  55187. finalize(state: NodeMaterialBuildState): void;
  55188. /** @hidden */
  55189. readonly _repeatableContentAnchor: string;
  55190. /** @hidden */
  55191. _getFreeVariableName(prefix: string): string;
  55192. /** @hidden */
  55193. _getFreeDefineName(prefix: string): string;
  55194. /** @hidden */
  55195. _excludeVariableName(name: string): void;
  55196. /** @hidden */
  55197. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  55198. /** @hidden */
  55199. _emitFunction(name: string, code: string, comments: string): void;
  55200. /** @hidden */
  55201. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  55202. replaceStrings?: {
  55203. search: RegExp;
  55204. replace: string;
  55205. }[];
  55206. repeatKey?: string;
  55207. }): string;
  55208. /** @hidden */
  55209. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  55210. repeatKey?: string;
  55211. removeAttributes?: boolean;
  55212. removeUniforms?: boolean;
  55213. removeVaryings?: boolean;
  55214. removeIfDef?: boolean;
  55215. replaceStrings?: {
  55216. search: RegExp;
  55217. replace: string;
  55218. }[];
  55219. }, storeKey?: string): void;
  55220. /** @hidden */
  55221. _registerTempVariable(name: string): boolean;
  55222. /** @hidden */
  55223. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  55224. /** @hidden */
  55225. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  55226. }
  55227. }
  55228. declare module "babylonjs/Materials/Node/nodeMaterialBlock" {
  55229. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPointTypes";
  55230. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  55231. import { Nullable } from "babylonjs/types";
  55232. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55233. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/nodeMaterialBlockTargets";
  55234. import { Effect, EffectFallbacks } from "babylonjs/Materials/effect";
  55235. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55236. import { Mesh } from "babylonjs/Meshes/mesh";
  55237. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  55238. import { Scene } from "babylonjs/scene";
  55239. /**
  55240. * Defines a block that can be used inside a node based material
  55241. */
  55242. export class NodeMaterialBlock {
  55243. private _buildId;
  55244. private _buildTarget;
  55245. private _target;
  55246. private _isFinalMerger;
  55247. private _isInput;
  55248. /** @hidden */
  55249. _codeVariableName: string;
  55250. /** @hidden */
  55251. _inputs: NodeMaterialConnectionPoint[];
  55252. /** @hidden */
  55253. _outputs: NodeMaterialConnectionPoint[];
  55254. /** @hidden */
  55255. _preparationId: number;
  55256. /**
  55257. * Gets or sets the name of the block
  55258. */
  55259. name: string;
  55260. /**
  55261. * Gets or sets the unique id of the node
  55262. */
  55263. uniqueId: number;
  55264. /**
  55265. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  55266. */
  55267. readonly isFinalMerger: boolean;
  55268. /**
  55269. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  55270. */
  55271. readonly isInput: boolean;
  55272. /**
  55273. * Gets or sets the build Id
  55274. */
  55275. buildId: number;
  55276. /**
  55277. * Gets or sets the target of the block
  55278. */
  55279. target: NodeMaterialBlockTargets;
  55280. /**
  55281. * Gets the list of input points
  55282. */
  55283. readonly inputs: NodeMaterialConnectionPoint[];
  55284. /** Gets the list of output points */
  55285. readonly outputs: NodeMaterialConnectionPoint[];
  55286. /**
  55287. * Find an input by its name
  55288. * @param name defines the name of the input to look for
  55289. * @returns the input or null if not found
  55290. */
  55291. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  55292. /**
  55293. * Find an output by its name
  55294. * @param name defines the name of the outputto look for
  55295. * @returns the output or null if not found
  55296. */
  55297. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  55298. /**
  55299. * Creates a new NodeMaterialBlock
  55300. * @param name defines the block name
  55301. * @param target defines the target of that block (Vertex by default)
  55302. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  55303. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  55304. */
  55305. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  55306. /**
  55307. * Initialize the block and prepare the context for build
  55308. * @param state defines the state that will be used for the build
  55309. */
  55310. initialize(state: NodeMaterialBuildState): void;
  55311. /**
  55312. * Bind data to effect. Will only be called for blocks with isBindable === true
  55313. * @param effect defines the effect to bind data to
  55314. * @param nodeMaterial defines the hosting NodeMaterial
  55315. * @param mesh defines the mesh that will be rendered
  55316. */
  55317. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  55318. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  55319. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  55320. protected _writeFloat(value: number): string;
  55321. /**
  55322. * Gets the current class name e.g. "NodeMaterialBlock"
  55323. * @returns the class name
  55324. */
  55325. getClassName(): string;
  55326. /**
  55327. * Register a new input. Must be called inside a block constructor
  55328. * @param name defines the connection point name
  55329. * @param type defines the connection point type
  55330. * @param isOptional defines a boolean indicating that this input can be omitted
  55331. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  55332. * @returns the current block
  55333. */
  55334. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets): this;
  55335. /**
  55336. * Register a new output. Must be called inside a block constructor
  55337. * @param name defines the connection point name
  55338. * @param type defines the connection point type
  55339. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  55340. * @returns the current block
  55341. */
  55342. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets): this;
  55343. /**
  55344. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  55345. * @param forOutput defines an optional connection point to check compatibility with
  55346. * @returns the first available input or null
  55347. */
  55348. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  55349. /**
  55350. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  55351. * @param forBlock defines an optional block to check compatibility with
  55352. * @returns the first available input or null
  55353. */
  55354. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  55355. /**
  55356. * Gets the sibling of the given output
  55357. * @param current defines the current output
  55358. * @returns the next output in the list or null
  55359. */
  55360. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  55361. /**
  55362. * Connect current block with another block
  55363. * @param other defines the block to connect with
  55364. * @param options define the various options to help pick the right connections
  55365. * @returns the current block
  55366. */
  55367. connectTo(other: NodeMaterialBlock, options?: {
  55368. input?: string;
  55369. output?: string;
  55370. outputSwizzle?: string;
  55371. }): this | undefined;
  55372. protected _buildBlock(state: NodeMaterialBuildState): void;
  55373. /**
  55374. * Add uniforms, samplers and uniform buffers at compilation time
  55375. * @param state defines the state to update
  55376. * @param nodeMaterial defines the node material requesting the update
  55377. * @param defines defines the material defines to update
  55378. */
  55379. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  55380. /**
  55381. * Add potential fallbacks if shader compilation fails
  55382. * @param mesh defines the mesh to be rendered
  55383. * @param fallbacks defines the current prioritized list of fallbacks
  55384. */
  55385. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  55386. /**
  55387. * Update defines for shader compilation
  55388. * @param mesh defines the mesh to be rendered
  55389. * @param nodeMaterial defines the node material requesting the update
  55390. * @param defines defines the material defines to update
  55391. * @param useInstances specifies that instances should be used
  55392. */
  55393. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  55394. /**
  55395. * Initialize defines for shader compilation
  55396. * @param mesh defines the mesh to be rendered
  55397. * @param nodeMaterial defines the node material requesting the update
  55398. * @param defines defines the material defines to be prepared
  55399. * @param useInstances specifies that instances should be used
  55400. */
  55401. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  55402. /**
  55403. * Lets the block try to connect some inputs automatically
  55404. * @param material defines the hosting NodeMaterial
  55405. */
  55406. autoConfigure(material: NodeMaterial): void;
  55407. /**
  55408. * Function called when a block is declared as repeatable content generator
  55409. * @param vertexShaderState defines the current compilation state for the vertex shader
  55410. * @param fragmentShaderState defines the current compilation state for the fragment shader
  55411. * @param mesh defines the mesh to be rendered
  55412. * @param defines defines the material defines to update
  55413. */
  55414. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  55415. /**
  55416. * Checks if the block is ready
  55417. * @param mesh defines the mesh to be rendered
  55418. * @param nodeMaterial defines the node material requesting the update
  55419. * @param defines defines the material defines to update
  55420. * @param useInstances specifies that instances should be used
  55421. * @returns true if the block is ready
  55422. */
  55423. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  55424. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number): void;
  55425. private _processBuild;
  55426. /**
  55427. * Compile the current node and generate the shader code
  55428. * @param state defines the current compilation state (uniforms, samplers, current string)
  55429. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  55430. * @returns true if already built
  55431. */
  55432. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  55433. protected _inputRename(name: string): string;
  55434. protected _outputRename(name: string): string;
  55435. protected _dumpPropertiesCode(): string;
  55436. /** @hidden */
  55437. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  55438. /**
  55439. * Clone the current block to a new identical block
  55440. * @param scene defines the hosting scene
  55441. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  55442. * @returns a copy of the current block
  55443. */
  55444. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  55445. /**
  55446. * Serializes this block in a JSON representation
  55447. * @returns the serialized block object
  55448. */
  55449. serialize(): any;
  55450. /** @hidden */
  55451. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  55452. }
  55453. }
  55454. declare module "babylonjs/Materials/Node/NodeMaterialBlockConnectionPointMode" {
  55455. /**
  55456. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  55457. */
  55458. export enum NodeMaterialBlockConnectionPointMode {
  55459. /** Value is an uniform */
  55460. Uniform = 0,
  55461. /** Value is a mesh attribute */
  55462. Attribute = 1,
  55463. /** Value is a varying between vertex and fragment shaders */
  55464. Varying = 2,
  55465. /** Mode is undefined */
  55466. Undefined = 3
  55467. }
  55468. }
  55469. declare module "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes" {
  55470. /**
  55471. * Enum defining the type of animations supported by InputBlock
  55472. */
  55473. export enum AnimatedInputBlockTypes {
  55474. /** No animation */
  55475. None = 0,
  55476. /** Time based animation. Will only work for floats */
  55477. Time = 1
  55478. }
  55479. }
  55480. declare module "babylonjs/Materials/Node/Blocks/Input/inputBlock" {
  55481. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55482. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPointTypes";
  55483. import { NodeMaterialSystemValues } from "babylonjs/Materials/Node/nodeMaterialSystemValues";
  55484. import { Nullable } from "babylonjs/types";
  55485. import { Effect } from "babylonjs/Materials/effect";
  55486. import { Matrix } from "babylonjs/Maths/math.vector";
  55487. import { Scene } from "babylonjs/scene";
  55488. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55489. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  55490. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/nodeMaterialBlockTargets";
  55491. import { AnimatedInputBlockTypes } from "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes";
  55492. /**
  55493. * Block used to expose an input value
  55494. */
  55495. export class InputBlock extends NodeMaterialBlock {
  55496. private _mode;
  55497. private _associatedVariableName;
  55498. private _storedValue;
  55499. private _valueCallback;
  55500. private _type;
  55501. private _animationType;
  55502. /** @hidden */
  55503. _systemValue: Nullable<NodeMaterialSystemValues>;
  55504. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  55505. visibleInInspector: boolean;
  55506. /**
  55507. * Gets or sets the connection point type (default is float)
  55508. */
  55509. readonly type: NodeMaterialBlockConnectionPointTypes;
  55510. /**
  55511. * Creates a new InputBlock
  55512. * @param name defines the block name
  55513. * @param target defines the target of that block (Vertex by default)
  55514. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  55515. */
  55516. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  55517. /**
  55518. * Gets the output component
  55519. */
  55520. readonly output: NodeMaterialConnectionPoint;
  55521. /**
  55522. * Set the source of this connection point to a vertex attribute
  55523. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  55524. * @returns the current connection point
  55525. */
  55526. setAsAttribute(attributeName?: string): InputBlock;
  55527. /**
  55528. * Set the source of this connection point to a system value
  55529. * @param value define the system value to use (world, view, etc...) or null to switch to manual value
  55530. * @returns the current connection point
  55531. */
  55532. setAsSystemValue(value: Nullable<NodeMaterialSystemValues>): InputBlock;
  55533. /**
  55534. * Gets or sets the value of that point.
  55535. * Please note that this value will be ignored if valueCallback is defined
  55536. */
  55537. value: any;
  55538. /**
  55539. * Gets or sets a callback used to get the value of that point.
  55540. * Please note that setting this value will force the connection point to ignore the value property
  55541. */
  55542. valueCallback: () => any;
  55543. /**
  55544. * Gets or sets the associated variable name in the shader
  55545. */
  55546. associatedVariableName: string;
  55547. /** Gets or sets the type of animation applied to the input */
  55548. animationType: AnimatedInputBlockTypes;
  55549. /**
  55550. * Gets a boolean indicating that this connection point not defined yet
  55551. */
  55552. readonly isUndefined: boolean;
  55553. /**
  55554. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  55555. * In this case the connection point name must be the name of the uniform to use.
  55556. * Can only be set on inputs
  55557. */
  55558. isUniform: boolean;
  55559. /**
  55560. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  55561. * In this case the connection point name must be the name of the attribute to use
  55562. * Can only be set on inputs
  55563. */
  55564. isAttribute: boolean;
  55565. /**
  55566. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  55567. * Can only be set on exit points
  55568. */
  55569. isVarying: boolean;
  55570. /**
  55571. * Gets a boolean indicating that the current connection point is a system value
  55572. */
  55573. readonly isSystemValue: boolean;
  55574. /**
  55575. * Gets or sets the current well known value or null if not defined as a system value
  55576. */
  55577. systemValue: Nullable<NodeMaterialSystemValues>;
  55578. /**
  55579. * Gets the current class name
  55580. * @returns the class name
  55581. */
  55582. getClassName(): string;
  55583. /**
  55584. * Animate the input if animationType !== None
  55585. * @param scene defines the rendering scene
  55586. */
  55587. animate(scene: Scene): void;
  55588. private _emitDefine;
  55589. /**
  55590. * Set the input block to its default value (based on its type)
  55591. */
  55592. setDefaultValue(): void;
  55593. protected _dumpPropertiesCode(): string;
  55594. private _emit;
  55595. /** @hidden */
  55596. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  55597. /** @hidden */
  55598. _transmit(effect: Effect, scene: Scene): void;
  55599. protected _buildBlock(state: NodeMaterialBuildState): void;
  55600. serialize(): any;
  55601. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  55602. }
  55603. }
  55604. declare module "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint" {
  55605. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPointTypes";
  55606. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/nodeMaterialBlockTargets";
  55607. import { Nullable } from "babylonjs/types";
  55608. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  55609. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55610. /**
  55611. * Defines a connection point for a block
  55612. */
  55613. export class NodeMaterialConnectionPoint {
  55614. /** @hidden */
  55615. _ownerBlock: NodeMaterialBlock;
  55616. /** @hidden */
  55617. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  55618. private _endpoints;
  55619. private _associatedVariableName;
  55620. /** @hidden */
  55621. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  55622. /** @hidden */
  55623. _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  55624. private _type;
  55625. /** @hidden */
  55626. _enforceAssociatedVariableName: boolean;
  55627. /**
  55628. * Gets or sets the additional types supported byt this connection point
  55629. */
  55630. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  55631. /**
  55632. * Gets or sets the associated variable name in the shader
  55633. */
  55634. associatedVariableName: string;
  55635. /**
  55636. * Gets or sets the connection point type (default is float)
  55637. */
  55638. type: NodeMaterialBlockConnectionPointTypes;
  55639. /**
  55640. * Gets or sets the connection point name
  55641. */
  55642. name: string;
  55643. /**
  55644. * Gets or sets a boolean indicating that this connection point can be omitted
  55645. */
  55646. isOptional: boolean;
  55647. /**
  55648. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  55649. */
  55650. define: string;
  55651. /** Gets or sets the target of that connection point */
  55652. target: NodeMaterialBlockTargets;
  55653. /**
  55654. * Gets a boolean indicating that the current point is connected
  55655. */
  55656. readonly isConnected: boolean;
  55657. /**
  55658. * Gets a boolean indicating that the current point is connected to an input block
  55659. */
  55660. readonly isConnectedToInputBlock: boolean;
  55661. /**
  55662. * Gets a the connected input block (if any)
  55663. */
  55664. readonly connectInputBlock: Nullable<InputBlock>;
  55665. /** Get the other side of the connection (if any) */
  55666. readonly connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  55667. /** Get the block that owns this connection point */
  55668. readonly ownerBlock: NodeMaterialBlock;
  55669. /** Get the block connected on the other side of this connection (if any) */
  55670. readonly sourceBlock: Nullable<NodeMaterialBlock>;
  55671. /** Get the block connected on the endpoints of this connection (if any) */
  55672. readonly connectedBlocks: Array<NodeMaterialBlock>;
  55673. /** Gets the list of connected endpoints */
  55674. readonly endpoints: NodeMaterialConnectionPoint[];
  55675. /** Gets a boolean indicating if that output point is connected to at least one input */
  55676. readonly hasEndpoints: boolean;
  55677. /**
  55678. * Creates a new connection point
  55679. * @param name defines the connection point name
  55680. * @param ownerBlock defines the block hosting this connection point
  55681. */
  55682. constructor(name: string, ownerBlock: NodeMaterialBlock);
  55683. /**
  55684. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  55685. * @returns the class name
  55686. */
  55687. getClassName(): string;
  55688. /**
  55689. * Gets an boolean indicating if the current point can be connected to another point
  55690. * @param connectionPoint defines the other connection point
  55691. * @returns true if the connection is possible
  55692. */
  55693. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  55694. /**
  55695. * Connect this point to another connection point
  55696. * @param connectionPoint defines the other connection point
  55697. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  55698. * @returns the current connection point
  55699. */
  55700. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  55701. /**
  55702. * Disconnect this point from one of his endpoint
  55703. * @param endpoint defines the other connection point
  55704. * @returns the current connection point
  55705. */
  55706. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  55707. /**
  55708. * Serializes this point in a JSON representation
  55709. * @returns the serialized point object
  55710. */
  55711. serialize(): any;
  55712. }
  55713. }
  55714. declare module "babylonjs/Materials/Node/Blocks/Vertex/bonesBlock" {
  55715. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55716. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  55717. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55718. import { Mesh } from "babylonjs/Meshes/mesh";
  55719. import { Effect, EffectFallbacks } from "babylonjs/Materials/effect";
  55720. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55721. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  55722. /**
  55723. * Block used to add support for vertex skinning (bones)
  55724. */
  55725. export class BonesBlock extends NodeMaterialBlock {
  55726. /**
  55727. * Creates a new BonesBlock
  55728. * @param name defines the block name
  55729. */
  55730. constructor(name: string);
  55731. /**
  55732. * Initialize the block and prepare the context for build
  55733. * @param state defines the state that will be used for the build
  55734. */
  55735. initialize(state: NodeMaterialBuildState): void;
  55736. /**
  55737. * Gets the current class name
  55738. * @returns the class name
  55739. */
  55740. getClassName(): string;
  55741. /**
  55742. * Gets the matrix indices input component
  55743. */
  55744. readonly matricesIndices: NodeMaterialConnectionPoint;
  55745. /**
  55746. * Gets the matrix weights input component
  55747. */
  55748. readonly matricesWeights: NodeMaterialConnectionPoint;
  55749. /**
  55750. * Gets the extra matrix indices input component
  55751. */
  55752. readonly matricesIndicesExtra: NodeMaterialConnectionPoint;
  55753. /**
  55754. * Gets the extra matrix weights input component
  55755. */
  55756. readonly matricesWeightsExtra: NodeMaterialConnectionPoint;
  55757. /**
  55758. * Gets the world input component
  55759. */
  55760. readonly world: NodeMaterialConnectionPoint;
  55761. /**
  55762. * Gets the output component
  55763. */
  55764. readonly output: NodeMaterialConnectionPoint;
  55765. autoConfigure(material: NodeMaterial): void;
  55766. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  55767. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  55768. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  55769. protected _buildBlock(state: NodeMaterialBuildState): this;
  55770. }
  55771. }
  55772. declare module "babylonjs/Materials/Node/Blocks/Vertex/instancesBlock" {
  55773. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55774. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55775. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  55776. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55777. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  55778. /**
  55779. * Block used to add support for instances
  55780. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  55781. */
  55782. export class InstancesBlock extends NodeMaterialBlock {
  55783. /**
  55784. * Creates a new InstancesBlock
  55785. * @param name defines the block name
  55786. */
  55787. constructor(name: string);
  55788. /**
  55789. * Gets the current class name
  55790. * @returns the class name
  55791. */
  55792. getClassName(): string;
  55793. /**
  55794. * Gets the first world row input component
  55795. */
  55796. readonly world0: NodeMaterialConnectionPoint;
  55797. /**
  55798. * Gets the second world row input component
  55799. */
  55800. readonly world1: NodeMaterialConnectionPoint;
  55801. /**
  55802. * Gets the third world row input component
  55803. */
  55804. readonly world2: NodeMaterialConnectionPoint;
  55805. /**
  55806. * Gets the forth world row input component
  55807. */
  55808. readonly world3: NodeMaterialConnectionPoint;
  55809. /**
  55810. * Gets the world input component
  55811. */
  55812. readonly world: NodeMaterialConnectionPoint;
  55813. /**
  55814. * Gets the output component
  55815. */
  55816. readonly output: NodeMaterialConnectionPoint;
  55817. autoConfigure(material: NodeMaterial): void;
  55818. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  55819. protected _buildBlock(state: NodeMaterialBuildState): this;
  55820. }
  55821. }
  55822. declare module "babylonjs/Materials/Node/Blocks/Vertex/morphTargetsBlock" {
  55823. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55824. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  55825. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55826. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55827. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  55828. import { Effect } from "babylonjs/Materials/effect";
  55829. import { Mesh } from "babylonjs/Meshes/mesh";
  55830. /**
  55831. * Block used to add morph targets support to vertex shader
  55832. */
  55833. export class MorphTargetsBlock extends NodeMaterialBlock {
  55834. private _repeatableContentAnchor;
  55835. private _repeatebleContentGenerated;
  55836. /**
  55837. * Create a new MorphTargetsBlock
  55838. * @param name defines the block name
  55839. */
  55840. constructor(name: string);
  55841. /**
  55842. * Gets the current class name
  55843. * @returns the class name
  55844. */
  55845. getClassName(): string;
  55846. /**
  55847. * Gets the position input component
  55848. */
  55849. readonly position: NodeMaterialConnectionPoint;
  55850. /**
  55851. * Gets the normal input component
  55852. */
  55853. readonly normal: NodeMaterialConnectionPoint;
  55854. /**
  55855. * Gets the tangent input component
  55856. */
  55857. readonly tangent: NodeMaterialConnectionPoint;
  55858. /**
  55859. * Gets the tangent input component
  55860. */
  55861. readonly uv: NodeMaterialConnectionPoint;
  55862. /**
  55863. * Gets the position output component
  55864. */
  55865. readonly positionOutput: NodeMaterialConnectionPoint;
  55866. /**
  55867. * Gets the normal output component
  55868. */
  55869. readonly normalOutput: NodeMaterialConnectionPoint;
  55870. /**
  55871. * Gets the tangent output component
  55872. */
  55873. readonly tangentOutput: NodeMaterialConnectionPoint;
  55874. /**
  55875. * Gets the tangent output component
  55876. */
  55877. readonly uvOutput: NodeMaterialConnectionPoint;
  55878. initialize(state: NodeMaterialBuildState): void;
  55879. autoConfigure(material: NodeMaterial): void;
  55880. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  55881. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  55882. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  55883. protected _buildBlock(state: NodeMaterialBuildState): this;
  55884. }
  55885. }
  55886. declare module "babylonjs/Materials/Node/Blocks/Vertex/lightInformationBlock" {
  55887. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55888. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  55889. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55890. import { Nullable } from "babylonjs/types";
  55891. import { Scene } from "babylonjs/scene";
  55892. import { Effect } from "babylonjs/Materials/effect";
  55893. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  55894. import { Mesh } from "babylonjs/Meshes/mesh";
  55895. import { Light } from "babylonjs/Lights/light";
  55896. /**
  55897. * Block used to get data information from a light
  55898. */
  55899. export class LightInformationBlock extends NodeMaterialBlock {
  55900. private _lightDataDefineName;
  55901. private _lightColorDefineName;
  55902. /**
  55903. * Gets or sets the light associated with this block
  55904. */
  55905. light: Nullable<Light>;
  55906. /**
  55907. * Creates a new LightInformationBlock
  55908. * @param name defines the block name
  55909. */
  55910. constructor(name: string);
  55911. /**
  55912. * Gets the current class name
  55913. * @returns the class name
  55914. */
  55915. getClassName(): string;
  55916. /**
  55917. * Gets the world position input component
  55918. */
  55919. readonly worldPosition: NodeMaterialConnectionPoint;
  55920. /**
  55921. * Gets the direction output component
  55922. */
  55923. readonly direction: NodeMaterialConnectionPoint;
  55924. /**
  55925. * Gets the direction output component
  55926. */
  55927. readonly color: NodeMaterialConnectionPoint;
  55928. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  55929. protected _buildBlock(state: NodeMaterialBuildState): this;
  55930. serialize(): any;
  55931. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  55932. }
  55933. }
  55934. declare module "babylonjs/Materials/Node/Blocks/Vertex/index" {
  55935. export * from "babylonjs/Materials/Node/Blocks/Vertex/vertexOutputBlock";
  55936. export * from "babylonjs/Materials/Node/Blocks/Vertex/bonesBlock";
  55937. export * from "babylonjs/Materials/Node/Blocks/Vertex/instancesBlock";
  55938. export * from "babylonjs/Materials/Node/Blocks/Vertex/morphTargetsBlock";
  55939. export * from "babylonjs/Materials/Node/Blocks/Vertex/lightInformationBlock";
  55940. }
  55941. declare module "babylonjs/Materials/Node/Blocks/Fragment/alphaTestBlock" {
  55942. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55943. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  55944. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55945. import { Scene } from "babylonjs/scene";
  55946. /**
  55947. * Block used to add an alpha test in the fragment shader
  55948. */
  55949. export class AlphaTestBlock extends NodeMaterialBlock {
  55950. /**
  55951. * Gets or sets the alpha value where alpha testing happens
  55952. */
  55953. alphaCutOff: number;
  55954. /**
  55955. * Create a new AlphaTestBlock
  55956. * @param name defines the block name
  55957. */
  55958. constructor(name: string);
  55959. /**
  55960. * Gets the current class name
  55961. * @returns the class name
  55962. */
  55963. getClassName(): string;
  55964. /**
  55965. * Gets the color input component
  55966. */
  55967. readonly color: NodeMaterialConnectionPoint;
  55968. /**
  55969. * Gets the alpha input component
  55970. */
  55971. readonly alpha: NodeMaterialConnectionPoint;
  55972. protected _buildBlock(state: NodeMaterialBuildState): this;
  55973. protected _dumpPropertiesCode(): string;
  55974. serialize(): any;
  55975. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  55976. }
  55977. }
  55978. declare module "babylonjs/Materials/Node/Blocks/Fragment/imageProcessingBlock" {
  55979. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55980. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  55981. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55982. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55983. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  55984. import { Effect } from "babylonjs/Materials/effect";
  55985. import { Mesh } from "babylonjs/Meshes/mesh";
  55986. /**
  55987. * Block used to add image processing support to fragment shader
  55988. */
  55989. export class ImageProcessingBlock extends NodeMaterialBlock {
  55990. /**
  55991. * Create a new ImageProcessingBlock
  55992. * @param name defines the block name
  55993. */
  55994. constructor(name: string);
  55995. /**
  55996. * Gets the current class name
  55997. * @returns the class name
  55998. */
  55999. getClassName(): string;
  56000. /**
  56001. * Gets the color input component
  56002. */
  56003. readonly color: NodeMaterialConnectionPoint;
  56004. /**
  56005. * Gets the output component
  56006. */
  56007. readonly output: NodeMaterialConnectionPoint;
  56008. /**
  56009. * Initialize the block and prepare the context for build
  56010. * @param state defines the state that will be used for the build
  56011. */
  56012. initialize(state: NodeMaterialBuildState): void;
  56013. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  56014. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  56015. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  56016. protected _buildBlock(state: NodeMaterialBuildState): this;
  56017. }
  56018. }
  56019. declare module "babylonjs/Materials/Node/Blocks/Fragment/index" {
  56020. export * from "babylonjs/Materials/Node/Blocks/Fragment/fragmentOutputBlock";
  56021. export * from "babylonjs/Materials/Node/Blocks/Fragment/alphaTestBlock";
  56022. export * from "babylonjs/Materials/Node/Blocks/Fragment/imageProcessingBlock";
  56023. }
  56024. declare module "babylonjs/Materials/Node/Blocks/Dual/fogBlock" {
  56025. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56026. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56027. import { Mesh } from "babylonjs/Meshes/mesh";
  56028. import { Effect } from "babylonjs/Materials/effect";
  56029. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56030. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56031. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  56032. /**
  56033. * Block used to add support for scene fog
  56034. */
  56035. export class FogBlock extends NodeMaterialBlock {
  56036. private _fogDistanceName;
  56037. private _fogParameters;
  56038. /**
  56039. * Create a new FogBlock
  56040. * @param name defines the block name
  56041. */
  56042. constructor(name: string);
  56043. /**
  56044. * Gets the current class name
  56045. * @returns the class name
  56046. */
  56047. getClassName(): string;
  56048. /**
  56049. * Gets the world position input component
  56050. */
  56051. readonly worldPosition: NodeMaterialConnectionPoint;
  56052. /**
  56053. * Gets the view input component
  56054. */
  56055. readonly view: NodeMaterialConnectionPoint;
  56056. /**
  56057. * Gets the color input component
  56058. */
  56059. readonly input: NodeMaterialConnectionPoint;
  56060. /**
  56061. * Gets the fog color input component
  56062. */
  56063. readonly fogColor: NodeMaterialConnectionPoint;
  56064. /**
  56065. * Gets the output component
  56066. */
  56067. readonly output: NodeMaterialConnectionPoint;
  56068. autoConfigure(material: NodeMaterial): void;
  56069. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  56070. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  56071. protected _buildBlock(state: NodeMaterialBuildState): this;
  56072. }
  56073. }
  56074. declare module "babylonjs/Materials/Node/Blocks/Dual/lightBlock" {
  56075. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56076. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56077. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56078. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56079. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  56080. import { Effect } from "babylonjs/Materials/effect";
  56081. import { Mesh } from "babylonjs/Meshes/mesh";
  56082. import { Light } from "babylonjs/Lights/light";
  56083. import { Nullable } from "babylonjs/types";
  56084. import { Scene } from "babylonjs/scene";
  56085. /**
  56086. * Block used to add light in the fragment shader
  56087. */
  56088. export class LightBlock extends NodeMaterialBlock {
  56089. private _lightId;
  56090. /**
  56091. * Gets or sets the light associated with this block
  56092. */
  56093. light: Nullable<Light>;
  56094. /**
  56095. * Create a new LightBlock
  56096. * @param name defines the block name
  56097. */
  56098. constructor(name: string);
  56099. /**
  56100. * Gets the current class name
  56101. * @returns the class name
  56102. */
  56103. getClassName(): string;
  56104. /**
  56105. * Gets the world position input component
  56106. */
  56107. readonly worldPosition: NodeMaterialConnectionPoint;
  56108. /**
  56109. * Gets the world normal input component
  56110. */
  56111. readonly worldNormal: NodeMaterialConnectionPoint;
  56112. /**
  56113. * Gets the camera (or eye) position component
  56114. */
  56115. readonly cameraPosition: NodeMaterialConnectionPoint;
  56116. /**
  56117. * Gets the diffuse output component
  56118. */
  56119. readonly diffuseOutput: NodeMaterialConnectionPoint;
  56120. /**
  56121. * Gets the specular output component
  56122. */
  56123. readonly specularOutput: NodeMaterialConnectionPoint;
  56124. autoConfigure(material: NodeMaterial): void;
  56125. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  56126. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  56127. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  56128. private _injectVertexCode;
  56129. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  56130. serialize(): any;
  56131. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  56132. }
  56133. }
  56134. declare module "babylonjs/Materials/Node/Blocks/Dual/index" {
  56135. export * from "babylonjs/Materials/Node/Blocks/Dual/fogBlock";
  56136. export * from "babylonjs/Materials/Node/Blocks/Dual/lightBlock";
  56137. export * from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  56138. export * from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock";
  56139. }
  56140. declare module "babylonjs/Materials/Node/Blocks/Input/index" {
  56141. export * from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  56142. export * from "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes";
  56143. }
  56144. declare module "babylonjs/Materials/Node/Blocks/multiplyBlock" {
  56145. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56146. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56147. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56148. /**
  56149. * Block used to multiply 2 values
  56150. */
  56151. export class MultiplyBlock extends NodeMaterialBlock {
  56152. /**
  56153. * Creates a new MultiplyBlock
  56154. * @param name defines the block name
  56155. */
  56156. constructor(name: string);
  56157. /**
  56158. * Gets the current class name
  56159. * @returns the class name
  56160. */
  56161. getClassName(): string;
  56162. /**
  56163. * Gets the left operand input component
  56164. */
  56165. readonly left: NodeMaterialConnectionPoint;
  56166. /**
  56167. * Gets the right operand input component
  56168. */
  56169. readonly right: NodeMaterialConnectionPoint;
  56170. /**
  56171. * Gets the output component
  56172. */
  56173. readonly output: NodeMaterialConnectionPoint;
  56174. protected _buildBlock(state: NodeMaterialBuildState): this;
  56175. }
  56176. }
  56177. declare module "babylonjs/Materials/Node/Blocks/addBlock" {
  56178. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56179. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56180. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56181. /**
  56182. * Block used to add 2 vectors
  56183. */
  56184. export class AddBlock extends NodeMaterialBlock {
  56185. /**
  56186. * Creates a new AddBlock
  56187. * @param name defines the block name
  56188. */
  56189. constructor(name: string);
  56190. /**
  56191. * Gets the current class name
  56192. * @returns the class name
  56193. */
  56194. getClassName(): string;
  56195. /**
  56196. * Gets the left operand input component
  56197. */
  56198. readonly left: NodeMaterialConnectionPoint;
  56199. /**
  56200. * Gets the right operand input component
  56201. */
  56202. readonly right: NodeMaterialConnectionPoint;
  56203. /**
  56204. * Gets the output component
  56205. */
  56206. readonly output: NodeMaterialConnectionPoint;
  56207. protected _buildBlock(state: NodeMaterialBuildState): this;
  56208. }
  56209. }
  56210. declare module "babylonjs/Materials/Node/Blocks/scaleBlock" {
  56211. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56212. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56213. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56214. /**
  56215. * Block used to scale a vector by a float
  56216. */
  56217. export class ScaleBlock extends NodeMaterialBlock {
  56218. /**
  56219. * Creates a new ScaleBlock
  56220. * @param name defines the block name
  56221. */
  56222. constructor(name: string);
  56223. /**
  56224. * Gets the current class name
  56225. * @returns the class name
  56226. */
  56227. getClassName(): string;
  56228. /**
  56229. * Gets the input component
  56230. */
  56231. readonly input: NodeMaterialConnectionPoint;
  56232. /**
  56233. * Gets the factor input component
  56234. */
  56235. readonly factor: NodeMaterialConnectionPoint;
  56236. /**
  56237. * Gets the output component
  56238. */
  56239. readonly output: NodeMaterialConnectionPoint;
  56240. protected _buildBlock(state: NodeMaterialBuildState): this;
  56241. }
  56242. }
  56243. declare module "babylonjs/Materials/Node/Blocks/clampBlock" {
  56244. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56245. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56246. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56247. import { Scene } from "babylonjs/scene";
  56248. /**
  56249. * Block used to clamp a float
  56250. */
  56251. export class ClampBlock extends NodeMaterialBlock {
  56252. /** Gets or sets the minimum range */
  56253. minimum: number;
  56254. /** Gets or sets the maximum range */
  56255. maximum: number;
  56256. /**
  56257. * Creates a new ClampBlock
  56258. * @param name defines the block name
  56259. */
  56260. constructor(name: string);
  56261. /**
  56262. * Gets the current class name
  56263. * @returns the class name
  56264. */
  56265. getClassName(): string;
  56266. /**
  56267. * Gets the value input component
  56268. */
  56269. readonly value: NodeMaterialConnectionPoint;
  56270. /**
  56271. * Gets the output component
  56272. */
  56273. readonly output: NodeMaterialConnectionPoint;
  56274. protected _buildBlock(state: NodeMaterialBuildState): this;
  56275. protected _dumpPropertiesCode(): string;
  56276. serialize(): any;
  56277. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  56278. }
  56279. }
  56280. declare module "babylonjs/Materials/Node/Blocks/crossBlock" {
  56281. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56282. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56283. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56284. /**
  56285. * Block used to apply a cross product between 2 vectors
  56286. */
  56287. export class CrossBlock extends NodeMaterialBlock {
  56288. /**
  56289. * Creates a new CrossBlock
  56290. * @param name defines the block name
  56291. */
  56292. constructor(name: string);
  56293. /**
  56294. * Gets the current class name
  56295. * @returns the class name
  56296. */
  56297. getClassName(): string;
  56298. /**
  56299. * Gets the left operand input component
  56300. */
  56301. readonly left: NodeMaterialConnectionPoint;
  56302. /**
  56303. * Gets the right operand input component
  56304. */
  56305. readonly right: NodeMaterialConnectionPoint;
  56306. /**
  56307. * Gets the output component
  56308. */
  56309. readonly output: NodeMaterialConnectionPoint;
  56310. protected _buildBlock(state: NodeMaterialBuildState): this;
  56311. }
  56312. }
  56313. declare module "babylonjs/Materials/Node/Blocks/dotBlock" {
  56314. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56315. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56316. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56317. /**
  56318. * Block used to apply a dot product between 2 vectors
  56319. */
  56320. export class DotBlock extends NodeMaterialBlock {
  56321. /**
  56322. * Creates a new DotBlock
  56323. * @param name defines the block name
  56324. */
  56325. constructor(name: string);
  56326. /**
  56327. * Gets the current class name
  56328. * @returns the class name
  56329. */
  56330. getClassName(): string;
  56331. /**
  56332. * Gets the left operand input component
  56333. */
  56334. readonly left: NodeMaterialConnectionPoint;
  56335. /**
  56336. * Gets the right operand input component
  56337. */
  56338. readonly right: NodeMaterialConnectionPoint;
  56339. /**
  56340. * Gets the output component
  56341. */
  56342. readonly output: NodeMaterialConnectionPoint;
  56343. protected _buildBlock(state: NodeMaterialBuildState): this;
  56344. }
  56345. }
  56346. declare module "babylonjs/Materials/Node/Blocks/remapBlock" {
  56347. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56348. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56349. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56350. import { Vector2 } from "babylonjs/Maths/math.vector";
  56351. import { Scene } from "babylonjs/scene";
  56352. /**
  56353. * Block used to remap a float from a range to a new one
  56354. */
  56355. export class RemapBlock extends NodeMaterialBlock {
  56356. /**
  56357. * Gets or sets the source range
  56358. */
  56359. sourceRange: Vector2;
  56360. /**
  56361. * Gets or sets the target range
  56362. */
  56363. targetRange: Vector2;
  56364. /**
  56365. * Creates a new RemapBlock
  56366. * @param name defines the block name
  56367. */
  56368. constructor(name: string);
  56369. /**
  56370. * Gets the current class name
  56371. * @returns the class name
  56372. */
  56373. getClassName(): string;
  56374. /**
  56375. * Gets the input component
  56376. */
  56377. readonly input: NodeMaterialConnectionPoint;
  56378. /**
  56379. * Gets the output component
  56380. */
  56381. readonly output: NodeMaterialConnectionPoint;
  56382. protected _buildBlock(state: NodeMaterialBuildState): this;
  56383. protected _dumpPropertiesCode(): string;
  56384. serialize(): any;
  56385. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  56386. }
  56387. }
  56388. declare module "babylonjs/Materials/Node/Blocks/normalizeBlock" {
  56389. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56390. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56391. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56392. /**
  56393. * Block used to normalize a vector
  56394. */
  56395. export class NormalizeBlock extends NodeMaterialBlock {
  56396. /**
  56397. * Creates a new NormalizeBlock
  56398. * @param name defines the block name
  56399. */
  56400. constructor(name: string);
  56401. /**
  56402. * Gets the current class name
  56403. * @returns the class name
  56404. */
  56405. getClassName(): string;
  56406. /**
  56407. * Gets the input component
  56408. */
  56409. readonly input: NodeMaterialConnectionPoint;
  56410. /**
  56411. * Gets the output component
  56412. */
  56413. readonly output: NodeMaterialConnectionPoint;
  56414. protected _buildBlock(state: NodeMaterialBuildState): this;
  56415. }
  56416. }
  56417. declare module "babylonjs/Materials/Node/Blocks/trigonometryBlock" {
  56418. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56419. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56420. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56421. import { Scene } from "babylonjs/scene";
  56422. /**
  56423. * Operations supported by the Trigonometry block
  56424. */
  56425. export enum TrigonometryBlockOperations {
  56426. /** Cos */
  56427. Cos = 0,
  56428. /** Sin */
  56429. Sin = 1,
  56430. /** Abs */
  56431. Abs = 2,
  56432. /** Exp */
  56433. Exp = 3,
  56434. /** Exp2 */
  56435. Exp2 = 4,
  56436. /** Round */
  56437. Round = 5,
  56438. /** Floor */
  56439. Floor = 6,
  56440. /** Ceiling */
  56441. Ceiling = 7
  56442. }
  56443. /**
  56444. * Block used to apply trigonometry operation to floats
  56445. */
  56446. export class TrigonometryBlock extends NodeMaterialBlock {
  56447. /**
  56448. * Gets or sets the operation applied by the block
  56449. */
  56450. operation: TrigonometryBlockOperations;
  56451. /**
  56452. * Creates a new TrigonometryBlock
  56453. * @param name defines the block name
  56454. */
  56455. constructor(name: string);
  56456. /**
  56457. * Gets the current class name
  56458. * @returns the class name
  56459. */
  56460. getClassName(): string;
  56461. /**
  56462. * Gets the input component
  56463. */
  56464. readonly input: NodeMaterialConnectionPoint;
  56465. /**
  56466. * Gets the output component
  56467. */
  56468. readonly output: NodeMaterialConnectionPoint;
  56469. protected _buildBlock(state: NodeMaterialBuildState): this;
  56470. serialize(): any;
  56471. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  56472. }
  56473. }
  56474. declare module "babylonjs/Materials/Node/Blocks/colorMergerBlock" {
  56475. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56476. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56477. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56478. /**
  56479. * Block used to create a Color3/4 out of individual inputs (one for each component)
  56480. */
  56481. export class ColorMergerBlock extends NodeMaterialBlock {
  56482. /**
  56483. * Create a new ColorMergerBlock
  56484. * @param name defines the block name
  56485. */
  56486. constructor(name: string);
  56487. /**
  56488. * Gets the current class name
  56489. * @returns the class name
  56490. */
  56491. getClassName(): string;
  56492. /**
  56493. * Gets the r component (input)
  56494. */
  56495. readonly r: NodeMaterialConnectionPoint;
  56496. /**
  56497. * Gets the g component (input)
  56498. */
  56499. readonly g: NodeMaterialConnectionPoint;
  56500. /**
  56501. * Gets the b component (input)
  56502. */
  56503. readonly b: NodeMaterialConnectionPoint;
  56504. /**
  56505. * Gets the a component (input)
  56506. */
  56507. readonly a: NodeMaterialConnectionPoint;
  56508. /**
  56509. * Gets the rgba component (output)
  56510. */
  56511. readonly rgba: NodeMaterialConnectionPoint;
  56512. /**
  56513. * Gets the rgb component (output)
  56514. */
  56515. readonly rgb: NodeMaterialConnectionPoint;
  56516. protected _buildBlock(state: NodeMaterialBuildState): this;
  56517. }
  56518. }
  56519. declare module "babylonjs/Materials/Node/Blocks/vectorMergerBlock" {
  56520. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56521. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56522. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56523. /**
  56524. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  56525. */
  56526. export class VectorMergerBlock extends NodeMaterialBlock {
  56527. /**
  56528. * Create a new VectorMergerBlock
  56529. * @param name defines the block name
  56530. */
  56531. constructor(name: string);
  56532. /**
  56533. * Gets the current class name
  56534. * @returns the class name
  56535. */
  56536. getClassName(): string;
  56537. /**
  56538. * Gets the x component (input)
  56539. */
  56540. readonly x: NodeMaterialConnectionPoint;
  56541. /**
  56542. * Gets the y component (input)
  56543. */
  56544. readonly y: NodeMaterialConnectionPoint;
  56545. /**
  56546. * Gets the z component (input)
  56547. */
  56548. readonly z: NodeMaterialConnectionPoint;
  56549. /**
  56550. * Gets the w component (input)
  56551. */
  56552. readonly w: NodeMaterialConnectionPoint;
  56553. /**
  56554. * Gets the xyzw component (output)
  56555. */
  56556. readonly xyzw: NodeMaterialConnectionPoint;
  56557. /**
  56558. * Gets the xyz component (output)
  56559. */
  56560. readonly xyz: NodeMaterialConnectionPoint;
  56561. /**
  56562. * Gets the xy component (output)
  56563. */
  56564. readonly xy: NodeMaterialConnectionPoint;
  56565. protected _buildBlock(state: NodeMaterialBuildState): this;
  56566. }
  56567. }
  56568. declare module "babylonjs/Materials/Node/Blocks/colorSplitterBlock" {
  56569. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56570. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56571. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56572. /**
  56573. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  56574. */
  56575. export class ColorSplitterBlock extends NodeMaterialBlock {
  56576. /**
  56577. * Create a new ColorSplitterBlock
  56578. * @param name defines the block name
  56579. */
  56580. constructor(name: string);
  56581. /**
  56582. * Gets the current class name
  56583. * @returns the class name
  56584. */
  56585. getClassName(): string;
  56586. /**
  56587. * Gets the rgba component (input)
  56588. */
  56589. readonly rgba: NodeMaterialConnectionPoint;
  56590. /**
  56591. * Gets the rgb component (input)
  56592. */
  56593. readonly rgbIn: NodeMaterialConnectionPoint;
  56594. /**
  56595. * Gets the rgb component (output)
  56596. */
  56597. readonly rgbOut: NodeMaterialConnectionPoint;
  56598. /**
  56599. * Gets the r component (output)
  56600. */
  56601. readonly r: NodeMaterialConnectionPoint;
  56602. /**
  56603. * Gets the g component (output)
  56604. */
  56605. readonly g: NodeMaterialConnectionPoint;
  56606. /**
  56607. * Gets the b component (output)
  56608. */
  56609. readonly b: NodeMaterialConnectionPoint;
  56610. /**
  56611. * Gets the a component (output)
  56612. */
  56613. readonly a: NodeMaterialConnectionPoint;
  56614. protected _inputRename(name: string): string;
  56615. protected _outputRename(name: string): string;
  56616. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  56617. }
  56618. }
  56619. declare module "babylonjs/Materials/Node/Blocks/vectorSplitterBlock" {
  56620. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56621. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56622. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56623. /**
  56624. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  56625. */
  56626. export class VectorSplitterBlock extends NodeMaterialBlock {
  56627. /**
  56628. * Create a new VectorSplitterBlock
  56629. * @param name defines the block name
  56630. */
  56631. constructor(name: string);
  56632. /**
  56633. * Gets the current class name
  56634. * @returns the class name
  56635. */
  56636. getClassName(): string;
  56637. /**
  56638. * Gets the xyzw component (input)
  56639. */
  56640. readonly xyzw: NodeMaterialConnectionPoint;
  56641. /**
  56642. * Gets the xyz component (input)
  56643. */
  56644. readonly xyzIn: NodeMaterialConnectionPoint;
  56645. /**
  56646. * Gets the xy component (input)
  56647. */
  56648. readonly xyIn: NodeMaterialConnectionPoint;
  56649. /**
  56650. * Gets the xyz component (output)
  56651. */
  56652. readonly xyzOut: NodeMaterialConnectionPoint;
  56653. /**
  56654. * Gets the xy component (output)
  56655. */
  56656. readonly xyOut: NodeMaterialConnectionPoint;
  56657. /**
  56658. * Gets the x component (output)
  56659. */
  56660. readonly x: NodeMaterialConnectionPoint;
  56661. /**
  56662. * Gets the y component (output)
  56663. */
  56664. readonly y: NodeMaterialConnectionPoint;
  56665. /**
  56666. * Gets the z component (output)
  56667. */
  56668. readonly z: NodeMaterialConnectionPoint;
  56669. /**
  56670. * Gets the w component (output)
  56671. */
  56672. readonly w: NodeMaterialConnectionPoint;
  56673. protected _inputRename(name: string): string;
  56674. protected _outputRename(name: string): string;
  56675. protected _buildBlock(state: NodeMaterialBuildState): this;
  56676. }
  56677. }
  56678. declare module "babylonjs/Materials/Node/Blocks/lerpBlock" {
  56679. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56680. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56681. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56682. /**
  56683. * Block used to lerp 2 values
  56684. */
  56685. export class LerpBlock extends NodeMaterialBlock {
  56686. /**
  56687. * Creates a new LerpBlock
  56688. * @param name defines the block name
  56689. */
  56690. constructor(name: string);
  56691. /**
  56692. * Gets the current class name
  56693. * @returns the class name
  56694. */
  56695. getClassName(): string;
  56696. /**
  56697. * Gets the left operand input component
  56698. */
  56699. readonly left: NodeMaterialConnectionPoint;
  56700. /**
  56701. * Gets the right operand input component
  56702. */
  56703. readonly right: NodeMaterialConnectionPoint;
  56704. /**
  56705. * Gets the gradient operand input component
  56706. */
  56707. readonly gradient: NodeMaterialConnectionPoint;
  56708. /**
  56709. * Gets the output component
  56710. */
  56711. readonly output: NodeMaterialConnectionPoint;
  56712. protected _buildBlock(state: NodeMaterialBuildState): this;
  56713. }
  56714. }
  56715. declare module "babylonjs/Materials/Node/Blocks/divideBlock" {
  56716. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56717. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56718. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56719. /**
  56720. * Block used to divide 2 vectors
  56721. */
  56722. export class DivideBlock extends NodeMaterialBlock {
  56723. /**
  56724. * Creates a new DivideBlock
  56725. * @param name defines the block name
  56726. */
  56727. constructor(name: string);
  56728. /**
  56729. * Gets the current class name
  56730. * @returns the class name
  56731. */
  56732. getClassName(): string;
  56733. /**
  56734. * Gets the left operand input component
  56735. */
  56736. readonly left: NodeMaterialConnectionPoint;
  56737. /**
  56738. * Gets the right operand input component
  56739. */
  56740. readonly right: NodeMaterialConnectionPoint;
  56741. /**
  56742. * Gets the output component
  56743. */
  56744. readonly output: NodeMaterialConnectionPoint;
  56745. protected _buildBlock(state: NodeMaterialBuildState): this;
  56746. }
  56747. }
  56748. declare module "babylonjs/Materials/Node/Blocks/subtractBlock" {
  56749. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56750. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56751. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56752. /**
  56753. * Block used to subtract 2 vectors
  56754. */
  56755. export class SubtractBlock extends NodeMaterialBlock {
  56756. /**
  56757. * Creates a new SubtractBlock
  56758. * @param name defines the block name
  56759. */
  56760. constructor(name: string);
  56761. /**
  56762. * Gets the current class name
  56763. * @returns the class name
  56764. */
  56765. getClassName(): string;
  56766. /**
  56767. * Gets the left operand input component
  56768. */
  56769. readonly left: NodeMaterialConnectionPoint;
  56770. /**
  56771. * Gets the right operand input component
  56772. */
  56773. readonly right: NodeMaterialConnectionPoint;
  56774. /**
  56775. * Gets the output component
  56776. */
  56777. readonly output: NodeMaterialConnectionPoint;
  56778. protected _buildBlock(state: NodeMaterialBuildState): this;
  56779. }
  56780. }
  56781. declare module "babylonjs/Materials/Node/Blocks/stepBlock" {
  56782. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56783. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56784. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56785. /**
  56786. * Block used to step a value
  56787. */
  56788. export class StepBlock extends NodeMaterialBlock {
  56789. /**
  56790. * Creates a new AddBlock
  56791. * @param name defines the block name
  56792. */
  56793. constructor(name: string);
  56794. /**
  56795. * Gets the current class name
  56796. * @returns the class name
  56797. */
  56798. getClassName(): string;
  56799. /**
  56800. * Gets the value operand input component
  56801. */
  56802. readonly value: NodeMaterialConnectionPoint;
  56803. /**
  56804. * Gets the edge operand input component
  56805. */
  56806. readonly edge: NodeMaterialConnectionPoint;
  56807. /**
  56808. * Gets the output component
  56809. */
  56810. readonly output: NodeMaterialConnectionPoint;
  56811. protected _buildBlock(state: NodeMaterialBuildState): this;
  56812. }
  56813. }
  56814. declare module "babylonjs/Materials/Node/Blocks/oppositeBlock" {
  56815. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56816. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56817. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56818. /**
  56819. * Block used to get the opposite of a value
  56820. */
  56821. export class OppositeBlock extends NodeMaterialBlock {
  56822. /**
  56823. * Creates a new OppositeBlock
  56824. * @param name defines the block name
  56825. */
  56826. constructor(name: string);
  56827. /**
  56828. * Gets the current class name
  56829. * @returns the class name
  56830. */
  56831. getClassName(): string;
  56832. /**
  56833. * Gets the input component
  56834. */
  56835. readonly input: NodeMaterialConnectionPoint;
  56836. /**
  56837. * Gets the output component
  56838. */
  56839. readonly output: NodeMaterialConnectionPoint;
  56840. protected _buildBlock(state: NodeMaterialBuildState): this;
  56841. }
  56842. }
  56843. declare module "babylonjs/Materials/Node/Blocks/viewDirectionBlock" {
  56844. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56845. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56846. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56847. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  56848. /**
  56849. * Block used to get the view direction
  56850. */
  56851. export class ViewDirectionBlock extends NodeMaterialBlock {
  56852. /**
  56853. * Creates a new ViewDirectionBlock
  56854. * @param name defines the block name
  56855. */
  56856. constructor(name: string);
  56857. /**
  56858. * Gets the current class name
  56859. * @returns the class name
  56860. */
  56861. getClassName(): string;
  56862. /**
  56863. * Gets the world position component
  56864. */
  56865. readonly worldPosition: NodeMaterialConnectionPoint;
  56866. /**
  56867. * Gets the camera position component
  56868. */
  56869. readonly cameraPosition: NodeMaterialConnectionPoint;
  56870. /**
  56871. * Gets the output component
  56872. */
  56873. readonly output: NodeMaterialConnectionPoint;
  56874. autoConfigure(material: NodeMaterial): void;
  56875. protected _buildBlock(state: NodeMaterialBuildState): this;
  56876. }
  56877. }
  56878. declare module "babylonjs/Materials/Node/Blocks/fresnelBlock" {
  56879. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56880. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56881. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56882. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  56883. /**
  56884. * Block used to compute fresnel value
  56885. */
  56886. export class FresnelBlock extends NodeMaterialBlock {
  56887. /**
  56888. * Create a new FresnelBlock
  56889. * @param name defines the block name
  56890. */
  56891. constructor(name: string);
  56892. /**
  56893. * Gets the current class name
  56894. * @returns the class name
  56895. */
  56896. getClassName(): string;
  56897. /**
  56898. * Gets the world normal input component
  56899. */
  56900. readonly worldNormal: NodeMaterialConnectionPoint;
  56901. /**
  56902. * Gets the view direction input component
  56903. */
  56904. readonly viewDirection: NodeMaterialConnectionPoint;
  56905. /**
  56906. * Gets the bias input component
  56907. */
  56908. readonly bias: NodeMaterialConnectionPoint;
  56909. /**
  56910. * Gets the camera (or eye) position component
  56911. */
  56912. readonly power: NodeMaterialConnectionPoint;
  56913. /**
  56914. * Gets the fresnel output component
  56915. */
  56916. readonly fresnel: NodeMaterialConnectionPoint;
  56917. autoConfigure(material: NodeMaterial): void;
  56918. protected _buildBlock(state: NodeMaterialBuildState): this;
  56919. }
  56920. }
  56921. declare module "babylonjs/Materials/Node/Blocks/maxBlock" {
  56922. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56923. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56924. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56925. /**
  56926. * Block used to get the max of 2 values
  56927. */
  56928. export class MaxBlock extends NodeMaterialBlock {
  56929. /**
  56930. * Creates a new MaxBlock
  56931. * @param name defines the block name
  56932. */
  56933. constructor(name: string);
  56934. /**
  56935. * Gets the current class name
  56936. * @returns the class name
  56937. */
  56938. getClassName(): string;
  56939. /**
  56940. * Gets the left operand input component
  56941. */
  56942. readonly left: NodeMaterialConnectionPoint;
  56943. /**
  56944. * Gets the right operand input component
  56945. */
  56946. readonly right: NodeMaterialConnectionPoint;
  56947. /**
  56948. * Gets the output component
  56949. */
  56950. readonly output: NodeMaterialConnectionPoint;
  56951. protected _buildBlock(state: NodeMaterialBuildState): this;
  56952. }
  56953. }
  56954. declare module "babylonjs/Materials/Node/Blocks/minBlock" {
  56955. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56956. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56957. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56958. /**
  56959. * Block used to get the min of 2 values
  56960. */
  56961. export class MinBlock extends NodeMaterialBlock {
  56962. /**
  56963. * Creates a new MinBlock
  56964. * @param name defines the block name
  56965. */
  56966. constructor(name: string);
  56967. /**
  56968. * Gets the current class name
  56969. * @returns the class name
  56970. */
  56971. getClassName(): string;
  56972. /**
  56973. * Gets the left operand input component
  56974. */
  56975. readonly left: NodeMaterialConnectionPoint;
  56976. /**
  56977. * Gets the right operand input component
  56978. */
  56979. readonly right: NodeMaterialConnectionPoint;
  56980. /**
  56981. * Gets the output component
  56982. */
  56983. readonly output: NodeMaterialConnectionPoint;
  56984. protected _buildBlock(state: NodeMaterialBuildState): this;
  56985. }
  56986. }
  56987. declare module "babylonjs/Materials/Node/Blocks/index" {
  56988. export * from "babylonjs/Materials/Node/Blocks/Vertex/index";
  56989. export * from "babylonjs/Materials/Node/Blocks/Fragment/index";
  56990. export * from "babylonjs/Materials/Node/Blocks/Dual/index";
  56991. export * from "babylonjs/Materials/Node/Blocks/Input/index";
  56992. export * from "babylonjs/Materials/Node/Blocks/multiplyBlock";
  56993. export * from "babylonjs/Materials/Node/Blocks/addBlock";
  56994. export * from "babylonjs/Materials/Node/Blocks/scaleBlock";
  56995. export * from "babylonjs/Materials/Node/Blocks/clampBlock";
  56996. export * from "babylonjs/Materials/Node/Blocks/crossBlock";
  56997. export * from "babylonjs/Materials/Node/Blocks/dotBlock";
  56998. export * from "babylonjs/Materials/Node/Blocks/transformBlock";
  56999. export * from "babylonjs/Materials/Node/Blocks/remapBlock";
  57000. export * from "babylonjs/Materials/Node/Blocks/normalizeBlock";
  57001. export * from "babylonjs/Materials/Node/Blocks/trigonometryBlock";
  57002. export * from "babylonjs/Materials/Node/Blocks/colorMergerBlock";
  57003. export * from "babylonjs/Materials/Node/Blocks/vectorMergerBlock";
  57004. export * from "babylonjs/Materials/Node/Blocks/colorSplitterBlock";
  57005. export * from "babylonjs/Materials/Node/Blocks/vectorSplitterBlock";
  57006. export * from "babylonjs/Materials/Node/Blocks/lerpBlock";
  57007. export * from "babylonjs/Materials/Node/Blocks/divideBlock";
  57008. export * from "babylonjs/Materials/Node/Blocks/subtractBlock";
  57009. export * from "babylonjs/Materials/Node/Blocks/stepBlock";
  57010. export * from "babylonjs/Materials/Node/Blocks/oppositeBlock";
  57011. export * from "babylonjs/Materials/Node/Blocks/viewDirectionBlock";
  57012. export * from "babylonjs/Materials/Node/Blocks/fresnelBlock";
  57013. export * from "babylonjs/Materials/Node/Blocks/maxBlock";
  57014. export * from "babylonjs/Materials/Node/Blocks/minBlock";
  57015. }
  57016. declare module "babylonjs/Materials/Node/Optimizers/index" {
  57017. export * from "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer";
  57018. }
  57019. declare module "babylonjs/Materials/Node/index" {
  57020. export * from "babylonjs/Materials/Node/nodeMaterialBlockTargets";
  57021. export * from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPointTypes";
  57022. export * from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57023. export * from "babylonjs/Materials/Node/nodeMaterialBlock";
  57024. export * from "babylonjs/Materials/Node/nodeMaterial";
  57025. export * from "babylonjs/Materials/Node/nodeMaterialSystemValues";
  57026. export * from "babylonjs/Materials/Node/Blocks/index";
  57027. export * from "babylonjs/Materials/Node/Optimizers/index";
  57028. }
  57029. declare module "babylonjs/Materials/effectRenderer" {
  57030. import { Nullable } from "babylonjs/types";
  57031. import { Texture } from "babylonjs/Materials/Textures/texture";
  57032. import { Engine } from "babylonjs/Engines/engine";
  57033. import { Viewport } from "babylonjs/Maths/math.viewport";
  57034. import { Observable } from "babylonjs/Misc/observable";
  57035. import { Effect } from "babylonjs/Materials/effect";
  57036. import "babylonjs/Shaders/postprocess.vertex";
  57037. /**
  57038. * Effect Render Options
  57039. */
  57040. export interface IEffectRendererOptions {
  57041. /**
  57042. * Defines the vertices positions.
  57043. */
  57044. positions?: number[];
  57045. /**
  57046. * Defines the indices.
  57047. */
  57048. indices?: number[];
  57049. }
  57050. /**
  57051. * Helper class to render one or more effects
  57052. */
  57053. export class EffectRenderer {
  57054. private engine;
  57055. private static _DefaultOptions;
  57056. private _vertexBuffers;
  57057. private _indexBuffer;
  57058. private _ringBufferIndex;
  57059. private _ringScreenBuffer;
  57060. private _fullscreenViewport;
  57061. private _getNextFrameBuffer;
  57062. /**
  57063. * Creates an effect renderer
  57064. * @param engine the engine to use for rendering
  57065. * @param options defines the options of the effect renderer
  57066. */
  57067. constructor(engine: Engine, options?: IEffectRendererOptions);
  57068. /**
  57069. * Sets the current viewport in normalized coordinates 0-1
  57070. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  57071. */
  57072. setViewport(viewport?: Viewport): void;
  57073. /**
  57074. * Binds the embedded attributes buffer to the effect.
  57075. * @param effect Defines the effect to bind the attributes for
  57076. */
  57077. bindBuffers(effect: Effect): void;
  57078. /**
  57079. * Sets the current effect wrapper to use during draw.
  57080. * The effect needs to be ready before calling this api.
  57081. * This also sets the default full screen position attribute.
  57082. * @param effectWrapper Defines the effect to draw with
  57083. */
  57084. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  57085. /**
  57086. * Draws a full screen quad.
  57087. */
  57088. draw(): void;
  57089. /**
  57090. * renders one or more effects to a specified texture
  57091. * @param effectWrappers list of effects to renderer
  57092. * @param outputTexture texture to draw to, if null it will render to the screen
  57093. */
  57094. render(effectWrappers: Array<EffectWrapper> | EffectWrapper, outputTexture?: Nullable<Texture>): void;
  57095. /**
  57096. * Disposes of the effect renderer
  57097. */
  57098. dispose(): void;
  57099. }
  57100. /**
  57101. * Options to create an EffectWrapper
  57102. */
  57103. interface EffectWrapperCreationOptions {
  57104. /**
  57105. * Engine to use to create the effect
  57106. */
  57107. engine: Engine;
  57108. /**
  57109. * Fragment shader for the effect
  57110. */
  57111. fragmentShader: string;
  57112. /**
  57113. * Vertex shader for the effect
  57114. */
  57115. vertexShader?: string;
  57116. /**
  57117. * Attributes to use in the shader
  57118. */
  57119. attributeNames?: Array<string>;
  57120. /**
  57121. * Uniforms to use in the shader
  57122. */
  57123. uniformNames?: Array<string>;
  57124. /**
  57125. * Texture sampler names to use in the shader
  57126. */
  57127. samplerNames?: Array<string>;
  57128. /**
  57129. * The friendly name of the effect displayed in Spector.
  57130. */
  57131. name?: string;
  57132. }
  57133. /**
  57134. * Wraps an effect to be used for rendering
  57135. */
  57136. export class EffectWrapper {
  57137. /**
  57138. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  57139. */
  57140. onApplyObservable: Observable<{}>;
  57141. /**
  57142. * The underlying effect
  57143. */
  57144. effect: Effect;
  57145. /**
  57146. * Creates an effect to be renderer
  57147. * @param creationOptions options to create the effect
  57148. */
  57149. constructor(creationOptions: EffectWrapperCreationOptions);
  57150. /**
  57151. * Disposes of the effect wrapper
  57152. */
  57153. dispose(): void;
  57154. }
  57155. }
  57156. declare module "babylonjs/Materials/index" {
  57157. export * from "babylonjs/Materials/Background/index";
  57158. export * from "babylonjs/Materials/colorCurves";
  57159. export * from "babylonjs/Materials/effect";
  57160. export * from "babylonjs/Materials/fresnelParameters";
  57161. export * from "babylonjs/Materials/imageProcessingConfiguration";
  57162. export * from "babylonjs/Materials/material";
  57163. export * from "babylonjs/Materials/materialDefines";
  57164. export * from "babylonjs/Materials/materialHelper";
  57165. export * from "babylonjs/Materials/multiMaterial";
  57166. export * from "babylonjs/Materials/PBR/index";
  57167. export * from "babylonjs/Materials/pushMaterial";
  57168. export * from "babylonjs/Materials/shaderMaterial";
  57169. export * from "babylonjs/Materials/standardMaterial";
  57170. export * from "babylonjs/Materials/Textures/index";
  57171. export * from "babylonjs/Materials/uniformBuffer";
  57172. export * from "babylonjs/Materials/materialFlags";
  57173. export * from "babylonjs/Materials/Node/index";
  57174. export * from "babylonjs/Materials/effectRenderer";
  57175. }
  57176. declare module "babylonjs/Maths/index" {
  57177. export * from "babylonjs/Maths/math.scalar";
  57178. export * from "babylonjs/Maths/math";
  57179. export * from "babylonjs/Maths/sphericalPolynomial";
  57180. }
  57181. declare module "babylonjs/Misc/workerPool" {
  57182. import { IDisposable } from "babylonjs/scene";
  57183. /**
  57184. * Helper class to push actions to a pool of workers.
  57185. */
  57186. export class WorkerPool implements IDisposable {
  57187. private _workerInfos;
  57188. private _pendingActions;
  57189. /**
  57190. * Constructor
  57191. * @param workers Array of workers to use for actions
  57192. */
  57193. constructor(workers: Array<Worker>);
  57194. /**
  57195. * Terminates all workers and clears any pending actions.
  57196. */
  57197. dispose(): void;
  57198. /**
  57199. * Pushes an action to the worker pool. If all the workers are active, the action will be
  57200. * pended until a worker has completed its action.
  57201. * @param action The action to perform. Call onComplete when the action is complete.
  57202. */
  57203. push(action: (worker: Worker, onComplete: () => void) => void): void;
  57204. private _execute;
  57205. }
  57206. }
  57207. declare module "babylonjs/Meshes/Compression/dracoCompression" {
  57208. import { IDisposable } from "babylonjs/scene";
  57209. import { VertexData } from "babylonjs/Meshes/mesh.vertexData";
  57210. /**
  57211. * Configuration for Draco compression
  57212. */
  57213. export interface IDracoCompressionConfiguration {
  57214. /**
  57215. * Configuration for the decoder.
  57216. */
  57217. decoder: {
  57218. /**
  57219. * The url to the WebAssembly module.
  57220. */
  57221. wasmUrl?: string;
  57222. /**
  57223. * The url to the WebAssembly binary.
  57224. */
  57225. wasmBinaryUrl?: string;
  57226. /**
  57227. * The url to the fallback JavaScript module.
  57228. */
  57229. fallbackUrl?: string;
  57230. };
  57231. }
  57232. /**
  57233. * Draco compression (https://google.github.io/draco/)
  57234. *
  57235. * This class wraps the Draco module.
  57236. *
  57237. * **Encoder**
  57238. *
  57239. * The encoder is not currently implemented.
  57240. *
  57241. * **Decoder**
  57242. *
  57243. * 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.
  57244. *
  57245. * To update the configuration, use the following code:
  57246. * ```javascript
  57247. * DracoCompression.Configuration = {
  57248. * decoder: {
  57249. * wasmUrl: "<url to the WebAssembly library>",
  57250. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  57251. * fallbackUrl: "<url to the fallback JavaScript library>",
  57252. * }
  57253. * };
  57254. * ```
  57255. *
  57256. * 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.
  57257. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  57258. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  57259. *
  57260. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  57261. * ```javascript
  57262. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  57263. * ```
  57264. *
  57265. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  57266. */
  57267. export class DracoCompression implements IDisposable {
  57268. private _workerPoolPromise?;
  57269. private _decoderModulePromise?;
  57270. /**
  57271. * The configuration. Defaults to the following urls:
  57272. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  57273. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  57274. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  57275. */
  57276. static Configuration: IDracoCompressionConfiguration;
  57277. /**
  57278. * Returns true if the decoder configuration is available.
  57279. */
  57280. static readonly DecoderAvailable: boolean;
  57281. /**
  57282. * Default number of workers to create when creating the draco compression object.
  57283. */
  57284. static DefaultNumWorkers: number;
  57285. private static GetDefaultNumWorkers;
  57286. private static _Default;
  57287. /**
  57288. * Default instance for the draco compression object.
  57289. */
  57290. static readonly Default: DracoCompression;
  57291. /**
  57292. * Constructor
  57293. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  57294. */
  57295. constructor(numWorkers?: number);
  57296. /**
  57297. * Stop all async operations and release resources.
  57298. */
  57299. dispose(): void;
  57300. /**
  57301. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  57302. * @returns a promise that resolves when ready
  57303. */
  57304. whenReadyAsync(): Promise<void>;
  57305. /**
  57306. * Decode Draco compressed mesh data to vertex data.
  57307. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  57308. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  57309. * @returns A promise that resolves with the decoded vertex data
  57310. */
  57311. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  57312. [kind: string]: number;
  57313. }): Promise<VertexData>;
  57314. }
  57315. }
  57316. declare module "babylonjs/Meshes/Compression/index" {
  57317. export * from "babylonjs/Meshes/Compression/dracoCompression";
  57318. }
  57319. declare module "babylonjs/Meshes/csg" {
  57320. import { Nullable } from "babylonjs/types";
  57321. import { Scene } from "babylonjs/scene";
  57322. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  57323. import { Mesh } from "babylonjs/Meshes/mesh";
  57324. import { Material } from "babylonjs/Materials/material";
  57325. /**
  57326. * Class for building Constructive Solid Geometry
  57327. */
  57328. export class CSG {
  57329. private polygons;
  57330. /**
  57331. * The world matrix
  57332. */
  57333. matrix: Matrix;
  57334. /**
  57335. * Stores the position
  57336. */
  57337. position: Vector3;
  57338. /**
  57339. * Stores the rotation
  57340. */
  57341. rotation: Vector3;
  57342. /**
  57343. * Stores the rotation quaternion
  57344. */
  57345. rotationQuaternion: Nullable<Quaternion>;
  57346. /**
  57347. * Stores the scaling vector
  57348. */
  57349. scaling: Vector3;
  57350. /**
  57351. * Convert the Mesh to CSG
  57352. * @param mesh The Mesh to convert to CSG
  57353. * @returns A new CSG from the Mesh
  57354. */
  57355. static FromMesh(mesh: Mesh): CSG;
  57356. /**
  57357. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  57358. * @param polygons Polygons used to construct a CSG solid
  57359. */
  57360. private static FromPolygons;
  57361. /**
  57362. * Clones, or makes a deep copy, of the CSG
  57363. * @returns A new CSG
  57364. */
  57365. clone(): CSG;
  57366. /**
  57367. * Unions this CSG with another CSG
  57368. * @param csg The CSG to union against this CSG
  57369. * @returns The unioned CSG
  57370. */
  57371. union(csg: CSG): CSG;
  57372. /**
  57373. * Unions this CSG with another CSG in place
  57374. * @param csg The CSG to union against this CSG
  57375. */
  57376. unionInPlace(csg: CSG): void;
  57377. /**
  57378. * Subtracts this CSG with another CSG
  57379. * @param csg The CSG to subtract against this CSG
  57380. * @returns A new CSG
  57381. */
  57382. subtract(csg: CSG): CSG;
  57383. /**
  57384. * Subtracts this CSG with another CSG in place
  57385. * @param csg The CSG to subtact against this CSG
  57386. */
  57387. subtractInPlace(csg: CSG): void;
  57388. /**
  57389. * Intersect this CSG with another CSG
  57390. * @param csg The CSG to intersect against this CSG
  57391. * @returns A new CSG
  57392. */
  57393. intersect(csg: CSG): CSG;
  57394. /**
  57395. * Intersects this CSG with another CSG in place
  57396. * @param csg The CSG to intersect against this CSG
  57397. */
  57398. intersectInPlace(csg: CSG): void;
  57399. /**
  57400. * Return a new CSG solid with solid and empty space switched. This solid is
  57401. * not modified.
  57402. * @returns A new CSG solid with solid and empty space switched
  57403. */
  57404. inverse(): CSG;
  57405. /**
  57406. * Inverses the CSG in place
  57407. */
  57408. inverseInPlace(): void;
  57409. /**
  57410. * This is used to keep meshes transformations so they can be restored
  57411. * when we build back a Babylon Mesh
  57412. * NB : All CSG operations are performed in world coordinates
  57413. * @param csg The CSG to copy the transform attributes from
  57414. * @returns This CSG
  57415. */
  57416. copyTransformAttributes(csg: CSG): CSG;
  57417. /**
  57418. * Build Raw mesh from CSG
  57419. * Coordinates here are in world space
  57420. * @param name The name of the mesh geometry
  57421. * @param scene The Scene
  57422. * @param keepSubMeshes Specifies if the submeshes should be kept
  57423. * @returns A new Mesh
  57424. */
  57425. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  57426. /**
  57427. * Build Mesh from CSG taking material and transforms into account
  57428. * @param name The name of the Mesh
  57429. * @param material The material of the Mesh
  57430. * @param scene The Scene
  57431. * @param keepSubMeshes Specifies if submeshes should be kept
  57432. * @returns The new Mesh
  57433. */
  57434. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  57435. }
  57436. }
  57437. declare module "babylonjs/Meshes/trailMesh" {
  57438. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57439. import { Mesh } from "babylonjs/Meshes/mesh";
  57440. import { Scene } from "babylonjs/scene";
  57441. /**
  57442. * Class used to create a trail following a mesh
  57443. */
  57444. export class TrailMesh extends Mesh {
  57445. private _generator;
  57446. private _autoStart;
  57447. private _running;
  57448. private _diameter;
  57449. private _length;
  57450. private _sectionPolygonPointsCount;
  57451. private _sectionVectors;
  57452. private _sectionNormalVectors;
  57453. private _beforeRenderObserver;
  57454. /**
  57455. * @constructor
  57456. * @param name The value used by scene.getMeshByName() to do a lookup.
  57457. * @param generator The mesh to generate a trail.
  57458. * @param scene The scene to add this mesh to.
  57459. * @param diameter Diameter of trailing mesh. Default is 1.
  57460. * @param length Length of trailing mesh. Default is 60.
  57461. * @param autoStart Automatically start trailing mesh. Default true.
  57462. */
  57463. constructor(name: string, generator: AbstractMesh, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  57464. /**
  57465. * "TrailMesh"
  57466. * @returns "TrailMesh"
  57467. */
  57468. getClassName(): string;
  57469. private _createMesh;
  57470. /**
  57471. * Start trailing mesh.
  57472. */
  57473. start(): void;
  57474. /**
  57475. * Stop trailing mesh.
  57476. */
  57477. stop(): void;
  57478. /**
  57479. * Update trailing mesh geometry.
  57480. */
  57481. update(): void;
  57482. /**
  57483. * Returns a new TrailMesh object.
  57484. * @param name is a string, the name given to the new mesh
  57485. * @param newGenerator use new generator object for cloned trail mesh
  57486. * @returns a new mesh
  57487. */
  57488. clone(name: string | undefined, newGenerator: AbstractMesh): TrailMesh;
  57489. /**
  57490. * Serializes this trail mesh
  57491. * @param serializationObject object to write serialization to
  57492. */
  57493. serialize(serializationObject: any): void;
  57494. /**
  57495. * Parses a serialized trail mesh
  57496. * @param parsedMesh the serialized mesh
  57497. * @param scene the scene to create the trail mesh in
  57498. * @returns the created trail mesh
  57499. */
  57500. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  57501. }
  57502. }
  57503. declare module "babylonjs/Meshes/Builders/tiledBoxBuilder" {
  57504. import { Nullable } from "babylonjs/types";
  57505. import { Scene } from "babylonjs/scene";
  57506. import { Vector4 } from "babylonjs/Maths/math.vector";
  57507. import { Color4 } from "babylonjs/Maths/math.color";
  57508. import { Mesh } from "babylonjs/Meshes/mesh";
  57509. /**
  57510. * Class containing static functions to help procedurally build meshes
  57511. */
  57512. export class TiledBoxBuilder {
  57513. /**
  57514. * Creates a box mesh
  57515. * 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)
  57516. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  57517. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  57518. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  57519. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  57520. * @param name defines the name of the mesh
  57521. * @param options defines the options used to create the mesh
  57522. * @param scene defines the hosting scene
  57523. * @returns the box mesh
  57524. */
  57525. static CreateTiledBox(name: string, options: {
  57526. pattern?: number;
  57527. width?: number;
  57528. height?: number;
  57529. depth?: number;
  57530. tileSize?: number;
  57531. tileWidth?: number;
  57532. tileHeight?: number;
  57533. alignHorizontal?: number;
  57534. alignVertical?: number;
  57535. faceUV?: Vector4[];
  57536. faceColors?: Color4[];
  57537. sideOrientation?: number;
  57538. updatable?: boolean;
  57539. }, scene?: Nullable<Scene>): Mesh;
  57540. }
  57541. }
  57542. declare module "babylonjs/Meshes/Builders/torusKnotBuilder" {
  57543. import { Vector4 } from "babylonjs/Maths/math.vector";
  57544. import { Mesh } from "babylonjs/Meshes/mesh";
  57545. /**
  57546. * Class containing static functions to help procedurally build meshes
  57547. */
  57548. export class TorusKnotBuilder {
  57549. /**
  57550. * Creates a torus knot mesh
  57551. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  57552. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  57553. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  57554. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  57555. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  57556. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  57557. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  57558. * @param name defines the name of the mesh
  57559. * @param options defines the options used to create the mesh
  57560. * @param scene defines the hosting scene
  57561. * @returns the torus knot mesh
  57562. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  57563. */
  57564. static CreateTorusKnot(name: string, options: {
  57565. radius?: number;
  57566. tube?: number;
  57567. radialSegments?: number;
  57568. tubularSegments?: number;
  57569. p?: number;
  57570. q?: number;
  57571. updatable?: boolean;
  57572. sideOrientation?: number;
  57573. frontUVs?: Vector4;
  57574. backUVs?: Vector4;
  57575. }, scene: any): Mesh;
  57576. }
  57577. }
  57578. declare module "babylonjs/Meshes/polygonMesh" {
  57579. import { Scene } from "babylonjs/scene";
  57580. import { Vector2 } from "babylonjs/Maths/math.vector";
  57581. import { Mesh } from "babylonjs/Meshes/mesh";
  57582. import { VertexData } from "babylonjs/Meshes/mesh.vertexData";
  57583. import { Path2 } from "babylonjs/Maths/math.path";
  57584. /**
  57585. * Polygon
  57586. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  57587. */
  57588. export class Polygon {
  57589. /**
  57590. * Creates a rectangle
  57591. * @param xmin bottom X coord
  57592. * @param ymin bottom Y coord
  57593. * @param xmax top X coord
  57594. * @param ymax top Y coord
  57595. * @returns points that make the resulting rectation
  57596. */
  57597. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  57598. /**
  57599. * Creates a circle
  57600. * @param radius radius of circle
  57601. * @param cx scale in x
  57602. * @param cy scale in y
  57603. * @param numberOfSides number of sides that make up the circle
  57604. * @returns points that make the resulting circle
  57605. */
  57606. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  57607. /**
  57608. * Creates a polygon from input string
  57609. * @param input Input polygon data
  57610. * @returns the parsed points
  57611. */
  57612. static Parse(input: string): Vector2[];
  57613. /**
  57614. * Starts building a polygon from x and y coordinates
  57615. * @param x x coordinate
  57616. * @param y y coordinate
  57617. * @returns the started path2
  57618. */
  57619. static StartingAt(x: number, y: number): Path2;
  57620. }
  57621. /**
  57622. * Builds a polygon
  57623. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  57624. */
  57625. export class PolygonMeshBuilder {
  57626. private _points;
  57627. private _outlinepoints;
  57628. private _holes;
  57629. private _name;
  57630. private _scene;
  57631. private _epoints;
  57632. private _eholes;
  57633. private _addToepoint;
  57634. /**
  57635. * Babylon reference to the earcut plugin.
  57636. */
  57637. bjsEarcut: any;
  57638. /**
  57639. * Creates a PolygonMeshBuilder
  57640. * @param name name of the builder
  57641. * @param contours Path of the polygon
  57642. * @param scene scene to add to when creating the mesh
  57643. * @param earcutInjection can be used to inject your own earcut reference
  57644. */
  57645. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  57646. /**
  57647. * Adds a whole within the polygon
  57648. * @param hole Array of points defining the hole
  57649. * @returns this
  57650. */
  57651. addHole(hole: Vector2[]): PolygonMeshBuilder;
  57652. /**
  57653. * Creates the polygon
  57654. * @param updatable If the mesh should be updatable
  57655. * @param depth The depth of the mesh created
  57656. * @returns the created mesh
  57657. */
  57658. build(updatable?: boolean, depth?: number): Mesh;
  57659. /**
  57660. * Creates the polygon
  57661. * @param depth The depth of the mesh created
  57662. * @returns the created VertexData
  57663. */
  57664. buildVertexData(depth?: number): VertexData;
  57665. /**
  57666. * Adds a side to the polygon
  57667. * @param positions points that make the polygon
  57668. * @param normals normals of the polygon
  57669. * @param uvs uvs of the polygon
  57670. * @param indices indices of the polygon
  57671. * @param bounds bounds of the polygon
  57672. * @param points points of the polygon
  57673. * @param depth depth of the polygon
  57674. * @param flip flip of the polygon
  57675. */
  57676. private addSide;
  57677. }
  57678. }
  57679. declare module "babylonjs/Meshes/Builders/polygonBuilder" {
  57680. import { Scene } from "babylonjs/scene";
  57681. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  57682. import { Color4 } from "babylonjs/Maths/math.color";
  57683. import { Mesh } from "babylonjs/Meshes/mesh";
  57684. import { Nullable } from "babylonjs/types";
  57685. /**
  57686. * Class containing static functions to help procedurally build meshes
  57687. */
  57688. export class PolygonBuilder {
  57689. /**
  57690. * Creates a polygon mesh
  57691. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  57692. * * 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
  57693. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  57694. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  57695. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  57696. * * Remember you can only change the shape positions, not their number when updating a polygon
  57697. * @param name defines the name of the mesh
  57698. * @param options defines the options used to create the mesh
  57699. * @param scene defines the hosting scene
  57700. * @param earcutInjection can be used to inject your own earcut reference
  57701. * @returns the polygon mesh
  57702. */
  57703. static CreatePolygon(name: string, options: {
  57704. shape: Vector3[];
  57705. holes?: Vector3[][];
  57706. depth?: number;
  57707. faceUV?: Vector4[];
  57708. faceColors?: Color4[];
  57709. updatable?: boolean;
  57710. sideOrientation?: number;
  57711. frontUVs?: Vector4;
  57712. backUVs?: Vector4;
  57713. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  57714. /**
  57715. * Creates an extruded polygon mesh, with depth in the Y direction.
  57716. * * 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)
  57717. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  57718. * @param name defines the name of the mesh
  57719. * @param options defines the options used to create the mesh
  57720. * @param scene defines the hosting scene
  57721. * @param earcutInjection can be used to inject your own earcut reference
  57722. * @returns the polygon mesh
  57723. */
  57724. static ExtrudePolygon(name: string, options: {
  57725. shape: Vector3[];
  57726. holes?: Vector3[][];
  57727. depth?: number;
  57728. faceUV?: Vector4[];
  57729. faceColors?: Color4[];
  57730. updatable?: boolean;
  57731. sideOrientation?: number;
  57732. frontUVs?: Vector4;
  57733. backUVs?: Vector4;
  57734. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  57735. }
  57736. }
  57737. declare module "babylonjs/Meshes/Builders/latheBuilder" {
  57738. import { Scene } from "babylonjs/scene";
  57739. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  57740. import { Mesh } from "babylonjs/Meshes/mesh";
  57741. import { Nullable } from "babylonjs/types";
  57742. /**
  57743. * Class containing static functions to help procedurally build meshes
  57744. */
  57745. export class LatheBuilder {
  57746. /**
  57747. * Creates lathe mesh.
  57748. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  57749. * * 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
  57750. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  57751. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  57752. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  57753. * * 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
  57754. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  57755. * * 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
  57756. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  57757. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  57758. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  57759. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  57760. * @param name defines the name of the mesh
  57761. * @param options defines the options used to create the mesh
  57762. * @param scene defines the hosting scene
  57763. * @returns the lathe mesh
  57764. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  57765. */
  57766. static CreateLathe(name: string, options: {
  57767. shape: Vector3[];
  57768. radius?: number;
  57769. tessellation?: number;
  57770. clip?: number;
  57771. arc?: number;
  57772. closed?: boolean;
  57773. updatable?: boolean;
  57774. sideOrientation?: number;
  57775. frontUVs?: Vector4;
  57776. backUVs?: Vector4;
  57777. cap?: number;
  57778. invertUV?: boolean;
  57779. }, scene?: Nullable<Scene>): Mesh;
  57780. }
  57781. }
  57782. declare module "babylonjs/Meshes/Builders/tiledPlaneBuilder" {
  57783. import { Nullable } from "babylonjs/types";
  57784. import { Scene } from "babylonjs/scene";
  57785. import { Vector4 } from "babylonjs/Maths/math.vector";
  57786. import { Mesh } from "babylonjs/Meshes/mesh";
  57787. /**
  57788. * Class containing static functions to help procedurally build meshes
  57789. */
  57790. export class TiledPlaneBuilder {
  57791. /**
  57792. * Creates a tiled plane mesh
  57793. * * The parameter `pattern` will, depending on value, do nothing or
  57794. * * * flip (reflect about central vertical) alternate tiles across and up
  57795. * * * flip every tile on alternate rows
  57796. * * * rotate (180 degs) alternate tiles across and up
  57797. * * * rotate every tile on alternate rows
  57798. * * * flip and rotate alternate tiles across and up
  57799. * * * flip and rotate every tile on alternate rows
  57800. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  57801. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  57802. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  57803. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  57804. * * 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)
  57805. * * 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)
  57806. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  57807. * @param name defines the name of the mesh
  57808. * @param options defines the options used to create the mesh
  57809. * @param scene defines the hosting scene
  57810. * @returns the box mesh
  57811. */
  57812. static CreateTiledPlane(name: string, options: {
  57813. pattern?: number;
  57814. tileSize?: number;
  57815. tileWidth?: number;
  57816. tileHeight?: number;
  57817. size?: number;
  57818. width?: number;
  57819. height?: number;
  57820. alignHorizontal?: number;
  57821. alignVertical?: number;
  57822. sideOrientation?: number;
  57823. frontUVs?: Vector4;
  57824. backUVs?: Vector4;
  57825. updatable?: boolean;
  57826. }, scene?: Nullable<Scene>): Mesh;
  57827. }
  57828. }
  57829. declare module "babylonjs/Meshes/Builders/tubeBuilder" {
  57830. import { Nullable } from "babylonjs/types";
  57831. import { Scene } from "babylonjs/scene";
  57832. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  57833. import { Mesh } from "babylonjs/Meshes/mesh";
  57834. /**
  57835. * Class containing static functions to help procedurally build meshes
  57836. */
  57837. export class TubeBuilder {
  57838. /**
  57839. * Creates a tube mesh.
  57840. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  57841. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  57842. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  57843. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  57844. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  57845. * * 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)
  57846. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  57847. * * 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
  57848. * * 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
  57849. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  57850. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  57851. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  57852. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  57853. * @param name defines the name of the mesh
  57854. * @param options defines the options used to create the mesh
  57855. * @param scene defines the hosting scene
  57856. * @returns the tube mesh
  57857. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  57858. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  57859. */
  57860. static CreateTube(name: string, options: {
  57861. path: Vector3[];
  57862. radius?: number;
  57863. tessellation?: number;
  57864. radiusFunction?: {
  57865. (i: number, distance: number): number;
  57866. };
  57867. cap?: number;
  57868. arc?: number;
  57869. updatable?: boolean;
  57870. sideOrientation?: number;
  57871. frontUVs?: Vector4;
  57872. backUVs?: Vector4;
  57873. instance?: Mesh;
  57874. invertUV?: boolean;
  57875. }, scene?: Nullable<Scene>): Mesh;
  57876. }
  57877. }
  57878. declare module "babylonjs/Meshes/Builders/icoSphereBuilder" {
  57879. import { Scene } from "babylonjs/scene";
  57880. import { Vector4 } from "babylonjs/Maths/math.vector";
  57881. import { Mesh } from "babylonjs/Meshes/mesh";
  57882. import { Nullable } from "babylonjs/types";
  57883. /**
  57884. * Class containing static functions to help procedurally build meshes
  57885. */
  57886. export class IcoSphereBuilder {
  57887. /**
  57888. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  57889. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  57890. * * 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`)
  57891. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  57892. * * 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
  57893. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  57894. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  57895. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  57896. * @param name defines the name of the mesh
  57897. * @param options defines the options used to create the mesh
  57898. * @param scene defines the hosting scene
  57899. * @returns the icosahedron mesh
  57900. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  57901. */
  57902. static CreateIcoSphere(name: string, options: {
  57903. radius?: number;
  57904. radiusX?: number;
  57905. radiusY?: number;
  57906. radiusZ?: number;
  57907. flat?: boolean;
  57908. subdivisions?: number;
  57909. sideOrientation?: number;
  57910. frontUVs?: Vector4;
  57911. backUVs?: Vector4;
  57912. updatable?: boolean;
  57913. }, scene?: Nullable<Scene>): Mesh;
  57914. }
  57915. }
  57916. declare module "babylonjs/Meshes/Builders/decalBuilder" {
  57917. import { Vector3 } from "babylonjs/Maths/math.vector";
  57918. import { Mesh } from "babylonjs/Meshes/mesh";
  57919. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57920. /**
  57921. * Class containing static functions to help procedurally build meshes
  57922. */
  57923. export class DecalBuilder {
  57924. /**
  57925. * Creates a decal mesh.
  57926. * 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
  57927. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  57928. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  57929. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  57930. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  57931. * @param name defines the name of the mesh
  57932. * @param sourceMesh defines the mesh where the decal must be applied
  57933. * @param options defines the options used to create the mesh
  57934. * @param scene defines the hosting scene
  57935. * @returns the decal mesh
  57936. * @see https://doc.babylonjs.com/how_to/decals
  57937. */
  57938. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  57939. position?: Vector3;
  57940. normal?: Vector3;
  57941. size?: Vector3;
  57942. angle?: number;
  57943. }): Mesh;
  57944. }
  57945. }
  57946. declare module "babylonjs/Meshes/meshBuilder" {
  57947. import { Vector4, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  57948. import { Nullable } from "babylonjs/types";
  57949. import { Scene } from "babylonjs/scene";
  57950. import { Mesh } from "babylonjs/Meshes/mesh";
  57951. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  57952. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  57953. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57954. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  57955. import { Plane } from "babylonjs/Maths/math.plane";
  57956. /**
  57957. * Class containing static functions to help procedurally build meshes
  57958. */
  57959. export class MeshBuilder {
  57960. /**
  57961. * Creates a box mesh
  57962. * * The parameter `size` sets the size (float) of each box side (default 1)
  57963. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  57964. * * 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)
  57965. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  57966. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  57967. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  57968. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  57969. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  57970. * @param name defines the name of the mesh
  57971. * @param options defines the options used to create the mesh
  57972. * @param scene defines the hosting scene
  57973. * @returns the box mesh
  57974. */
  57975. static CreateBox(name: string, options: {
  57976. size?: number;
  57977. width?: number;
  57978. height?: number;
  57979. depth?: number;
  57980. faceUV?: Vector4[];
  57981. faceColors?: Color4[];
  57982. sideOrientation?: number;
  57983. frontUVs?: Vector4;
  57984. backUVs?: Vector4;
  57985. updatable?: boolean;
  57986. }, scene?: Nullable<Scene>): Mesh;
  57987. /**
  57988. * Creates a tiled box mesh
  57989. * * faceTiles sets the pattern, tile size and number of tiles for a face
  57990. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  57991. * @param name defines the name of the mesh
  57992. * @param options defines the options used to create the mesh
  57993. * @param scene defines the hosting scene
  57994. * @returns the tiled box mesh
  57995. */
  57996. static CreateTiledBox(name: string, options: {
  57997. pattern?: number;
  57998. size?: number;
  57999. width?: number;
  58000. height?: number;
  58001. depth: number;
  58002. tileSize?: number;
  58003. tileWidth?: number;
  58004. tileHeight?: number;
  58005. faceUV?: Vector4[];
  58006. faceColors?: Color4[];
  58007. alignHorizontal?: number;
  58008. alignVertical?: number;
  58009. sideOrientation?: number;
  58010. updatable?: boolean;
  58011. }, scene?: Nullable<Scene>): Mesh;
  58012. /**
  58013. * Creates a sphere mesh
  58014. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  58015. * * 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`)
  58016. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  58017. * * 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
  58018. * * 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)
  58019. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58020. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  58021. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58022. * @param name defines the name of the mesh
  58023. * @param options defines the options used to create the mesh
  58024. * @param scene defines the hosting scene
  58025. * @returns the sphere mesh
  58026. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  58027. */
  58028. static CreateSphere(name: string, options: {
  58029. segments?: number;
  58030. diameter?: number;
  58031. diameterX?: number;
  58032. diameterY?: number;
  58033. diameterZ?: number;
  58034. arc?: number;
  58035. slice?: number;
  58036. sideOrientation?: number;
  58037. frontUVs?: Vector4;
  58038. backUVs?: Vector4;
  58039. updatable?: boolean;
  58040. }, scene?: Nullable<Scene>): Mesh;
  58041. /**
  58042. * Creates a plane polygonal mesh. By default, this is a disc
  58043. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  58044. * * 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
  58045. * * 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
  58046. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58047. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  58048. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58049. * @param name defines the name of the mesh
  58050. * @param options defines the options used to create the mesh
  58051. * @param scene defines the hosting scene
  58052. * @returns the plane polygonal mesh
  58053. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  58054. */
  58055. static CreateDisc(name: string, options: {
  58056. radius?: number;
  58057. tessellation?: number;
  58058. arc?: number;
  58059. updatable?: boolean;
  58060. sideOrientation?: number;
  58061. frontUVs?: Vector4;
  58062. backUVs?: Vector4;
  58063. }, scene?: Nullable<Scene>): Mesh;
  58064. /**
  58065. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  58066. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  58067. * * 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`)
  58068. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  58069. * * 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
  58070. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58071. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  58072. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58073. * @param name defines the name of the mesh
  58074. * @param options defines the options used to create the mesh
  58075. * @param scene defines the hosting scene
  58076. * @returns the icosahedron mesh
  58077. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  58078. */
  58079. static CreateIcoSphere(name: string, options: {
  58080. radius?: number;
  58081. radiusX?: number;
  58082. radiusY?: number;
  58083. radiusZ?: number;
  58084. flat?: boolean;
  58085. subdivisions?: number;
  58086. sideOrientation?: number;
  58087. frontUVs?: Vector4;
  58088. backUVs?: Vector4;
  58089. updatable?: boolean;
  58090. }, scene?: Nullable<Scene>): Mesh;
  58091. /**
  58092. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  58093. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  58094. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  58095. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  58096. * * 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
  58097. * * 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
  58098. * * 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
  58099. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58100. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  58101. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  58102. * * 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
  58103. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  58104. * * 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
  58105. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  58106. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58107. * @param name defines the name of the mesh
  58108. * @param options defines the options used to create the mesh
  58109. * @param scene defines the hosting scene
  58110. * @returns the ribbon mesh
  58111. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  58112. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  58113. */
  58114. static CreateRibbon(name: string, options: {
  58115. pathArray: Vector3[][];
  58116. closeArray?: boolean;
  58117. closePath?: boolean;
  58118. offset?: number;
  58119. updatable?: boolean;
  58120. sideOrientation?: number;
  58121. frontUVs?: Vector4;
  58122. backUVs?: Vector4;
  58123. instance?: Mesh;
  58124. invertUV?: boolean;
  58125. uvs?: Vector2[];
  58126. colors?: Color4[];
  58127. }, scene?: Nullable<Scene>): Mesh;
  58128. /**
  58129. * Creates a cylinder or a cone mesh
  58130. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  58131. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  58132. * * 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.
  58133. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  58134. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  58135. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  58136. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  58137. * * 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).
  58138. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  58139. * * 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).
  58140. * * 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
  58141. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  58142. * * 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
  58143. * * 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.
  58144. * * If `enclose` is false, a ring surface is one element.
  58145. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  58146. * * 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
  58147. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58148. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  58149. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  58150. * @param name defines the name of the mesh
  58151. * @param options defines the options used to create the mesh
  58152. * @param scene defines the hosting scene
  58153. * @returns the cylinder mesh
  58154. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  58155. */
  58156. static CreateCylinder(name: string, options: {
  58157. height?: number;
  58158. diameterTop?: number;
  58159. diameterBottom?: number;
  58160. diameter?: number;
  58161. tessellation?: number;
  58162. subdivisions?: number;
  58163. arc?: number;
  58164. faceColors?: Color4[];
  58165. faceUV?: Vector4[];
  58166. updatable?: boolean;
  58167. hasRings?: boolean;
  58168. enclose?: boolean;
  58169. cap?: number;
  58170. sideOrientation?: number;
  58171. frontUVs?: Vector4;
  58172. backUVs?: Vector4;
  58173. }, scene?: Nullable<Scene>): Mesh;
  58174. /**
  58175. * Creates a torus mesh
  58176. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  58177. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  58178. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  58179. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58180. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  58181. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  58182. * @param name defines the name of the mesh
  58183. * @param options defines the options used to create the mesh
  58184. * @param scene defines the hosting scene
  58185. * @returns the torus mesh
  58186. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  58187. */
  58188. static CreateTorus(name: string, options: {
  58189. diameter?: number;
  58190. thickness?: number;
  58191. tessellation?: number;
  58192. updatable?: boolean;
  58193. sideOrientation?: number;
  58194. frontUVs?: Vector4;
  58195. backUVs?: Vector4;
  58196. }, scene?: Nullable<Scene>): Mesh;
  58197. /**
  58198. * Creates a torus knot mesh
  58199. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  58200. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  58201. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  58202. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  58203. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58204. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  58205. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  58206. * @param name defines the name of the mesh
  58207. * @param options defines the options used to create the mesh
  58208. * @param scene defines the hosting scene
  58209. * @returns the torus knot mesh
  58210. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  58211. */
  58212. static CreateTorusKnot(name: string, options: {
  58213. radius?: number;
  58214. tube?: number;
  58215. radialSegments?: number;
  58216. tubularSegments?: number;
  58217. p?: number;
  58218. q?: number;
  58219. updatable?: boolean;
  58220. sideOrientation?: number;
  58221. frontUVs?: Vector4;
  58222. backUVs?: Vector4;
  58223. }, scene?: Nullable<Scene>): Mesh;
  58224. /**
  58225. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  58226. * * 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
  58227. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  58228. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  58229. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  58230. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  58231. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  58232. * * 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
  58233. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  58234. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58235. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  58236. * @param name defines the name of the new line system
  58237. * @param options defines the options used to create the line system
  58238. * @param scene defines the hosting scene
  58239. * @returns a new line system mesh
  58240. */
  58241. static CreateLineSystem(name: string, options: {
  58242. lines: Vector3[][];
  58243. updatable?: boolean;
  58244. instance?: Nullable<LinesMesh>;
  58245. colors?: Nullable<Color4[][]>;
  58246. useVertexAlpha?: boolean;
  58247. }, scene: Nullable<Scene>): LinesMesh;
  58248. /**
  58249. * Creates a line mesh
  58250. * 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
  58251. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  58252. * * The parameter `points` is an array successive Vector3
  58253. * * 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
  58254. * * The optional parameter `colors` is an array of successive Color4, one per line point
  58255. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  58256. * * When updating an instance, remember that only point positions can change, not the number of points
  58257. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58258. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  58259. * @param name defines the name of the new line system
  58260. * @param options defines the options used to create the line system
  58261. * @param scene defines the hosting scene
  58262. * @returns a new line mesh
  58263. */
  58264. static CreateLines(name: string, options: {
  58265. points: Vector3[];
  58266. updatable?: boolean;
  58267. instance?: Nullable<LinesMesh>;
  58268. colors?: Color4[];
  58269. useVertexAlpha?: boolean;
  58270. }, scene?: Nullable<Scene>): LinesMesh;
  58271. /**
  58272. * Creates a dashed line mesh
  58273. * * 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
  58274. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  58275. * * The parameter `points` is an array successive Vector3
  58276. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  58277. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  58278. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  58279. * * 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
  58280. * * When updating an instance, remember that only point positions can change, not the number of points
  58281. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58282. * @param name defines the name of the mesh
  58283. * @param options defines the options used to create the mesh
  58284. * @param scene defines the hosting scene
  58285. * @returns the dashed line mesh
  58286. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  58287. */
  58288. static CreateDashedLines(name: string, options: {
  58289. points: Vector3[];
  58290. dashSize?: number;
  58291. gapSize?: number;
  58292. dashNb?: number;
  58293. updatable?: boolean;
  58294. instance?: LinesMesh;
  58295. }, scene?: Nullable<Scene>): LinesMesh;
  58296. /**
  58297. * 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.
  58298. * * 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.
  58299. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  58300. * * 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.
  58301. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  58302. * * 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
  58303. * * 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
  58304. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  58305. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58306. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  58307. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  58308. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  58309. * @param name defines the name of the mesh
  58310. * @param options defines the options used to create the mesh
  58311. * @param scene defines the hosting scene
  58312. * @returns the extruded shape mesh
  58313. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  58314. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  58315. */
  58316. static ExtrudeShape(name: string, options: {
  58317. shape: Vector3[];
  58318. path: Vector3[];
  58319. scale?: number;
  58320. rotation?: number;
  58321. cap?: number;
  58322. updatable?: boolean;
  58323. sideOrientation?: number;
  58324. frontUVs?: Vector4;
  58325. backUVs?: Vector4;
  58326. instance?: Mesh;
  58327. invertUV?: boolean;
  58328. }, scene?: Nullable<Scene>): Mesh;
  58329. /**
  58330. * Creates an custom extruded shape mesh.
  58331. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  58332. * * 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.
  58333. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  58334. * * 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
  58335. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  58336. * * 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
  58337. * * It must returns a float value that will be the scale value applied to the shape on each path point
  58338. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  58339. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  58340. * * 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
  58341. * * 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
  58342. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  58343. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58344. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  58345. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  58346. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58347. * @param name defines the name of the mesh
  58348. * @param options defines the options used to create the mesh
  58349. * @param scene defines the hosting scene
  58350. * @returns the custom extruded shape mesh
  58351. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  58352. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  58353. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  58354. */
  58355. static ExtrudeShapeCustom(name: string, options: {
  58356. shape: Vector3[];
  58357. path: Vector3[];
  58358. scaleFunction?: any;
  58359. rotationFunction?: any;
  58360. ribbonCloseArray?: boolean;
  58361. ribbonClosePath?: boolean;
  58362. cap?: number;
  58363. updatable?: boolean;
  58364. sideOrientation?: number;
  58365. frontUVs?: Vector4;
  58366. backUVs?: Vector4;
  58367. instance?: Mesh;
  58368. invertUV?: boolean;
  58369. }, scene?: Nullable<Scene>): Mesh;
  58370. /**
  58371. * Creates lathe mesh.
  58372. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  58373. * * 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
  58374. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  58375. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  58376. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  58377. * * 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
  58378. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  58379. * * 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
  58380. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58381. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  58382. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  58383. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58384. * @param name defines the name of the mesh
  58385. * @param options defines the options used to create the mesh
  58386. * @param scene defines the hosting scene
  58387. * @returns the lathe mesh
  58388. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  58389. */
  58390. static CreateLathe(name: string, options: {
  58391. shape: Vector3[];
  58392. radius?: number;
  58393. tessellation?: number;
  58394. clip?: number;
  58395. arc?: number;
  58396. closed?: boolean;
  58397. updatable?: boolean;
  58398. sideOrientation?: number;
  58399. frontUVs?: Vector4;
  58400. backUVs?: Vector4;
  58401. cap?: number;
  58402. invertUV?: boolean;
  58403. }, scene?: Nullable<Scene>): Mesh;
  58404. /**
  58405. * Creates a tiled plane mesh
  58406. * * You can set a limited pattern arrangement with the tiles
  58407. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58408. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  58409. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58410. * @param name defines the name of the mesh
  58411. * @param options defines the options used to create the mesh
  58412. * @param scene defines the hosting scene
  58413. * @returns the plane mesh
  58414. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  58415. */
  58416. static CreateTiledPlane(name: string, options: {
  58417. pattern?: number;
  58418. tileSize?: number;
  58419. tileWidth?: number;
  58420. tileHeight?: number;
  58421. size?: number;
  58422. width?: number;
  58423. height?: number;
  58424. alignHorizontal?: number;
  58425. alignVertical?: number;
  58426. sideOrientation?: number;
  58427. frontUVs?: Vector4;
  58428. backUVs?: Vector4;
  58429. updatable?: boolean;
  58430. }, scene?: Nullable<Scene>): Mesh;
  58431. /**
  58432. * Creates a plane mesh
  58433. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  58434. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  58435. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  58436. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58437. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  58438. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58439. * @param name defines the name of the mesh
  58440. * @param options defines the options used to create the mesh
  58441. * @param scene defines the hosting scene
  58442. * @returns the plane mesh
  58443. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  58444. */
  58445. static CreatePlane(name: string, options: {
  58446. size?: number;
  58447. width?: number;
  58448. height?: number;
  58449. sideOrientation?: number;
  58450. frontUVs?: Vector4;
  58451. backUVs?: Vector4;
  58452. updatable?: boolean;
  58453. sourcePlane?: Plane;
  58454. }, scene?: Nullable<Scene>): Mesh;
  58455. /**
  58456. * Creates a ground mesh
  58457. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  58458. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  58459. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58460. * @param name defines the name of the mesh
  58461. * @param options defines the options used to create the mesh
  58462. * @param scene defines the hosting scene
  58463. * @returns the ground mesh
  58464. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  58465. */
  58466. static CreateGround(name: string, options: {
  58467. width?: number;
  58468. height?: number;
  58469. subdivisions?: number;
  58470. subdivisionsX?: number;
  58471. subdivisionsY?: number;
  58472. updatable?: boolean;
  58473. }, scene?: Nullable<Scene>): Mesh;
  58474. /**
  58475. * Creates a tiled ground mesh
  58476. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  58477. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  58478. * * 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
  58479. * * 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
  58480. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  58481. * @param name defines the name of the mesh
  58482. * @param options defines the options used to create the mesh
  58483. * @param scene defines the hosting scene
  58484. * @returns the tiled ground mesh
  58485. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  58486. */
  58487. static CreateTiledGround(name: string, options: {
  58488. xmin: number;
  58489. zmin: number;
  58490. xmax: number;
  58491. zmax: number;
  58492. subdivisions?: {
  58493. w: number;
  58494. h: number;
  58495. };
  58496. precision?: {
  58497. w: number;
  58498. h: number;
  58499. };
  58500. updatable?: boolean;
  58501. }, scene?: Nullable<Scene>): Mesh;
  58502. /**
  58503. * Creates a ground mesh from a height map
  58504. * * The parameter `url` sets the URL of the height map image resource.
  58505. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  58506. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  58507. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  58508. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  58509. * * 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.
  58510. * * 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).
  58511. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  58512. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  58513. * @param name defines the name of the mesh
  58514. * @param url defines the url to the height map
  58515. * @param options defines the options used to create the mesh
  58516. * @param scene defines the hosting scene
  58517. * @returns the ground mesh
  58518. * @see https://doc.babylonjs.com/babylon101/height_map
  58519. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  58520. */
  58521. static CreateGroundFromHeightMap(name: string, url: string, options: {
  58522. width?: number;
  58523. height?: number;
  58524. subdivisions?: number;
  58525. minHeight?: number;
  58526. maxHeight?: number;
  58527. colorFilter?: Color3;
  58528. alphaFilter?: number;
  58529. updatable?: boolean;
  58530. onReady?: (mesh: GroundMesh) => void;
  58531. }, scene?: Nullable<Scene>): GroundMesh;
  58532. /**
  58533. * Creates a polygon mesh
  58534. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  58535. * * 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
  58536. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  58537. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58538. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  58539. * * Remember you can only change the shape positions, not their number when updating a polygon
  58540. * @param name defines the name of the mesh
  58541. * @param options defines the options used to create the mesh
  58542. * @param scene defines the hosting scene
  58543. * @param earcutInjection can be used to inject your own earcut reference
  58544. * @returns the polygon mesh
  58545. */
  58546. static CreatePolygon(name: string, options: {
  58547. shape: Vector3[];
  58548. holes?: Vector3[][];
  58549. depth?: number;
  58550. faceUV?: Vector4[];
  58551. faceColors?: Color4[];
  58552. updatable?: boolean;
  58553. sideOrientation?: number;
  58554. frontUVs?: Vector4;
  58555. backUVs?: Vector4;
  58556. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  58557. /**
  58558. * Creates an extruded polygon mesh, with depth in the Y direction.
  58559. * * 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)
  58560. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  58561. * @param name defines the name of the mesh
  58562. * @param options defines the options used to create the mesh
  58563. * @param scene defines the hosting scene
  58564. * @param earcutInjection can be used to inject your own earcut reference
  58565. * @returns the polygon mesh
  58566. */
  58567. static ExtrudePolygon(name: string, options: {
  58568. shape: Vector3[];
  58569. holes?: Vector3[][];
  58570. depth?: number;
  58571. faceUV?: Vector4[];
  58572. faceColors?: Color4[];
  58573. updatable?: boolean;
  58574. sideOrientation?: number;
  58575. frontUVs?: Vector4;
  58576. backUVs?: Vector4;
  58577. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  58578. /**
  58579. * Creates a tube mesh.
  58580. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  58581. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  58582. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  58583. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  58584. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  58585. * * 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)
  58586. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  58587. * * 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
  58588. * * 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
  58589. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58590. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  58591. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  58592. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58593. * @param name defines the name of the mesh
  58594. * @param options defines the options used to create the mesh
  58595. * @param scene defines the hosting scene
  58596. * @returns the tube mesh
  58597. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  58598. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  58599. */
  58600. static CreateTube(name: string, options: {
  58601. path: Vector3[];
  58602. radius?: number;
  58603. tessellation?: number;
  58604. radiusFunction?: {
  58605. (i: number, distance: number): number;
  58606. };
  58607. cap?: number;
  58608. arc?: number;
  58609. updatable?: boolean;
  58610. sideOrientation?: number;
  58611. frontUVs?: Vector4;
  58612. backUVs?: Vector4;
  58613. instance?: Mesh;
  58614. invertUV?: boolean;
  58615. }, scene?: Nullable<Scene>): Mesh;
  58616. /**
  58617. * Creates a polyhedron mesh
  58618. * * 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
  58619. * * The parameter `size` (positive float, default 1) sets the polygon size
  58620. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  58621. * * 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`
  58622. * * 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
  58623. * * 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)`)
  58624. * * 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
  58625. * * 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
  58626. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58627. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  58628. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58629. * @param name defines the name of the mesh
  58630. * @param options defines the options used to create the mesh
  58631. * @param scene defines the hosting scene
  58632. * @returns the polyhedron mesh
  58633. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  58634. */
  58635. static CreatePolyhedron(name: string, options: {
  58636. type?: number;
  58637. size?: number;
  58638. sizeX?: number;
  58639. sizeY?: number;
  58640. sizeZ?: number;
  58641. custom?: any;
  58642. faceUV?: Vector4[];
  58643. faceColors?: Color4[];
  58644. flat?: boolean;
  58645. updatable?: boolean;
  58646. sideOrientation?: number;
  58647. frontUVs?: Vector4;
  58648. backUVs?: Vector4;
  58649. }, scene?: Nullable<Scene>): Mesh;
  58650. /**
  58651. * Creates a decal mesh.
  58652. * 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
  58653. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  58654. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  58655. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  58656. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  58657. * @param name defines the name of the mesh
  58658. * @param sourceMesh defines the mesh where the decal must be applied
  58659. * @param options defines the options used to create the mesh
  58660. * @param scene defines the hosting scene
  58661. * @returns the decal mesh
  58662. * @see https://doc.babylonjs.com/how_to/decals
  58663. */
  58664. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  58665. position?: Vector3;
  58666. normal?: Vector3;
  58667. size?: Vector3;
  58668. angle?: number;
  58669. }): Mesh;
  58670. }
  58671. }
  58672. declare module "babylonjs/Meshes/meshSimplification" {
  58673. import { Mesh } from "babylonjs/Meshes/mesh";
  58674. /**
  58675. * A simplifier interface for future simplification implementations
  58676. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  58677. */
  58678. export interface ISimplifier {
  58679. /**
  58680. * Simplification of a given mesh according to the given settings.
  58681. * Since this requires computation, it is assumed that the function runs async.
  58682. * @param settings The settings of the simplification, including quality and distance
  58683. * @param successCallback A callback that will be called after the mesh was simplified.
  58684. * @param errorCallback in case of an error, this callback will be called. optional.
  58685. */
  58686. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  58687. }
  58688. /**
  58689. * Expected simplification settings.
  58690. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  58691. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  58692. */
  58693. export interface ISimplificationSettings {
  58694. /**
  58695. * Gets or sets the expected quality
  58696. */
  58697. quality: number;
  58698. /**
  58699. * Gets or sets the distance when this optimized version should be used
  58700. */
  58701. distance: number;
  58702. /**
  58703. * Gets an already optimized mesh
  58704. */
  58705. optimizeMesh?: boolean;
  58706. }
  58707. /**
  58708. * Class used to specify simplification options
  58709. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  58710. */
  58711. export class SimplificationSettings implements ISimplificationSettings {
  58712. /** expected quality */
  58713. quality: number;
  58714. /** distance when this optimized version should be used */
  58715. distance: number;
  58716. /** already optimized mesh */
  58717. optimizeMesh?: boolean | undefined;
  58718. /**
  58719. * Creates a SimplificationSettings
  58720. * @param quality expected quality
  58721. * @param distance distance when this optimized version should be used
  58722. * @param optimizeMesh already optimized mesh
  58723. */
  58724. constructor(
  58725. /** expected quality */
  58726. quality: number,
  58727. /** distance when this optimized version should be used */
  58728. distance: number,
  58729. /** already optimized mesh */
  58730. optimizeMesh?: boolean | undefined);
  58731. }
  58732. /**
  58733. * Interface used to define a simplification task
  58734. */
  58735. export interface ISimplificationTask {
  58736. /**
  58737. * Array of settings
  58738. */
  58739. settings: Array<ISimplificationSettings>;
  58740. /**
  58741. * Simplification type
  58742. */
  58743. simplificationType: SimplificationType;
  58744. /**
  58745. * Mesh to simplify
  58746. */
  58747. mesh: Mesh;
  58748. /**
  58749. * Callback called on success
  58750. */
  58751. successCallback?: () => void;
  58752. /**
  58753. * Defines if parallel processing can be used
  58754. */
  58755. parallelProcessing: boolean;
  58756. }
  58757. /**
  58758. * Queue used to order the simplification tasks
  58759. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  58760. */
  58761. export class SimplificationQueue {
  58762. private _simplificationArray;
  58763. /**
  58764. * Gets a boolean indicating that the process is still running
  58765. */
  58766. running: boolean;
  58767. /**
  58768. * Creates a new queue
  58769. */
  58770. constructor();
  58771. /**
  58772. * Adds a new simplification task
  58773. * @param task defines a task to add
  58774. */
  58775. addTask(task: ISimplificationTask): void;
  58776. /**
  58777. * Execute next task
  58778. */
  58779. executeNext(): void;
  58780. /**
  58781. * Execute a simplification task
  58782. * @param task defines the task to run
  58783. */
  58784. runSimplification(task: ISimplificationTask): void;
  58785. private getSimplifier;
  58786. }
  58787. /**
  58788. * The implemented types of simplification
  58789. * At the moment only Quadratic Error Decimation is implemented
  58790. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  58791. */
  58792. export enum SimplificationType {
  58793. /** Quadratic error decimation */
  58794. QUADRATIC = 0
  58795. }
  58796. }
  58797. declare module "babylonjs/Meshes/meshSimplificationSceneComponent" {
  58798. import { Scene } from "babylonjs/scene";
  58799. import { SimplificationQueue, ISimplificationSettings, SimplificationType } from "babylonjs/Meshes/meshSimplification";
  58800. import { ISceneComponent } from "babylonjs/sceneComponent";
  58801. module "babylonjs/scene" {
  58802. interface Scene {
  58803. /** @hidden (Backing field) */
  58804. _simplificationQueue: SimplificationQueue;
  58805. /**
  58806. * Gets or sets the simplification queue attached to the scene
  58807. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  58808. */
  58809. simplificationQueue: SimplificationQueue;
  58810. }
  58811. }
  58812. module "babylonjs/Meshes/mesh" {
  58813. interface Mesh {
  58814. /**
  58815. * Simplify the mesh according to the given array of settings.
  58816. * Function will return immediately and will simplify async
  58817. * @param settings a collection of simplification settings
  58818. * @param parallelProcessing should all levels calculate parallel or one after the other
  58819. * @param simplificationType the type of simplification to run
  58820. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  58821. * @returns the current mesh
  58822. */
  58823. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  58824. }
  58825. }
  58826. /**
  58827. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  58828. * created in a scene
  58829. */
  58830. export class SimplicationQueueSceneComponent implements ISceneComponent {
  58831. /**
  58832. * The component name helpfull to identify the component in the list of scene components.
  58833. */
  58834. readonly name: string;
  58835. /**
  58836. * The scene the component belongs to.
  58837. */
  58838. scene: Scene;
  58839. /**
  58840. * Creates a new instance of the component for the given scene
  58841. * @param scene Defines the scene to register the component in
  58842. */
  58843. constructor(scene: Scene);
  58844. /**
  58845. * Registers the component in a given scene
  58846. */
  58847. register(): void;
  58848. /**
  58849. * Rebuilds the elements related to this component in case of
  58850. * context lost for instance.
  58851. */
  58852. rebuild(): void;
  58853. /**
  58854. * Disposes the component and the associated ressources
  58855. */
  58856. dispose(): void;
  58857. private _beforeCameraUpdate;
  58858. }
  58859. }
  58860. declare module "babylonjs/Meshes/Builders/index" {
  58861. export * from "babylonjs/Meshes/Builders/boxBuilder";
  58862. export * from "babylonjs/Meshes/Builders/tiledBoxBuilder";
  58863. export * from "babylonjs/Meshes/Builders/discBuilder";
  58864. export * from "babylonjs/Meshes/Builders/ribbonBuilder";
  58865. export * from "babylonjs/Meshes/Builders/sphereBuilder";
  58866. export * from "babylonjs/Meshes/Builders/hemisphereBuilder";
  58867. export * from "babylonjs/Meshes/Builders/cylinderBuilder";
  58868. export * from "babylonjs/Meshes/Builders/torusBuilder";
  58869. export * from "babylonjs/Meshes/Builders/torusKnotBuilder";
  58870. export * from "babylonjs/Meshes/Builders/linesBuilder";
  58871. export * from "babylonjs/Meshes/Builders/polygonBuilder";
  58872. export * from "babylonjs/Meshes/Builders/shapeBuilder";
  58873. export * from "babylonjs/Meshes/Builders/latheBuilder";
  58874. export * from "babylonjs/Meshes/Builders/planeBuilder";
  58875. export * from "babylonjs/Meshes/Builders/tiledPlaneBuilder";
  58876. export * from "babylonjs/Meshes/Builders/groundBuilder";
  58877. export * from "babylonjs/Meshes/Builders/tubeBuilder";
  58878. export * from "babylonjs/Meshes/Builders/polyhedronBuilder";
  58879. export * from "babylonjs/Meshes/Builders/icoSphereBuilder";
  58880. export * from "babylonjs/Meshes/Builders/decalBuilder";
  58881. }
  58882. declare module "babylonjs/Meshes/index" {
  58883. export * from "babylonjs/Meshes/abstractMesh";
  58884. export * from "babylonjs/Meshes/buffer";
  58885. export * from "babylonjs/Meshes/Compression/index";
  58886. export * from "babylonjs/Meshes/csg";
  58887. export * from "babylonjs/Meshes/geometry";
  58888. export * from "babylonjs/Meshes/groundMesh";
  58889. export * from "babylonjs/Meshes/trailMesh";
  58890. export * from "babylonjs/Meshes/instancedMesh";
  58891. export * from "babylonjs/Meshes/linesMesh";
  58892. export * from "babylonjs/Meshes/mesh";
  58893. export * from "babylonjs/Meshes/mesh.vertexData";
  58894. export * from "babylonjs/Meshes/meshBuilder";
  58895. export * from "babylonjs/Meshes/meshSimplification";
  58896. export * from "babylonjs/Meshes/meshSimplificationSceneComponent";
  58897. export * from "babylonjs/Meshes/polygonMesh";
  58898. export * from "babylonjs/Meshes/subMesh";
  58899. export * from "babylonjs/Meshes/meshLODLevel";
  58900. export * from "babylonjs/Meshes/transformNode";
  58901. export * from "babylonjs/Meshes/Builders/index";
  58902. export * from "babylonjs/Meshes/dataBuffer";
  58903. export * from "babylonjs/Meshes/WebGL/webGLDataBuffer";
  58904. }
  58905. declare module "babylonjs/Morph/index" {
  58906. export * from "babylonjs/Morph/morphTarget";
  58907. export * from "babylonjs/Morph/morphTargetManager";
  58908. }
  58909. declare module "babylonjs/Navigation/INavigationEngine" {
  58910. import { TransformNode } from "babylonjs/Meshes/transformNode";
  58911. import { Vector3 } from "babylonjs/Maths/math";
  58912. import { Mesh } from "babylonjs/Meshes/mesh";
  58913. import { Scene } from "babylonjs/scene";
  58914. /**
  58915. * Navigation plugin interface to add navigation constrained by a navigation mesh
  58916. */
  58917. export interface INavigationEnginePlugin {
  58918. /**
  58919. * plugin name
  58920. */
  58921. name: string;
  58922. /**
  58923. * Creates a navigation mesh
  58924. * @param meshes array of all the geometry used to compute the navigatio mesh
  58925. * @param parameters bunch of parameters used to filter geometry
  58926. */
  58927. createMavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  58928. /**
  58929. * Create a navigation mesh debug mesh
  58930. * @param scene is where the mesh will be added
  58931. * @returns debug display mesh
  58932. */
  58933. createDebugNavMesh(scene: Scene): Mesh;
  58934. /**
  58935. * Get a navigation mesh constrained position, closest to the parameter position
  58936. * @param position world position
  58937. * @returns the closest point to position constrained by the navigation mesh
  58938. */
  58939. getClosestPoint(position: Vector3): Vector3;
  58940. /**
  58941. * Get a navigation mesh constrained position, within a particular radius
  58942. * @param position world position
  58943. * @param maxRadius the maximum distance to the constrained world position
  58944. * @returns the closest point to position constrained by the navigation mesh
  58945. */
  58946. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  58947. /**
  58948. * Compute the final position from a segment made of destination-position
  58949. * @param position world position
  58950. * @param destination world position
  58951. * @returns the resulting point along the navmesh
  58952. */
  58953. moveAlong(position: Vector3, destination: Vector3): Vector3;
  58954. /**
  58955. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  58956. * @param start world position
  58957. * @param end world position
  58958. * @returns array containing world position composing the path
  58959. */
  58960. computePath(start: Vector3, end: Vector3): Vector3[];
  58961. /**
  58962. * If this plugin is supported
  58963. * @returns true if plugin is supported
  58964. */
  58965. isSupported(): boolean;
  58966. /**
  58967. * Create a new Crowd so you can add agents
  58968. * @param maxAgents the maximum agent count in the crowd
  58969. * @param maxAgentRadius the maximum radius an agent can have
  58970. * @param scene to attach the crowd to
  58971. * @returns the crowd you can add agents to
  58972. */
  58973. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  58974. /**
  58975. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  58976. * The queries will try to find a solution within those bounds
  58977. * default is (1,1,1)
  58978. * @param extent x,y,z value that define the extent around the queries point of reference
  58979. */
  58980. setDefaultQueryExtent(extent: Vector3): void;
  58981. /**
  58982. * Get the Bounding box extent specified by setDefaultQueryExtent
  58983. * @returns the box extent values
  58984. */
  58985. getDefaultQueryExtent(): Vector3;
  58986. /**
  58987. * Release all resources
  58988. */
  58989. dispose(): void;
  58990. }
  58991. /**
  58992. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  58993. */
  58994. export interface ICrowd {
  58995. /**
  58996. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  58997. * You can attach anything to that node. The node position is updated in the scene update tick.
  58998. * @param pos world position that will be constrained by the navigation mesh
  58999. * @param parameters agent parameters
  59000. * @param transform hooked to the agent that will be update by the scene
  59001. * @returns agent index
  59002. */
  59003. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  59004. /**
  59005. * Returns the agent position in world space
  59006. * @param index agent index returned by addAgent
  59007. * @returns world space position
  59008. */
  59009. getAgentPosition(index: number): Vector3;
  59010. /**
  59011. * Gets the agent velocity in world space
  59012. * @param index agent index returned by addAgent
  59013. * @returns world space velocity
  59014. */
  59015. getAgentVelocity(index: number): Vector3;
  59016. /**
  59017. * remove a particular agent previously created
  59018. * @param index agent index returned by addAgent
  59019. */
  59020. removeAgent(index: number): void;
  59021. /**
  59022. * get the list of all agents attached to this crowd
  59023. * @returns list of agent indices
  59024. */
  59025. getAgents(): number[];
  59026. /**
  59027. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  59028. * @param deltaTime in seconds
  59029. */
  59030. update(deltaTime: number): void;
  59031. /**
  59032. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  59033. * @param index agent index returned by addAgent
  59034. * @param destination targeted world position
  59035. */
  59036. agentGoto(index: number, destination: Vector3): void;
  59037. /**
  59038. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  59039. * The queries will try to find a solution within those bounds
  59040. * default is (1,1,1)
  59041. * @param extent x,y,z value that define the extent around the queries point of reference
  59042. */
  59043. setDefaultQueryExtent(extent: Vector3): void;
  59044. /**
  59045. * Get the Bounding box extent specified by setDefaultQueryExtent
  59046. * @returns the box extent values
  59047. */
  59048. getDefaultQueryExtent(): Vector3;
  59049. /**
  59050. * Release all resources
  59051. */
  59052. dispose(): void;
  59053. }
  59054. /**
  59055. * Configures an agent
  59056. */
  59057. export interface IAgentParameters {
  59058. /**
  59059. * Agent radius. [Limit: >= 0]
  59060. */
  59061. radius: number;
  59062. /**
  59063. * Agent height. [Limit: > 0]
  59064. */
  59065. height: number;
  59066. /**
  59067. * Maximum allowed acceleration. [Limit: >= 0]
  59068. */
  59069. maxAcceleration: number;
  59070. /**
  59071. * Maximum allowed speed. [Limit: >= 0]
  59072. */
  59073. maxSpeed: number;
  59074. /**
  59075. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  59076. */
  59077. collisionQueryRange: number;
  59078. /**
  59079. * The path visibility optimization range. [Limit: > 0]
  59080. */
  59081. pathOptimizationRange: number;
  59082. /**
  59083. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  59084. */
  59085. separationWeight: number;
  59086. }
  59087. /**
  59088. * Configures the navigation mesh creation
  59089. */
  59090. export interface INavMeshParameters {
  59091. /**
  59092. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  59093. */
  59094. cs: number;
  59095. /**
  59096. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  59097. */
  59098. ch: number;
  59099. /**
  59100. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  59101. */
  59102. walkableSlopeAngle: number;
  59103. /**
  59104. * Minimum floor to 'ceiling' height that will still allow the floor area to
  59105. * be considered walkable. [Limit: >= 3] [Units: vx]
  59106. */
  59107. walkableHeight: number;
  59108. /**
  59109. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  59110. */
  59111. walkableClimb: number;
  59112. /**
  59113. * The distance to erode/shrink the walkable area of the heightfield away from
  59114. * obstructions. [Limit: >=0] [Units: vx]
  59115. */
  59116. walkableRadius: number;
  59117. /**
  59118. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  59119. */
  59120. maxEdgeLen: number;
  59121. /**
  59122. * The maximum distance a simplfied contour's border edges should deviate
  59123. * the original raw contour. [Limit: >=0] [Units: vx]
  59124. */
  59125. maxSimplificationError: number;
  59126. /**
  59127. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  59128. */
  59129. minRegionArea: number;
  59130. /**
  59131. * Any regions with a span count smaller than this value will, if possible,
  59132. * be merged with larger regions. [Limit: >=0] [Units: vx]
  59133. */
  59134. mergeRegionArea: number;
  59135. /**
  59136. * The maximum number of vertices allowed for polygons generated during the
  59137. * contour to polygon conversion process. [Limit: >= 3]
  59138. */
  59139. maxVertsPerPoly: number;
  59140. /**
  59141. * Sets the sampling distance to use when generating the detail mesh.
  59142. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  59143. */
  59144. detailSampleDist: number;
  59145. /**
  59146. * The maximum distance the detail mesh surface should deviate from heightfield
  59147. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  59148. */
  59149. detailSampleMaxError: number;
  59150. }
  59151. }
  59152. declare module "babylonjs/Navigation/Plugins/recastJSPlugin" {
  59153. import { INavigationEnginePlugin, ICrowd, IAgentParameters, INavMeshParameters } from "babylonjs/Navigation/INavigationEngine";
  59154. import { Mesh } from "babylonjs/Meshes/mesh";
  59155. import { Scene } from "babylonjs/scene";
  59156. import { Vector3 } from "babylonjs/Maths/math";
  59157. import { TransformNode } from "babylonjs/Meshes/transformNode";
  59158. /**
  59159. * RecastJS navigation plugin
  59160. */
  59161. export class RecastJSPlugin implements INavigationEnginePlugin {
  59162. /**
  59163. * Reference to the Recast library
  59164. */
  59165. bjsRECAST: any;
  59166. /**
  59167. * plugin name
  59168. */
  59169. name: string;
  59170. /**
  59171. * the first navmesh created. We might extend this to support multiple navmeshes
  59172. */
  59173. navMesh: any;
  59174. /**
  59175. * Initializes the recastJS plugin
  59176. * @param recastInjection can be used to inject your own recast reference
  59177. */
  59178. constructor(recastInjection?: any);
  59179. /**
  59180. * Creates a navigation mesh
  59181. * @param meshes array of all the geometry used to compute the navigatio mesh
  59182. * @param parameters bunch of parameters used to filter geometry
  59183. */
  59184. createMavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  59185. /**
  59186. * Create a navigation mesh debug mesh
  59187. * @param scene is where the mesh will be added
  59188. * @returns debug display mesh
  59189. */
  59190. createDebugNavMesh(scene: Scene): Mesh;
  59191. /**
  59192. * Get a navigation mesh constrained position, closest to the parameter position
  59193. * @param position world position
  59194. * @returns the closest point to position constrained by the navigation mesh
  59195. */
  59196. getClosestPoint(position: Vector3): Vector3;
  59197. /**
  59198. * Get a navigation mesh constrained position, within a particular radius
  59199. * @param position world position
  59200. * @param maxRadius the maximum distance to the constrained world position
  59201. * @returns the closest point to position constrained by the navigation mesh
  59202. */
  59203. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  59204. /**
  59205. * Compute the final position from a segment made of destination-position
  59206. * @param position world position
  59207. * @param destination world position
  59208. * @returns the resulting point along the navmesh
  59209. */
  59210. moveAlong(position: Vector3, destination: Vector3): Vector3;
  59211. /**
  59212. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  59213. * @param start world position
  59214. * @param end world position
  59215. * @returns array containing world position composing the path
  59216. */
  59217. computePath(start: Vector3, end: Vector3): Vector3[];
  59218. /**
  59219. * Create a new Crowd so you can add agents
  59220. * @param maxAgents the maximum agent count in the crowd
  59221. * @param maxAgentRadius the maximum radius an agent can have
  59222. * @param scene to attach the crowd to
  59223. * @returns the crowd you can add agents to
  59224. */
  59225. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  59226. /**
  59227. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  59228. * The queries will try to find a solution within those bounds
  59229. * default is (1,1,1)
  59230. * @param extent x,y,z value that define the extent around the queries point of reference
  59231. */
  59232. setDefaultQueryExtent(extent: Vector3): void;
  59233. /**
  59234. * Get the Bounding box extent specified by setDefaultQueryExtent
  59235. * @returns the box extent values
  59236. */
  59237. getDefaultQueryExtent(): Vector3;
  59238. /**
  59239. * Disposes
  59240. */
  59241. dispose(): void;
  59242. /**
  59243. * If this plugin is supported
  59244. * @returns true if plugin is supported
  59245. */
  59246. isSupported(): boolean;
  59247. }
  59248. /**
  59249. * Recast detour crowd implementation
  59250. */
  59251. export class RecastJSCrowd implements ICrowd {
  59252. /**
  59253. * Recast/detour plugin
  59254. */
  59255. bjsRECASTPlugin: RecastJSPlugin;
  59256. /**
  59257. * Link to the detour crowd
  59258. */
  59259. recastCrowd: any;
  59260. /**
  59261. * One transform per agent
  59262. */
  59263. transforms: TransformNode[];
  59264. /**
  59265. * All agents created
  59266. */
  59267. agents: number[];
  59268. /**
  59269. * Link to the scene is kept to unregister the crowd from the scene
  59270. */
  59271. private _scene;
  59272. /**
  59273. * Observer for crowd updates
  59274. */
  59275. private _onBeforeAnimationsObserver;
  59276. /**
  59277. * Constructor
  59278. * @param plugin recastJS plugin
  59279. * @param maxAgents the maximum agent count in the crowd
  59280. * @param maxAgentRadius the maximum radius an agent can have
  59281. * @param scene to attach the crowd to
  59282. * @returns the crowd you can add agents to
  59283. */
  59284. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  59285. /**
  59286. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  59287. * You can attach anything to that node. The node position is updated in the scene update tick.
  59288. * @param pos world position that will be constrained by the navigation mesh
  59289. * @param parameters agent parameters
  59290. * @param transform hooked to the agent that will be update by the scene
  59291. * @returns agent index
  59292. */
  59293. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  59294. /**
  59295. * Returns the agent position in world space
  59296. * @param index agent index returned by addAgent
  59297. * @returns world space position
  59298. */
  59299. getAgentPosition(index: number): Vector3;
  59300. /**
  59301. * Returns the agent velocity in world space
  59302. * @param index agent index returned by addAgent
  59303. * @returns world space velocity
  59304. */
  59305. getAgentVelocity(index: number): Vector3;
  59306. /**
  59307. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  59308. * @param index agent index returned by addAgent
  59309. * @param destination targeted world position
  59310. */
  59311. agentGoto(index: number, destination: Vector3): void;
  59312. /**
  59313. * remove a particular agent previously created
  59314. * @param index agent index returned by addAgent
  59315. */
  59316. removeAgent(index: number): void;
  59317. /**
  59318. * get the list of all agents attached to this crowd
  59319. * @returns list of agent indices
  59320. */
  59321. getAgents(): number[];
  59322. /**
  59323. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  59324. * @param deltaTime in seconds
  59325. */
  59326. update(deltaTime: number): void;
  59327. /**
  59328. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  59329. * The queries will try to find a solution within those bounds
  59330. * default is (1,1,1)
  59331. * @param extent x,y,z value that define the extent around the queries point of reference
  59332. */
  59333. setDefaultQueryExtent(extent: Vector3): void;
  59334. /**
  59335. * Get the Bounding box extent specified by setDefaultQueryExtent
  59336. * @returns the box extent values
  59337. */
  59338. getDefaultQueryExtent(): Vector3;
  59339. /**
  59340. * Release all resources
  59341. */
  59342. dispose(): void;
  59343. }
  59344. }
  59345. declare module "babylonjs/Navigation/Plugins/index" {
  59346. export * from "babylonjs/Navigation/Plugins/recastJSPlugin";
  59347. }
  59348. declare module "babylonjs/Navigation/index" {
  59349. export * from "babylonjs/Navigation/INavigationEngine";
  59350. export * from "babylonjs/Navigation/Plugins/index";
  59351. }
  59352. declare module "babylonjs/Offline/database" {
  59353. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  59354. /**
  59355. * Class used to enable access to IndexedDB
  59356. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  59357. */
  59358. export class Database implements IOfflineProvider {
  59359. private _callbackManifestChecked;
  59360. private _currentSceneUrl;
  59361. private _db;
  59362. private _enableSceneOffline;
  59363. private _enableTexturesOffline;
  59364. private _manifestVersionFound;
  59365. private _mustUpdateRessources;
  59366. private _hasReachedQuota;
  59367. private _isSupported;
  59368. private _idbFactory;
  59369. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  59370. private static IsUASupportingBlobStorage;
  59371. /**
  59372. * Gets a boolean indicating if Database storate is enabled (off by default)
  59373. */
  59374. static IDBStorageEnabled: boolean;
  59375. /**
  59376. * Gets a boolean indicating if scene must be saved in the database
  59377. */
  59378. readonly enableSceneOffline: boolean;
  59379. /**
  59380. * Gets a boolean indicating if textures must be saved in the database
  59381. */
  59382. readonly enableTexturesOffline: boolean;
  59383. /**
  59384. * Creates a new Database
  59385. * @param urlToScene defines the url to load the scene
  59386. * @param callbackManifestChecked defines the callback to use when manifest is checked
  59387. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  59388. */
  59389. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  59390. private static _ParseURL;
  59391. private static _ReturnFullUrlLocation;
  59392. private _checkManifestFile;
  59393. /**
  59394. * Open the database and make it available
  59395. * @param successCallback defines the callback to call on success
  59396. * @param errorCallback defines the callback to call on error
  59397. */
  59398. open(successCallback: () => void, errorCallback: () => void): void;
  59399. /**
  59400. * Loads an image from the database
  59401. * @param url defines the url to load from
  59402. * @param image defines the target DOM image
  59403. */
  59404. loadImage(url: string, image: HTMLImageElement): void;
  59405. private _loadImageFromDBAsync;
  59406. private _saveImageIntoDBAsync;
  59407. private _checkVersionFromDB;
  59408. private _loadVersionFromDBAsync;
  59409. private _saveVersionIntoDBAsync;
  59410. /**
  59411. * Loads a file from database
  59412. * @param url defines the URL to load from
  59413. * @param sceneLoaded defines a callback to call on success
  59414. * @param progressCallBack defines a callback to call when progress changed
  59415. * @param errorCallback defines a callback to call on error
  59416. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  59417. */
  59418. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  59419. private _loadFileAsync;
  59420. private _saveFileAsync;
  59421. /**
  59422. * Validates if xhr data is correct
  59423. * @param xhr defines the request to validate
  59424. * @param dataType defines the expected data type
  59425. * @returns true if data is correct
  59426. */
  59427. private static _ValidateXHRData;
  59428. }
  59429. }
  59430. declare module "babylonjs/Offline/index" {
  59431. export * from "babylonjs/Offline/database";
  59432. export * from "babylonjs/Offline/IOfflineProvider";
  59433. }
  59434. declare module "babylonjs/Shaders/gpuUpdateParticles.fragment" {
  59435. /** @hidden */
  59436. export var gpuUpdateParticlesPixelShader: {
  59437. name: string;
  59438. shader: string;
  59439. };
  59440. }
  59441. declare module "babylonjs/Shaders/gpuUpdateParticles.vertex" {
  59442. /** @hidden */
  59443. export var gpuUpdateParticlesVertexShader: {
  59444. name: string;
  59445. shader: string;
  59446. };
  59447. }
  59448. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2" {
  59449. /** @hidden */
  59450. export var clipPlaneFragmentDeclaration2: {
  59451. name: string;
  59452. shader: string;
  59453. };
  59454. }
  59455. declare module "babylonjs/Shaders/gpuRenderParticles.fragment" {
  59456. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2";
  59457. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  59458. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  59459. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  59460. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  59461. /** @hidden */
  59462. export var gpuRenderParticlesPixelShader: {
  59463. name: string;
  59464. shader: string;
  59465. };
  59466. }
  59467. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2" {
  59468. /** @hidden */
  59469. export var clipPlaneVertexDeclaration2: {
  59470. name: string;
  59471. shader: string;
  59472. };
  59473. }
  59474. declare module "babylonjs/Shaders/gpuRenderParticles.vertex" {
  59475. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2";
  59476. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  59477. /** @hidden */
  59478. export var gpuRenderParticlesVertexShader: {
  59479. name: string;
  59480. shader: string;
  59481. };
  59482. }
  59483. declare module "babylonjs/Particles/gpuParticleSystem" {
  59484. import { Nullable } from "babylonjs/types";
  59485. import { Color3Gradient, IValueGradient } from "babylonjs/Misc/gradients";
  59486. import { Observable } from "babylonjs/Misc/observable";
  59487. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  59488. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  59489. import { BaseParticleSystem } from "babylonjs/Particles/baseParticleSystem";
  59490. import { Scene, IDisposable } from "babylonjs/scene";
  59491. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  59492. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  59493. import "babylonjs/Shaders/gpuUpdateParticles.fragment";
  59494. import "babylonjs/Shaders/gpuUpdateParticles.vertex";
  59495. import "babylonjs/Shaders/gpuRenderParticles.fragment";
  59496. import "babylonjs/Shaders/gpuRenderParticles.vertex";
  59497. /**
  59498. * This represents a GPU particle system in Babylon
  59499. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  59500. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  59501. */
  59502. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  59503. /**
  59504. * The layer mask we are rendering the particles through.
  59505. */
  59506. layerMask: number;
  59507. private _capacity;
  59508. private _activeCount;
  59509. private _currentActiveCount;
  59510. private _accumulatedCount;
  59511. private _renderEffect;
  59512. private _updateEffect;
  59513. private _buffer0;
  59514. private _buffer1;
  59515. private _spriteBuffer;
  59516. private _updateVAO;
  59517. private _renderVAO;
  59518. private _targetIndex;
  59519. private _sourceBuffer;
  59520. private _targetBuffer;
  59521. private _engine;
  59522. private _currentRenderId;
  59523. private _started;
  59524. private _stopped;
  59525. private _timeDelta;
  59526. private _randomTexture;
  59527. private _randomTexture2;
  59528. private _attributesStrideSize;
  59529. private _updateEffectOptions;
  59530. private _randomTextureSize;
  59531. private _actualFrame;
  59532. private readonly _rawTextureWidth;
  59533. /**
  59534. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  59535. */
  59536. static readonly IsSupported: boolean;
  59537. /**
  59538. * An event triggered when the system is disposed.
  59539. */
  59540. onDisposeObservable: Observable<GPUParticleSystem>;
  59541. /**
  59542. * Gets the maximum number of particles active at the same time.
  59543. * @returns The max number of active particles.
  59544. */
  59545. getCapacity(): number;
  59546. /**
  59547. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  59548. * to override the particles.
  59549. */
  59550. forceDepthWrite: boolean;
  59551. /**
  59552. * Gets or set the number of active particles
  59553. */
  59554. activeParticleCount: number;
  59555. private _preWarmDone;
  59556. /**
  59557. * Is this system ready to be used/rendered
  59558. * @return true if the system is ready
  59559. */
  59560. isReady(): boolean;
  59561. /**
  59562. * Gets if the system has been started. (Note: this will still be true after stop is called)
  59563. * @returns True if it has been started, otherwise false.
  59564. */
  59565. isStarted(): boolean;
  59566. /**
  59567. * Starts the particle system and begins to emit
  59568. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  59569. */
  59570. start(delay?: number): void;
  59571. /**
  59572. * Stops the particle system.
  59573. */
  59574. stop(): void;
  59575. /**
  59576. * Remove all active particles
  59577. */
  59578. reset(): void;
  59579. /**
  59580. * Returns the string "GPUParticleSystem"
  59581. * @returns a string containing the class name
  59582. */
  59583. getClassName(): string;
  59584. private _colorGradientsTexture;
  59585. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  59586. /**
  59587. * Adds a new color gradient
  59588. * @param gradient defines the gradient to use (between 0 and 1)
  59589. * @param color1 defines the color to affect to the specified gradient
  59590. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  59591. * @returns the current particle system
  59592. */
  59593. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  59594. /**
  59595. * Remove a specific color gradient
  59596. * @param gradient defines the gradient to remove
  59597. * @returns the current particle system
  59598. */
  59599. removeColorGradient(gradient: number): GPUParticleSystem;
  59600. private _angularSpeedGradientsTexture;
  59601. private _sizeGradientsTexture;
  59602. private _velocityGradientsTexture;
  59603. private _limitVelocityGradientsTexture;
  59604. private _dragGradientsTexture;
  59605. private _addFactorGradient;
  59606. /**
  59607. * Adds a new size gradient
  59608. * @param gradient defines the gradient to use (between 0 and 1)
  59609. * @param factor defines the size factor to affect to the specified gradient
  59610. * @returns the current particle system
  59611. */
  59612. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  59613. /**
  59614. * Remove a specific size gradient
  59615. * @param gradient defines the gradient to remove
  59616. * @returns the current particle system
  59617. */
  59618. removeSizeGradient(gradient: number): GPUParticleSystem;
  59619. /**
  59620. * Adds a new angular speed gradient
  59621. * @param gradient defines the gradient to use (between 0 and 1)
  59622. * @param factor defines the angular speed to affect to the specified gradient
  59623. * @returns the current particle system
  59624. */
  59625. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  59626. /**
  59627. * Remove a specific angular speed gradient
  59628. * @param gradient defines the gradient to remove
  59629. * @returns the current particle system
  59630. */
  59631. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  59632. /**
  59633. * Adds a new velocity gradient
  59634. * @param gradient defines the gradient to use (between 0 and 1)
  59635. * @param factor defines the velocity to affect to the specified gradient
  59636. * @returns the current particle system
  59637. */
  59638. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  59639. /**
  59640. * Remove a specific velocity gradient
  59641. * @param gradient defines the gradient to remove
  59642. * @returns the current particle system
  59643. */
  59644. removeVelocityGradient(gradient: number): GPUParticleSystem;
  59645. /**
  59646. * Adds a new limit velocity gradient
  59647. * @param gradient defines the gradient to use (between 0 and 1)
  59648. * @param factor defines the limit velocity value to affect to the specified gradient
  59649. * @returns the current particle system
  59650. */
  59651. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  59652. /**
  59653. * Remove a specific limit velocity gradient
  59654. * @param gradient defines the gradient to remove
  59655. * @returns the current particle system
  59656. */
  59657. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  59658. /**
  59659. * Adds a new drag gradient
  59660. * @param gradient defines the gradient to use (between 0 and 1)
  59661. * @param factor defines the drag value to affect to the specified gradient
  59662. * @returns the current particle system
  59663. */
  59664. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  59665. /**
  59666. * Remove a specific drag gradient
  59667. * @param gradient defines the gradient to remove
  59668. * @returns the current particle system
  59669. */
  59670. removeDragGradient(gradient: number): GPUParticleSystem;
  59671. /**
  59672. * Not supported by GPUParticleSystem
  59673. * @param gradient defines the gradient to use (between 0 and 1)
  59674. * @param factor defines the emit rate value to affect to the specified gradient
  59675. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  59676. * @returns the current particle system
  59677. */
  59678. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  59679. /**
  59680. * Not supported by GPUParticleSystem
  59681. * @param gradient defines the gradient to remove
  59682. * @returns the current particle system
  59683. */
  59684. removeEmitRateGradient(gradient: number): IParticleSystem;
  59685. /**
  59686. * Not supported by GPUParticleSystem
  59687. * @param gradient defines the gradient to use (between 0 and 1)
  59688. * @param factor defines the start size value to affect to the specified gradient
  59689. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  59690. * @returns the current particle system
  59691. */
  59692. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  59693. /**
  59694. * Not supported by GPUParticleSystem
  59695. * @param gradient defines the gradient to remove
  59696. * @returns the current particle system
  59697. */
  59698. removeStartSizeGradient(gradient: number): IParticleSystem;
  59699. /**
  59700. * Not supported by GPUParticleSystem
  59701. * @param gradient defines the gradient to use (between 0 and 1)
  59702. * @param min defines the color remap minimal range
  59703. * @param max defines the color remap maximal range
  59704. * @returns the current particle system
  59705. */
  59706. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  59707. /**
  59708. * Not supported by GPUParticleSystem
  59709. * @param gradient defines the gradient to remove
  59710. * @returns the current particle system
  59711. */
  59712. removeColorRemapGradient(): IParticleSystem;
  59713. /**
  59714. * Not supported by GPUParticleSystem
  59715. * @param gradient defines the gradient to use (between 0 and 1)
  59716. * @param min defines the alpha remap minimal range
  59717. * @param max defines the alpha remap maximal range
  59718. * @returns the current particle system
  59719. */
  59720. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  59721. /**
  59722. * Not supported by GPUParticleSystem
  59723. * @param gradient defines the gradient to remove
  59724. * @returns the current particle system
  59725. */
  59726. removeAlphaRemapGradient(): IParticleSystem;
  59727. /**
  59728. * Not supported by GPUParticleSystem
  59729. * @param gradient defines the gradient to use (between 0 and 1)
  59730. * @param color defines the color to affect to the specified gradient
  59731. * @returns the current particle system
  59732. */
  59733. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  59734. /**
  59735. * Not supported by GPUParticleSystem
  59736. * @param gradient defines the gradient to remove
  59737. * @returns the current particle system
  59738. */
  59739. removeRampGradient(): IParticleSystem;
  59740. /**
  59741. * Not supported by GPUParticleSystem
  59742. * @returns the list of ramp gradients
  59743. */
  59744. getRampGradients(): Nullable<Array<Color3Gradient>>;
  59745. /**
  59746. * Not supported by GPUParticleSystem
  59747. * Gets or sets a boolean indicating that ramp gradients must be used
  59748. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  59749. */
  59750. useRampGradients: boolean;
  59751. /**
  59752. * Not supported by GPUParticleSystem
  59753. * @param gradient defines the gradient to use (between 0 and 1)
  59754. * @param factor defines the life time factor to affect to the specified gradient
  59755. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  59756. * @returns the current particle system
  59757. */
  59758. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  59759. /**
  59760. * Not supported by GPUParticleSystem
  59761. * @param gradient defines the gradient to remove
  59762. * @returns the current particle system
  59763. */
  59764. removeLifeTimeGradient(gradient: number): IParticleSystem;
  59765. /**
  59766. * Instantiates a GPU particle system.
  59767. * 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.
  59768. * @param name The name of the particle system
  59769. * @param options The options used to create the system
  59770. * @param scene The scene the particle system belongs to
  59771. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  59772. */
  59773. constructor(name: string, options: Partial<{
  59774. capacity: number;
  59775. randomTextureSize: number;
  59776. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  59777. protected _reset(): void;
  59778. private _createUpdateVAO;
  59779. private _createRenderVAO;
  59780. private _initialize;
  59781. /** @hidden */
  59782. _recreateUpdateEffect(): void;
  59783. /** @hidden */
  59784. _recreateRenderEffect(): void;
  59785. /**
  59786. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  59787. * @param preWarm defines if we are in the pre-warmimg phase
  59788. */
  59789. animate(preWarm?: boolean): void;
  59790. private _createFactorGradientTexture;
  59791. private _createSizeGradientTexture;
  59792. private _createAngularSpeedGradientTexture;
  59793. private _createVelocityGradientTexture;
  59794. private _createLimitVelocityGradientTexture;
  59795. private _createDragGradientTexture;
  59796. private _createColorGradientTexture;
  59797. /**
  59798. * Renders the particle system in its current state
  59799. * @param preWarm defines if the system should only update the particles but not render them
  59800. * @returns the current number of particles
  59801. */
  59802. render(preWarm?: boolean): number;
  59803. /**
  59804. * Rebuilds the particle system
  59805. */
  59806. rebuild(): void;
  59807. private _releaseBuffers;
  59808. private _releaseVAOs;
  59809. /**
  59810. * Disposes the particle system and free the associated resources
  59811. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  59812. */
  59813. dispose(disposeTexture?: boolean): void;
  59814. /**
  59815. * Clones the particle system.
  59816. * @param name The name of the cloned object
  59817. * @param newEmitter The new emitter to use
  59818. * @returns the cloned particle system
  59819. */
  59820. clone(name: string, newEmitter: any): GPUParticleSystem;
  59821. /**
  59822. * Serializes the particle system to a JSON object.
  59823. * @returns the JSON object
  59824. */
  59825. serialize(): any;
  59826. /**
  59827. * Parses a JSON object to create a GPU particle system.
  59828. * @param parsedParticleSystem The JSON object to parse
  59829. * @param scene The scene to create the particle system in
  59830. * @param rootUrl The root url to use to load external dependencies like texture
  59831. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  59832. * @returns the parsed GPU particle system
  59833. */
  59834. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  59835. }
  59836. }
  59837. declare module "babylonjs/Particles/particleSystemSet" {
  59838. import { Nullable } from "babylonjs/types";
  59839. import { Color3 } from "babylonjs/Maths/math.color";
  59840. import { TransformNode } from "babylonjs/Meshes/transformNode";
  59841. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  59842. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  59843. import { Scene, IDisposable } from "babylonjs/scene";
  59844. /**
  59845. * Represents a set of particle systems working together to create a specific effect
  59846. */
  59847. export class ParticleSystemSet implements IDisposable {
  59848. private _emitterCreationOptions;
  59849. private _emitterNode;
  59850. /**
  59851. * Gets the particle system list
  59852. */
  59853. systems: IParticleSystem[];
  59854. /**
  59855. * Gets the emitter node used with this set
  59856. */
  59857. readonly emitterNode: Nullable<TransformNode>;
  59858. /**
  59859. * Creates a new emitter mesh as a sphere
  59860. * @param options defines the options used to create the sphere
  59861. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  59862. * @param scene defines the hosting scene
  59863. */
  59864. setEmitterAsSphere(options: {
  59865. diameter: number;
  59866. segments: number;
  59867. color: Color3;
  59868. }, renderingGroupId: number, scene: Scene): void;
  59869. /**
  59870. * Starts all particle systems of the set
  59871. * @param emitter defines an optional mesh to use as emitter for the particle systems
  59872. */
  59873. start(emitter?: AbstractMesh): void;
  59874. /**
  59875. * Release all associated resources
  59876. */
  59877. dispose(): void;
  59878. /**
  59879. * Serialize the set into a JSON compatible object
  59880. * @returns a JSON compatible representation of the set
  59881. */
  59882. serialize(): any;
  59883. /**
  59884. * Parse a new ParticleSystemSet from a serialized source
  59885. * @param data defines a JSON compatible representation of the set
  59886. * @param scene defines the hosting scene
  59887. * @param gpu defines if we want GPU particles or CPU particles
  59888. * @returns a new ParticleSystemSet
  59889. */
  59890. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  59891. }
  59892. }
  59893. declare module "babylonjs/Particles/particleHelper" {
  59894. import { Nullable } from "babylonjs/types";
  59895. import { Scene } from "babylonjs/scene";
  59896. import { Vector3 } from "babylonjs/Maths/math.vector";
  59897. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  59898. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  59899. import { ParticleSystemSet } from "babylonjs/Particles/particleSystemSet";
  59900. /**
  59901. * This class is made for on one-liner static method to help creating particle system set.
  59902. */
  59903. export class ParticleHelper {
  59904. /**
  59905. * Gets or sets base Assets URL
  59906. */
  59907. static BaseAssetsUrl: string;
  59908. /**
  59909. * Create a default particle system that you can tweak
  59910. * @param emitter defines the emitter to use
  59911. * @param capacity defines the system capacity (default is 500 particles)
  59912. * @param scene defines the hosting scene
  59913. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  59914. * @returns the new Particle system
  59915. */
  59916. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  59917. /**
  59918. * This is the main static method (one-liner) of this helper to create different particle systems
  59919. * @param type This string represents the type to the particle system to create
  59920. * @param scene The scene where the particle system should live
  59921. * @param gpu If the system will use gpu
  59922. * @returns the ParticleSystemSet created
  59923. */
  59924. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  59925. /**
  59926. * Static function used to export a particle system to a ParticleSystemSet variable.
  59927. * Please note that the emitter shape is not exported
  59928. * @param systems defines the particle systems to export
  59929. * @returns the created particle system set
  59930. */
  59931. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  59932. }
  59933. }
  59934. declare module "babylonjs/Particles/particleSystemComponent" {
  59935. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  59936. import { Effect, EffectFallbacks } from "babylonjs/Materials/effect";
  59937. import "babylonjs/Shaders/particles.vertex";
  59938. module "babylonjs/Engines/engine" {
  59939. interface Engine {
  59940. /**
  59941. * Create an effect to use with particle systems.
  59942. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  59943. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  59944. * @param uniformsNames defines a list of attribute names
  59945. * @param samplers defines an array of string used to represent textures
  59946. * @param defines defines the string containing the defines to use to compile the shaders
  59947. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  59948. * @param onCompiled defines a function to call when the effect creation is successful
  59949. * @param onError defines a function to call when the effect creation has failed
  59950. * @returns the new Effect
  59951. */
  59952. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  59953. }
  59954. }
  59955. module "babylonjs/Meshes/mesh" {
  59956. interface Mesh {
  59957. /**
  59958. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  59959. * @returns an array of IParticleSystem
  59960. */
  59961. getEmittedParticleSystems(): IParticleSystem[];
  59962. /**
  59963. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  59964. * @returns an array of IParticleSystem
  59965. */
  59966. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  59967. }
  59968. }
  59969. /**
  59970. * @hidden
  59971. */
  59972. export var _IDoNeedToBeInTheBuild: number;
  59973. }
  59974. declare module "babylonjs/Particles/index" {
  59975. export * from "babylonjs/Particles/baseParticleSystem";
  59976. export * from "babylonjs/Particles/EmitterTypes/index";
  59977. export * from "babylonjs/Particles/gpuParticleSystem";
  59978. export * from "babylonjs/Particles/IParticleSystem";
  59979. export * from "babylonjs/Particles/particle";
  59980. export * from "babylonjs/Particles/particleHelper";
  59981. export * from "babylonjs/Particles/particleSystem";
  59982. export * from "babylonjs/Particles/particleSystemComponent";
  59983. export * from "babylonjs/Particles/particleSystemSet";
  59984. export * from "babylonjs/Particles/solidParticle";
  59985. export * from "babylonjs/Particles/solidParticleSystem";
  59986. export * from "babylonjs/Particles/subEmitter";
  59987. }
  59988. declare module "babylonjs/Physics/physicsEngineComponent" {
  59989. import { Nullable } from "babylonjs/types";
  59990. import { Observable, Observer } from "babylonjs/Misc/observable";
  59991. import { Vector3 } from "babylonjs/Maths/math.vector";
  59992. import { Mesh } from "babylonjs/Meshes/mesh";
  59993. import { ISceneComponent } from "babylonjs/sceneComponent";
  59994. import { Scene } from "babylonjs/scene";
  59995. import { Node } from "babylonjs/node";
  59996. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  59997. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  59998. module "babylonjs/scene" {
  59999. interface Scene {
  60000. /** @hidden (Backing field) */
  60001. _physicsEngine: Nullable<IPhysicsEngine>;
  60002. /**
  60003. * Gets the current physics engine
  60004. * @returns a IPhysicsEngine or null if none attached
  60005. */
  60006. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  60007. /**
  60008. * Enables physics to the current scene
  60009. * @param gravity defines the scene's gravity for the physics engine
  60010. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  60011. * @return a boolean indicating if the physics engine was initialized
  60012. */
  60013. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  60014. /**
  60015. * Disables and disposes the physics engine associated with the scene
  60016. */
  60017. disablePhysicsEngine(): void;
  60018. /**
  60019. * Gets a boolean indicating if there is an active physics engine
  60020. * @returns a boolean indicating if there is an active physics engine
  60021. */
  60022. isPhysicsEnabled(): boolean;
  60023. /**
  60024. * Deletes a physics compound impostor
  60025. * @param compound defines the compound to delete
  60026. */
  60027. deleteCompoundImpostor(compound: any): void;
  60028. /**
  60029. * An event triggered when physic simulation is about to be run
  60030. */
  60031. onBeforePhysicsObservable: Observable<Scene>;
  60032. /**
  60033. * An event triggered when physic simulation has been done
  60034. */
  60035. onAfterPhysicsObservable: Observable<Scene>;
  60036. }
  60037. }
  60038. module "babylonjs/Meshes/abstractMesh" {
  60039. interface AbstractMesh {
  60040. /** @hidden */
  60041. _physicsImpostor: Nullable<PhysicsImpostor>;
  60042. /**
  60043. * Gets or sets impostor used for physic simulation
  60044. * @see http://doc.babylonjs.com/features/physics_engine
  60045. */
  60046. physicsImpostor: Nullable<PhysicsImpostor>;
  60047. /**
  60048. * Gets the current physics impostor
  60049. * @see http://doc.babylonjs.com/features/physics_engine
  60050. * @returns a physics impostor or null
  60051. */
  60052. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  60053. /** Apply a physic impulse to the mesh
  60054. * @param force defines the force to apply
  60055. * @param contactPoint defines where to apply the force
  60056. * @returns the current mesh
  60057. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  60058. */
  60059. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  60060. /**
  60061. * Creates a physic joint between two meshes
  60062. * @param otherMesh defines the other mesh to use
  60063. * @param pivot1 defines the pivot to use on this mesh
  60064. * @param pivot2 defines the pivot to use on the other mesh
  60065. * @param options defines additional options (can be plugin dependent)
  60066. * @returns the current mesh
  60067. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  60068. */
  60069. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  60070. /** @hidden */
  60071. _disposePhysicsObserver: Nullable<Observer<Node>>;
  60072. }
  60073. }
  60074. /**
  60075. * Defines the physics engine scene component responsible to manage a physics engine
  60076. */
  60077. export class PhysicsEngineSceneComponent implements ISceneComponent {
  60078. /**
  60079. * The component name helpful to identify the component in the list of scene components.
  60080. */
  60081. readonly name: string;
  60082. /**
  60083. * The scene the component belongs to.
  60084. */
  60085. scene: Scene;
  60086. /**
  60087. * Creates a new instance of the component for the given scene
  60088. * @param scene Defines the scene to register the component in
  60089. */
  60090. constructor(scene: Scene);
  60091. /**
  60092. * Registers the component in a given scene
  60093. */
  60094. register(): void;
  60095. /**
  60096. * Rebuilds the elements related to this component in case of
  60097. * context lost for instance.
  60098. */
  60099. rebuild(): void;
  60100. /**
  60101. * Disposes the component and the associated ressources
  60102. */
  60103. dispose(): void;
  60104. }
  60105. }
  60106. declare module "babylonjs/Physics/physicsHelper" {
  60107. import { Nullable } from "babylonjs/types";
  60108. import { Vector3 } from "babylonjs/Maths/math.vector";
  60109. import { Mesh } from "babylonjs/Meshes/mesh";
  60110. import { Scene } from "babylonjs/scene";
  60111. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  60112. /**
  60113. * A helper for physics simulations
  60114. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  60115. */
  60116. export class PhysicsHelper {
  60117. private _scene;
  60118. private _physicsEngine;
  60119. /**
  60120. * Initializes the Physics helper
  60121. * @param scene Babylon.js scene
  60122. */
  60123. constructor(scene: Scene);
  60124. /**
  60125. * Applies a radial explosion impulse
  60126. * @param origin the origin of the explosion
  60127. * @param radiusOrEventOptions the radius or the options of radial explosion
  60128. * @param strength the explosion strength
  60129. * @param falloff possible options: Constant & Linear. Defaults to Constant
  60130. * @returns A physics radial explosion event, or null
  60131. */
  60132. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  60133. /**
  60134. * Applies a radial explosion force
  60135. * @param origin the origin of the explosion
  60136. * @param radiusOrEventOptions the radius or the options of radial explosion
  60137. * @param strength the explosion strength
  60138. * @param falloff possible options: Constant & Linear. Defaults to Constant
  60139. * @returns A physics radial explosion event, or null
  60140. */
  60141. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  60142. /**
  60143. * Creates a gravitational field
  60144. * @param origin the origin of the explosion
  60145. * @param radiusOrEventOptions the radius or the options of radial explosion
  60146. * @param strength the explosion strength
  60147. * @param falloff possible options: Constant & Linear. Defaults to Constant
  60148. * @returns A physics gravitational field event, or null
  60149. */
  60150. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  60151. /**
  60152. * Creates a physics updraft event
  60153. * @param origin the origin of the updraft
  60154. * @param radiusOrEventOptions the radius or the options of the updraft
  60155. * @param strength the strength of the updraft
  60156. * @param height the height of the updraft
  60157. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  60158. * @returns A physics updraft event, or null
  60159. */
  60160. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  60161. /**
  60162. * Creates a physics vortex event
  60163. * @param origin the of the vortex
  60164. * @param radiusOrEventOptions the radius or the options of the vortex
  60165. * @param strength the strength of the vortex
  60166. * @param height the height of the vortex
  60167. * @returns a Physics vortex event, or null
  60168. * A physics vortex event or null
  60169. */
  60170. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  60171. }
  60172. /**
  60173. * Represents a physics radial explosion event
  60174. */
  60175. class PhysicsRadialExplosionEvent {
  60176. private _scene;
  60177. private _options;
  60178. private _sphere;
  60179. private _dataFetched;
  60180. /**
  60181. * Initializes a radial explosioin event
  60182. * @param _scene BabylonJS scene
  60183. * @param _options The options for the vortex event
  60184. */
  60185. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  60186. /**
  60187. * Returns the data related to the radial explosion event (sphere).
  60188. * @returns The radial explosion event data
  60189. */
  60190. getData(): PhysicsRadialExplosionEventData;
  60191. /**
  60192. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  60193. * @param impostor A physics imposter
  60194. * @param origin the origin of the explosion
  60195. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  60196. */
  60197. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  60198. /**
  60199. * Triggers affecterd impostors callbacks
  60200. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  60201. */
  60202. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  60203. /**
  60204. * Disposes the sphere.
  60205. * @param force Specifies if the sphere should be disposed by force
  60206. */
  60207. dispose(force?: boolean): void;
  60208. /*** Helpers ***/
  60209. private _prepareSphere;
  60210. private _intersectsWithSphere;
  60211. }
  60212. /**
  60213. * Represents a gravitational field event
  60214. */
  60215. class PhysicsGravitationalFieldEvent {
  60216. private _physicsHelper;
  60217. private _scene;
  60218. private _origin;
  60219. private _options;
  60220. private _tickCallback;
  60221. private _sphere;
  60222. private _dataFetched;
  60223. /**
  60224. * Initializes the physics gravitational field event
  60225. * @param _physicsHelper A physics helper
  60226. * @param _scene BabylonJS scene
  60227. * @param _origin The origin position of the gravitational field event
  60228. * @param _options The options for the vortex event
  60229. */
  60230. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  60231. /**
  60232. * Returns the data related to the gravitational field event (sphere).
  60233. * @returns A gravitational field event
  60234. */
  60235. getData(): PhysicsGravitationalFieldEventData;
  60236. /**
  60237. * Enables the gravitational field.
  60238. */
  60239. enable(): void;
  60240. /**
  60241. * Disables the gravitational field.
  60242. */
  60243. disable(): void;
  60244. /**
  60245. * Disposes the sphere.
  60246. * @param force The force to dispose from the gravitational field event
  60247. */
  60248. dispose(force?: boolean): void;
  60249. private _tick;
  60250. }
  60251. /**
  60252. * Represents a physics updraft event
  60253. */
  60254. class PhysicsUpdraftEvent {
  60255. private _scene;
  60256. private _origin;
  60257. private _options;
  60258. private _physicsEngine;
  60259. private _originTop;
  60260. private _originDirection;
  60261. private _tickCallback;
  60262. private _cylinder;
  60263. private _cylinderPosition;
  60264. private _dataFetched;
  60265. /**
  60266. * Initializes the physics updraft event
  60267. * @param _scene BabylonJS scene
  60268. * @param _origin The origin position of the updraft
  60269. * @param _options The options for the updraft event
  60270. */
  60271. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  60272. /**
  60273. * Returns the data related to the updraft event (cylinder).
  60274. * @returns A physics updraft event
  60275. */
  60276. getData(): PhysicsUpdraftEventData;
  60277. /**
  60278. * Enables the updraft.
  60279. */
  60280. enable(): void;
  60281. /**
  60282. * Disables the updraft.
  60283. */
  60284. disable(): void;
  60285. /**
  60286. * Disposes the cylinder.
  60287. * @param force Specifies if the updraft should be disposed by force
  60288. */
  60289. dispose(force?: boolean): void;
  60290. private getImpostorHitData;
  60291. private _tick;
  60292. /*** Helpers ***/
  60293. private _prepareCylinder;
  60294. private _intersectsWithCylinder;
  60295. }
  60296. /**
  60297. * Represents a physics vortex event
  60298. */
  60299. class PhysicsVortexEvent {
  60300. private _scene;
  60301. private _origin;
  60302. private _options;
  60303. private _physicsEngine;
  60304. private _originTop;
  60305. private _tickCallback;
  60306. private _cylinder;
  60307. private _cylinderPosition;
  60308. private _dataFetched;
  60309. /**
  60310. * Initializes the physics vortex event
  60311. * @param _scene The BabylonJS scene
  60312. * @param _origin The origin position of the vortex
  60313. * @param _options The options for the vortex event
  60314. */
  60315. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  60316. /**
  60317. * Returns the data related to the vortex event (cylinder).
  60318. * @returns The physics vortex event data
  60319. */
  60320. getData(): PhysicsVortexEventData;
  60321. /**
  60322. * Enables the vortex.
  60323. */
  60324. enable(): void;
  60325. /**
  60326. * Disables the cortex.
  60327. */
  60328. disable(): void;
  60329. /**
  60330. * Disposes the sphere.
  60331. * @param force
  60332. */
  60333. dispose(force?: boolean): void;
  60334. private getImpostorHitData;
  60335. private _tick;
  60336. /*** Helpers ***/
  60337. private _prepareCylinder;
  60338. private _intersectsWithCylinder;
  60339. }
  60340. /**
  60341. * Options fot the radial explosion event
  60342. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  60343. */
  60344. export class PhysicsRadialExplosionEventOptions {
  60345. /**
  60346. * The radius of the sphere for the radial explosion.
  60347. */
  60348. radius: number;
  60349. /**
  60350. * The strenth of the explosion.
  60351. */
  60352. strength: number;
  60353. /**
  60354. * The strenght of the force in correspondence to the distance of the affected object
  60355. */
  60356. falloff: PhysicsRadialImpulseFalloff;
  60357. /**
  60358. * Sphere options for the radial explosion.
  60359. */
  60360. sphere: {
  60361. segments: number;
  60362. diameter: number;
  60363. };
  60364. /**
  60365. * Sphere options for the radial explosion.
  60366. */
  60367. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  60368. }
  60369. /**
  60370. * Options fot the updraft event
  60371. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  60372. */
  60373. export class PhysicsUpdraftEventOptions {
  60374. /**
  60375. * The radius of the cylinder for the vortex
  60376. */
  60377. radius: number;
  60378. /**
  60379. * The strenth of the updraft.
  60380. */
  60381. strength: number;
  60382. /**
  60383. * The height of the cylinder for the updraft.
  60384. */
  60385. height: number;
  60386. /**
  60387. * The mode for the the updraft.
  60388. */
  60389. updraftMode: PhysicsUpdraftMode;
  60390. }
  60391. /**
  60392. * Options fot the vortex event
  60393. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  60394. */
  60395. export class PhysicsVortexEventOptions {
  60396. /**
  60397. * The radius of the cylinder for the vortex
  60398. */
  60399. radius: number;
  60400. /**
  60401. * The strenth of the vortex.
  60402. */
  60403. strength: number;
  60404. /**
  60405. * The height of the cylinder for the vortex.
  60406. */
  60407. height: number;
  60408. /**
  60409. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  60410. */
  60411. centripetalForceThreshold: number;
  60412. /**
  60413. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  60414. */
  60415. centripetalForceMultiplier: number;
  60416. /**
  60417. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  60418. */
  60419. centrifugalForceMultiplier: number;
  60420. /**
  60421. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  60422. */
  60423. updraftForceMultiplier: number;
  60424. }
  60425. /**
  60426. * The strenght of the force in correspondence to the distance of the affected object
  60427. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  60428. */
  60429. export enum PhysicsRadialImpulseFalloff {
  60430. /** Defines that impulse is constant in strength across it's whole radius */
  60431. Constant = 0,
  60432. /** Defines that impulse gets weaker if it's further from the origin */
  60433. Linear = 1
  60434. }
  60435. /**
  60436. * The strength of the force in correspondence to the distance of the affected object
  60437. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  60438. */
  60439. export enum PhysicsUpdraftMode {
  60440. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  60441. Center = 0,
  60442. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  60443. Perpendicular = 1
  60444. }
  60445. /**
  60446. * Interface for a physics hit data
  60447. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  60448. */
  60449. export interface PhysicsHitData {
  60450. /**
  60451. * The force applied at the contact point
  60452. */
  60453. force: Vector3;
  60454. /**
  60455. * The contact point
  60456. */
  60457. contactPoint: Vector3;
  60458. /**
  60459. * The distance from the origin to the contact point
  60460. */
  60461. distanceFromOrigin: number;
  60462. }
  60463. /**
  60464. * Interface for radial explosion event data
  60465. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  60466. */
  60467. export interface PhysicsRadialExplosionEventData {
  60468. /**
  60469. * A sphere used for the radial explosion event
  60470. */
  60471. sphere: Mesh;
  60472. }
  60473. /**
  60474. * Interface for gravitational field event data
  60475. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  60476. */
  60477. export interface PhysicsGravitationalFieldEventData {
  60478. /**
  60479. * A sphere mesh used for the gravitational field event
  60480. */
  60481. sphere: Mesh;
  60482. }
  60483. /**
  60484. * Interface for updraft event data
  60485. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  60486. */
  60487. export interface PhysicsUpdraftEventData {
  60488. /**
  60489. * A cylinder used for the updraft event
  60490. */
  60491. cylinder: Mesh;
  60492. }
  60493. /**
  60494. * Interface for vortex event data
  60495. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  60496. */
  60497. export interface PhysicsVortexEventData {
  60498. /**
  60499. * A cylinder used for the vortex event
  60500. */
  60501. cylinder: Mesh;
  60502. }
  60503. /**
  60504. * Interface for an affected physics impostor
  60505. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  60506. */
  60507. export interface PhysicsAffectedImpostorWithData {
  60508. /**
  60509. * The impostor affected by the effect
  60510. */
  60511. impostor: PhysicsImpostor;
  60512. /**
  60513. * The data about the hit/horce from the explosion
  60514. */
  60515. hitData: PhysicsHitData;
  60516. }
  60517. }
  60518. declare module "babylonjs/Physics/Plugins/index" {
  60519. export * from "babylonjs/Physics/Plugins/cannonJSPlugin";
  60520. export * from "babylonjs/Physics/Plugins/ammoJSPlugin";
  60521. export * from "babylonjs/Physics/Plugins/oimoJSPlugin";
  60522. }
  60523. declare module "babylonjs/Physics/index" {
  60524. export * from "babylonjs/Physics/IPhysicsEngine";
  60525. export * from "babylonjs/Physics/physicsEngine";
  60526. export * from "babylonjs/Physics/physicsEngineComponent";
  60527. export * from "babylonjs/Physics/physicsHelper";
  60528. export * from "babylonjs/Physics/physicsImpostor";
  60529. export * from "babylonjs/Physics/physicsJoint";
  60530. export * from "babylonjs/Physics/Plugins/index";
  60531. }
  60532. declare module "babylonjs/Shaders/blackAndWhite.fragment" {
  60533. /** @hidden */
  60534. export var blackAndWhitePixelShader: {
  60535. name: string;
  60536. shader: string;
  60537. };
  60538. }
  60539. declare module "babylonjs/PostProcesses/blackAndWhitePostProcess" {
  60540. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  60541. import { Camera } from "babylonjs/Cameras/camera";
  60542. import { Engine } from "babylonjs/Engines/engine";
  60543. import "babylonjs/Shaders/blackAndWhite.fragment";
  60544. /**
  60545. * Post process used to render in black and white
  60546. */
  60547. export class BlackAndWhitePostProcess extends PostProcess {
  60548. /**
  60549. * Linear about to convert he result to black and white (default: 1)
  60550. */
  60551. degree: number;
  60552. /**
  60553. * Creates a black and white post process
  60554. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  60555. * @param name The name of the effect.
  60556. * @param options The required width/height ratio to downsize to before computing the render pass.
  60557. * @param camera The camera to apply the render pass to.
  60558. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  60559. * @param engine The engine which the post process will be applied. (default: current engine)
  60560. * @param reusable If the post process can be reused on the same frame. (default: false)
  60561. */
  60562. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  60563. }
  60564. }
  60565. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect" {
  60566. import { Nullable } from "babylonjs/types";
  60567. import { Camera } from "babylonjs/Cameras/camera";
  60568. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  60569. import { Engine } from "babylonjs/Engines/engine";
  60570. /**
  60571. * This represents a set of one or more post processes in Babylon.
  60572. * A post process can be used to apply a shader to a texture after it is rendered.
  60573. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  60574. */
  60575. export class PostProcessRenderEffect {
  60576. private _postProcesses;
  60577. private _getPostProcesses;
  60578. private _singleInstance;
  60579. private _cameras;
  60580. private _indicesForCamera;
  60581. /**
  60582. * Name of the effect
  60583. * @hidden
  60584. */
  60585. _name: string;
  60586. /**
  60587. * Instantiates a post process render effect.
  60588. * A post process can be used to apply a shader to a texture after it is rendered.
  60589. * @param engine The engine the effect is tied to
  60590. * @param name The name of the effect
  60591. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  60592. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  60593. */
  60594. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  60595. /**
  60596. * Checks if all the post processes in the effect are supported.
  60597. */
  60598. readonly isSupported: boolean;
  60599. /**
  60600. * Updates the current state of the effect
  60601. * @hidden
  60602. */
  60603. _update(): void;
  60604. /**
  60605. * Attaches the effect on cameras
  60606. * @param cameras The camera to attach to.
  60607. * @hidden
  60608. */
  60609. _attachCameras(cameras: Camera): void;
  60610. /**
  60611. * Attaches the effect on cameras
  60612. * @param cameras The camera to attach to.
  60613. * @hidden
  60614. */
  60615. _attachCameras(cameras: Camera[]): void;
  60616. /**
  60617. * Detaches the effect on cameras
  60618. * @param cameras The camera to detatch from.
  60619. * @hidden
  60620. */
  60621. _detachCameras(cameras: Camera): void;
  60622. /**
  60623. * Detatches the effect on cameras
  60624. * @param cameras The camera to detatch from.
  60625. * @hidden
  60626. */
  60627. _detachCameras(cameras: Camera[]): void;
  60628. /**
  60629. * Enables the effect on given cameras
  60630. * @param cameras The camera to enable.
  60631. * @hidden
  60632. */
  60633. _enable(cameras: Camera): void;
  60634. /**
  60635. * Enables the effect on given cameras
  60636. * @param cameras The camera to enable.
  60637. * @hidden
  60638. */
  60639. _enable(cameras: Nullable<Camera[]>): void;
  60640. /**
  60641. * Disables the effect on the given cameras
  60642. * @param cameras The camera to disable.
  60643. * @hidden
  60644. */
  60645. _disable(cameras: Camera): void;
  60646. /**
  60647. * Disables the effect on the given cameras
  60648. * @param cameras The camera to disable.
  60649. * @hidden
  60650. */
  60651. _disable(cameras: Nullable<Camera[]>): void;
  60652. /**
  60653. * Gets a list of the post processes contained in the effect.
  60654. * @param camera The camera to get the post processes on.
  60655. * @returns The list of the post processes in the effect.
  60656. */
  60657. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  60658. }
  60659. }
  60660. declare module "babylonjs/Shaders/extractHighlights.fragment" {
  60661. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  60662. /** @hidden */
  60663. export var extractHighlightsPixelShader: {
  60664. name: string;
  60665. shader: string;
  60666. };
  60667. }
  60668. declare module "babylonjs/PostProcesses/extractHighlightsPostProcess" {
  60669. import { Nullable } from "babylonjs/types";
  60670. import { Camera } from "babylonjs/Cameras/camera";
  60671. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  60672. import { Engine } from "babylonjs/Engines/engine";
  60673. import "babylonjs/Shaders/extractHighlights.fragment";
  60674. /**
  60675. * 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.
  60676. */
  60677. export class ExtractHighlightsPostProcess extends PostProcess {
  60678. /**
  60679. * The luminance threshold, pixels below this value will be set to black.
  60680. */
  60681. threshold: number;
  60682. /** @hidden */
  60683. _exposure: number;
  60684. /**
  60685. * Post process which has the input texture to be used when performing highlight extraction
  60686. * @hidden
  60687. */
  60688. _inputPostProcess: Nullable<PostProcess>;
  60689. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  60690. }
  60691. }
  60692. declare module "babylonjs/Shaders/bloomMerge.fragment" {
  60693. /** @hidden */
  60694. export var bloomMergePixelShader: {
  60695. name: string;
  60696. shader: string;
  60697. };
  60698. }
  60699. declare module "babylonjs/PostProcesses/bloomMergePostProcess" {
  60700. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  60701. import { Nullable } from "babylonjs/types";
  60702. import { Engine } from "babylonjs/Engines/engine";
  60703. import { Camera } from "babylonjs/Cameras/camera";
  60704. import "babylonjs/Shaders/bloomMerge.fragment";
  60705. /**
  60706. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  60707. */
  60708. export class BloomMergePostProcess extends PostProcess {
  60709. /** Weight of the bloom to be added to the original input. */
  60710. weight: number;
  60711. /**
  60712. * Creates a new instance of @see BloomMergePostProcess
  60713. * @param name The name of the effect.
  60714. * @param originalFromInput Post process which's input will be used for the merge.
  60715. * @param blurred Blurred highlights post process which's output will be used.
  60716. * @param weight Weight of the bloom to be added to the original input.
  60717. * @param options The required width/height ratio to downsize to before computing the render pass.
  60718. * @param camera The camera to apply the render pass to.
  60719. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  60720. * @param engine The engine which the post process will be applied. (default: current engine)
  60721. * @param reusable If the post process can be reused on the same frame. (default: false)
  60722. * @param textureType Type of textures used when performing the post process. (default: 0)
  60723. * @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)
  60724. */
  60725. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  60726. /** Weight of the bloom to be added to the original input. */
  60727. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  60728. }
  60729. }
  60730. declare module "babylonjs/PostProcesses/bloomEffect" {
  60731. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  60732. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  60733. import { ExtractHighlightsPostProcess } from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  60734. import { Camera } from "babylonjs/Cameras/camera";
  60735. import { Scene } from "babylonjs/scene";
  60736. /**
  60737. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  60738. */
  60739. export class BloomEffect extends PostProcessRenderEffect {
  60740. private bloomScale;
  60741. /**
  60742. * @hidden Internal
  60743. */
  60744. _effects: Array<PostProcess>;
  60745. /**
  60746. * @hidden Internal
  60747. */
  60748. _downscale: ExtractHighlightsPostProcess;
  60749. private _blurX;
  60750. private _blurY;
  60751. private _merge;
  60752. /**
  60753. * The luminance threshold to find bright areas of the image to bloom.
  60754. */
  60755. threshold: number;
  60756. /**
  60757. * The strength of the bloom.
  60758. */
  60759. weight: number;
  60760. /**
  60761. * Specifies the size of the bloom blur kernel, relative to the final output size
  60762. */
  60763. kernel: number;
  60764. /**
  60765. * Creates a new instance of @see BloomEffect
  60766. * @param scene The scene the effect belongs to.
  60767. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  60768. * @param bloomKernel The size of the kernel to be used when applying the blur.
  60769. * @param bloomWeight The the strength of bloom.
  60770. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  60771. * @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)
  60772. */
  60773. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  60774. /**
  60775. * Disposes each of the internal effects for a given camera.
  60776. * @param camera The camera to dispose the effect on.
  60777. */
  60778. disposeEffects(camera: Camera): void;
  60779. /**
  60780. * @hidden Internal
  60781. */
  60782. _updateEffects(): void;
  60783. /**
  60784. * Internal
  60785. * @returns if all the contained post processes are ready.
  60786. * @hidden
  60787. */
  60788. _isReady(): boolean;
  60789. }
  60790. }
  60791. declare module "babylonjs/Shaders/chromaticAberration.fragment" {
  60792. /** @hidden */
  60793. export var chromaticAberrationPixelShader: {
  60794. name: string;
  60795. shader: string;
  60796. };
  60797. }
  60798. declare module "babylonjs/PostProcesses/chromaticAberrationPostProcess" {
  60799. import { Vector2 } from "babylonjs/Maths/math.vector";
  60800. import { Nullable } from "babylonjs/types";
  60801. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  60802. import { Camera } from "babylonjs/Cameras/camera";
  60803. import { Engine } from "babylonjs/Engines/engine";
  60804. import "babylonjs/Shaders/chromaticAberration.fragment";
  60805. /**
  60806. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  60807. */
  60808. export class ChromaticAberrationPostProcess extends PostProcess {
  60809. /**
  60810. * The amount of seperation of rgb channels (default: 30)
  60811. */
  60812. aberrationAmount: number;
  60813. /**
  60814. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  60815. */
  60816. radialIntensity: number;
  60817. /**
  60818. * 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))
  60819. */
  60820. direction: Vector2;
  60821. /**
  60822. * 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))
  60823. */
  60824. centerPosition: Vector2;
  60825. /**
  60826. * Creates a new instance ChromaticAberrationPostProcess
  60827. * @param name The name of the effect.
  60828. * @param screenWidth The width of the screen to apply the effect on.
  60829. * @param screenHeight The height of the screen to apply the effect on.
  60830. * @param options The required width/height ratio to downsize to before computing the render pass.
  60831. * @param camera The camera to apply the render pass to.
  60832. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  60833. * @param engine The engine which the post process will be applied. (default: current engine)
  60834. * @param reusable If the post process can be reused on the same frame. (default: false)
  60835. * @param textureType Type of textures used when performing the post process. (default: 0)
  60836. * @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)
  60837. */
  60838. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  60839. }
  60840. }
  60841. declare module "babylonjs/Shaders/circleOfConfusion.fragment" {
  60842. /** @hidden */
  60843. export var circleOfConfusionPixelShader: {
  60844. name: string;
  60845. shader: string;
  60846. };
  60847. }
  60848. declare module "babylonjs/PostProcesses/circleOfConfusionPostProcess" {
  60849. import { Nullable } from "babylonjs/types";
  60850. import { Engine } from "babylonjs/Engines/engine";
  60851. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  60852. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  60853. import { Camera } from "babylonjs/Cameras/camera";
  60854. import "babylonjs/Shaders/circleOfConfusion.fragment";
  60855. /**
  60856. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  60857. */
  60858. export class CircleOfConfusionPostProcess extends PostProcess {
  60859. /**
  60860. * 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.
  60861. */
  60862. lensSize: number;
  60863. /**
  60864. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  60865. */
  60866. fStop: number;
  60867. /**
  60868. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  60869. */
  60870. focusDistance: number;
  60871. /**
  60872. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  60873. */
  60874. focalLength: number;
  60875. private _depthTexture;
  60876. /**
  60877. * Creates a new instance CircleOfConfusionPostProcess
  60878. * @param name The name of the effect.
  60879. * @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.
  60880. * @param options The required width/height ratio to downsize to before computing the render pass.
  60881. * @param camera The camera to apply the render pass to.
  60882. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  60883. * @param engine The engine which the post process will be applied. (default: current engine)
  60884. * @param reusable If the post process can be reused on the same frame. (default: false)
  60885. * @param textureType Type of textures used when performing the post process. (default: 0)
  60886. * @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)
  60887. */
  60888. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  60889. /**
  60890. * 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.
  60891. */
  60892. depthTexture: RenderTargetTexture;
  60893. }
  60894. }
  60895. declare module "babylonjs/Shaders/colorCorrection.fragment" {
  60896. /** @hidden */
  60897. export var colorCorrectionPixelShader: {
  60898. name: string;
  60899. shader: string;
  60900. };
  60901. }
  60902. declare module "babylonjs/PostProcesses/colorCorrectionPostProcess" {
  60903. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  60904. import { Engine } from "babylonjs/Engines/engine";
  60905. import { Camera } from "babylonjs/Cameras/camera";
  60906. import "babylonjs/Shaders/colorCorrection.fragment";
  60907. /**
  60908. *
  60909. * This post-process allows the modification of rendered colors by using
  60910. * a 'look-up table' (LUT). This effect is also called Color Grading.
  60911. *
  60912. * The object needs to be provided an url to a texture containing the color
  60913. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  60914. * Use an image editing software to tweak the LUT to match your needs.
  60915. *
  60916. * For an example of a color LUT, see here:
  60917. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  60918. * For explanations on color grading, see here:
  60919. * @see http://udn.epicgames.com/Three/ColorGrading.html
  60920. *
  60921. */
  60922. export class ColorCorrectionPostProcess extends PostProcess {
  60923. private _colorTableTexture;
  60924. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  60925. }
  60926. }
  60927. declare module "babylonjs/Shaders/convolution.fragment" {
  60928. /** @hidden */
  60929. export var convolutionPixelShader: {
  60930. name: string;
  60931. shader: string;
  60932. };
  60933. }
  60934. declare module "babylonjs/PostProcesses/convolutionPostProcess" {
  60935. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  60936. import { Nullable } from "babylonjs/types";
  60937. import { Camera } from "babylonjs/Cameras/camera";
  60938. import { Engine } from "babylonjs/Engines/engine";
  60939. import "babylonjs/Shaders/convolution.fragment";
  60940. /**
  60941. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  60942. * input texture to perform effects such as edge detection or sharpening
  60943. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  60944. */
  60945. export class ConvolutionPostProcess extends PostProcess {
  60946. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  60947. kernel: number[];
  60948. /**
  60949. * Creates a new instance ConvolutionPostProcess
  60950. * @param name The name of the effect.
  60951. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  60952. * @param options The required width/height ratio to downsize to before computing the render pass.
  60953. * @param camera The camera to apply the render pass to.
  60954. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  60955. * @param engine The engine which the post process will be applied. (default: current engine)
  60956. * @param reusable If the post process can be reused on the same frame. (default: false)
  60957. * @param textureType Type of textures used when performing the post process. (default: 0)
  60958. */
  60959. constructor(name: string,
  60960. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  60961. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  60962. /**
  60963. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  60964. */
  60965. static EdgeDetect0Kernel: number[];
  60966. /**
  60967. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  60968. */
  60969. static EdgeDetect1Kernel: number[];
  60970. /**
  60971. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  60972. */
  60973. static EdgeDetect2Kernel: number[];
  60974. /**
  60975. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  60976. */
  60977. static SharpenKernel: number[];
  60978. /**
  60979. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  60980. */
  60981. static EmbossKernel: number[];
  60982. /**
  60983. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  60984. */
  60985. static GaussianKernel: number[];
  60986. }
  60987. }
  60988. declare module "babylonjs/PostProcesses/depthOfFieldBlurPostProcess" {
  60989. import { Nullable } from "babylonjs/types";
  60990. import { Vector2 } from "babylonjs/Maths/math.vector";
  60991. import { Camera } from "babylonjs/Cameras/camera";
  60992. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  60993. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  60994. import { Engine } from "babylonjs/Engines/engine";
  60995. import { Scene } from "babylonjs/scene";
  60996. /**
  60997. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  60998. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  60999. * based on samples that have a large difference in distance than the center pixel.
  61000. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  61001. */
  61002. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  61003. direction: Vector2;
  61004. /**
  61005. * Creates a new instance CircleOfConfusionPostProcess
  61006. * @param name The name of the effect.
  61007. * @param scene The scene the effect belongs to.
  61008. * @param direction The direction the blur should be applied.
  61009. * @param kernel The size of the kernel used to blur.
  61010. * @param options The required width/height ratio to downsize to before computing the render pass.
  61011. * @param camera The camera to apply the render pass to.
  61012. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  61013. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  61014. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  61015. * @param engine The engine which the post process will be applied. (default: current engine)
  61016. * @param reusable If the post process can be reused on the same frame. (default: false)
  61017. * @param textureType Type of textures used when performing the post process. (default: 0)
  61018. * @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)
  61019. */
  61020. 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);
  61021. }
  61022. }
  61023. declare module "babylonjs/Shaders/depthOfFieldMerge.fragment" {
  61024. /** @hidden */
  61025. export var depthOfFieldMergePixelShader: {
  61026. name: string;
  61027. shader: string;
  61028. };
  61029. }
  61030. declare module "babylonjs/PostProcesses/depthOfFieldMergePostProcess" {
  61031. import { Nullable } from "babylonjs/types";
  61032. import { Camera } from "babylonjs/Cameras/camera";
  61033. import { Effect } from "babylonjs/Materials/effect";
  61034. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  61035. import { Engine } from "babylonjs/Engines/engine";
  61036. import "babylonjs/Shaders/depthOfFieldMerge.fragment";
  61037. /**
  61038. * Options to be set when merging outputs from the default pipeline.
  61039. */
  61040. export class DepthOfFieldMergePostProcessOptions {
  61041. /**
  61042. * The original image to merge on top of
  61043. */
  61044. originalFromInput: PostProcess;
  61045. /**
  61046. * Parameters to perform the merge of the depth of field effect
  61047. */
  61048. depthOfField?: {
  61049. circleOfConfusion: PostProcess;
  61050. blurSteps: Array<PostProcess>;
  61051. };
  61052. /**
  61053. * Parameters to perform the merge of bloom effect
  61054. */
  61055. bloom?: {
  61056. blurred: PostProcess;
  61057. weight: number;
  61058. };
  61059. }
  61060. /**
  61061. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  61062. */
  61063. export class DepthOfFieldMergePostProcess extends PostProcess {
  61064. private blurSteps;
  61065. /**
  61066. * Creates a new instance of DepthOfFieldMergePostProcess
  61067. * @param name The name of the effect.
  61068. * @param originalFromInput Post process which's input will be used for the merge.
  61069. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  61070. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  61071. * @param options The required width/height ratio to downsize to before computing the render pass.
  61072. * @param camera The camera to apply the render pass to.
  61073. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  61074. * @param engine The engine which the post process will be applied. (default: current engine)
  61075. * @param reusable If the post process can be reused on the same frame. (default: false)
  61076. * @param textureType Type of textures used when performing the post process. (default: 0)
  61077. * @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)
  61078. */
  61079. 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);
  61080. /**
  61081. * Updates the effect with the current post process compile time values and recompiles the shader.
  61082. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  61083. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  61084. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  61085. * @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
  61086. * @param onCompiled Called when the shader has been compiled.
  61087. * @param onError Called if there is an error when compiling a shader.
  61088. */
  61089. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  61090. }
  61091. }
  61092. declare module "babylonjs/PostProcesses/depthOfFieldEffect" {
  61093. import { Nullable } from "babylonjs/types";
  61094. import { Camera } from "babylonjs/Cameras/camera";
  61095. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  61096. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  61097. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  61098. import { DepthOfFieldBlurPostProcess } from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  61099. import { Scene } from "babylonjs/scene";
  61100. /**
  61101. * Specifies the level of max blur that should be applied when using the depth of field effect
  61102. */
  61103. export enum DepthOfFieldEffectBlurLevel {
  61104. /**
  61105. * Subtle blur
  61106. */
  61107. Low = 0,
  61108. /**
  61109. * Medium blur
  61110. */
  61111. Medium = 1,
  61112. /**
  61113. * Large blur
  61114. */
  61115. High = 2
  61116. }
  61117. /**
  61118. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  61119. */
  61120. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  61121. private _circleOfConfusion;
  61122. /**
  61123. * @hidden Internal, blurs from high to low
  61124. */
  61125. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  61126. private _depthOfFieldBlurY;
  61127. private _dofMerge;
  61128. /**
  61129. * @hidden Internal post processes in depth of field effect
  61130. */
  61131. _effects: Array<PostProcess>;
  61132. /**
  61133. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  61134. */
  61135. focalLength: number;
  61136. /**
  61137. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  61138. */
  61139. fStop: number;
  61140. /**
  61141. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  61142. */
  61143. focusDistance: number;
  61144. /**
  61145. * 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.
  61146. */
  61147. lensSize: number;
  61148. /**
  61149. * Creates a new instance DepthOfFieldEffect
  61150. * @param scene The scene the effect belongs to.
  61151. * @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.
  61152. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  61153. * @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)
  61154. */
  61155. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  61156. /**
  61157. * Get the current class name of the current effet
  61158. * @returns "DepthOfFieldEffect"
  61159. */
  61160. getClassName(): string;
  61161. /**
  61162. * 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.
  61163. */
  61164. depthTexture: RenderTargetTexture;
  61165. /**
  61166. * Disposes each of the internal effects for a given camera.
  61167. * @param camera The camera to dispose the effect on.
  61168. */
  61169. disposeEffects(camera: Camera): void;
  61170. /**
  61171. * @hidden Internal
  61172. */
  61173. _updateEffects(): void;
  61174. /**
  61175. * Internal
  61176. * @returns if all the contained post processes are ready.
  61177. * @hidden
  61178. */
  61179. _isReady(): boolean;
  61180. }
  61181. }
  61182. declare module "babylonjs/Shaders/displayPass.fragment" {
  61183. /** @hidden */
  61184. export var displayPassPixelShader: {
  61185. name: string;
  61186. shader: string;
  61187. };
  61188. }
  61189. declare module "babylonjs/PostProcesses/displayPassPostProcess" {
  61190. import { Nullable } from "babylonjs/types";
  61191. import { Camera } from "babylonjs/Cameras/camera";
  61192. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  61193. import { Engine } from "babylonjs/Engines/engine";
  61194. import "babylonjs/Shaders/displayPass.fragment";
  61195. /**
  61196. * DisplayPassPostProcess which produces an output the same as it's input
  61197. */
  61198. export class DisplayPassPostProcess extends PostProcess {
  61199. /**
  61200. * Creates the DisplayPassPostProcess
  61201. * @param name The name of the effect.
  61202. * @param options The required width/height ratio to downsize to before computing the render pass.
  61203. * @param camera The camera to apply the render pass to.
  61204. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  61205. * @param engine The engine which the post process will be applied. (default: current engine)
  61206. * @param reusable If the post process can be reused on the same frame. (default: false)
  61207. */
  61208. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  61209. }
  61210. }
  61211. declare module "babylonjs/Shaders/filter.fragment" {
  61212. /** @hidden */
  61213. export var filterPixelShader: {
  61214. name: string;
  61215. shader: string;
  61216. };
  61217. }
  61218. declare module "babylonjs/PostProcesses/filterPostProcess" {
  61219. import { Nullable } from "babylonjs/types";
  61220. import { Matrix } from "babylonjs/Maths/math.vector";
  61221. import { Camera } from "babylonjs/Cameras/camera";
  61222. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  61223. import { Engine } from "babylonjs/Engines/engine";
  61224. import "babylonjs/Shaders/filter.fragment";
  61225. /**
  61226. * Applies a kernel filter to the image
  61227. */
  61228. export class FilterPostProcess extends PostProcess {
  61229. /** The matrix to be applied to the image */
  61230. kernelMatrix: Matrix;
  61231. /**
  61232. *
  61233. * @param name The name of the effect.
  61234. * @param kernelMatrix The matrix to be applied to the image
  61235. * @param options The required width/height ratio to downsize to before computing the render pass.
  61236. * @param camera The camera to apply the render pass to.
  61237. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  61238. * @param engine The engine which the post process will be applied. (default: current engine)
  61239. * @param reusable If the post process can be reused on the same frame. (default: false)
  61240. */
  61241. constructor(name: string,
  61242. /** The matrix to be applied to the image */
  61243. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  61244. }
  61245. }
  61246. declare module "babylonjs/Shaders/fxaa.fragment" {
  61247. /** @hidden */
  61248. export var fxaaPixelShader: {
  61249. name: string;
  61250. shader: string;
  61251. };
  61252. }
  61253. declare module "babylonjs/Shaders/fxaa.vertex" {
  61254. /** @hidden */
  61255. export var fxaaVertexShader: {
  61256. name: string;
  61257. shader: string;
  61258. };
  61259. }
  61260. declare module "babylonjs/PostProcesses/fxaaPostProcess" {
  61261. import { Nullable } from "babylonjs/types";
  61262. import { Camera } from "babylonjs/Cameras/camera";
  61263. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  61264. import { Engine } from "babylonjs/Engines/engine";
  61265. import "babylonjs/Shaders/fxaa.fragment";
  61266. import "babylonjs/Shaders/fxaa.vertex";
  61267. /**
  61268. * Fxaa post process
  61269. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  61270. */
  61271. export class FxaaPostProcess extends PostProcess {
  61272. /** @hidden */
  61273. texelWidth: number;
  61274. /** @hidden */
  61275. texelHeight: number;
  61276. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  61277. private _getDefines;
  61278. }
  61279. }
  61280. declare module "babylonjs/Shaders/grain.fragment" {
  61281. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  61282. /** @hidden */
  61283. export var grainPixelShader: {
  61284. name: string;
  61285. shader: string;
  61286. };
  61287. }
  61288. declare module "babylonjs/PostProcesses/grainPostProcess" {
  61289. import { Nullable } from "babylonjs/types";
  61290. import { Camera } from "babylonjs/Cameras/camera";
  61291. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  61292. import { Engine } from "babylonjs/Engines/engine";
  61293. import "babylonjs/Shaders/grain.fragment";
  61294. /**
  61295. * The GrainPostProcess adds noise to the image at mid luminance levels
  61296. */
  61297. export class GrainPostProcess extends PostProcess {
  61298. /**
  61299. * The intensity of the grain added (default: 30)
  61300. */
  61301. intensity: number;
  61302. /**
  61303. * If the grain should be randomized on every frame
  61304. */
  61305. animated: boolean;
  61306. /**
  61307. * Creates a new instance of @see GrainPostProcess
  61308. * @param name The name of the effect.
  61309. * @param options The required width/height ratio to downsize to before computing the render pass.
  61310. * @param camera The camera to apply the render pass to.
  61311. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  61312. * @param engine The engine which the post process will be applied. (default: current engine)
  61313. * @param reusable If the post process can be reused on the same frame. (default: false)
  61314. * @param textureType Type of textures used when performing the post process. (default: 0)
  61315. * @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)
  61316. */
  61317. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  61318. }
  61319. }
  61320. declare module "babylonjs/Shaders/highlights.fragment" {
  61321. /** @hidden */
  61322. export var highlightsPixelShader: {
  61323. name: string;
  61324. shader: string;
  61325. };
  61326. }
  61327. declare module "babylonjs/PostProcesses/highlightsPostProcess" {
  61328. import { Nullable } from "babylonjs/types";
  61329. import { Camera } from "babylonjs/Cameras/camera";
  61330. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  61331. import { Engine } from "babylonjs/Engines/engine";
  61332. import "babylonjs/Shaders/highlights.fragment";
  61333. /**
  61334. * Extracts highlights from the image
  61335. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  61336. */
  61337. export class HighlightsPostProcess extends PostProcess {
  61338. /**
  61339. * Extracts highlights from the image
  61340. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  61341. * @param name The name of the effect.
  61342. * @param options The required width/height ratio to downsize to before computing the render pass.
  61343. * @param camera The camera to apply the render pass to.
  61344. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  61345. * @param engine The engine which the post process will be applied. (default: current engine)
  61346. * @param reusable If the post process can be reused on the same frame. (default: false)
  61347. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  61348. */
  61349. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  61350. }
  61351. }
  61352. declare module "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration" {
  61353. /** @hidden */
  61354. export var mrtFragmentDeclaration: {
  61355. name: string;
  61356. shader: string;
  61357. };
  61358. }
  61359. declare module "babylonjs/Shaders/geometry.fragment" {
  61360. import "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration";
  61361. /** @hidden */
  61362. export var geometryPixelShader: {
  61363. name: string;
  61364. shader: string;
  61365. };
  61366. }
  61367. declare module "babylonjs/Shaders/geometry.vertex" {
  61368. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  61369. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  61370. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  61371. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  61372. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  61373. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  61374. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  61375. /** @hidden */
  61376. export var geometryVertexShader: {
  61377. name: string;
  61378. shader: string;
  61379. };
  61380. }
  61381. declare module "babylonjs/Rendering/geometryBufferRenderer" {
  61382. import { Matrix } from "babylonjs/Maths/math.vector";
  61383. import { SubMesh } from "babylonjs/Meshes/subMesh";
  61384. import { Mesh } from "babylonjs/Meshes/mesh";
  61385. import { MultiRenderTarget } from "babylonjs/Materials/Textures/multiRenderTarget";
  61386. import { Effect } from "babylonjs/Materials/effect";
  61387. import { Scene } from "babylonjs/scene";
  61388. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  61389. import "babylonjs/Shaders/geometry.fragment";
  61390. import "babylonjs/Shaders/geometry.vertex";
  61391. /** @hidden */
  61392. interface ISavedTransformationMatrix {
  61393. world: Matrix;
  61394. viewProjection: Matrix;
  61395. }
  61396. /**
  61397. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  61398. */
  61399. export class GeometryBufferRenderer {
  61400. /**
  61401. * Constant used to retrieve the position texture index in the G-Buffer textures array
  61402. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  61403. */
  61404. static readonly POSITION_TEXTURE_TYPE: number;
  61405. /**
  61406. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  61407. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  61408. */
  61409. static readonly VELOCITY_TEXTURE_TYPE: number;
  61410. /**
  61411. * Dictionary used to store the previous transformation matrices of each rendered mesh
  61412. * in order to compute objects velocities when enableVelocity is set to "true"
  61413. * @hidden
  61414. */
  61415. _previousTransformationMatrices: {
  61416. [index: number]: ISavedTransformationMatrix;
  61417. };
  61418. /**
  61419. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  61420. * in order to compute objects velocities when enableVelocity is set to "true"
  61421. * @hidden
  61422. */
  61423. _previousBonesTransformationMatrices: {
  61424. [index: number]: Float32Array;
  61425. };
  61426. /**
  61427. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  61428. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  61429. */
  61430. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  61431. private _scene;
  61432. private _multiRenderTarget;
  61433. private _ratio;
  61434. private _enablePosition;
  61435. private _enableVelocity;
  61436. private _positionIndex;
  61437. private _velocityIndex;
  61438. protected _effect: Effect;
  61439. protected _cachedDefines: string;
  61440. /**
  61441. * Set the render list (meshes to be rendered) used in the G buffer.
  61442. */
  61443. renderList: Mesh[];
  61444. /**
  61445. * Gets wether or not G buffer are supported by the running hardware.
  61446. * This requires draw buffer supports
  61447. */
  61448. readonly isSupported: boolean;
  61449. /**
  61450. * Returns the index of the given texture type in the G-Buffer textures array
  61451. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  61452. * @returns the index of the given texture type in the G-Buffer textures array
  61453. */
  61454. getTextureIndex(textureType: number): number;
  61455. /**
  61456. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  61457. */
  61458. /**
  61459. * Sets whether or not objects positions are enabled for the G buffer.
  61460. */
  61461. enablePosition: boolean;
  61462. /**
  61463. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  61464. */
  61465. /**
  61466. * Sets wether or not objects velocities are enabled for the G buffer.
  61467. */
  61468. enableVelocity: boolean;
  61469. /**
  61470. * Gets the scene associated with the buffer.
  61471. */
  61472. readonly scene: Scene;
  61473. /**
  61474. * Gets the ratio used by the buffer during its creation.
  61475. * How big is the buffer related to the main canvas.
  61476. */
  61477. readonly ratio: number;
  61478. /** @hidden */
  61479. static _SceneComponentInitialization: (scene: Scene) => void;
  61480. /**
  61481. * Creates a new G Buffer for the scene
  61482. * @param scene The scene the buffer belongs to
  61483. * @param ratio How big is the buffer related to the main canvas.
  61484. */
  61485. constructor(scene: Scene, ratio?: number);
  61486. /**
  61487. * Checks wether everything is ready to render a submesh to the G buffer.
  61488. * @param subMesh the submesh to check readiness for
  61489. * @param useInstances is the mesh drawn using instance or not
  61490. * @returns true if ready otherwise false
  61491. */
  61492. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  61493. /**
  61494. * Gets the current underlying G Buffer.
  61495. * @returns the buffer
  61496. */
  61497. getGBuffer(): MultiRenderTarget;
  61498. /**
  61499. * Gets the number of samples used to render the buffer (anti aliasing).
  61500. */
  61501. /**
  61502. * Sets the number of samples used to render the buffer (anti aliasing).
  61503. */
  61504. samples: number;
  61505. /**
  61506. * Disposes the renderer and frees up associated resources.
  61507. */
  61508. dispose(): void;
  61509. protected _createRenderTargets(): void;
  61510. private _copyBonesTransformationMatrices;
  61511. }
  61512. }
  61513. declare module "babylonjs/Rendering/geometryBufferRendererSceneComponent" {
  61514. import { Nullable } from "babylonjs/types";
  61515. import { Scene } from "babylonjs/scene";
  61516. import { ISceneComponent } from "babylonjs/sceneComponent";
  61517. import { GeometryBufferRenderer } from "babylonjs/Rendering/geometryBufferRenderer";
  61518. module "babylonjs/scene" {
  61519. interface Scene {
  61520. /** @hidden (Backing field) */
  61521. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  61522. /**
  61523. * Gets or Sets the current geometry buffer associated to the scene.
  61524. */
  61525. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  61526. /**
  61527. * Enables a GeometryBufferRender and associates it with the scene
  61528. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  61529. * @returns the GeometryBufferRenderer
  61530. */
  61531. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  61532. /**
  61533. * Disables the GeometryBufferRender associated with the scene
  61534. */
  61535. disableGeometryBufferRenderer(): void;
  61536. }
  61537. }
  61538. /**
  61539. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  61540. * in several rendering techniques.
  61541. */
  61542. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  61543. /**
  61544. * The component name helpful to identify the component in the list of scene components.
  61545. */
  61546. readonly name: string;
  61547. /**
  61548. * The scene the component belongs to.
  61549. */
  61550. scene: Scene;
  61551. /**
  61552. * Creates a new instance of the component for the given scene
  61553. * @param scene Defines the scene to register the component in
  61554. */
  61555. constructor(scene: Scene);
  61556. /**
  61557. * Registers the component in a given scene
  61558. */
  61559. register(): void;
  61560. /**
  61561. * Rebuilds the elements related to this component in case of
  61562. * context lost for instance.
  61563. */
  61564. rebuild(): void;
  61565. /**
  61566. * Disposes the component and the associated ressources
  61567. */
  61568. dispose(): void;
  61569. private _gatherRenderTargets;
  61570. }
  61571. }
  61572. declare module "babylonjs/Shaders/motionBlur.fragment" {
  61573. /** @hidden */
  61574. export var motionBlurPixelShader: {
  61575. name: string;
  61576. shader: string;
  61577. };
  61578. }
  61579. declare module "babylonjs/PostProcesses/motionBlurPostProcess" {
  61580. import { Nullable } from "babylonjs/types";
  61581. import { Camera } from "babylonjs/Cameras/camera";
  61582. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  61583. import { Scene } from "babylonjs/scene";
  61584. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  61585. import "babylonjs/Animations/animatable";
  61586. import "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  61587. import "babylonjs/Shaders/motionBlur.fragment";
  61588. import { Engine } from "babylonjs/Engines/engine";
  61589. /**
  61590. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  61591. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  61592. * As an example, all you have to do is to create the post-process:
  61593. * var mb = new BABYLON.MotionBlurPostProcess(
  61594. * 'mb', // The name of the effect.
  61595. * scene, // The scene containing the objects to blur according to their velocity.
  61596. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  61597. * camera // The camera to apply the render pass to.
  61598. * );
  61599. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  61600. */
  61601. export class MotionBlurPostProcess extends PostProcess {
  61602. /**
  61603. * Defines how much the image is blurred by the movement. Default value is equal to 1
  61604. */
  61605. motionStrength: number;
  61606. /**
  61607. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  61608. */
  61609. /**
  61610. * Sets the number of iterations to be used for motion blur quality
  61611. */
  61612. motionBlurSamples: number;
  61613. private _motionBlurSamples;
  61614. private _geometryBufferRenderer;
  61615. /**
  61616. * Creates a new instance MotionBlurPostProcess
  61617. * @param name The name of the effect.
  61618. * @param scene The scene containing the objects to blur according to their velocity.
  61619. * @param options The required width/height ratio to downsize to before computing the render pass.
  61620. * @param camera The camera to apply the render pass to.
  61621. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  61622. * @param engine The engine which the post process will be applied. (default: current engine)
  61623. * @param reusable If the post process can be reused on the same frame. (default: false)
  61624. * @param textureType Type of textures used when performing the post process. (default: 0)
  61625. * @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)
  61626. */
  61627. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  61628. /**
  61629. * Excludes the given skinned mesh from computing bones velocities.
  61630. * 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.
  61631. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  61632. */
  61633. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  61634. /**
  61635. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  61636. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  61637. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  61638. */
  61639. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  61640. /**
  61641. * Disposes the post process.
  61642. * @param camera The camera to dispose the post process on.
  61643. */
  61644. dispose(camera?: Camera): void;
  61645. }
  61646. }
  61647. declare module "babylonjs/Shaders/refraction.fragment" {
  61648. /** @hidden */
  61649. export var refractionPixelShader: {
  61650. name: string;
  61651. shader: string;
  61652. };
  61653. }
  61654. declare module "babylonjs/PostProcesses/refractionPostProcess" {
  61655. import { Color3 } from "babylonjs/Maths/math.color";
  61656. import { Camera } from "babylonjs/Cameras/camera";
  61657. import { Texture } from "babylonjs/Materials/Textures/texture";
  61658. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  61659. import { Engine } from "babylonjs/Engines/engine";
  61660. import "babylonjs/Shaders/refraction.fragment";
  61661. /**
  61662. * Post process which applies a refractin texture
  61663. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  61664. */
  61665. export class RefractionPostProcess extends PostProcess {
  61666. /** the base color of the refraction (used to taint the rendering) */
  61667. color: Color3;
  61668. /** simulated refraction depth */
  61669. depth: number;
  61670. /** the coefficient of the base color (0 to remove base color tainting) */
  61671. colorLevel: number;
  61672. private _refTexture;
  61673. private _ownRefractionTexture;
  61674. /**
  61675. * Gets or sets the refraction texture
  61676. * Please note that you are responsible for disposing the texture if you set it manually
  61677. */
  61678. refractionTexture: Texture;
  61679. /**
  61680. * Initializes the RefractionPostProcess
  61681. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  61682. * @param name The name of the effect.
  61683. * @param refractionTextureUrl Url of the refraction texture to use
  61684. * @param color the base color of the refraction (used to taint the rendering)
  61685. * @param depth simulated refraction depth
  61686. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  61687. * @param camera The camera to apply the render pass to.
  61688. * @param options The required width/height ratio to downsize to before computing the render pass.
  61689. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  61690. * @param engine The engine which the post process will be applied. (default: current engine)
  61691. * @param reusable If the post process can be reused on the same frame. (default: false)
  61692. */
  61693. constructor(name: string, refractionTextureUrl: string,
  61694. /** the base color of the refraction (used to taint the rendering) */
  61695. color: Color3,
  61696. /** simulated refraction depth */
  61697. depth: number,
  61698. /** the coefficient of the base color (0 to remove base color tainting) */
  61699. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  61700. /**
  61701. * Disposes of the post process
  61702. * @param camera Camera to dispose post process on
  61703. */
  61704. dispose(camera: Camera): void;
  61705. }
  61706. }
  61707. declare module "babylonjs/Shaders/sharpen.fragment" {
  61708. /** @hidden */
  61709. export var sharpenPixelShader: {
  61710. name: string;
  61711. shader: string;
  61712. };
  61713. }
  61714. declare module "babylonjs/PostProcesses/sharpenPostProcess" {
  61715. import { Nullable } from "babylonjs/types";
  61716. import { Camera } from "babylonjs/Cameras/camera";
  61717. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  61718. import "babylonjs/Shaders/sharpen.fragment";
  61719. import { Engine } from "babylonjs/Engines/engine";
  61720. /**
  61721. * The SharpenPostProcess applies a sharpen kernel to every pixel
  61722. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  61723. */
  61724. export class SharpenPostProcess extends PostProcess {
  61725. /**
  61726. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  61727. */
  61728. colorAmount: number;
  61729. /**
  61730. * How much sharpness should be applied (default: 0.3)
  61731. */
  61732. edgeAmount: number;
  61733. /**
  61734. * Creates a new instance ConvolutionPostProcess
  61735. * @param name The name of the effect.
  61736. * @param options The required width/height ratio to downsize to before computing the render pass.
  61737. * @param camera The camera to apply the render pass to.
  61738. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  61739. * @param engine The engine which the post process will be applied. (default: current engine)
  61740. * @param reusable If the post process can be reused on the same frame. (default: false)
  61741. * @param textureType Type of textures used when performing the post process. (default: 0)
  61742. * @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)
  61743. */
  61744. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  61745. }
  61746. }
  61747. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline" {
  61748. import { Nullable } from "babylonjs/types";
  61749. import { Camera } from "babylonjs/Cameras/camera";
  61750. import { Engine } from "babylonjs/Engines/engine";
  61751. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  61752. import { IInspectable } from "babylonjs/Misc/iInspectable";
  61753. /**
  61754. * PostProcessRenderPipeline
  61755. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  61756. */
  61757. export class PostProcessRenderPipeline {
  61758. private engine;
  61759. private _renderEffects;
  61760. private _renderEffectsForIsolatedPass;
  61761. /**
  61762. * List of inspectable custom properties (used by the Inspector)
  61763. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  61764. */
  61765. inspectableCustomProperties: IInspectable[];
  61766. /**
  61767. * @hidden
  61768. */
  61769. protected _cameras: Camera[];
  61770. /** @hidden */
  61771. _name: string;
  61772. /**
  61773. * Gets pipeline name
  61774. */
  61775. readonly name: string;
  61776. /**
  61777. * Initializes a PostProcessRenderPipeline
  61778. * @param engine engine to add the pipeline to
  61779. * @param name name of the pipeline
  61780. */
  61781. constructor(engine: Engine, name: string);
  61782. /**
  61783. * Gets the class name
  61784. * @returns "PostProcessRenderPipeline"
  61785. */
  61786. getClassName(): string;
  61787. /**
  61788. * If all the render effects in the pipeline are supported
  61789. */
  61790. readonly isSupported: boolean;
  61791. /**
  61792. * Adds an effect to the pipeline
  61793. * @param renderEffect the effect to add
  61794. */
  61795. addEffect(renderEffect: PostProcessRenderEffect): void;
  61796. /** @hidden */
  61797. _rebuild(): void;
  61798. /** @hidden */
  61799. _enableEffect(renderEffectName: string, cameras: Camera): void;
  61800. /** @hidden */
  61801. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  61802. /** @hidden */
  61803. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  61804. /** @hidden */
  61805. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  61806. /** @hidden */
  61807. _attachCameras(cameras: Camera, unique: boolean): void;
  61808. /** @hidden */
  61809. _attachCameras(cameras: Camera[], unique: boolean): void;
  61810. /** @hidden */
  61811. _detachCameras(cameras: Camera): void;
  61812. /** @hidden */
  61813. _detachCameras(cameras: Nullable<Camera[]>): void;
  61814. /** @hidden */
  61815. _update(): void;
  61816. /** @hidden */
  61817. _reset(): void;
  61818. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  61819. /**
  61820. * Disposes of the pipeline
  61821. */
  61822. dispose(): void;
  61823. }
  61824. }
  61825. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager" {
  61826. import { Camera } from "babylonjs/Cameras/camera";
  61827. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  61828. /**
  61829. * PostProcessRenderPipelineManager class
  61830. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  61831. */
  61832. export class PostProcessRenderPipelineManager {
  61833. private _renderPipelines;
  61834. /**
  61835. * Initializes a PostProcessRenderPipelineManager
  61836. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  61837. */
  61838. constructor();
  61839. /**
  61840. * Gets the list of supported render pipelines
  61841. */
  61842. readonly supportedPipelines: PostProcessRenderPipeline[];
  61843. /**
  61844. * Adds a pipeline to the manager
  61845. * @param renderPipeline The pipeline to add
  61846. */
  61847. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  61848. /**
  61849. * Attaches a camera to the pipeline
  61850. * @param renderPipelineName The name of the pipeline to attach to
  61851. * @param cameras the camera to attach
  61852. * @param unique if the camera can be attached multiple times to the pipeline
  61853. */
  61854. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  61855. /**
  61856. * Detaches a camera from the pipeline
  61857. * @param renderPipelineName The name of the pipeline to detach from
  61858. * @param cameras the camera to detach
  61859. */
  61860. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  61861. /**
  61862. * Enables an effect by name on a pipeline
  61863. * @param renderPipelineName the name of the pipeline to enable the effect in
  61864. * @param renderEffectName the name of the effect to enable
  61865. * @param cameras the cameras that the effect should be enabled on
  61866. */
  61867. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  61868. /**
  61869. * Disables an effect by name on a pipeline
  61870. * @param renderPipelineName the name of the pipeline to disable the effect in
  61871. * @param renderEffectName the name of the effect to disable
  61872. * @param cameras the cameras that the effect should be disabled on
  61873. */
  61874. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  61875. /**
  61876. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  61877. */
  61878. update(): void;
  61879. /** @hidden */
  61880. _rebuild(): void;
  61881. /**
  61882. * Disposes of the manager and pipelines
  61883. */
  61884. dispose(): void;
  61885. }
  61886. }
  61887. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent" {
  61888. import { ISceneComponent } from "babylonjs/sceneComponent";
  61889. import { PostProcessRenderPipelineManager } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  61890. import { Scene } from "babylonjs/scene";
  61891. module "babylonjs/scene" {
  61892. interface Scene {
  61893. /** @hidden (Backing field) */
  61894. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  61895. /**
  61896. * Gets the postprocess render pipeline manager
  61897. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  61898. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  61899. */
  61900. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  61901. }
  61902. }
  61903. /**
  61904. * Defines the Render Pipeline scene component responsible to rendering pipelines
  61905. */
  61906. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  61907. /**
  61908. * The component name helpfull to identify the component in the list of scene components.
  61909. */
  61910. readonly name: string;
  61911. /**
  61912. * The scene the component belongs to.
  61913. */
  61914. scene: Scene;
  61915. /**
  61916. * Creates a new instance of the component for the given scene
  61917. * @param scene Defines the scene to register the component in
  61918. */
  61919. constructor(scene: Scene);
  61920. /**
  61921. * Registers the component in a given scene
  61922. */
  61923. register(): void;
  61924. /**
  61925. * Rebuilds the elements related to this component in case of
  61926. * context lost for instance.
  61927. */
  61928. rebuild(): void;
  61929. /**
  61930. * Disposes the component and the associated ressources
  61931. */
  61932. dispose(): void;
  61933. private _gatherRenderTargets;
  61934. }
  61935. }
  61936. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline" {
  61937. import { Nullable } from "babylonjs/types";
  61938. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  61939. import { Camera } from "babylonjs/Cameras/camera";
  61940. import { IDisposable } from "babylonjs/scene";
  61941. import { GlowLayer } from "babylonjs/Layers/glowLayer";
  61942. import { Scene } from "babylonjs/scene";
  61943. import { SharpenPostProcess } from "babylonjs/PostProcesses/sharpenPostProcess";
  61944. import { ImageProcessingPostProcess } from "babylonjs/PostProcesses/imageProcessingPostProcess";
  61945. import { ChromaticAberrationPostProcess } from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  61946. import { GrainPostProcess } from "babylonjs/PostProcesses/grainPostProcess";
  61947. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  61948. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  61949. import { DepthOfFieldEffect, DepthOfFieldEffectBlurLevel } from "babylonjs/PostProcesses/depthOfFieldEffect";
  61950. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  61951. import { Animation } from "babylonjs/Animations/animation";
  61952. /**
  61953. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  61954. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  61955. */
  61956. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  61957. private _scene;
  61958. private _camerasToBeAttached;
  61959. /**
  61960. * ID of the sharpen post process,
  61961. */
  61962. private readonly SharpenPostProcessId;
  61963. /**
  61964. * @ignore
  61965. * ID of the image processing post process;
  61966. */
  61967. readonly ImageProcessingPostProcessId: string;
  61968. /**
  61969. * @ignore
  61970. * ID of the Fast Approximate Anti-Aliasing post process;
  61971. */
  61972. readonly FxaaPostProcessId: string;
  61973. /**
  61974. * ID of the chromatic aberration post process,
  61975. */
  61976. private readonly ChromaticAberrationPostProcessId;
  61977. /**
  61978. * ID of the grain post process
  61979. */
  61980. private readonly GrainPostProcessId;
  61981. /**
  61982. * Sharpen post process which will apply a sharpen convolution to enhance edges
  61983. */
  61984. sharpen: SharpenPostProcess;
  61985. private _sharpenEffect;
  61986. private bloom;
  61987. /**
  61988. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  61989. */
  61990. depthOfField: DepthOfFieldEffect;
  61991. /**
  61992. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  61993. */
  61994. fxaa: FxaaPostProcess;
  61995. /**
  61996. * Image post processing pass used to perform operations such as tone mapping or color grading.
  61997. */
  61998. imageProcessing: ImageProcessingPostProcess;
  61999. /**
  62000. * Chromatic aberration post process which will shift rgb colors in the image
  62001. */
  62002. chromaticAberration: ChromaticAberrationPostProcess;
  62003. private _chromaticAberrationEffect;
  62004. /**
  62005. * Grain post process which add noise to the image
  62006. */
  62007. grain: GrainPostProcess;
  62008. private _grainEffect;
  62009. /**
  62010. * Glow post process which adds a glow to emissive areas of the image
  62011. */
  62012. private _glowLayer;
  62013. /**
  62014. * Animations which can be used to tweak settings over a period of time
  62015. */
  62016. animations: Animation[];
  62017. private _imageProcessingConfigurationObserver;
  62018. private _sharpenEnabled;
  62019. private _bloomEnabled;
  62020. private _depthOfFieldEnabled;
  62021. private _depthOfFieldBlurLevel;
  62022. private _fxaaEnabled;
  62023. private _imageProcessingEnabled;
  62024. private _defaultPipelineTextureType;
  62025. private _bloomScale;
  62026. private _chromaticAberrationEnabled;
  62027. private _grainEnabled;
  62028. private _buildAllowed;
  62029. /**
  62030. * Gets active scene
  62031. */
  62032. readonly scene: Scene;
  62033. /**
  62034. * Enable or disable the sharpen process from the pipeline
  62035. */
  62036. sharpenEnabled: boolean;
  62037. private _resizeObserver;
  62038. private _hardwareScaleLevel;
  62039. private _bloomKernel;
  62040. /**
  62041. * Specifies the size of the bloom blur kernel, relative to the final output size
  62042. */
  62043. bloomKernel: number;
  62044. /**
  62045. * Specifies the weight of the bloom in the final rendering
  62046. */
  62047. private _bloomWeight;
  62048. /**
  62049. * Specifies the luma threshold for the area that will be blurred by the bloom
  62050. */
  62051. private _bloomThreshold;
  62052. private _hdr;
  62053. /**
  62054. * The strength of the bloom.
  62055. */
  62056. bloomWeight: number;
  62057. /**
  62058. * The strength of the bloom.
  62059. */
  62060. bloomThreshold: number;
  62061. /**
  62062. * The scale of the bloom, lower value will provide better performance.
  62063. */
  62064. bloomScale: number;
  62065. /**
  62066. * Enable or disable the bloom from the pipeline
  62067. */
  62068. bloomEnabled: boolean;
  62069. private _rebuildBloom;
  62070. /**
  62071. * If the depth of field is enabled.
  62072. */
  62073. depthOfFieldEnabled: boolean;
  62074. /**
  62075. * Blur level of the depth of field effect. (Higher blur will effect performance)
  62076. */
  62077. depthOfFieldBlurLevel: DepthOfFieldEffectBlurLevel;
  62078. /**
  62079. * If the anti aliasing is enabled.
  62080. */
  62081. fxaaEnabled: boolean;
  62082. private _samples;
  62083. /**
  62084. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  62085. */
  62086. samples: number;
  62087. /**
  62088. * If image processing is enabled.
  62089. */
  62090. imageProcessingEnabled: boolean;
  62091. /**
  62092. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  62093. */
  62094. glowLayerEnabled: boolean;
  62095. /**
  62096. * Gets the glow layer (or null if not defined)
  62097. */
  62098. readonly glowLayer: Nullable<GlowLayer>;
  62099. /**
  62100. * Enable or disable the chromaticAberration process from the pipeline
  62101. */
  62102. chromaticAberrationEnabled: boolean;
  62103. /**
  62104. * Enable or disable the grain process from the pipeline
  62105. */
  62106. grainEnabled: boolean;
  62107. /**
  62108. * @constructor
  62109. * @param name - The rendering pipeline name (default: "")
  62110. * @param hdr - If high dynamic range textures should be used (default: true)
  62111. * @param scene - The scene linked to this pipeline (default: the last created scene)
  62112. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  62113. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  62114. */
  62115. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  62116. /**
  62117. * Get the class name
  62118. * @returns "DefaultRenderingPipeline"
  62119. */
  62120. getClassName(): string;
  62121. /**
  62122. * Force the compilation of the entire pipeline.
  62123. */
  62124. prepare(): void;
  62125. private _hasCleared;
  62126. private _prevPostProcess;
  62127. private _prevPrevPostProcess;
  62128. private _setAutoClearAndTextureSharing;
  62129. private _depthOfFieldSceneObserver;
  62130. private _buildPipeline;
  62131. private _disposePostProcesses;
  62132. /**
  62133. * Adds a camera to the pipeline
  62134. * @param camera the camera to be added
  62135. */
  62136. addCamera(camera: Camera): void;
  62137. /**
  62138. * Removes a camera from the pipeline
  62139. * @param camera the camera to remove
  62140. */
  62141. removeCamera(camera: Camera): void;
  62142. /**
  62143. * Dispose of the pipeline and stop all post processes
  62144. */
  62145. dispose(): void;
  62146. /**
  62147. * Serialize the rendering pipeline (Used when exporting)
  62148. * @returns the serialized object
  62149. */
  62150. serialize(): any;
  62151. /**
  62152. * Parse the serialized pipeline
  62153. * @param source Source pipeline.
  62154. * @param scene The scene to load the pipeline to.
  62155. * @param rootUrl The URL of the serialized pipeline.
  62156. * @returns An instantiated pipeline from the serialized object.
  62157. */
  62158. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  62159. }
  62160. }
  62161. declare module "babylonjs/Shaders/lensHighlights.fragment" {
  62162. /** @hidden */
  62163. export var lensHighlightsPixelShader: {
  62164. name: string;
  62165. shader: string;
  62166. };
  62167. }
  62168. declare module "babylonjs/Shaders/depthOfField.fragment" {
  62169. /** @hidden */
  62170. export var depthOfFieldPixelShader: {
  62171. name: string;
  62172. shader: string;
  62173. };
  62174. }
  62175. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline" {
  62176. import { Camera } from "babylonjs/Cameras/camera";
  62177. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  62178. import { Scene } from "babylonjs/scene";
  62179. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  62180. import "babylonjs/Shaders/chromaticAberration.fragment";
  62181. import "babylonjs/Shaders/lensHighlights.fragment";
  62182. import "babylonjs/Shaders/depthOfField.fragment";
  62183. /**
  62184. * BABYLON.JS Chromatic Aberration GLSL Shader
  62185. * Author: Olivier Guyot
  62186. * Separates very slightly R, G and B colors on the edges of the screen
  62187. * Inspired by Francois Tarlier & Martins Upitis
  62188. */
  62189. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  62190. /**
  62191. * @ignore
  62192. * The chromatic aberration PostProcess id in the pipeline
  62193. */
  62194. LensChromaticAberrationEffect: string;
  62195. /**
  62196. * @ignore
  62197. * The highlights enhancing PostProcess id in the pipeline
  62198. */
  62199. HighlightsEnhancingEffect: string;
  62200. /**
  62201. * @ignore
  62202. * The depth-of-field PostProcess id in the pipeline
  62203. */
  62204. LensDepthOfFieldEffect: string;
  62205. private _scene;
  62206. private _depthTexture;
  62207. private _grainTexture;
  62208. private _chromaticAberrationPostProcess;
  62209. private _highlightsPostProcess;
  62210. private _depthOfFieldPostProcess;
  62211. private _edgeBlur;
  62212. private _grainAmount;
  62213. private _chromaticAberration;
  62214. private _distortion;
  62215. private _highlightsGain;
  62216. private _highlightsThreshold;
  62217. private _dofDistance;
  62218. private _dofAperture;
  62219. private _dofDarken;
  62220. private _dofPentagon;
  62221. private _blurNoise;
  62222. /**
  62223. * @constructor
  62224. *
  62225. * Effect parameters are as follow:
  62226. * {
  62227. * chromatic_aberration: number; // from 0 to x (1 for realism)
  62228. * edge_blur: number; // from 0 to x (1 for realism)
  62229. * distortion: number; // from 0 to x (1 for realism)
  62230. * grain_amount: number; // from 0 to 1
  62231. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  62232. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  62233. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  62234. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  62235. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  62236. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  62237. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  62238. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  62239. * }
  62240. * Note: if an effect parameter is unset, effect is disabled
  62241. *
  62242. * @param name The rendering pipeline name
  62243. * @param parameters - An object containing all parameters (see above)
  62244. * @param scene The scene linked to this pipeline
  62245. * @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)
  62246. * @param cameras The array of cameras that the rendering pipeline will be attached to
  62247. */
  62248. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  62249. /**
  62250. * Get the class name
  62251. * @returns "LensRenderingPipeline"
  62252. */
  62253. getClassName(): string;
  62254. /**
  62255. * Gets associated scene
  62256. */
  62257. readonly scene: Scene;
  62258. /**
  62259. * Gets or sets the edge blur
  62260. */
  62261. edgeBlur: number;
  62262. /**
  62263. * Gets or sets the grain amount
  62264. */
  62265. grainAmount: number;
  62266. /**
  62267. * Gets or sets the chromatic aberration amount
  62268. */
  62269. chromaticAberration: number;
  62270. /**
  62271. * Gets or sets the depth of field aperture
  62272. */
  62273. dofAperture: number;
  62274. /**
  62275. * Gets or sets the edge distortion
  62276. */
  62277. edgeDistortion: number;
  62278. /**
  62279. * Gets or sets the depth of field distortion
  62280. */
  62281. dofDistortion: number;
  62282. /**
  62283. * Gets or sets the darken out of focus amount
  62284. */
  62285. darkenOutOfFocus: number;
  62286. /**
  62287. * Gets or sets a boolean indicating if blur noise is enabled
  62288. */
  62289. blurNoise: boolean;
  62290. /**
  62291. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  62292. */
  62293. pentagonBokeh: boolean;
  62294. /**
  62295. * Gets or sets the highlight grain amount
  62296. */
  62297. highlightsGain: number;
  62298. /**
  62299. * Gets or sets the highlight threshold
  62300. */
  62301. highlightsThreshold: number;
  62302. /**
  62303. * Sets the amount of blur at the edges
  62304. * @param amount blur amount
  62305. */
  62306. setEdgeBlur(amount: number): void;
  62307. /**
  62308. * Sets edge blur to 0
  62309. */
  62310. disableEdgeBlur(): void;
  62311. /**
  62312. * Sets the amout of grain
  62313. * @param amount Amount of grain
  62314. */
  62315. setGrainAmount(amount: number): void;
  62316. /**
  62317. * Set grain amount to 0
  62318. */
  62319. disableGrain(): void;
  62320. /**
  62321. * Sets the chromatic aberration amount
  62322. * @param amount amount of chromatic aberration
  62323. */
  62324. setChromaticAberration(amount: number): void;
  62325. /**
  62326. * Sets chromatic aberration amount to 0
  62327. */
  62328. disableChromaticAberration(): void;
  62329. /**
  62330. * Sets the EdgeDistortion amount
  62331. * @param amount amount of EdgeDistortion
  62332. */
  62333. setEdgeDistortion(amount: number): void;
  62334. /**
  62335. * Sets edge distortion to 0
  62336. */
  62337. disableEdgeDistortion(): void;
  62338. /**
  62339. * Sets the FocusDistance amount
  62340. * @param amount amount of FocusDistance
  62341. */
  62342. setFocusDistance(amount: number): void;
  62343. /**
  62344. * Disables depth of field
  62345. */
  62346. disableDepthOfField(): void;
  62347. /**
  62348. * Sets the Aperture amount
  62349. * @param amount amount of Aperture
  62350. */
  62351. setAperture(amount: number): void;
  62352. /**
  62353. * Sets the DarkenOutOfFocus amount
  62354. * @param amount amount of DarkenOutOfFocus
  62355. */
  62356. setDarkenOutOfFocus(amount: number): void;
  62357. private _pentagonBokehIsEnabled;
  62358. /**
  62359. * Creates a pentagon bokeh effect
  62360. */
  62361. enablePentagonBokeh(): void;
  62362. /**
  62363. * Disables the pentagon bokeh effect
  62364. */
  62365. disablePentagonBokeh(): void;
  62366. /**
  62367. * Enables noise blur
  62368. */
  62369. enableNoiseBlur(): void;
  62370. /**
  62371. * Disables noise blur
  62372. */
  62373. disableNoiseBlur(): void;
  62374. /**
  62375. * Sets the HighlightsGain amount
  62376. * @param amount amount of HighlightsGain
  62377. */
  62378. setHighlightsGain(amount: number): void;
  62379. /**
  62380. * Sets the HighlightsThreshold amount
  62381. * @param amount amount of HighlightsThreshold
  62382. */
  62383. setHighlightsThreshold(amount: number): void;
  62384. /**
  62385. * Disables highlights
  62386. */
  62387. disableHighlights(): void;
  62388. /**
  62389. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  62390. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  62391. */
  62392. dispose(disableDepthRender?: boolean): void;
  62393. private _createChromaticAberrationPostProcess;
  62394. private _createHighlightsPostProcess;
  62395. private _createDepthOfFieldPostProcess;
  62396. private _createGrainTexture;
  62397. }
  62398. }
  62399. declare module "babylonjs/Shaders/ssao2.fragment" {
  62400. /** @hidden */
  62401. export var ssao2PixelShader: {
  62402. name: string;
  62403. shader: string;
  62404. };
  62405. }
  62406. declare module "babylonjs/Shaders/ssaoCombine.fragment" {
  62407. /** @hidden */
  62408. export var ssaoCombinePixelShader: {
  62409. name: string;
  62410. shader: string;
  62411. };
  62412. }
  62413. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline" {
  62414. import { Camera } from "babylonjs/Cameras/camera";
  62415. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  62416. import { Scene } from "babylonjs/scene";
  62417. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  62418. import "babylonjs/Shaders/ssao2.fragment";
  62419. import "babylonjs/Shaders/ssaoCombine.fragment";
  62420. /**
  62421. * Render pipeline to produce ssao effect
  62422. */
  62423. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  62424. /**
  62425. * @ignore
  62426. * The PassPostProcess id in the pipeline that contains the original scene color
  62427. */
  62428. SSAOOriginalSceneColorEffect: string;
  62429. /**
  62430. * @ignore
  62431. * The SSAO PostProcess id in the pipeline
  62432. */
  62433. SSAORenderEffect: string;
  62434. /**
  62435. * @ignore
  62436. * The horizontal blur PostProcess id in the pipeline
  62437. */
  62438. SSAOBlurHRenderEffect: string;
  62439. /**
  62440. * @ignore
  62441. * The vertical blur PostProcess id in the pipeline
  62442. */
  62443. SSAOBlurVRenderEffect: string;
  62444. /**
  62445. * @ignore
  62446. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  62447. */
  62448. SSAOCombineRenderEffect: string;
  62449. /**
  62450. * The output strength of the SSAO post-process. Default value is 1.0.
  62451. */
  62452. totalStrength: number;
  62453. /**
  62454. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  62455. */
  62456. maxZ: number;
  62457. /**
  62458. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  62459. */
  62460. minZAspect: number;
  62461. private _samples;
  62462. /**
  62463. * Number of samples used for the SSAO calculations. Default value is 8
  62464. */
  62465. samples: number;
  62466. private _textureSamples;
  62467. /**
  62468. * Number of samples to use for antialiasing
  62469. */
  62470. textureSamples: number;
  62471. /**
  62472. * Ratio object used for SSAO ratio and blur ratio
  62473. */
  62474. private _ratio;
  62475. /**
  62476. * Dynamically generated sphere sampler.
  62477. */
  62478. private _sampleSphere;
  62479. /**
  62480. * Blur filter offsets
  62481. */
  62482. private _samplerOffsets;
  62483. private _expensiveBlur;
  62484. /**
  62485. * If bilateral blur should be used
  62486. */
  62487. expensiveBlur: boolean;
  62488. /**
  62489. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  62490. */
  62491. radius: number;
  62492. /**
  62493. * The base color of the SSAO post-process
  62494. * The final result is "base + ssao" between [0, 1]
  62495. */
  62496. base: number;
  62497. /**
  62498. * Support test.
  62499. */
  62500. static readonly IsSupported: boolean;
  62501. private _scene;
  62502. private _depthTexture;
  62503. private _normalTexture;
  62504. private _randomTexture;
  62505. private _originalColorPostProcess;
  62506. private _ssaoPostProcess;
  62507. private _blurHPostProcess;
  62508. private _blurVPostProcess;
  62509. private _ssaoCombinePostProcess;
  62510. private _firstUpdate;
  62511. /**
  62512. * Gets active scene
  62513. */
  62514. readonly scene: Scene;
  62515. /**
  62516. * @constructor
  62517. * @param name The rendering pipeline name
  62518. * @param scene The scene linked to this pipeline
  62519. * @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 }
  62520. * @param cameras The array of cameras that the rendering pipeline will be attached to
  62521. */
  62522. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  62523. /**
  62524. * Get the class name
  62525. * @returns "SSAO2RenderingPipeline"
  62526. */
  62527. getClassName(): string;
  62528. /**
  62529. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  62530. */
  62531. dispose(disableGeometryBufferRenderer?: boolean): void;
  62532. private _createBlurPostProcess;
  62533. /** @hidden */
  62534. _rebuild(): void;
  62535. private _bits;
  62536. private _radicalInverse_VdC;
  62537. private _hammersley;
  62538. private _hemisphereSample_uniform;
  62539. private _generateHemisphere;
  62540. private _createSSAOPostProcess;
  62541. private _createSSAOCombinePostProcess;
  62542. private _createRandomTexture;
  62543. /**
  62544. * Serialize the rendering pipeline (Used when exporting)
  62545. * @returns the serialized object
  62546. */
  62547. serialize(): any;
  62548. /**
  62549. * Parse the serialized pipeline
  62550. * @param source Source pipeline.
  62551. * @param scene The scene to load the pipeline to.
  62552. * @param rootUrl The URL of the serialized pipeline.
  62553. * @returns An instantiated pipeline from the serialized object.
  62554. */
  62555. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  62556. }
  62557. }
  62558. declare module "babylonjs/Shaders/ssao.fragment" {
  62559. /** @hidden */
  62560. export var ssaoPixelShader: {
  62561. name: string;
  62562. shader: string;
  62563. };
  62564. }
  62565. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline" {
  62566. import { Camera } from "babylonjs/Cameras/camera";
  62567. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  62568. import { Scene } from "babylonjs/scene";
  62569. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  62570. import "babylonjs/Shaders/ssao.fragment";
  62571. import "babylonjs/Shaders/ssaoCombine.fragment";
  62572. /**
  62573. * Render pipeline to produce ssao effect
  62574. */
  62575. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  62576. /**
  62577. * @ignore
  62578. * The PassPostProcess id in the pipeline that contains the original scene color
  62579. */
  62580. SSAOOriginalSceneColorEffect: string;
  62581. /**
  62582. * @ignore
  62583. * The SSAO PostProcess id in the pipeline
  62584. */
  62585. SSAORenderEffect: string;
  62586. /**
  62587. * @ignore
  62588. * The horizontal blur PostProcess id in the pipeline
  62589. */
  62590. SSAOBlurHRenderEffect: string;
  62591. /**
  62592. * @ignore
  62593. * The vertical blur PostProcess id in the pipeline
  62594. */
  62595. SSAOBlurVRenderEffect: string;
  62596. /**
  62597. * @ignore
  62598. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  62599. */
  62600. SSAOCombineRenderEffect: string;
  62601. /**
  62602. * The output strength of the SSAO post-process. Default value is 1.0.
  62603. */
  62604. totalStrength: number;
  62605. /**
  62606. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  62607. */
  62608. radius: number;
  62609. /**
  62610. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  62611. * Must not be equal to fallOff and superior to fallOff.
  62612. * Default value is 0.0075
  62613. */
  62614. area: number;
  62615. /**
  62616. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  62617. * Must not be equal to area and inferior to area.
  62618. * Default value is 0.000001
  62619. */
  62620. fallOff: number;
  62621. /**
  62622. * The base color of the SSAO post-process
  62623. * The final result is "base + ssao" between [0, 1]
  62624. */
  62625. base: number;
  62626. private _scene;
  62627. private _depthTexture;
  62628. private _randomTexture;
  62629. private _originalColorPostProcess;
  62630. private _ssaoPostProcess;
  62631. private _blurHPostProcess;
  62632. private _blurVPostProcess;
  62633. private _ssaoCombinePostProcess;
  62634. private _firstUpdate;
  62635. /**
  62636. * Gets active scene
  62637. */
  62638. readonly scene: Scene;
  62639. /**
  62640. * @constructor
  62641. * @param name - The rendering pipeline name
  62642. * @param scene - The scene linked to this pipeline
  62643. * @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 }
  62644. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  62645. */
  62646. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  62647. /**
  62648. * Get the class name
  62649. * @returns "SSAORenderingPipeline"
  62650. */
  62651. getClassName(): string;
  62652. /**
  62653. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  62654. */
  62655. dispose(disableDepthRender?: boolean): void;
  62656. private _createBlurPostProcess;
  62657. /** @hidden */
  62658. _rebuild(): void;
  62659. private _createSSAOPostProcess;
  62660. private _createSSAOCombinePostProcess;
  62661. private _createRandomTexture;
  62662. }
  62663. }
  62664. declare module "babylonjs/Shaders/standard.fragment" {
  62665. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  62666. /** @hidden */
  62667. export var standardPixelShader: {
  62668. name: string;
  62669. shader: string;
  62670. };
  62671. }
  62672. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline" {
  62673. import { Nullable } from "babylonjs/types";
  62674. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  62675. import { Camera } from "babylonjs/Cameras/camera";
  62676. import { Texture } from "babylonjs/Materials/Textures/texture";
  62677. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  62678. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  62679. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  62680. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  62681. import { IDisposable } from "babylonjs/scene";
  62682. import { SpotLight } from "babylonjs/Lights/spotLight";
  62683. import { DirectionalLight } from "babylonjs/Lights/directionalLight";
  62684. import { Scene } from "babylonjs/scene";
  62685. import { Animation } from "babylonjs/Animations/animation";
  62686. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  62687. import "babylonjs/Shaders/standard.fragment";
  62688. /**
  62689. * Standard rendering pipeline
  62690. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  62691. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  62692. */
  62693. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  62694. /**
  62695. * Public members
  62696. */
  62697. /**
  62698. * Post-process which contains the original scene color before the pipeline applies all the effects
  62699. */
  62700. originalPostProcess: Nullable<PostProcess>;
  62701. /**
  62702. * Post-process used to down scale an image x4
  62703. */
  62704. downSampleX4PostProcess: Nullable<PostProcess>;
  62705. /**
  62706. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  62707. */
  62708. brightPassPostProcess: Nullable<PostProcess>;
  62709. /**
  62710. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  62711. */
  62712. blurHPostProcesses: PostProcess[];
  62713. /**
  62714. * Post-process array storing all the vertical blur post-processes used by the pipeline
  62715. */
  62716. blurVPostProcesses: PostProcess[];
  62717. /**
  62718. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  62719. */
  62720. textureAdderPostProcess: Nullable<PostProcess>;
  62721. /**
  62722. * Post-process used to create volumetric lighting effect
  62723. */
  62724. volumetricLightPostProcess: Nullable<PostProcess>;
  62725. /**
  62726. * Post-process used to smooth the previous volumetric light post-process on the X axis
  62727. */
  62728. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  62729. /**
  62730. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  62731. */
  62732. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  62733. /**
  62734. * Post-process used to merge the volumetric light effect and the real scene color
  62735. */
  62736. volumetricLightMergePostProces: Nullable<PostProcess>;
  62737. /**
  62738. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  62739. */
  62740. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  62741. /**
  62742. * Base post-process used to calculate the average luminance of the final image for HDR
  62743. */
  62744. luminancePostProcess: Nullable<PostProcess>;
  62745. /**
  62746. * Post-processes used to create down sample post-processes in order to get
  62747. * the average luminance of the final image for HDR
  62748. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  62749. */
  62750. luminanceDownSamplePostProcesses: PostProcess[];
  62751. /**
  62752. * Post-process used to create a HDR effect (light adaptation)
  62753. */
  62754. hdrPostProcess: Nullable<PostProcess>;
  62755. /**
  62756. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  62757. */
  62758. textureAdderFinalPostProcess: Nullable<PostProcess>;
  62759. /**
  62760. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  62761. */
  62762. lensFlareFinalPostProcess: Nullable<PostProcess>;
  62763. /**
  62764. * Post-process used to merge the final HDR post-process and the real scene color
  62765. */
  62766. hdrFinalPostProcess: Nullable<PostProcess>;
  62767. /**
  62768. * Post-process used to create a lens flare effect
  62769. */
  62770. lensFlarePostProcess: Nullable<PostProcess>;
  62771. /**
  62772. * Post-process that merges the result of the lens flare post-process and the real scene color
  62773. */
  62774. lensFlareComposePostProcess: Nullable<PostProcess>;
  62775. /**
  62776. * Post-process used to create a motion blur effect
  62777. */
  62778. motionBlurPostProcess: Nullable<PostProcess>;
  62779. /**
  62780. * Post-process used to create a depth of field effect
  62781. */
  62782. depthOfFieldPostProcess: Nullable<PostProcess>;
  62783. /**
  62784. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  62785. */
  62786. fxaaPostProcess: Nullable<FxaaPostProcess>;
  62787. /**
  62788. * Represents the brightness threshold in order to configure the illuminated surfaces
  62789. */
  62790. brightThreshold: number;
  62791. /**
  62792. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  62793. */
  62794. blurWidth: number;
  62795. /**
  62796. * Sets if the blur for highlighted surfaces must be only horizontal
  62797. */
  62798. horizontalBlur: boolean;
  62799. /**
  62800. * Gets the overall exposure used by the pipeline
  62801. */
  62802. /**
  62803. * Sets the overall exposure used by the pipeline
  62804. */
  62805. exposure: number;
  62806. /**
  62807. * Texture used typically to simulate "dirty" on camera lens
  62808. */
  62809. lensTexture: Nullable<Texture>;
  62810. /**
  62811. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  62812. */
  62813. volumetricLightCoefficient: number;
  62814. /**
  62815. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  62816. */
  62817. volumetricLightPower: number;
  62818. /**
  62819. * Used the set the blur intensity to smooth the volumetric lights
  62820. */
  62821. volumetricLightBlurScale: number;
  62822. /**
  62823. * Light (spot or directional) used to generate the volumetric lights rays
  62824. * The source light must have a shadow generate so the pipeline can get its
  62825. * depth map
  62826. */
  62827. sourceLight: Nullable<SpotLight | DirectionalLight>;
  62828. /**
  62829. * For eye adaptation, represents the minimum luminance the eye can see
  62830. */
  62831. hdrMinimumLuminance: number;
  62832. /**
  62833. * For eye adaptation, represents the decrease luminance speed
  62834. */
  62835. hdrDecreaseRate: number;
  62836. /**
  62837. * For eye adaptation, represents the increase luminance speed
  62838. */
  62839. hdrIncreaseRate: number;
  62840. /**
  62841. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  62842. */
  62843. /**
  62844. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  62845. */
  62846. hdrAutoExposure: boolean;
  62847. /**
  62848. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  62849. */
  62850. lensColorTexture: Nullable<Texture>;
  62851. /**
  62852. * The overall strengh for the lens flare effect
  62853. */
  62854. lensFlareStrength: number;
  62855. /**
  62856. * Dispersion coefficient for lens flare ghosts
  62857. */
  62858. lensFlareGhostDispersal: number;
  62859. /**
  62860. * Main lens flare halo width
  62861. */
  62862. lensFlareHaloWidth: number;
  62863. /**
  62864. * Based on the lens distortion effect, defines how much the lens flare result
  62865. * is distorted
  62866. */
  62867. lensFlareDistortionStrength: number;
  62868. /**
  62869. * Configures the blur intensity used for for lens flare (halo)
  62870. */
  62871. lensFlareBlurWidth: number;
  62872. /**
  62873. * Lens star texture must be used to simulate rays on the flares and is available
  62874. * in the documentation
  62875. */
  62876. lensStarTexture: Nullable<Texture>;
  62877. /**
  62878. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  62879. * flare effect by taking account of the dirt texture
  62880. */
  62881. lensFlareDirtTexture: Nullable<Texture>;
  62882. /**
  62883. * Represents the focal length for the depth of field effect
  62884. */
  62885. depthOfFieldDistance: number;
  62886. /**
  62887. * Represents the blur intensity for the blurred part of the depth of field effect
  62888. */
  62889. depthOfFieldBlurWidth: number;
  62890. /**
  62891. * Gets how much the image is blurred by the movement while using the motion blur post-process
  62892. */
  62893. /**
  62894. * Sets how much the image is blurred by the movement while using the motion blur post-process
  62895. */
  62896. motionStrength: number;
  62897. /**
  62898. * Gets wether or not the motion blur post-process is object based or screen based.
  62899. */
  62900. /**
  62901. * Sets wether or not the motion blur post-process should be object based or screen based
  62902. */
  62903. objectBasedMotionBlur: boolean;
  62904. /**
  62905. * List of animations for the pipeline (IAnimatable implementation)
  62906. */
  62907. animations: Animation[];
  62908. /**
  62909. * Private members
  62910. */
  62911. private _scene;
  62912. private _currentDepthOfFieldSource;
  62913. private _basePostProcess;
  62914. private _fixedExposure;
  62915. private _currentExposure;
  62916. private _hdrAutoExposure;
  62917. private _hdrCurrentLuminance;
  62918. private _motionStrength;
  62919. private _isObjectBasedMotionBlur;
  62920. private _floatTextureType;
  62921. private _camerasToBeAttached;
  62922. private _ratio;
  62923. private _bloomEnabled;
  62924. private _depthOfFieldEnabled;
  62925. private _vlsEnabled;
  62926. private _lensFlareEnabled;
  62927. private _hdrEnabled;
  62928. private _motionBlurEnabled;
  62929. private _fxaaEnabled;
  62930. private _motionBlurSamples;
  62931. private _volumetricLightStepsCount;
  62932. private _samples;
  62933. /**
  62934. * @ignore
  62935. * Specifies if the bloom pipeline is enabled
  62936. */
  62937. BloomEnabled: boolean;
  62938. /**
  62939. * @ignore
  62940. * Specifies if the depth of field pipeline is enabed
  62941. */
  62942. DepthOfFieldEnabled: boolean;
  62943. /**
  62944. * @ignore
  62945. * Specifies if the lens flare pipeline is enabed
  62946. */
  62947. LensFlareEnabled: boolean;
  62948. /**
  62949. * @ignore
  62950. * Specifies if the HDR pipeline is enabled
  62951. */
  62952. HDREnabled: boolean;
  62953. /**
  62954. * @ignore
  62955. * Specifies if the volumetric lights scattering effect is enabled
  62956. */
  62957. VLSEnabled: boolean;
  62958. /**
  62959. * @ignore
  62960. * Specifies if the motion blur effect is enabled
  62961. */
  62962. MotionBlurEnabled: boolean;
  62963. /**
  62964. * Specifies if anti-aliasing is enabled
  62965. */
  62966. fxaaEnabled: boolean;
  62967. /**
  62968. * Specifies the number of steps used to calculate the volumetric lights
  62969. * Typically in interval [50, 200]
  62970. */
  62971. volumetricLightStepsCount: number;
  62972. /**
  62973. * Specifies the number of samples used for the motion blur effect
  62974. * Typically in interval [16, 64]
  62975. */
  62976. motionBlurSamples: number;
  62977. /**
  62978. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  62979. */
  62980. samples: number;
  62981. /**
  62982. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  62983. * @constructor
  62984. * @param name The rendering pipeline name
  62985. * @param scene The scene linked to this pipeline
  62986. * @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)
  62987. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  62988. * @param cameras The array of cameras that the rendering pipeline will be attached to
  62989. */
  62990. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  62991. private _buildPipeline;
  62992. private _createDownSampleX4PostProcess;
  62993. private _createBrightPassPostProcess;
  62994. private _createBlurPostProcesses;
  62995. private _createTextureAdderPostProcess;
  62996. private _createVolumetricLightPostProcess;
  62997. private _createLuminancePostProcesses;
  62998. private _createHdrPostProcess;
  62999. private _createLensFlarePostProcess;
  63000. private _createDepthOfFieldPostProcess;
  63001. private _createMotionBlurPostProcess;
  63002. private _getDepthTexture;
  63003. private _disposePostProcesses;
  63004. /**
  63005. * Dispose of the pipeline and stop all post processes
  63006. */
  63007. dispose(): void;
  63008. /**
  63009. * Serialize the rendering pipeline (Used when exporting)
  63010. * @returns the serialized object
  63011. */
  63012. serialize(): any;
  63013. /**
  63014. * Parse the serialized pipeline
  63015. * @param source Source pipeline.
  63016. * @param scene The scene to load the pipeline to.
  63017. * @param rootUrl The URL of the serialized pipeline.
  63018. * @returns An instantiated pipeline from the serialized object.
  63019. */
  63020. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  63021. /**
  63022. * Luminance steps
  63023. */
  63024. static LuminanceSteps: number;
  63025. }
  63026. }
  63027. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/index" {
  63028. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline";
  63029. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline";
  63030. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline";
  63031. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline";
  63032. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline";
  63033. }
  63034. declare module "babylonjs/PostProcesses/RenderPipeline/index" {
  63035. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/index";
  63036. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  63037. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  63038. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  63039. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  63040. }
  63041. declare module "babylonjs/Shaders/tonemap.fragment" {
  63042. /** @hidden */
  63043. export var tonemapPixelShader: {
  63044. name: string;
  63045. shader: string;
  63046. };
  63047. }
  63048. declare module "babylonjs/PostProcesses/tonemapPostProcess" {
  63049. import { Camera } from "babylonjs/Cameras/camera";
  63050. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  63051. import "babylonjs/Shaders/tonemap.fragment";
  63052. import { Engine } from "babylonjs/Engines/engine";
  63053. /** Defines operator used for tonemapping */
  63054. export enum TonemappingOperator {
  63055. /** Hable */
  63056. Hable = 0,
  63057. /** Reinhard */
  63058. Reinhard = 1,
  63059. /** HejiDawson */
  63060. HejiDawson = 2,
  63061. /** Photographic */
  63062. Photographic = 3
  63063. }
  63064. /**
  63065. * Defines a post process to apply tone mapping
  63066. */
  63067. export class TonemapPostProcess extends PostProcess {
  63068. private _operator;
  63069. /** Defines the required exposure adjustement */
  63070. exposureAdjustment: number;
  63071. /**
  63072. * Creates a new TonemapPostProcess
  63073. * @param name defines the name of the postprocess
  63074. * @param _operator defines the operator to use
  63075. * @param exposureAdjustment defines the required exposure adjustement
  63076. * @param camera defines the camera to use (can be null)
  63077. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  63078. * @param engine defines the hosting engine (can be ignore if camera is set)
  63079. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  63080. */
  63081. constructor(name: string, _operator: TonemappingOperator,
  63082. /** Defines the required exposure adjustement */
  63083. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  63084. }
  63085. }
  63086. declare module "babylonjs/Shaders/depth.vertex" {
  63087. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  63088. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  63089. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  63090. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  63091. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  63092. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  63093. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  63094. /** @hidden */
  63095. export var depthVertexShader: {
  63096. name: string;
  63097. shader: string;
  63098. };
  63099. }
  63100. declare module "babylonjs/Shaders/volumetricLightScattering.fragment" {
  63101. /** @hidden */
  63102. export var volumetricLightScatteringPixelShader: {
  63103. name: string;
  63104. shader: string;
  63105. };
  63106. }
  63107. declare module "babylonjs/Shaders/volumetricLightScatteringPass.vertex" {
  63108. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  63109. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  63110. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  63111. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  63112. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  63113. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  63114. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  63115. /** @hidden */
  63116. export var volumetricLightScatteringPassVertexShader: {
  63117. name: string;
  63118. shader: string;
  63119. };
  63120. }
  63121. declare module "babylonjs/Shaders/volumetricLightScatteringPass.fragment" {
  63122. /** @hidden */
  63123. export var volumetricLightScatteringPassPixelShader: {
  63124. name: string;
  63125. shader: string;
  63126. };
  63127. }
  63128. declare module "babylonjs/PostProcesses/volumetricLightScatteringPostProcess" {
  63129. import { Vector3 } from "babylonjs/Maths/math.vector";
  63130. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  63131. import { Mesh } from "babylonjs/Meshes/mesh";
  63132. import { Camera } from "babylonjs/Cameras/camera";
  63133. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  63134. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  63135. import { Scene } from "babylonjs/scene";
  63136. import "babylonjs/Meshes/Builders/planeBuilder";
  63137. import "babylonjs/Shaders/depth.vertex";
  63138. import "babylonjs/Shaders/volumetricLightScattering.fragment";
  63139. import "babylonjs/Shaders/volumetricLightScatteringPass.vertex";
  63140. import "babylonjs/Shaders/volumetricLightScatteringPass.fragment";
  63141. import { Engine } from "babylonjs/Engines/engine";
  63142. /**
  63143. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  63144. */
  63145. export class VolumetricLightScatteringPostProcess extends PostProcess {
  63146. private _volumetricLightScatteringPass;
  63147. private _volumetricLightScatteringRTT;
  63148. private _viewPort;
  63149. private _screenCoordinates;
  63150. private _cachedDefines;
  63151. /**
  63152. * If not undefined, the mesh position is computed from the attached node position
  63153. */
  63154. attachedNode: {
  63155. position: Vector3;
  63156. };
  63157. /**
  63158. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  63159. */
  63160. customMeshPosition: Vector3;
  63161. /**
  63162. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  63163. */
  63164. useCustomMeshPosition: boolean;
  63165. /**
  63166. * If the post-process should inverse the light scattering direction
  63167. */
  63168. invert: boolean;
  63169. /**
  63170. * The internal mesh used by the post-process
  63171. */
  63172. mesh: Mesh;
  63173. /**
  63174. * @hidden
  63175. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  63176. */
  63177. useDiffuseColor: boolean;
  63178. /**
  63179. * Array containing the excluded meshes not rendered in the internal pass
  63180. */
  63181. excludedMeshes: AbstractMesh[];
  63182. /**
  63183. * Controls the overall intensity of the post-process
  63184. */
  63185. exposure: number;
  63186. /**
  63187. * Dissipates each sample's contribution in range [0, 1]
  63188. */
  63189. decay: number;
  63190. /**
  63191. * Controls the overall intensity of each sample
  63192. */
  63193. weight: number;
  63194. /**
  63195. * Controls the density of each sample
  63196. */
  63197. density: number;
  63198. /**
  63199. * @constructor
  63200. * @param name The post-process name
  63201. * @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)
  63202. * @param camera The camera that the post-process will be attached to
  63203. * @param mesh The mesh used to create the light scattering
  63204. * @param samples The post-process quality, default 100
  63205. * @param samplingModeThe post-process filtering mode
  63206. * @param engine The babylon engine
  63207. * @param reusable If the post-process is reusable
  63208. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  63209. */
  63210. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  63211. /**
  63212. * Returns the string "VolumetricLightScatteringPostProcess"
  63213. * @returns "VolumetricLightScatteringPostProcess"
  63214. */
  63215. getClassName(): string;
  63216. private _isReady;
  63217. /**
  63218. * Sets the new light position for light scattering effect
  63219. * @param position The new custom light position
  63220. */
  63221. setCustomMeshPosition(position: Vector3): void;
  63222. /**
  63223. * Returns the light position for light scattering effect
  63224. * @return Vector3 The custom light position
  63225. */
  63226. getCustomMeshPosition(): Vector3;
  63227. /**
  63228. * Disposes the internal assets and detaches the post-process from the camera
  63229. */
  63230. dispose(camera: Camera): void;
  63231. /**
  63232. * Returns the render target texture used by the post-process
  63233. * @return the render target texture used by the post-process
  63234. */
  63235. getPass(): RenderTargetTexture;
  63236. private _meshExcluded;
  63237. private _createPass;
  63238. private _updateMeshScreenCoordinates;
  63239. /**
  63240. * Creates a default mesh for the Volumeric Light Scattering post-process
  63241. * @param name The mesh name
  63242. * @param scene The scene where to create the mesh
  63243. * @return the default mesh
  63244. */
  63245. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  63246. }
  63247. }
  63248. declare module "babylonjs/PostProcesses/index" {
  63249. export * from "babylonjs/PostProcesses/anaglyphPostProcess";
  63250. export * from "babylonjs/PostProcesses/blackAndWhitePostProcess";
  63251. export * from "babylonjs/PostProcesses/bloomEffect";
  63252. export * from "babylonjs/PostProcesses/bloomMergePostProcess";
  63253. export * from "babylonjs/PostProcesses/blurPostProcess";
  63254. export * from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  63255. export * from "babylonjs/PostProcesses/circleOfConfusionPostProcess";
  63256. export * from "babylonjs/PostProcesses/colorCorrectionPostProcess";
  63257. export * from "babylonjs/PostProcesses/convolutionPostProcess";
  63258. export * from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  63259. export * from "babylonjs/PostProcesses/depthOfFieldEffect";
  63260. export * from "babylonjs/PostProcesses/depthOfFieldMergePostProcess";
  63261. export * from "babylonjs/PostProcesses/displayPassPostProcess";
  63262. export * from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  63263. export * from "babylonjs/PostProcesses/filterPostProcess";
  63264. export * from "babylonjs/PostProcesses/fxaaPostProcess";
  63265. export * from "babylonjs/PostProcesses/grainPostProcess";
  63266. export * from "babylonjs/PostProcesses/highlightsPostProcess";
  63267. export * from "babylonjs/PostProcesses/imageProcessingPostProcess";
  63268. export * from "babylonjs/PostProcesses/motionBlurPostProcess";
  63269. export * from "babylonjs/PostProcesses/passPostProcess";
  63270. export * from "babylonjs/PostProcesses/postProcess";
  63271. export * from "babylonjs/PostProcesses/postProcessManager";
  63272. export * from "babylonjs/PostProcesses/refractionPostProcess";
  63273. export * from "babylonjs/PostProcesses/RenderPipeline/index";
  63274. export * from "babylonjs/PostProcesses/sharpenPostProcess";
  63275. export * from "babylonjs/PostProcesses/stereoscopicInterlacePostProcess";
  63276. export * from "babylonjs/PostProcesses/tonemapPostProcess";
  63277. export * from "babylonjs/PostProcesses/volumetricLightScatteringPostProcess";
  63278. export * from "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess";
  63279. export * from "babylonjs/PostProcesses/vrMultiviewToSingleviewPostProcess";
  63280. }
  63281. declare module "babylonjs/Probes/index" {
  63282. export * from "babylonjs/Probes/reflectionProbe";
  63283. }
  63284. declare module "babylonjs/Rendering/boundingBoxRenderer" {
  63285. import { Scene } from "babylonjs/scene";
  63286. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  63287. import { SmartArray } from "babylonjs/Misc/smartArray";
  63288. import { ISceneComponent } from "babylonjs/sceneComponent";
  63289. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  63290. import "babylonjs/Meshes/Builders/boxBuilder";
  63291. import "babylonjs/Shaders/color.fragment";
  63292. import "babylonjs/Shaders/color.vertex";
  63293. import { Color3 } from "babylonjs/Maths/math.color";
  63294. module "babylonjs/scene" {
  63295. interface Scene {
  63296. /** @hidden (Backing field) */
  63297. _boundingBoxRenderer: BoundingBoxRenderer;
  63298. /** @hidden (Backing field) */
  63299. _forceShowBoundingBoxes: boolean;
  63300. /**
  63301. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  63302. */
  63303. forceShowBoundingBoxes: boolean;
  63304. /**
  63305. * Gets the bounding box renderer associated with the scene
  63306. * @returns a BoundingBoxRenderer
  63307. */
  63308. getBoundingBoxRenderer(): BoundingBoxRenderer;
  63309. }
  63310. }
  63311. module "babylonjs/Meshes/abstractMesh" {
  63312. interface AbstractMesh {
  63313. /** @hidden (Backing field) */
  63314. _showBoundingBox: boolean;
  63315. /**
  63316. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  63317. */
  63318. showBoundingBox: boolean;
  63319. }
  63320. }
  63321. /**
  63322. * Component responsible of rendering the bounding box of the meshes in a scene.
  63323. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  63324. */
  63325. export class BoundingBoxRenderer implements ISceneComponent {
  63326. /**
  63327. * The component name helpfull to identify the component in the list of scene components.
  63328. */
  63329. readonly name: string;
  63330. /**
  63331. * The scene the component belongs to.
  63332. */
  63333. scene: Scene;
  63334. /**
  63335. * Color of the bounding box lines placed in front of an object
  63336. */
  63337. frontColor: Color3;
  63338. /**
  63339. * Color of the bounding box lines placed behind an object
  63340. */
  63341. backColor: Color3;
  63342. /**
  63343. * Defines if the renderer should show the back lines or not
  63344. */
  63345. showBackLines: boolean;
  63346. /**
  63347. * @hidden
  63348. */
  63349. renderList: SmartArray<BoundingBox>;
  63350. private _colorShader;
  63351. private _vertexBuffers;
  63352. private _indexBuffer;
  63353. private _fillIndexBuffer;
  63354. private _fillIndexData;
  63355. /**
  63356. * Instantiates a new bounding box renderer in a scene.
  63357. * @param scene the scene the renderer renders in
  63358. */
  63359. constructor(scene: Scene);
  63360. /**
  63361. * Registers the component in a given scene
  63362. */
  63363. register(): void;
  63364. private _evaluateSubMesh;
  63365. private _activeMesh;
  63366. private _prepareRessources;
  63367. private _createIndexBuffer;
  63368. /**
  63369. * Rebuilds the elements related to this component in case of
  63370. * context lost for instance.
  63371. */
  63372. rebuild(): void;
  63373. /**
  63374. * @hidden
  63375. */
  63376. reset(): void;
  63377. /**
  63378. * Render the bounding boxes of a specific rendering group
  63379. * @param renderingGroupId defines the rendering group to render
  63380. */
  63381. render(renderingGroupId: number): void;
  63382. /**
  63383. * In case of occlusion queries, we can render the occlusion bounding box through this method
  63384. * @param mesh Define the mesh to render the occlusion bounding box for
  63385. */
  63386. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  63387. /**
  63388. * Dispose and release the resources attached to this renderer.
  63389. */
  63390. dispose(): void;
  63391. }
  63392. }
  63393. declare module "babylonjs/Shaders/depth.fragment" {
  63394. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  63395. /** @hidden */
  63396. export var depthPixelShader: {
  63397. name: string;
  63398. shader: string;
  63399. };
  63400. }
  63401. declare module "babylonjs/Rendering/depthRenderer" {
  63402. import { Nullable } from "babylonjs/types";
  63403. import { SubMesh } from "babylonjs/Meshes/subMesh";
  63404. import { Scene } from "babylonjs/scene";
  63405. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  63406. import { Camera } from "babylonjs/Cameras/camera";
  63407. import "babylonjs/Shaders/depth.fragment";
  63408. import "babylonjs/Shaders/depth.vertex";
  63409. /**
  63410. * This represents a depth renderer in Babylon.
  63411. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  63412. */
  63413. export class DepthRenderer {
  63414. private _scene;
  63415. private _depthMap;
  63416. private _effect;
  63417. private readonly _storeNonLinearDepth;
  63418. private readonly _clearColor;
  63419. /** Get if the depth renderer is using packed depth or not */
  63420. readonly isPacked: boolean;
  63421. private _cachedDefines;
  63422. private _camera;
  63423. /**
  63424. * Specifiess that the depth renderer will only be used within
  63425. * the camera it is created for.
  63426. * This can help forcing its rendering during the camera processing.
  63427. */
  63428. useOnlyInActiveCamera: boolean;
  63429. /** @hidden */
  63430. static _SceneComponentInitialization: (scene: Scene) => void;
  63431. /**
  63432. * Instantiates a depth renderer
  63433. * @param scene The scene the renderer belongs to
  63434. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  63435. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  63436. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  63437. */
  63438. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  63439. /**
  63440. * Creates the depth rendering effect and checks if the effect is ready.
  63441. * @param subMesh The submesh to be used to render the depth map of
  63442. * @param useInstances If multiple world instances should be used
  63443. * @returns if the depth renderer is ready to render the depth map
  63444. */
  63445. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  63446. /**
  63447. * Gets the texture which the depth map will be written to.
  63448. * @returns The depth map texture
  63449. */
  63450. getDepthMap(): RenderTargetTexture;
  63451. /**
  63452. * Disposes of the depth renderer.
  63453. */
  63454. dispose(): void;
  63455. }
  63456. }
  63457. declare module "babylonjs/Rendering/depthRendererSceneComponent" {
  63458. import { Nullable } from "babylonjs/types";
  63459. import { Scene } from "babylonjs/scene";
  63460. import { DepthRenderer } from "babylonjs/Rendering/depthRenderer";
  63461. import { Camera } from "babylonjs/Cameras/camera";
  63462. import { ISceneComponent } from "babylonjs/sceneComponent";
  63463. module "babylonjs/scene" {
  63464. interface Scene {
  63465. /** @hidden (Backing field) */
  63466. _depthRenderer: {
  63467. [id: string]: DepthRenderer;
  63468. };
  63469. /**
  63470. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  63471. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  63472. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  63473. * @returns the created depth renderer
  63474. */
  63475. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean): DepthRenderer;
  63476. /**
  63477. * Disables a depth renderer for a given camera
  63478. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  63479. */
  63480. disableDepthRenderer(camera?: Nullable<Camera>): void;
  63481. }
  63482. }
  63483. /**
  63484. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  63485. * in several rendering techniques.
  63486. */
  63487. export class DepthRendererSceneComponent implements ISceneComponent {
  63488. /**
  63489. * The component name helpfull to identify the component in the list of scene components.
  63490. */
  63491. readonly name: string;
  63492. /**
  63493. * The scene the component belongs to.
  63494. */
  63495. scene: Scene;
  63496. /**
  63497. * Creates a new instance of the component for the given scene
  63498. * @param scene Defines the scene to register the component in
  63499. */
  63500. constructor(scene: Scene);
  63501. /**
  63502. * Registers the component in a given scene
  63503. */
  63504. register(): void;
  63505. /**
  63506. * Rebuilds the elements related to this component in case of
  63507. * context lost for instance.
  63508. */
  63509. rebuild(): void;
  63510. /**
  63511. * Disposes the component and the associated ressources
  63512. */
  63513. dispose(): void;
  63514. private _gatherRenderTargets;
  63515. private _gatherActiveCameraRenderTargets;
  63516. }
  63517. }
  63518. declare module "babylonjs/Shaders/outline.fragment" {
  63519. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  63520. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  63521. /** @hidden */
  63522. export var outlinePixelShader: {
  63523. name: string;
  63524. shader: string;
  63525. };
  63526. }
  63527. declare module "babylonjs/Shaders/outline.vertex" {
  63528. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  63529. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  63530. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  63531. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  63532. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  63533. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  63534. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  63535. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  63536. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  63537. /** @hidden */
  63538. export var outlineVertexShader: {
  63539. name: string;
  63540. shader: string;
  63541. };
  63542. }
  63543. declare module "babylonjs/Rendering/outlineRenderer" {
  63544. import { SubMesh } from "babylonjs/Meshes/subMesh";
  63545. import { _InstancesBatch } from "babylonjs/Meshes/mesh";
  63546. import { Scene } from "babylonjs/scene";
  63547. import { ISceneComponent } from "babylonjs/sceneComponent";
  63548. import "babylonjs/Shaders/outline.fragment";
  63549. import "babylonjs/Shaders/outline.vertex";
  63550. module "babylonjs/scene" {
  63551. interface Scene {
  63552. /** @hidden */
  63553. _outlineRenderer: OutlineRenderer;
  63554. /**
  63555. * Gets the outline renderer associated with the scene
  63556. * @returns a OutlineRenderer
  63557. */
  63558. getOutlineRenderer(): OutlineRenderer;
  63559. }
  63560. }
  63561. module "babylonjs/Meshes/abstractMesh" {
  63562. interface AbstractMesh {
  63563. /** @hidden (Backing field) */
  63564. _renderOutline: boolean;
  63565. /**
  63566. * Gets or sets a boolean indicating if the outline must be rendered as well
  63567. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  63568. */
  63569. renderOutline: boolean;
  63570. /** @hidden (Backing field) */
  63571. _renderOverlay: boolean;
  63572. /**
  63573. * Gets or sets a boolean indicating if the overlay must be rendered as well
  63574. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  63575. */
  63576. renderOverlay: boolean;
  63577. }
  63578. }
  63579. /**
  63580. * This class is responsible to draw bothe outline/overlay of meshes.
  63581. * It should not be used directly but through the available method on mesh.
  63582. */
  63583. export class OutlineRenderer implements ISceneComponent {
  63584. /**
  63585. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  63586. */
  63587. private static _StencilReference;
  63588. /**
  63589. * The name of the component. Each component must have a unique name.
  63590. */
  63591. name: string;
  63592. /**
  63593. * The scene the component belongs to.
  63594. */
  63595. scene: Scene;
  63596. /**
  63597. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  63598. */
  63599. zOffset: number;
  63600. private _engine;
  63601. private _effect;
  63602. private _cachedDefines;
  63603. private _savedDepthWrite;
  63604. /**
  63605. * Instantiates a new outline renderer. (There could be only one per scene).
  63606. * @param scene Defines the scene it belongs to
  63607. */
  63608. constructor(scene: Scene);
  63609. /**
  63610. * Register the component to one instance of a scene.
  63611. */
  63612. register(): void;
  63613. /**
  63614. * Rebuilds the elements related to this component in case of
  63615. * context lost for instance.
  63616. */
  63617. rebuild(): void;
  63618. /**
  63619. * Disposes the component and the associated ressources.
  63620. */
  63621. dispose(): void;
  63622. /**
  63623. * Renders the outline in the canvas.
  63624. * @param subMesh Defines the sumesh to render
  63625. * @param batch Defines the batch of meshes in case of instances
  63626. * @param useOverlay Defines if the rendering is for the overlay or the outline
  63627. */
  63628. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  63629. /**
  63630. * Returns whether or not the outline renderer is ready for a given submesh.
  63631. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  63632. * @param subMesh Defines the submesh to check readyness for
  63633. * @param useInstances Defines wheter wee are trying to render instances or not
  63634. * @returns true if ready otherwise false
  63635. */
  63636. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  63637. private _beforeRenderingMesh;
  63638. private _afterRenderingMesh;
  63639. }
  63640. }
  63641. declare module "babylonjs/Rendering/index" {
  63642. export * from "babylonjs/Rendering/boundingBoxRenderer";
  63643. export * from "babylonjs/Rendering/depthRenderer";
  63644. export * from "babylonjs/Rendering/depthRendererSceneComponent";
  63645. export * from "babylonjs/Rendering/edgesRenderer";
  63646. export * from "babylonjs/Rendering/geometryBufferRenderer";
  63647. export * from "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  63648. export * from "babylonjs/Rendering/outlineRenderer";
  63649. export * from "babylonjs/Rendering/renderingGroup";
  63650. export * from "babylonjs/Rendering/renderingManager";
  63651. export * from "babylonjs/Rendering/utilityLayerRenderer";
  63652. }
  63653. declare module "babylonjs/Sprites/spritePackedManager" {
  63654. import { SpriteManager } from "babylonjs/Sprites/spriteManager";
  63655. import { Scene } from "babylonjs/scene";
  63656. /**
  63657. * Class used to manage multiple sprites of different sizes on the same spritesheet
  63658. * @see http://doc.babylonjs.com/babylon101/sprites
  63659. */
  63660. export class SpritePackedManager extends SpriteManager {
  63661. /** defines the packed manager's name */
  63662. name: string;
  63663. /**
  63664. * Creates a new sprite manager from a packed sprite sheet
  63665. * @param name defines the manager's name
  63666. * @param imgUrl defines the sprite sheet url
  63667. * @param capacity defines the maximum allowed number of sprites
  63668. * @param scene defines the hosting scene
  63669. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  63670. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  63671. * @param samplingMode defines the smapling mode to use with spritesheet
  63672. * @param fromPacked set to true; do not alter
  63673. */
  63674. constructor(
  63675. /** defines the packed manager's name */
  63676. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  63677. }
  63678. }
  63679. declare module "babylonjs/Sprites/index" {
  63680. export * from "babylonjs/Sprites/sprite";
  63681. export * from "babylonjs/Sprites/spriteManager";
  63682. export * from "babylonjs/Sprites/spritePackedManager";
  63683. export * from "babylonjs/Sprites/spriteSceneComponent";
  63684. }
  63685. declare module "babylonjs/Misc/assetsManager" {
  63686. import { Scene } from "babylonjs/scene";
  63687. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  63688. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  63689. import { Skeleton } from "babylonjs/Bones/skeleton";
  63690. import { Observable } from "babylonjs/Misc/observable";
  63691. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  63692. import { Texture } from "babylonjs/Materials/Textures/texture";
  63693. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  63694. import { HDRCubeTexture } from "babylonjs/Materials/Textures/hdrCubeTexture";
  63695. import { EquiRectangularCubeTexture } from "babylonjs/Materials/Textures/equiRectangularCubeTexture";
  63696. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  63697. /**
  63698. * Defines the list of states available for a task inside a AssetsManager
  63699. */
  63700. export enum AssetTaskState {
  63701. /**
  63702. * Initialization
  63703. */
  63704. INIT = 0,
  63705. /**
  63706. * Running
  63707. */
  63708. RUNNING = 1,
  63709. /**
  63710. * Done
  63711. */
  63712. DONE = 2,
  63713. /**
  63714. * Error
  63715. */
  63716. ERROR = 3
  63717. }
  63718. /**
  63719. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  63720. */
  63721. export abstract class AbstractAssetTask {
  63722. /**
  63723. * Task name
  63724. */ name: string;
  63725. /**
  63726. * Callback called when the task is successful
  63727. */
  63728. onSuccess: (task: any) => void;
  63729. /**
  63730. * Callback called when the task is not successful
  63731. */
  63732. onError: (task: any, message?: string, exception?: any) => void;
  63733. /**
  63734. * Creates a new AssetsManager
  63735. * @param name defines the name of the task
  63736. */
  63737. constructor(
  63738. /**
  63739. * Task name
  63740. */ name: string);
  63741. private _isCompleted;
  63742. private _taskState;
  63743. private _errorObject;
  63744. /**
  63745. * Get if the task is completed
  63746. */
  63747. readonly isCompleted: boolean;
  63748. /**
  63749. * Gets the current state of the task
  63750. */
  63751. readonly taskState: AssetTaskState;
  63752. /**
  63753. * Gets the current error object (if task is in error)
  63754. */
  63755. readonly errorObject: {
  63756. message?: string;
  63757. exception?: any;
  63758. };
  63759. /**
  63760. * Internal only
  63761. * @hidden
  63762. */
  63763. _setErrorObject(message?: string, exception?: any): void;
  63764. /**
  63765. * Execute the current task
  63766. * @param scene defines the scene where you want your assets to be loaded
  63767. * @param onSuccess is a callback called when the task is successfully executed
  63768. * @param onError is a callback called if an error occurs
  63769. */
  63770. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  63771. /**
  63772. * Execute the current task
  63773. * @param scene defines the scene where you want your assets to be loaded
  63774. * @param onSuccess is a callback called when the task is successfully executed
  63775. * @param onError is a callback called if an error occurs
  63776. */
  63777. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  63778. /**
  63779. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  63780. * This can be used with failed tasks that have the reason for failure fixed.
  63781. */
  63782. reset(): void;
  63783. private onErrorCallback;
  63784. private onDoneCallback;
  63785. }
  63786. /**
  63787. * Define the interface used by progress events raised during assets loading
  63788. */
  63789. export interface IAssetsProgressEvent {
  63790. /**
  63791. * Defines the number of remaining tasks to process
  63792. */
  63793. remainingCount: number;
  63794. /**
  63795. * Defines the total number of tasks
  63796. */
  63797. totalCount: number;
  63798. /**
  63799. * Defines the task that was just processed
  63800. */
  63801. task: AbstractAssetTask;
  63802. }
  63803. /**
  63804. * Class used to share progress information about assets loading
  63805. */
  63806. export class AssetsProgressEvent implements IAssetsProgressEvent {
  63807. /**
  63808. * Defines the number of remaining tasks to process
  63809. */
  63810. remainingCount: number;
  63811. /**
  63812. * Defines the total number of tasks
  63813. */
  63814. totalCount: number;
  63815. /**
  63816. * Defines the task that was just processed
  63817. */
  63818. task: AbstractAssetTask;
  63819. /**
  63820. * Creates a AssetsProgressEvent
  63821. * @param remainingCount defines the number of remaining tasks to process
  63822. * @param totalCount defines the total number of tasks
  63823. * @param task defines the task that was just processed
  63824. */
  63825. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  63826. }
  63827. /**
  63828. * Define a task used by AssetsManager to load meshes
  63829. */
  63830. export class MeshAssetTask extends AbstractAssetTask {
  63831. /**
  63832. * Defines the name of the task
  63833. */
  63834. name: string;
  63835. /**
  63836. * Defines the list of mesh's names you want to load
  63837. */
  63838. meshesNames: any;
  63839. /**
  63840. * Defines the root url to use as a base to load your meshes and associated resources
  63841. */
  63842. rootUrl: string;
  63843. /**
  63844. * Defines the filename of the scene to load from
  63845. */
  63846. sceneFilename: string;
  63847. /**
  63848. * Gets the list of loaded meshes
  63849. */
  63850. loadedMeshes: Array<AbstractMesh>;
  63851. /**
  63852. * Gets the list of loaded particle systems
  63853. */
  63854. loadedParticleSystems: Array<IParticleSystem>;
  63855. /**
  63856. * Gets the list of loaded skeletons
  63857. */
  63858. loadedSkeletons: Array<Skeleton>;
  63859. /**
  63860. * Gets the list of loaded animation groups
  63861. */
  63862. loadedAnimationGroups: Array<AnimationGroup>;
  63863. /**
  63864. * Callback called when the task is successful
  63865. */
  63866. onSuccess: (task: MeshAssetTask) => void;
  63867. /**
  63868. * Callback called when the task is successful
  63869. */
  63870. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  63871. /**
  63872. * Creates a new MeshAssetTask
  63873. * @param name defines the name of the task
  63874. * @param meshesNames defines the list of mesh's names you want to load
  63875. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  63876. * @param sceneFilename defines the filename of the scene to load from
  63877. */
  63878. constructor(
  63879. /**
  63880. * Defines the name of the task
  63881. */
  63882. name: string,
  63883. /**
  63884. * Defines the list of mesh's names you want to load
  63885. */
  63886. meshesNames: any,
  63887. /**
  63888. * Defines the root url to use as a base to load your meshes and associated resources
  63889. */
  63890. rootUrl: string,
  63891. /**
  63892. * Defines the filename of the scene to load from
  63893. */
  63894. sceneFilename: string);
  63895. /**
  63896. * Execute the current task
  63897. * @param scene defines the scene where you want your assets to be loaded
  63898. * @param onSuccess is a callback called when the task is successfully executed
  63899. * @param onError is a callback called if an error occurs
  63900. */
  63901. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  63902. }
  63903. /**
  63904. * Define a task used by AssetsManager to load text content
  63905. */
  63906. export class TextFileAssetTask extends AbstractAssetTask {
  63907. /**
  63908. * Defines the name of the task
  63909. */
  63910. name: string;
  63911. /**
  63912. * Defines the location of the file to load
  63913. */
  63914. url: string;
  63915. /**
  63916. * Gets the loaded text string
  63917. */
  63918. text: string;
  63919. /**
  63920. * Callback called when the task is successful
  63921. */
  63922. onSuccess: (task: TextFileAssetTask) => void;
  63923. /**
  63924. * Callback called when the task is successful
  63925. */
  63926. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  63927. /**
  63928. * Creates a new TextFileAssetTask object
  63929. * @param name defines the name of the task
  63930. * @param url defines the location of the file to load
  63931. */
  63932. constructor(
  63933. /**
  63934. * Defines the name of the task
  63935. */
  63936. name: string,
  63937. /**
  63938. * Defines the location of the file to load
  63939. */
  63940. url: string);
  63941. /**
  63942. * Execute the current task
  63943. * @param scene defines the scene where you want your assets to be loaded
  63944. * @param onSuccess is a callback called when the task is successfully executed
  63945. * @param onError is a callback called if an error occurs
  63946. */
  63947. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  63948. }
  63949. /**
  63950. * Define a task used by AssetsManager to load binary data
  63951. */
  63952. export class BinaryFileAssetTask extends AbstractAssetTask {
  63953. /**
  63954. * Defines the name of the task
  63955. */
  63956. name: string;
  63957. /**
  63958. * Defines the location of the file to load
  63959. */
  63960. url: string;
  63961. /**
  63962. * Gets the lodaded data (as an array buffer)
  63963. */
  63964. data: ArrayBuffer;
  63965. /**
  63966. * Callback called when the task is successful
  63967. */
  63968. onSuccess: (task: BinaryFileAssetTask) => void;
  63969. /**
  63970. * Callback called when the task is successful
  63971. */
  63972. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  63973. /**
  63974. * Creates a new BinaryFileAssetTask object
  63975. * @param name defines the name of the new task
  63976. * @param url defines the location of the file to load
  63977. */
  63978. constructor(
  63979. /**
  63980. * Defines the name of the task
  63981. */
  63982. name: string,
  63983. /**
  63984. * Defines the location of the file to load
  63985. */
  63986. url: string);
  63987. /**
  63988. * Execute the current task
  63989. * @param scene defines the scene where you want your assets to be loaded
  63990. * @param onSuccess is a callback called when the task is successfully executed
  63991. * @param onError is a callback called if an error occurs
  63992. */
  63993. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  63994. }
  63995. /**
  63996. * Define a task used by AssetsManager to load images
  63997. */
  63998. export class ImageAssetTask extends AbstractAssetTask {
  63999. /**
  64000. * Defines the name of the task
  64001. */
  64002. name: string;
  64003. /**
  64004. * Defines the location of the image to load
  64005. */
  64006. url: string;
  64007. /**
  64008. * Gets the loaded images
  64009. */
  64010. image: HTMLImageElement;
  64011. /**
  64012. * Callback called when the task is successful
  64013. */
  64014. onSuccess: (task: ImageAssetTask) => void;
  64015. /**
  64016. * Callback called when the task is successful
  64017. */
  64018. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  64019. /**
  64020. * Creates a new ImageAssetTask
  64021. * @param name defines the name of the task
  64022. * @param url defines the location of the image to load
  64023. */
  64024. constructor(
  64025. /**
  64026. * Defines the name of the task
  64027. */
  64028. name: string,
  64029. /**
  64030. * Defines the location of the image to load
  64031. */
  64032. url: string);
  64033. /**
  64034. * Execute the current task
  64035. * @param scene defines the scene where you want your assets to be loaded
  64036. * @param onSuccess is a callback called when the task is successfully executed
  64037. * @param onError is a callback called if an error occurs
  64038. */
  64039. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  64040. }
  64041. /**
  64042. * Defines the interface used by texture loading tasks
  64043. */
  64044. export interface ITextureAssetTask<TEX extends BaseTexture> {
  64045. /**
  64046. * Gets the loaded texture
  64047. */
  64048. texture: TEX;
  64049. }
  64050. /**
  64051. * Define a task used by AssetsManager to load 2D textures
  64052. */
  64053. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  64054. /**
  64055. * Defines the name of the task
  64056. */
  64057. name: string;
  64058. /**
  64059. * Defines the location of the file to load
  64060. */
  64061. url: string;
  64062. /**
  64063. * Defines if mipmap should not be generated (default is false)
  64064. */
  64065. noMipmap?: boolean | undefined;
  64066. /**
  64067. * Defines if texture must be inverted on Y axis (default is false)
  64068. */
  64069. invertY?: boolean | undefined;
  64070. /**
  64071. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  64072. */
  64073. samplingMode: number;
  64074. /**
  64075. * Gets the loaded texture
  64076. */
  64077. texture: Texture;
  64078. /**
  64079. * Callback called when the task is successful
  64080. */
  64081. onSuccess: (task: TextureAssetTask) => void;
  64082. /**
  64083. * Callback called when the task is successful
  64084. */
  64085. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  64086. /**
  64087. * Creates a new TextureAssetTask object
  64088. * @param name defines the name of the task
  64089. * @param url defines the location of the file to load
  64090. * @param noMipmap defines if mipmap should not be generated (default is false)
  64091. * @param invertY defines if texture must be inverted on Y axis (default is false)
  64092. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  64093. */
  64094. constructor(
  64095. /**
  64096. * Defines the name of the task
  64097. */
  64098. name: string,
  64099. /**
  64100. * Defines the location of the file to load
  64101. */
  64102. url: string,
  64103. /**
  64104. * Defines if mipmap should not be generated (default is false)
  64105. */
  64106. noMipmap?: boolean | undefined,
  64107. /**
  64108. * Defines if texture must be inverted on Y axis (default is false)
  64109. */
  64110. invertY?: boolean | undefined,
  64111. /**
  64112. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  64113. */
  64114. samplingMode?: number);
  64115. /**
  64116. * Execute the current task
  64117. * @param scene defines the scene where you want your assets to be loaded
  64118. * @param onSuccess is a callback called when the task is successfully executed
  64119. * @param onError is a callback called if an error occurs
  64120. */
  64121. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  64122. }
  64123. /**
  64124. * Define a task used by AssetsManager to load cube textures
  64125. */
  64126. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  64127. /**
  64128. * Defines the name of the task
  64129. */
  64130. name: string;
  64131. /**
  64132. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  64133. */
  64134. url: string;
  64135. /**
  64136. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  64137. */
  64138. extensions?: string[] | undefined;
  64139. /**
  64140. * Defines if mipmaps should not be generated (default is false)
  64141. */
  64142. noMipmap?: boolean | undefined;
  64143. /**
  64144. * Defines the explicit list of files (undefined by default)
  64145. */
  64146. files?: string[] | undefined;
  64147. /**
  64148. * Gets the loaded texture
  64149. */
  64150. texture: CubeTexture;
  64151. /**
  64152. * Callback called when the task is successful
  64153. */
  64154. onSuccess: (task: CubeTextureAssetTask) => void;
  64155. /**
  64156. * Callback called when the task is successful
  64157. */
  64158. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  64159. /**
  64160. * Creates a new CubeTextureAssetTask
  64161. * @param name defines the name of the task
  64162. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  64163. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  64164. * @param noMipmap defines if mipmaps should not be generated (default is false)
  64165. * @param files defines the explicit list of files (undefined by default)
  64166. */
  64167. constructor(
  64168. /**
  64169. * Defines the name of the task
  64170. */
  64171. name: string,
  64172. /**
  64173. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  64174. */
  64175. url: string,
  64176. /**
  64177. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  64178. */
  64179. extensions?: string[] | undefined,
  64180. /**
  64181. * Defines if mipmaps should not be generated (default is false)
  64182. */
  64183. noMipmap?: boolean | undefined,
  64184. /**
  64185. * Defines the explicit list of files (undefined by default)
  64186. */
  64187. files?: string[] | undefined);
  64188. /**
  64189. * Execute the current task
  64190. * @param scene defines the scene where you want your assets to be loaded
  64191. * @param onSuccess is a callback called when the task is successfully executed
  64192. * @param onError is a callback called if an error occurs
  64193. */
  64194. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  64195. }
  64196. /**
  64197. * Define a task used by AssetsManager to load HDR cube textures
  64198. */
  64199. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  64200. /**
  64201. * Defines the name of the task
  64202. */
  64203. name: string;
  64204. /**
  64205. * Defines the location of the file to load
  64206. */
  64207. url: string;
  64208. /**
  64209. * Defines the desired size (the more it increases the longer the generation will be)
  64210. */
  64211. size: number;
  64212. /**
  64213. * Defines if mipmaps should not be generated (default is false)
  64214. */
  64215. noMipmap: boolean;
  64216. /**
  64217. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  64218. */
  64219. generateHarmonics: boolean;
  64220. /**
  64221. * 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)
  64222. */
  64223. gammaSpace: boolean;
  64224. /**
  64225. * Internal Use Only
  64226. */
  64227. reserved: boolean;
  64228. /**
  64229. * Gets the loaded texture
  64230. */
  64231. texture: HDRCubeTexture;
  64232. /**
  64233. * Callback called when the task is successful
  64234. */
  64235. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  64236. /**
  64237. * Callback called when the task is successful
  64238. */
  64239. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  64240. /**
  64241. * Creates a new HDRCubeTextureAssetTask object
  64242. * @param name defines the name of the task
  64243. * @param url defines the location of the file to load
  64244. * @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.
  64245. * @param noMipmap defines if mipmaps should not be generated (default is false)
  64246. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  64247. * @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)
  64248. * @param reserved Internal use only
  64249. */
  64250. constructor(
  64251. /**
  64252. * Defines the name of the task
  64253. */
  64254. name: string,
  64255. /**
  64256. * Defines the location of the file to load
  64257. */
  64258. url: string,
  64259. /**
  64260. * Defines the desired size (the more it increases the longer the generation will be)
  64261. */
  64262. size: number,
  64263. /**
  64264. * Defines if mipmaps should not be generated (default is false)
  64265. */
  64266. noMipmap?: boolean,
  64267. /**
  64268. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  64269. */
  64270. generateHarmonics?: boolean,
  64271. /**
  64272. * 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)
  64273. */
  64274. gammaSpace?: boolean,
  64275. /**
  64276. * Internal Use Only
  64277. */
  64278. reserved?: boolean);
  64279. /**
  64280. * Execute the current task
  64281. * @param scene defines the scene where you want your assets to be loaded
  64282. * @param onSuccess is a callback called when the task is successfully executed
  64283. * @param onError is a callback called if an error occurs
  64284. */
  64285. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  64286. }
  64287. /**
  64288. * Define a task used by AssetsManager to load Equirectangular cube textures
  64289. */
  64290. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  64291. /**
  64292. * Defines the name of the task
  64293. */
  64294. name: string;
  64295. /**
  64296. * Defines the location of the file to load
  64297. */
  64298. url: string;
  64299. /**
  64300. * Defines the desired size (the more it increases the longer the generation will be)
  64301. */
  64302. size: number;
  64303. /**
  64304. * Defines if mipmaps should not be generated (default is false)
  64305. */
  64306. noMipmap: boolean;
  64307. /**
  64308. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  64309. * but the standard material would require them in Gamma space) (default is true)
  64310. */
  64311. gammaSpace: boolean;
  64312. /**
  64313. * Gets the loaded texture
  64314. */
  64315. texture: EquiRectangularCubeTexture;
  64316. /**
  64317. * Callback called when the task is successful
  64318. */
  64319. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  64320. /**
  64321. * Callback called when the task is successful
  64322. */
  64323. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  64324. /**
  64325. * Creates a new EquiRectangularCubeTextureAssetTask object
  64326. * @param name defines the name of the task
  64327. * @param url defines the location of the file to load
  64328. * @param size defines the desired size (the more it increases the longer the generation will be)
  64329. * If the size is omitted this implies you are using a preprocessed cubemap.
  64330. * @param noMipmap defines if mipmaps should not be generated (default is false)
  64331. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  64332. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  64333. * (default is true)
  64334. */
  64335. constructor(
  64336. /**
  64337. * Defines the name of the task
  64338. */
  64339. name: string,
  64340. /**
  64341. * Defines the location of the file to load
  64342. */
  64343. url: string,
  64344. /**
  64345. * Defines the desired size (the more it increases the longer the generation will be)
  64346. */
  64347. size: number,
  64348. /**
  64349. * Defines if mipmaps should not be generated (default is false)
  64350. */
  64351. noMipmap?: boolean,
  64352. /**
  64353. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  64354. * but the standard material would require them in Gamma space) (default is true)
  64355. */
  64356. gammaSpace?: boolean);
  64357. /**
  64358. * Execute the current task
  64359. * @param scene defines the scene where you want your assets to be loaded
  64360. * @param onSuccess is a callback called when the task is successfully executed
  64361. * @param onError is a callback called if an error occurs
  64362. */
  64363. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  64364. }
  64365. /**
  64366. * This class can be used to easily import assets into a scene
  64367. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  64368. */
  64369. export class AssetsManager {
  64370. private _scene;
  64371. private _isLoading;
  64372. protected _tasks: AbstractAssetTask[];
  64373. protected _waitingTasksCount: number;
  64374. protected _totalTasksCount: number;
  64375. /**
  64376. * Callback called when all tasks are processed
  64377. */
  64378. onFinish: (tasks: AbstractAssetTask[]) => void;
  64379. /**
  64380. * Callback called when a task is successful
  64381. */
  64382. onTaskSuccess: (task: AbstractAssetTask) => void;
  64383. /**
  64384. * Callback called when a task had an error
  64385. */
  64386. onTaskError: (task: AbstractAssetTask) => void;
  64387. /**
  64388. * Callback called when a task is done (whatever the result is)
  64389. */
  64390. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  64391. /**
  64392. * Observable called when all tasks are processed
  64393. */
  64394. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  64395. /**
  64396. * Observable called when a task had an error
  64397. */
  64398. onTaskErrorObservable: Observable<AbstractAssetTask>;
  64399. /**
  64400. * Observable called when all tasks were executed
  64401. */
  64402. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  64403. /**
  64404. * Observable called when a task is done (whatever the result is)
  64405. */
  64406. onProgressObservable: Observable<IAssetsProgressEvent>;
  64407. /**
  64408. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  64409. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  64410. */
  64411. useDefaultLoadingScreen: boolean;
  64412. /**
  64413. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  64414. * when all assets have been downloaded.
  64415. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  64416. */
  64417. autoHideLoadingUI: boolean;
  64418. /**
  64419. * Creates a new AssetsManager
  64420. * @param scene defines the scene to work on
  64421. */
  64422. constructor(scene: Scene);
  64423. /**
  64424. * Add a MeshAssetTask to the list of active tasks
  64425. * @param taskName defines the name of the new task
  64426. * @param meshesNames defines the name of meshes to load
  64427. * @param rootUrl defines the root url to use to locate files
  64428. * @param sceneFilename defines the filename of the scene file
  64429. * @returns a new MeshAssetTask object
  64430. */
  64431. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  64432. /**
  64433. * Add a TextFileAssetTask to the list of active tasks
  64434. * @param taskName defines the name of the new task
  64435. * @param url defines the url of the file to load
  64436. * @returns a new TextFileAssetTask object
  64437. */
  64438. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  64439. /**
  64440. * Add a BinaryFileAssetTask to the list of active tasks
  64441. * @param taskName defines the name of the new task
  64442. * @param url defines the url of the file to load
  64443. * @returns a new BinaryFileAssetTask object
  64444. */
  64445. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  64446. /**
  64447. * Add a ImageAssetTask to the list of active tasks
  64448. * @param taskName defines the name of the new task
  64449. * @param url defines the url of the file to load
  64450. * @returns a new ImageAssetTask object
  64451. */
  64452. addImageTask(taskName: string, url: string): ImageAssetTask;
  64453. /**
  64454. * Add a TextureAssetTask to the list of active tasks
  64455. * @param taskName defines the name of the new task
  64456. * @param url defines the url of the file to load
  64457. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  64458. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  64459. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  64460. * @returns a new TextureAssetTask object
  64461. */
  64462. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  64463. /**
  64464. * Add a CubeTextureAssetTask to the list of active tasks
  64465. * @param taskName defines the name of the new task
  64466. * @param url defines the url of the file to load
  64467. * @param extensions defines the extension to use to load the cube map (can be null)
  64468. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  64469. * @param files defines the list of files to load (can be null)
  64470. * @returns a new CubeTextureAssetTask object
  64471. */
  64472. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  64473. /**
  64474. *
  64475. * Add a HDRCubeTextureAssetTask to the list of active tasks
  64476. * @param taskName defines the name of the new task
  64477. * @param url defines the url of the file to load
  64478. * @param size defines the size you want for the cubemap (can be null)
  64479. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  64480. * @param generateHarmonics defines if you want to automatically generate (true by default)
  64481. * @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)
  64482. * @param reserved Internal use only
  64483. * @returns a new HDRCubeTextureAssetTask object
  64484. */
  64485. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  64486. /**
  64487. *
  64488. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  64489. * @param taskName defines the name of the new task
  64490. * @param url defines the url of the file to load
  64491. * @param size defines the size you want for the cubemap (can be null)
  64492. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  64493. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  64494. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  64495. * @returns a new EquiRectangularCubeTextureAssetTask object
  64496. */
  64497. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  64498. /**
  64499. * Remove a task from the assets manager.
  64500. * @param task the task to remove
  64501. */
  64502. removeTask(task: AbstractAssetTask): void;
  64503. private _decreaseWaitingTasksCount;
  64504. private _runTask;
  64505. /**
  64506. * Reset the AssetsManager and remove all tasks
  64507. * @return the current instance of the AssetsManager
  64508. */
  64509. reset(): AssetsManager;
  64510. /**
  64511. * Start the loading process
  64512. * @return the current instance of the AssetsManager
  64513. */
  64514. load(): AssetsManager;
  64515. /**
  64516. * Start the loading process as an async operation
  64517. * @return a promise returning the list of failed tasks
  64518. */
  64519. loadAsync(): Promise<void>;
  64520. }
  64521. }
  64522. declare module "babylonjs/Misc/deferred" {
  64523. /**
  64524. * Wrapper class for promise with external resolve and reject.
  64525. */
  64526. export class Deferred<T> {
  64527. /**
  64528. * The promise associated with this deferred object.
  64529. */
  64530. readonly promise: Promise<T>;
  64531. private _resolve;
  64532. private _reject;
  64533. /**
  64534. * The resolve method of the promise associated with this deferred object.
  64535. */
  64536. readonly resolve: (value?: T | PromiseLike<T> | undefined) => void;
  64537. /**
  64538. * The reject method of the promise associated with this deferred object.
  64539. */
  64540. readonly reject: (reason?: any) => void;
  64541. /**
  64542. * Constructor for this deferred object.
  64543. */
  64544. constructor();
  64545. }
  64546. }
  64547. declare module "babylonjs/Misc/meshExploder" {
  64548. import { Mesh } from "babylonjs/Meshes/mesh";
  64549. /**
  64550. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  64551. */
  64552. export class MeshExploder {
  64553. private _centerMesh;
  64554. private _meshes;
  64555. private _meshesOrigins;
  64556. private _toCenterVectors;
  64557. private _scaledDirection;
  64558. private _newPosition;
  64559. private _centerPosition;
  64560. /**
  64561. * Explodes meshes from a center mesh.
  64562. * @param meshes The meshes to explode.
  64563. * @param centerMesh The mesh to be center of explosion.
  64564. */
  64565. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  64566. private _setCenterMesh;
  64567. /**
  64568. * Get class name
  64569. * @returns "MeshExploder"
  64570. */
  64571. getClassName(): string;
  64572. /**
  64573. * "Exploded meshes"
  64574. * @returns Array of meshes with the centerMesh at index 0.
  64575. */
  64576. getMeshes(): Array<Mesh>;
  64577. /**
  64578. * Explodes meshes giving a specific direction
  64579. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  64580. */
  64581. explode(direction?: number): void;
  64582. }
  64583. }
  64584. declare module "babylonjs/Misc/filesInput" {
  64585. import { Engine } from "babylonjs/Engines/engine";
  64586. import { Scene } from "babylonjs/scene";
  64587. import { SceneLoaderProgressEvent } from "babylonjs/Loading/sceneLoader";
  64588. /**
  64589. * Class used to help managing file picking and drag'n'drop
  64590. */
  64591. export class FilesInput {
  64592. /**
  64593. * List of files ready to be loaded
  64594. */
  64595. static readonly FilesToLoad: {
  64596. [key: string]: File;
  64597. };
  64598. /**
  64599. * Callback called when a file is processed
  64600. */
  64601. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  64602. private _engine;
  64603. private _currentScene;
  64604. private _sceneLoadedCallback;
  64605. private _progressCallback;
  64606. private _additionalRenderLoopLogicCallback;
  64607. private _textureLoadingCallback;
  64608. private _startingProcessingFilesCallback;
  64609. private _onReloadCallback;
  64610. private _errorCallback;
  64611. private _elementToMonitor;
  64612. private _sceneFileToLoad;
  64613. private _filesToLoad;
  64614. /**
  64615. * Creates a new FilesInput
  64616. * @param engine defines the rendering engine
  64617. * @param scene defines the hosting scene
  64618. * @param sceneLoadedCallback callback called when scene is loaded
  64619. * @param progressCallback callback called to track progress
  64620. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  64621. * @param textureLoadingCallback callback called when a texture is loading
  64622. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  64623. * @param onReloadCallback callback called when a reload is requested
  64624. * @param errorCallback callback call if an error occurs
  64625. */
  64626. 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);
  64627. private _dragEnterHandler;
  64628. private _dragOverHandler;
  64629. private _dropHandler;
  64630. /**
  64631. * Calls this function to listen to drag'n'drop events on a specific DOM element
  64632. * @param elementToMonitor defines the DOM element to track
  64633. */
  64634. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  64635. /**
  64636. * Release all associated resources
  64637. */
  64638. dispose(): void;
  64639. private renderFunction;
  64640. private drag;
  64641. private drop;
  64642. private _traverseFolder;
  64643. private _processFiles;
  64644. /**
  64645. * Load files from a drop event
  64646. * @param event defines the drop event to use as source
  64647. */
  64648. loadFiles(event: any): void;
  64649. private _processReload;
  64650. /**
  64651. * Reload the current scene from the loaded files
  64652. */
  64653. reload(): void;
  64654. }
  64655. }
  64656. declare module "babylonjs/Misc/HighDynamicRange/index" {
  64657. export * from "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial";
  64658. export * from "babylonjs/Misc/HighDynamicRange/hdr";
  64659. export * from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  64660. }
  64661. declare module "babylonjs/Misc/sceneOptimizer" {
  64662. import { Scene, IDisposable } from "babylonjs/scene";
  64663. import { Observable } from "babylonjs/Misc/observable";
  64664. /**
  64665. * Defines the root class used to create scene optimization to use with SceneOptimizer
  64666. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  64667. */
  64668. export class SceneOptimization {
  64669. /**
  64670. * Defines the priority of this optimization (0 by default which means first in the list)
  64671. */
  64672. priority: number;
  64673. /**
  64674. * Gets a string describing the action executed by the current optimization
  64675. * @returns description string
  64676. */
  64677. getDescription(): string;
  64678. /**
  64679. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  64680. * @param scene defines the current scene where to apply this optimization
  64681. * @param optimizer defines the current optimizer
  64682. * @returns true if everything that can be done was applied
  64683. */
  64684. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  64685. /**
  64686. * Creates the SceneOptimization object
  64687. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  64688. * @param desc defines the description associated with the optimization
  64689. */
  64690. constructor(
  64691. /**
  64692. * Defines the priority of this optimization (0 by default which means first in the list)
  64693. */
  64694. priority?: number);
  64695. }
  64696. /**
  64697. * Defines an optimization used to reduce the size of render target textures
  64698. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  64699. */
  64700. export class TextureOptimization extends SceneOptimization {
  64701. /**
  64702. * Defines the priority of this optimization (0 by default which means first in the list)
  64703. */
  64704. priority: number;
  64705. /**
  64706. * 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
  64707. */
  64708. maximumSize: number;
  64709. /**
  64710. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  64711. */
  64712. step: number;
  64713. /**
  64714. * Gets a string describing the action executed by the current optimization
  64715. * @returns description string
  64716. */
  64717. getDescription(): string;
  64718. /**
  64719. * Creates the TextureOptimization object
  64720. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  64721. * @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
  64722. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  64723. */
  64724. constructor(
  64725. /**
  64726. * Defines the priority of this optimization (0 by default which means first in the list)
  64727. */
  64728. priority?: number,
  64729. /**
  64730. * 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
  64731. */
  64732. maximumSize?: number,
  64733. /**
  64734. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  64735. */
  64736. step?: number);
  64737. /**
  64738. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  64739. * @param scene defines the current scene where to apply this optimization
  64740. * @param optimizer defines the current optimizer
  64741. * @returns true if everything that can be done was applied
  64742. */
  64743. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  64744. }
  64745. /**
  64746. * Defines an optimization used to increase or decrease the rendering resolution
  64747. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  64748. */
  64749. export class HardwareScalingOptimization extends SceneOptimization {
  64750. /**
  64751. * Defines the priority of this optimization (0 by default which means first in the list)
  64752. */
  64753. priority: number;
  64754. /**
  64755. * Defines the maximum scale to use (2 by default)
  64756. */
  64757. maximumScale: number;
  64758. /**
  64759. * Defines the step to use between two passes (0.5 by default)
  64760. */
  64761. step: number;
  64762. private _currentScale;
  64763. private _directionOffset;
  64764. /**
  64765. * Gets a string describing the action executed by the current optimization
  64766. * @return description string
  64767. */
  64768. getDescription(): string;
  64769. /**
  64770. * Creates the HardwareScalingOptimization object
  64771. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  64772. * @param maximumScale defines the maximum scale to use (2 by default)
  64773. * @param step defines the step to use between two passes (0.5 by default)
  64774. */
  64775. constructor(
  64776. /**
  64777. * Defines the priority of this optimization (0 by default which means first in the list)
  64778. */
  64779. priority?: number,
  64780. /**
  64781. * Defines the maximum scale to use (2 by default)
  64782. */
  64783. maximumScale?: number,
  64784. /**
  64785. * Defines the step to use between two passes (0.5 by default)
  64786. */
  64787. step?: number);
  64788. /**
  64789. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  64790. * @param scene defines the current scene where to apply this optimization
  64791. * @param optimizer defines the current optimizer
  64792. * @returns true if everything that can be done was applied
  64793. */
  64794. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  64795. }
  64796. /**
  64797. * Defines an optimization used to remove shadows
  64798. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  64799. */
  64800. export class ShadowsOptimization extends SceneOptimization {
  64801. /**
  64802. * Gets a string describing the action executed by the current optimization
  64803. * @return description string
  64804. */
  64805. getDescription(): string;
  64806. /**
  64807. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  64808. * @param scene defines the current scene where to apply this optimization
  64809. * @param optimizer defines the current optimizer
  64810. * @returns true if everything that can be done was applied
  64811. */
  64812. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  64813. }
  64814. /**
  64815. * Defines an optimization used to turn post-processes off
  64816. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  64817. */
  64818. export class PostProcessesOptimization extends SceneOptimization {
  64819. /**
  64820. * Gets a string describing the action executed by the current optimization
  64821. * @return description string
  64822. */
  64823. getDescription(): string;
  64824. /**
  64825. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  64826. * @param scene defines the current scene where to apply this optimization
  64827. * @param optimizer defines the current optimizer
  64828. * @returns true if everything that can be done was applied
  64829. */
  64830. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  64831. }
  64832. /**
  64833. * Defines an optimization used to turn lens flares off
  64834. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  64835. */
  64836. export class LensFlaresOptimization extends SceneOptimization {
  64837. /**
  64838. * Gets a string describing the action executed by the current optimization
  64839. * @return description string
  64840. */
  64841. getDescription(): string;
  64842. /**
  64843. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  64844. * @param scene defines the current scene where to apply this optimization
  64845. * @param optimizer defines the current optimizer
  64846. * @returns true if everything that can be done was applied
  64847. */
  64848. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  64849. }
  64850. /**
  64851. * Defines an optimization based on user defined callback.
  64852. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  64853. */
  64854. export class CustomOptimization extends SceneOptimization {
  64855. /**
  64856. * Callback called to apply the custom optimization.
  64857. */
  64858. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  64859. /**
  64860. * Callback called to get custom description
  64861. */
  64862. onGetDescription: () => string;
  64863. /**
  64864. * Gets a string describing the action executed by the current optimization
  64865. * @returns description string
  64866. */
  64867. getDescription(): string;
  64868. /**
  64869. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  64870. * @param scene defines the current scene where to apply this optimization
  64871. * @param optimizer defines the current optimizer
  64872. * @returns true if everything that can be done was applied
  64873. */
  64874. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  64875. }
  64876. /**
  64877. * Defines an optimization used to turn particles off
  64878. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  64879. */
  64880. export class ParticlesOptimization extends SceneOptimization {
  64881. /**
  64882. * Gets a string describing the action executed by the current optimization
  64883. * @return description string
  64884. */
  64885. getDescription(): string;
  64886. /**
  64887. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  64888. * @param scene defines the current scene where to apply this optimization
  64889. * @param optimizer defines the current optimizer
  64890. * @returns true if everything that can be done was applied
  64891. */
  64892. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  64893. }
  64894. /**
  64895. * Defines an optimization used to turn render targets off
  64896. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  64897. */
  64898. export class RenderTargetsOptimization extends SceneOptimization {
  64899. /**
  64900. * Gets a string describing the action executed by the current optimization
  64901. * @return description string
  64902. */
  64903. getDescription(): string;
  64904. /**
  64905. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  64906. * @param scene defines the current scene where to apply this optimization
  64907. * @param optimizer defines the current optimizer
  64908. * @returns true if everything that can be done was applied
  64909. */
  64910. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  64911. }
  64912. /**
  64913. * Defines an optimization used to merge meshes with compatible materials
  64914. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  64915. */
  64916. export class MergeMeshesOptimization extends SceneOptimization {
  64917. private static _UpdateSelectionTree;
  64918. /**
  64919. * Gets or sets a boolean which defines if optimization octree has to be updated
  64920. */
  64921. /**
  64922. * Gets or sets a boolean which defines if optimization octree has to be updated
  64923. */
  64924. static UpdateSelectionTree: boolean;
  64925. /**
  64926. * Gets a string describing the action executed by the current optimization
  64927. * @return description string
  64928. */
  64929. getDescription(): string;
  64930. private _canBeMerged;
  64931. /**
  64932. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  64933. * @param scene defines the current scene where to apply this optimization
  64934. * @param optimizer defines the current optimizer
  64935. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  64936. * @returns true if everything that can be done was applied
  64937. */
  64938. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  64939. }
  64940. /**
  64941. * Defines a list of options used by SceneOptimizer
  64942. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  64943. */
  64944. export class SceneOptimizerOptions {
  64945. /**
  64946. * Defines the target frame rate to reach (60 by default)
  64947. */
  64948. targetFrameRate: number;
  64949. /**
  64950. * Defines the interval between two checkes (2000ms by default)
  64951. */
  64952. trackerDuration: number;
  64953. /**
  64954. * Gets the list of optimizations to apply
  64955. */
  64956. optimizations: SceneOptimization[];
  64957. /**
  64958. * Creates a new list of options used by SceneOptimizer
  64959. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  64960. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  64961. */
  64962. constructor(
  64963. /**
  64964. * Defines the target frame rate to reach (60 by default)
  64965. */
  64966. targetFrameRate?: number,
  64967. /**
  64968. * Defines the interval between two checkes (2000ms by default)
  64969. */
  64970. trackerDuration?: number);
  64971. /**
  64972. * Add a new optimization
  64973. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  64974. * @returns the current SceneOptimizerOptions
  64975. */
  64976. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  64977. /**
  64978. * Add a new custom optimization
  64979. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  64980. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  64981. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  64982. * @returns the current SceneOptimizerOptions
  64983. */
  64984. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  64985. /**
  64986. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  64987. * @param targetFrameRate defines the target frame rate (60 by default)
  64988. * @returns a SceneOptimizerOptions object
  64989. */
  64990. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  64991. /**
  64992. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  64993. * @param targetFrameRate defines the target frame rate (60 by default)
  64994. * @returns a SceneOptimizerOptions object
  64995. */
  64996. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  64997. /**
  64998. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  64999. * @param targetFrameRate defines the target frame rate (60 by default)
  65000. * @returns a SceneOptimizerOptions object
  65001. */
  65002. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  65003. }
  65004. /**
  65005. * Class used to run optimizations in order to reach a target frame rate
  65006. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  65007. */
  65008. export class SceneOptimizer implements IDisposable {
  65009. private _isRunning;
  65010. private _options;
  65011. private _scene;
  65012. private _currentPriorityLevel;
  65013. private _targetFrameRate;
  65014. private _trackerDuration;
  65015. private _currentFrameRate;
  65016. private _sceneDisposeObserver;
  65017. private _improvementMode;
  65018. /**
  65019. * Defines an observable called when the optimizer reaches the target frame rate
  65020. */
  65021. onSuccessObservable: Observable<SceneOptimizer>;
  65022. /**
  65023. * Defines an observable called when the optimizer enables an optimization
  65024. */
  65025. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  65026. /**
  65027. * Defines an observable called when the optimizer is not able to reach the target frame rate
  65028. */
  65029. onFailureObservable: Observable<SceneOptimizer>;
  65030. /**
  65031. * Gets a boolean indicating if the optimizer is in improvement mode
  65032. */
  65033. readonly isInImprovementMode: boolean;
  65034. /**
  65035. * Gets the current priority level (0 at start)
  65036. */
  65037. readonly currentPriorityLevel: number;
  65038. /**
  65039. * Gets the current frame rate checked by the SceneOptimizer
  65040. */
  65041. readonly currentFrameRate: number;
  65042. /**
  65043. * Gets or sets the current target frame rate (60 by default)
  65044. */
  65045. /**
  65046. * Gets or sets the current target frame rate (60 by default)
  65047. */
  65048. targetFrameRate: number;
  65049. /**
  65050. * Gets or sets the current interval between two checks (every 2000ms by default)
  65051. */
  65052. /**
  65053. * Gets or sets the current interval between two checks (every 2000ms by default)
  65054. */
  65055. trackerDuration: number;
  65056. /**
  65057. * Gets the list of active optimizations
  65058. */
  65059. readonly optimizations: SceneOptimization[];
  65060. /**
  65061. * Creates a new SceneOptimizer
  65062. * @param scene defines the scene to work on
  65063. * @param options defines the options to use with the SceneOptimizer
  65064. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  65065. * @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)
  65066. */
  65067. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  65068. /**
  65069. * Stops the current optimizer
  65070. */
  65071. stop(): void;
  65072. /**
  65073. * Reset the optimizer to initial step (current priority level = 0)
  65074. */
  65075. reset(): void;
  65076. /**
  65077. * Start the optimizer. By default it will try to reach a specific framerate
  65078. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  65079. */
  65080. start(): void;
  65081. private _checkCurrentState;
  65082. /**
  65083. * Release all resources
  65084. */
  65085. dispose(): void;
  65086. /**
  65087. * Helper function to create a SceneOptimizer with one single line of code
  65088. * @param scene defines the scene to work on
  65089. * @param options defines the options to use with the SceneOptimizer
  65090. * @param onSuccess defines a callback to call on success
  65091. * @param onFailure defines a callback to call on failure
  65092. * @returns the new SceneOptimizer object
  65093. */
  65094. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  65095. }
  65096. }
  65097. declare module "babylonjs/Misc/sceneSerializer" {
  65098. import { Scene } from "babylonjs/scene";
  65099. /**
  65100. * Class used to serialize a scene into a string
  65101. */
  65102. export class SceneSerializer {
  65103. /**
  65104. * Clear cache used by a previous serialization
  65105. */
  65106. static ClearCache(): void;
  65107. /**
  65108. * Serialize a scene into a JSON compatible object
  65109. * @param scene defines the scene to serialize
  65110. * @returns a JSON compatible object
  65111. */
  65112. static Serialize(scene: Scene): any;
  65113. /**
  65114. * Serialize a mesh into a JSON compatible object
  65115. * @param toSerialize defines the mesh to serialize
  65116. * @param withParents defines if parents must be serialized as well
  65117. * @param withChildren defines if children must be serialized as well
  65118. * @returns a JSON compatible object
  65119. */
  65120. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  65121. }
  65122. }
  65123. declare module "babylonjs/Misc/textureTools" {
  65124. import { Texture } from "babylonjs/Materials/Textures/texture";
  65125. /**
  65126. * Class used to host texture specific utilities
  65127. */
  65128. export class TextureTools {
  65129. /**
  65130. * Uses the GPU to create a copy texture rescaled at a given size
  65131. * @param texture Texture to copy from
  65132. * @param width defines the desired width
  65133. * @param height defines the desired height
  65134. * @param useBilinearMode defines if bilinear mode has to be used
  65135. * @return the generated texture
  65136. */
  65137. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  65138. }
  65139. }
  65140. declare module "babylonjs/Misc/videoRecorder" {
  65141. import { Nullable } from "babylonjs/types";
  65142. import { Engine } from "babylonjs/Engines/engine";
  65143. /**
  65144. * This represents the different options available for the video capture.
  65145. */
  65146. export interface VideoRecorderOptions {
  65147. /** Defines the mime type of the video. */
  65148. mimeType: string;
  65149. /** Defines the FPS the video should be recorded at. */
  65150. fps: number;
  65151. /** Defines the chunk size for the recording data. */
  65152. recordChunckSize: number;
  65153. /** The audio tracks to attach to the recording. */
  65154. audioTracks?: MediaStreamTrack[];
  65155. }
  65156. /**
  65157. * This can help with recording videos from BabylonJS.
  65158. * This is based on the available WebRTC functionalities of the browser.
  65159. *
  65160. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  65161. */
  65162. export class VideoRecorder {
  65163. private static readonly _defaultOptions;
  65164. /**
  65165. * Returns whether or not the VideoRecorder is available in your browser.
  65166. * @param engine Defines the Babylon Engine.
  65167. * @returns true if supported otherwise false.
  65168. */
  65169. static IsSupported(engine: Engine): boolean;
  65170. private readonly _options;
  65171. private _canvas;
  65172. private _mediaRecorder;
  65173. private _recordedChunks;
  65174. private _fileName;
  65175. private _resolve;
  65176. private _reject;
  65177. /**
  65178. * True when a recording is already in progress.
  65179. */
  65180. readonly isRecording: boolean;
  65181. /**
  65182. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  65183. * @param engine Defines the BabylonJS Engine you wish to record.
  65184. * @param options Defines options that can be used to customize the capture.
  65185. */
  65186. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  65187. /**
  65188. * Stops the current recording before the default capture timeout passed in the startRecording function.
  65189. */
  65190. stopRecording(): void;
  65191. /**
  65192. * Starts recording the canvas for a max duration specified in parameters.
  65193. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  65194. * If null no automatic download will start and you can rely on the promise to get the data back.
  65195. * @param maxDuration Defines the maximum recording time in seconds.
  65196. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  65197. * @return A promise callback at the end of the recording with the video data in Blob.
  65198. */
  65199. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  65200. /**
  65201. * Releases internal resources used during the recording.
  65202. */
  65203. dispose(): void;
  65204. private _handleDataAvailable;
  65205. private _handleError;
  65206. private _handleStop;
  65207. }
  65208. }
  65209. declare module "babylonjs/Misc/screenshotTools" {
  65210. import { Camera } from "babylonjs/Cameras/camera";
  65211. import { IScreenshotSize } from "babylonjs/Misc/interfaces/screenshotSize";
  65212. import { Engine } from "babylonjs/Engines/engine";
  65213. /**
  65214. * Class containing a set of static utilities functions for screenshots
  65215. */
  65216. export class ScreenshotTools {
  65217. /**
  65218. * Captures a screenshot of the current rendering
  65219. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  65220. * @param engine defines the rendering engine
  65221. * @param camera defines the source camera
  65222. * @param size This parameter can be set to a single number or to an object with the
  65223. * following (optional) properties: precision, width, height. If a single number is passed,
  65224. * it will be used for both width and height. If an object is passed, the screenshot size
  65225. * will be derived from the parameters. The precision property is a multiplier allowing
  65226. * rendering at a higher or lower resolution
  65227. * @param successCallback defines the callback receives a single parameter which contains the
  65228. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  65229. * src parameter of an <img> to display it
  65230. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  65231. * Check your browser for supported MIME types
  65232. */
  65233. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  65234. /**
  65235. * Captures a screenshot of the current rendering
  65236. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  65237. * @param engine defines the rendering engine
  65238. * @param camera defines the source camera
  65239. * @param size This parameter can be set to a single number or to an object with the
  65240. * following (optional) properties: precision, width, height. If a single number is passed,
  65241. * it will be used for both width and height. If an object is passed, the screenshot size
  65242. * will be derived from the parameters. The precision property is a multiplier allowing
  65243. * rendering at a higher or lower resolution
  65244. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  65245. * Check your browser for supported MIME types
  65246. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  65247. * to the src parameter of an <img> to display it
  65248. */
  65249. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  65250. /**
  65251. * Generates an image screenshot from the specified camera.
  65252. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  65253. * @param engine The engine to use for rendering
  65254. * @param camera The camera to use for rendering
  65255. * @param size This parameter can be set to a single number or to an object with the
  65256. * following (optional) properties: precision, width, height. If a single number is passed,
  65257. * it will be used for both width and height. If an object is passed, the screenshot size
  65258. * will be derived from the parameters. The precision property is a multiplier allowing
  65259. * rendering at a higher or lower resolution
  65260. * @param successCallback The callback receives a single parameter which contains the
  65261. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  65262. * src parameter of an <img> to display it
  65263. * @param mimeType The MIME type of the screenshot image (default: image/png).
  65264. * Check your browser for supported MIME types
  65265. * @param samples Texture samples (default: 1)
  65266. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  65267. * @param fileName A name for for the downloaded file.
  65268. */
  65269. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  65270. /**
  65271. * Generates an image screenshot from the specified camera.
  65272. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  65273. * @param engine The engine to use for rendering
  65274. * @param camera The camera to use for rendering
  65275. * @param size This parameter can be set to a single number or to an object with the
  65276. * following (optional) properties: precision, width, height. If a single number is passed,
  65277. * it will be used for both width and height. If an object is passed, the screenshot size
  65278. * will be derived from the parameters. The precision property is a multiplier allowing
  65279. * rendering at a higher or lower resolution
  65280. * @param mimeType The MIME type of the screenshot image (default: image/png).
  65281. * Check your browser for supported MIME types
  65282. * @param samples Texture samples (default: 1)
  65283. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  65284. * @param fileName A name for for the downloaded file.
  65285. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  65286. * to the src parameter of an <img> to display it
  65287. */
  65288. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  65289. /**
  65290. * Gets height and width for screenshot size
  65291. * @private
  65292. */
  65293. private static _getScreenshotSize;
  65294. }
  65295. }
  65296. declare module "babylonjs/Misc/index" {
  65297. export * from "babylonjs/Misc/andOrNotEvaluator";
  65298. export * from "babylonjs/Misc/assetsManager";
  65299. export * from "babylonjs/Misc/dds";
  65300. export * from "babylonjs/Misc/decorators";
  65301. export * from "babylonjs/Misc/deferred";
  65302. export * from "babylonjs/Misc/environmentTextureTools";
  65303. export * from "babylonjs/Misc/meshExploder";
  65304. export * from "babylonjs/Misc/filesInput";
  65305. export * from "babylonjs/Misc/HighDynamicRange/index";
  65306. export * from "babylonjs/Misc/khronosTextureContainer";
  65307. export * from "babylonjs/Misc/observable";
  65308. export * from "babylonjs/Misc/performanceMonitor";
  65309. export * from "babylonjs/Misc/promise";
  65310. export * from "babylonjs/Misc/sceneOptimizer";
  65311. export * from "babylonjs/Misc/sceneSerializer";
  65312. export * from "babylonjs/Misc/smartArray";
  65313. export * from "babylonjs/Misc/stringDictionary";
  65314. export * from "babylonjs/Misc/tags";
  65315. export * from "babylonjs/Misc/textureTools";
  65316. export * from "babylonjs/Misc/tga";
  65317. export * from "babylonjs/Misc/tools";
  65318. export * from "babylonjs/Misc/videoRecorder";
  65319. export * from "babylonjs/Misc/virtualJoystick";
  65320. export * from "babylonjs/Misc/workerPool";
  65321. export * from "babylonjs/Misc/logger";
  65322. export * from "babylonjs/Misc/typeStore";
  65323. export * from "babylonjs/Misc/filesInputStore";
  65324. export * from "babylonjs/Misc/deepCopier";
  65325. export * from "babylonjs/Misc/pivotTools";
  65326. export * from "babylonjs/Misc/precisionDate";
  65327. export * from "babylonjs/Misc/screenshotTools";
  65328. export * from "babylonjs/Misc/typeStore";
  65329. export * from "babylonjs/Misc/webRequest";
  65330. export * from "babylonjs/Misc/iInspectable";
  65331. export * from "babylonjs/Misc/brdfTextureTools";
  65332. export * from "babylonjs/Misc/gradients";
  65333. export * from "babylonjs/Misc/perfCounter";
  65334. export * from "babylonjs/Misc/fileRequest";
  65335. export * from "babylonjs/Misc/customAnimationFrameRequester";
  65336. export * from "babylonjs/Misc/retryStrategy";
  65337. export * from "babylonjs/Misc/loadFileError";
  65338. }
  65339. declare module "babylonjs/index" {
  65340. export * from "babylonjs/abstractScene";
  65341. export * from "babylonjs/Actions/index";
  65342. export * from "babylonjs/Animations/index";
  65343. export * from "babylonjs/assetContainer";
  65344. export * from "babylonjs/Audio/index";
  65345. export * from "babylonjs/Behaviors/index";
  65346. export * from "babylonjs/Bones/index";
  65347. export * from "babylonjs/Cameras/index";
  65348. export * from "babylonjs/Collisions/index";
  65349. export * from "babylonjs/Culling/index";
  65350. export * from "babylonjs/Debug/index";
  65351. export * from "babylonjs/Engines/index";
  65352. export * from "babylonjs/Events/index";
  65353. export * from "babylonjs/Gamepads/index";
  65354. export * from "babylonjs/Gizmos/index";
  65355. export * from "babylonjs/Helpers/index";
  65356. export * from "babylonjs/Instrumentation/index";
  65357. export * from "babylonjs/Layers/index";
  65358. export * from "babylonjs/LensFlares/index";
  65359. export * from "babylonjs/Lights/index";
  65360. export * from "babylonjs/Loading/index";
  65361. export * from "babylonjs/Materials/index";
  65362. export * from "babylonjs/Maths/index";
  65363. export * from "babylonjs/Meshes/index";
  65364. export * from "babylonjs/Morph/index";
  65365. export * from "babylonjs/Navigation/index";
  65366. export * from "babylonjs/node";
  65367. export * from "babylonjs/Offline/index";
  65368. export * from "babylonjs/Particles/index";
  65369. export * from "babylonjs/Physics/index";
  65370. export * from "babylonjs/PostProcesses/index";
  65371. export * from "babylonjs/Probes/index";
  65372. export * from "babylonjs/Rendering/index";
  65373. export * from "babylonjs/scene";
  65374. export * from "babylonjs/sceneComponent";
  65375. export * from "babylonjs/Sprites/index";
  65376. export * from "babylonjs/States/index";
  65377. export * from "babylonjs/Misc/index";
  65378. export * from "babylonjs/types";
  65379. }
  65380. declare module "babylonjs/Animations/pathCursor" {
  65381. import { Vector3 } from "babylonjs/Maths/math.vector";
  65382. import { Path2 } from "babylonjs/Maths/math.path";
  65383. /**
  65384. * A cursor which tracks a point on a path
  65385. */
  65386. export class PathCursor {
  65387. private path;
  65388. /**
  65389. * Stores path cursor callbacks for when an onchange event is triggered
  65390. */
  65391. private _onchange;
  65392. /**
  65393. * The value of the path cursor
  65394. */
  65395. value: number;
  65396. /**
  65397. * The animation array of the path cursor
  65398. */
  65399. animations: Animation[];
  65400. /**
  65401. * Initializes the path cursor
  65402. * @param path The path to track
  65403. */
  65404. constructor(path: Path2);
  65405. /**
  65406. * Gets the cursor point on the path
  65407. * @returns A point on the path cursor at the cursor location
  65408. */
  65409. getPoint(): Vector3;
  65410. /**
  65411. * Moves the cursor ahead by the step amount
  65412. * @param step The amount to move the cursor forward
  65413. * @returns This path cursor
  65414. */
  65415. moveAhead(step?: number): PathCursor;
  65416. /**
  65417. * Moves the cursor behind by the step amount
  65418. * @param step The amount to move the cursor back
  65419. * @returns This path cursor
  65420. */
  65421. moveBack(step?: number): PathCursor;
  65422. /**
  65423. * Moves the cursor by the step amount
  65424. * If the step amount is greater than one, an exception is thrown
  65425. * @param step The amount to move the cursor
  65426. * @returns This path cursor
  65427. */
  65428. move(step: number): PathCursor;
  65429. /**
  65430. * Ensures that the value is limited between zero and one
  65431. * @returns This path cursor
  65432. */
  65433. private ensureLimits;
  65434. /**
  65435. * Runs onchange callbacks on change (used by the animation engine)
  65436. * @returns This path cursor
  65437. */
  65438. private raiseOnChange;
  65439. /**
  65440. * Executes a function on change
  65441. * @param f A path cursor onchange callback
  65442. * @returns This path cursor
  65443. */
  65444. onchange(f: (cursor: PathCursor) => void): PathCursor;
  65445. }
  65446. }
  65447. declare module "babylonjs/Engines/Processors/Expressions/Operators/index" {
  65448. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineAndOperator";
  65449. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineArithmeticOperator";
  65450. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineIsDefinedOperator";
  65451. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineOrOperator";
  65452. }
  65453. declare module "babylonjs/Engines/Processors/Expressions/index" {
  65454. export * from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  65455. export * from "babylonjs/Engines/Processors/Expressions/Operators/index";
  65456. }
  65457. declare module "babylonjs/Engines/Processors/index" {
  65458. export * from "babylonjs/Engines/Processors/iShaderProcessor";
  65459. export * from "babylonjs/Engines/Processors/Expressions/index";
  65460. export * from "babylonjs/Engines/Processors/shaderCodeConditionNode";
  65461. export * from "babylonjs/Engines/Processors/shaderCodeCursor";
  65462. export * from "babylonjs/Engines/Processors/shaderCodeNode";
  65463. export * from "babylonjs/Engines/Processors/shaderCodeTestNode";
  65464. export * from "babylonjs/Engines/Processors/shaderProcessingOptions";
  65465. export * from "babylonjs/Engines/Processors/shaderProcessor";
  65466. }
  65467. declare module "babylonjs/Legacy/legacy" {
  65468. import * as Babylon from "babylonjs/index";
  65469. export * from "babylonjs/index";
  65470. }
  65471. declare module "babylonjs/Shaders/blur.fragment" {
  65472. /** @hidden */
  65473. export var blurPixelShader: {
  65474. name: string;
  65475. shader: string;
  65476. };
  65477. }
  65478. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertexDeclaration" {
  65479. /** @hidden */
  65480. export var pointCloudVertexDeclaration: {
  65481. name: string;
  65482. shader: string;
  65483. };
  65484. }
  65485. declare module "babylonjs" {
  65486. export * from "babylonjs/Legacy/legacy";
  65487. }
  65488. declare module BABYLON {
  65489. /** Alias type for value that can be null */
  65490. export type Nullable<T> = T | null;
  65491. /**
  65492. * Alias type for number that are floats
  65493. * @ignorenaming
  65494. */
  65495. export type float = number;
  65496. /**
  65497. * Alias type for number that are doubles.
  65498. * @ignorenaming
  65499. */
  65500. export type double = number;
  65501. /**
  65502. * Alias type for number that are integer
  65503. * @ignorenaming
  65504. */
  65505. export type int = number;
  65506. /** Alias type for number array or Float32Array */
  65507. export type FloatArray = number[] | Float32Array;
  65508. /** Alias type for number array or Float32Array or Int32Array or Uint32Array or Uint16Array */
  65509. export type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  65510. /**
  65511. * Alias for types that can be used by a Buffer or VertexBuffer.
  65512. */
  65513. export type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  65514. /**
  65515. * Alias type for primitive types
  65516. * @ignorenaming
  65517. */
  65518. type Primitive = undefined | null | boolean | string | number | Function;
  65519. /**
  65520. * Type modifier to make all the properties of an object Readonly
  65521. */
  65522. export type Immutable<T> = T extends Primitive ? T : T extends Array<infer U> ? ReadonlyArray<U> : DeepImmutable<T>;
  65523. /**
  65524. * Type modifier to make all the properties of an object Readonly recursively
  65525. */
  65526. export type DeepImmutable<T> = T extends Primitive ? T : T extends Array<infer U> ? DeepImmutableArray<U> : DeepImmutableObject<T>;
  65527. /** @hidden */
  65528. interface DeepImmutableArray<T> extends ReadonlyArray<DeepImmutable<T>> {
  65529. }
  65530. /** @hidden */
  65531. /** @hidden */
  65532. type DeepImmutableObject<T> = {
  65533. readonly [K in keyof T]: DeepImmutable<T[K]>;
  65534. };
  65535. }
  65536. declare module BABYLON {
  65537. /**
  65538. * A class serves as a medium between the observable and its observers
  65539. */
  65540. export class EventState {
  65541. /**
  65542. * Create a new EventState
  65543. * @param mask defines the mask associated with this state
  65544. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  65545. * @param target defines the original target of the state
  65546. * @param currentTarget defines the current target of the state
  65547. */
  65548. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  65549. /**
  65550. * Initialize the current event state
  65551. * @param mask defines the mask associated with this state
  65552. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  65553. * @param target defines the original target of the state
  65554. * @param currentTarget defines the current target of the state
  65555. * @returns the current event state
  65556. */
  65557. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  65558. /**
  65559. * An Observer can set this property to true to prevent subsequent observers of being notified
  65560. */
  65561. skipNextObservers: boolean;
  65562. /**
  65563. * Get the mask value that were used to trigger the event corresponding to this EventState object
  65564. */
  65565. mask: number;
  65566. /**
  65567. * The object that originally notified the event
  65568. */
  65569. target?: any;
  65570. /**
  65571. * The current object in the bubbling phase
  65572. */
  65573. currentTarget?: any;
  65574. /**
  65575. * This will be populated with the return value of the last function that was executed.
  65576. * If it is the first function in the callback chain it will be the event data.
  65577. */
  65578. lastReturnValue?: any;
  65579. }
  65580. /**
  65581. * Represent an Observer registered to a given Observable object.
  65582. */
  65583. export class Observer<T> {
  65584. /**
  65585. * Defines the callback to call when the observer is notified
  65586. */
  65587. callback: (eventData: T, eventState: EventState) => void;
  65588. /**
  65589. * Defines the mask of the observer (used to filter notifications)
  65590. */
  65591. mask: number;
  65592. /**
  65593. * Defines the current scope used to restore the JS context
  65594. */
  65595. scope: any;
  65596. /** @hidden */
  65597. _willBeUnregistered: boolean;
  65598. /**
  65599. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  65600. */
  65601. unregisterOnNextCall: boolean;
  65602. /**
  65603. * Creates a new observer
  65604. * @param callback defines the callback to call when the observer is notified
  65605. * @param mask defines the mask of the observer (used to filter notifications)
  65606. * @param scope defines the current scope used to restore the JS context
  65607. */
  65608. constructor(
  65609. /**
  65610. * Defines the callback to call when the observer is notified
  65611. */
  65612. callback: (eventData: T, eventState: EventState) => void,
  65613. /**
  65614. * Defines the mask of the observer (used to filter notifications)
  65615. */
  65616. mask: number,
  65617. /**
  65618. * Defines the current scope used to restore the JS context
  65619. */
  65620. scope?: any);
  65621. }
  65622. /**
  65623. * Represent a list of observers registered to multiple Observables object.
  65624. */
  65625. export class MultiObserver<T> {
  65626. private _observers;
  65627. private _observables;
  65628. /**
  65629. * Release associated resources
  65630. */
  65631. dispose(): void;
  65632. /**
  65633. * Raise a callback when one of the observable will notify
  65634. * @param observables defines a list of observables to watch
  65635. * @param callback defines the callback to call on notification
  65636. * @param mask defines the mask used to filter notifications
  65637. * @param scope defines the current scope used to restore the JS context
  65638. * @returns the new MultiObserver
  65639. */
  65640. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  65641. }
  65642. /**
  65643. * The Observable class is a simple implementation of the Observable pattern.
  65644. *
  65645. * 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.
  65646. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  65647. * 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).
  65648. * 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.
  65649. */
  65650. export class Observable<T> {
  65651. private _observers;
  65652. private _eventState;
  65653. private _onObserverAdded;
  65654. /**
  65655. * Gets the list of observers
  65656. */
  65657. readonly observers: Array<Observer<T>>;
  65658. /**
  65659. * Creates a new observable
  65660. * @param onObserverAdded defines a callback to call when a new observer is added
  65661. */
  65662. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  65663. /**
  65664. * Create a new Observer with the specified callback
  65665. * @param callback the callback that will be executed for that Observer
  65666. * @param mask the mask used to filter observers
  65667. * @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.
  65668. * @param scope optional scope for the callback to be called from
  65669. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  65670. * @returns the new observer created for the callback
  65671. */
  65672. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  65673. /**
  65674. * Create a new Observer with the specified callback and unregisters after the next notification
  65675. * @param callback the callback that will be executed for that Observer
  65676. * @returns the new observer created for the callback
  65677. */
  65678. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  65679. /**
  65680. * Remove an Observer from the Observable object
  65681. * @param observer the instance of the Observer to remove
  65682. * @returns false if it doesn't belong to this Observable
  65683. */
  65684. remove(observer: Nullable<Observer<T>>): boolean;
  65685. /**
  65686. * Remove a callback from the Observable object
  65687. * @param callback the callback to remove
  65688. * @param scope optional scope. If used only the callbacks with this scope will be removed
  65689. * @returns false if it doesn't belong to this Observable
  65690. */
  65691. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  65692. private _deferUnregister;
  65693. private _remove;
  65694. /**
  65695. * Moves the observable to the top of the observer list making it get called first when notified
  65696. * @param observer the observer to move
  65697. */
  65698. makeObserverTopPriority(observer: Observer<T>): void;
  65699. /**
  65700. * Moves the observable to the bottom of the observer list making it get called last when notified
  65701. * @param observer the observer to move
  65702. */
  65703. makeObserverBottomPriority(observer: Observer<T>): void;
  65704. /**
  65705. * Notify all Observers by calling their respective callback with the given data
  65706. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  65707. * @param eventData defines the data to send to all observers
  65708. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  65709. * @param target defines the original target of the state
  65710. * @param currentTarget defines the current target of the state
  65711. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  65712. */
  65713. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  65714. /**
  65715. * Calling this will execute each callback, expecting it to be a promise or return a value.
  65716. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  65717. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  65718. * and it is crucial that all callbacks will be executed.
  65719. * The order of the callbacks is kept, callbacks are not executed parallel.
  65720. *
  65721. * @param eventData The data to be sent to each callback
  65722. * @param mask is used to filter observers defaults to -1
  65723. * @param target defines the callback target (see EventState)
  65724. * @param currentTarget defines he current object in the bubbling phase
  65725. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  65726. */
  65727. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  65728. /**
  65729. * Notify a specific observer
  65730. * @param observer defines the observer to notify
  65731. * @param eventData defines the data to be sent to each callback
  65732. * @param mask is used to filter observers defaults to -1
  65733. */
  65734. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  65735. /**
  65736. * Gets a boolean indicating if the observable has at least one observer
  65737. * @returns true is the Observable has at least one Observer registered
  65738. */
  65739. hasObservers(): boolean;
  65740. /**
  65741. * Clear the list of observers
  65742. */
  65743. clear(): void;
  65744. /**
  65745. * Clone the current observable
  65746. * @returns a new observable
  65747. */
  65748. clone(): Observable<T>;
  65749. /**
  65750. * Does this observable handles observer registered with a given mask
  65751. * @param mask defines the mask to be tested
  65752. * @return whether or not one observer registered with the given mask is handeled
  65753. **/
  65754. hasSpecificMask(mask?: number): boolean;
  65755. }
  65756. }
  65757. declare module BABYLON {
  65758. /**
  65759. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  65760. * Babylon.js
  65761. */
  65762. export class DomManagement {
  65763. /**
  65764. * Checks if the window object exists
  65765. * @returns true if the window object exists
  65766. */
  65767. static IsWindowObjectExist(): boolean;
  65768. /**
  65769. * Checks if the navigator object exists
  65770. * @returns true if the navigator object exists
  65771. */
  65772. static IsNavigatorAvailable(): boolean;
  65773. /**
  65774. * Extracts text content from a DOM element hierarchy
  65775. * @param element defines the root element
  65776. * @returns a string
  65777. */
  65778. static GetDOMTextContent(element: HTMLElement): string;
  65779. }
  65780. }
  65781. declare module BABYLON {
  65782. /**
  65783. * Logger used througouht the application to allow configuration of
  65784. * the log level required for the messages.
  65785. */
  65786. export class Logger {
  65787. /**
  65788. * No log
  65789. */
  65790. static readonly NoneLogLevel: number;
  65791. /**
  65792. * Only message logs
  65793. */
  65794. static readonly MessageLogLevel: number;
  65795. /**
  65796. * Only warning logs
  65797. */
  65798. static readonly WarningLogLevel: number;
  65799. /**
  65800. * Only error logs
  65801. */
  65802. static readonly ErrorLogLevel: number;
  65803. /**
  65804. * All logs
  65805. */
  65806. static readonly AllLogLevel: number;
  65807. private static _LogCache;
  65808. /**
  65809. * Gets a value indicating the number of loading errors
  65810. * @ignorenaming
  65811. */
  65812. static errorsCount: number;
  65813. /**
  65814. * Callback called when a new log is added
  65815. */
  65816. static OnNewCacheEntry: (entry: string) => void;
  65817. private static _AddLogEntry;
  65818. private static _FormatMessage;
  65819. private static _LogDisabled;
  65820. private static _LogEnabled;
  65821. private static _WarnDisabled;
  65822. private static _WarnEnabled;
  65823. private static _ErrorDisabled;
  65824. private static _ErrorEnabled;
  65825. /**
  65826. * Log a message to the console
  65827. */
  65828. static Log: (message: string) => void;
  65829. /**
  65830. * Write a warning message to the console
  65831. */
  65832. static Warn: (message: string) => void;
  65833. /**
  65834. * Write an error message to the console
  65835. */
  65836. static Error: (message: string) => void;
  65837. /**
  65838. * Gets current log cache (list of logs)
  65839. */
  65840. static readonly LogCache: string;
  65841. /**
  65842. * Clears the log cache
  65843. */
  65844. static ClearLogCache(): void;
  65845. /**
  65846. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  65847. */
  65848. static LogLevels: number;
  65849. }
  65850. }
  65851. declare module BABYLON {
  65852. /** @hidden */
  65853. export class _TypeStore {
  65854. /** @hidden */
  65855. static RegisteredTypes: {
  65856. [key: string]: Object;
  65857. };
  65858. /** @hidden */
  65859. static GetClass(fqdn: string): any;
  65860. }
  65861. }
  65862. declare module BABYLON {
  65863. /**
  65864. * Class containing a set of static utilities functions for deep copy.
  65865. */
  65866. export class DeepCopier {
  65867. /**
  65868. * Tries to copy an object by duplicating every property
  65869. * @param source defines the source object
  65870. * @param destination defines the target object
  65871. * @param doNotCopyList defines a list of properties to avoid
  65872. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  65873. */
  65874. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  65875. }
  65876. }
  65877. declare module BABYLON {
  65878. /**
  65879. * Class containing a set of static utilities functions for precision date
  65880. */
  65881. export class PrecisionDate {
  65882. /**
  65883. * Gets either window.performance.now() if supported or Date.now() else
  65884. */
  65885. static readonly Now: number;
  65886. }
  65887. }
  65888. declare module BABYLON {
  65889. /** @hidden */
  65890. export class _DevTools {
  65891. static WarnImport(name: string): string;
  65892. }
  65893. }
  65894. declare module BABYLON {
  65895. /**
  65896. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  65897. */
  65898. export class WebRequest {
  65899. private _xhr;
  65900. /**
  65901. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  65902. * i.e. when loading files, where the server/service expects an Authorization header
  65903. */
  65904. static CustomRequestHeaders: {
  65905. [key: string]: string;
  65906. };
  65907. /**
  65908. * Add callback functions in this array to update all the requests before they get sent to the network
  65909. */
  65910. static CustomRequestModifiers: ((request: XMLHttpRequest, url: string) => void)[];
  65911. private _injectCustomRequestHeaders;
  65912. /**
  65913. * Gets or sets a function to be called when loading progress changes
  65914. */
  65915. onprogress: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  65916. /**
  65917. * Returns client's state
  65918. */
  65919. readonly readyState: number;
  65920. /**
  65921. * Returns client's status
  65922. */
  65923. readonly status: number;
  65924. /**
  65925. * Returns client's status as a text
  65926. */
  65927. readonly statusText: string;
  65928. /**
  65929. * Returns client's response
  65930. */
  65931. readonly response: any;
  65932. /**
  65933. * Returns client's response url
  65934. */
  65935. readonly responseURL: string;
  65936. /**
  65937. * Returns client's response as text
  65938. */
  65939. readonly responseText: string;
  65940. /**
  65941. * Gets or sets the expected response type
  65942. */
  65943. responseType: XMLHttpRequestResponseType;
  65944. /** @hidden */
  65945. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  65946. /** @hidden */
  65947. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  65948. /**
  65949. * Cancels any network activity
  65950. */
  65951. abort(): void;
  65952. /**
  65953. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  65954. * @param body defines an optional request body
  65955. */
  65956. send(body?: Document | BodyInit | null): void;
  65957. /**
  65958. * Sets the request method, request URL
  65959. * @param method defines the method to use (GET, POST, etc..)
  65960. * @param url defines the url to connect with
  65961. */
  65962. open(method: string, url: string): void;
  65963. }
  65964. }
  65965. declare module BABYLON {
  65966. /**
  65967. * File request interface
  65968. */
  65969. export interface IFileRequest {
  65970. /**
  65971. * Raised when the request is complete (success or error).
  65972. */
  65973. onCompleteObservable: Observable<IFileRequest>;
  65974. /**
  65975. * Aborts the request for a file.
  65976. */
  65977. abort: () => void;
  65978. }
  65979. }
  65980. declare module BABYLON {
  65981. /**
  65982. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  65983. */
  65984. export class PerformanceMonitor {
  65985. private _enabled;
  65986. private _rollingFrameTime;
  65987. private _lastFrameTimeMs;
  65988. /**
  65989. * constructor
  65990. * @param frameSampleSize The number of samples required to saturate the sliding window
  65991. */
  65992. constructor(frameSampleSize?: number);
  65993. /**
  65994. * Samples current frame
  65995. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  65996. */
  65997. sampleFrame(timeMs?: number): void;
  65998. /**
  65999. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  66000. */
  66001. readonly averageFrameTime: number;
  66002. /**
  66003. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  66004. */
  66005. readonly averageFrameTimeVariance: number;
  66006. /**
  66007. * Returns the frame time of the most recent frame
  66008. */
  66009. readonly instantaneousFrameTime: number;
  66010. /**
  66011. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  66012. */
  66013. readonly averageFPS: number;
  66014. /**
  66015. * Returns the average framerate in frames per second using the most recent frame time
  66016. */
  66017. readonly instantaneousFPS: number;
  66018. /**
  66019. * Returns true if enough samples have been taken to completely fill the sliding window
  66020. */
  66021. readonly isSaturated: boolean;
  66022. /**
  66023. * Enables contributions to the sliding window sample set
  66024. */
  66025. enable(): void;
  66026. /**
  66027. * Disables contributions to the sliding window sample set
  66028. * Samples will not be interpolated over the disabled period
  66029. */
  66030. disable(): void;
  66031. /**
  66032. * Returns true if sampling is enabled
  66033. */
  66034. readonly isEnabled: boolean;
  66035. /**
  66036. * Resets performance monitor
  66037. */
  66038. reset(): void;
  66039. }
  66040. /**
  66041. * RollingAverage
  66042. *
  66043. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  66044. */
  66045. export class RollingAverage {
  66046. /**
  66047. * Current average
  66048. */
  66049. average: number;
  66050. /**
  66051. * Current variance
  66052. */
  66053. variance: number;
  66054. protected _samples: Array<number>;
  66055. protected _sampleCount: number;
  66056. protected _pos: number;
  66057. protected _m2: number;
  66058. /**
  66059. * constructor
  66060. * @param length The number of samples required to saturate the sliding window
  66061. */
  66062. constructor(length: number);
  66063. /**
  66064. * Adds a sample to the sample set
  66065. * @param v The sample value
  66066. */
  66067. add(v: number): void;
  66068. /**
  66069. * Returns previously added values or null if outside of history or outside the sliding window domain
  66070. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  66071. * @return Value previously recorded with add() or null if outside of range
  66072. */
  66073. history(i: number): number;
  66074. /**
  66075. * Returns true if enough samples have been taken to completely fill the sliding window
  66076. * @return true if sample-set saturated
  66077. */
  66078. isSaturated(): boolean;
  66079. /**
  66080. * Resets the rolling average (equivalent to 0 samples taken so far)
  66081. */
  66082. reset(): void;
  66083. /**
  66084. * Wraps a value around the sample range boundaries
  66085. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  66086. * @return Wrapped position in sample range
  66087. */
  66088. protected _wrapPosition(i: number): number;
  66089. }
  66090. }
  66091. declare module BABYLON {
  66092. /**
  66093. * This class implement a typical dictionary using a string as key and the generic type T as value.
  66094. * The underlying implementation relies on an associative array to ensure the best performances.
  66095. * The value can be anything including 'null' but except 'undefined'
  66096. */
  66097. export class StringDictionary<T> {
  66098. /**
  66099. * This will clear this dictionary and copy the content from the 'source' one.
  66100. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  66101. * @param source the dictionary to take the content from and copy to this dictionary
  66102. */
  66103. copyFrom(source: StringDictionary<T>): void;
  66104. /**
  66105. * Get a value based from its key
  66106. * @param key the given key to get the matching value from
  66107. * @return the value if found, otherwise undefined is returned
  66108. */
  66109. get(key: string): T | undefined;
  66110. /**
  66111. * Get a value from its key or add it if it doesn't exist.
  66112. * This method will ensure you that a given key/data will be present in the dictionary.
  66113. * @param key the given key to get the matching value from
  66114. * @param factory the factory that will create the value if the key is not present in the dictionary.
  66115. * The factory will only be invoked if there's no data for the given key.
  66116. * @return the value corresponding to the key.
  66117. */
  66118. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  66119. /**
  66120. * Get a value from its key if present in the dictionary otherwise add it
  66121. * @param key the key to get the value from
  66122. * @param val if there's no such key/value pair in the dictionary add it with this value
  66123. * @return the value corresponding to the key
  66124. */
  66125. getOrAdd(key: string, val: T): T;
  66126. /**
  66127. * Check if there's a given key in the dictionary
  66128. * @param key the key to check for
  66129. * @return true if the key is present, false otherwise
  66130. */
  66131. contains(key: string): boolean;
  66132. /**
  66133. * Add a new key and its corresponding value
  66134. * @param key the key to add
  66135. * @param value the value corresponding to the key
  66136. * @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
  66137. */
  66138. add(key: string, value: T): boolean;
  66139. /**
  66140. * Update a specific value associated to a key
  66141. * @param key defines the key to use
  66142. * @param value defines the value to store
  66143. * @returns true if the value was updated (or false if the key was not found)
  66144. */
  66145. set(key: string, value: T): boolean;
  66146. /**
  66147. * Get the element of the given key and remove it from the dictionary
  66148. * @param key defines the key to search
  66149. * @returns the value associated with the key or null if not found
  66150. */
  66151. getAndRemove(key: string): Nullable<T>;
  66152. /**
  66153. * Remove a key/value from the dictionary.
  66154. * @param key the key to remove
  66155. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  66156. */
  66157. remove(key: string): boolean;
  66158. /**
  66159. * Clear the whole content of the dictionary
  66160. */
  66161. clear(): void;
  66162. /**
  66163. * Gets the current count
  66164. */
  66165. readonly count: number;
  66166. /**
  66167. * Execute a callback on each key/val of the dictionary.
  66168. * Note that you can remove any element in this dictionary in the callback implementation
  66169. * @param callback the callback to execute on a given key/value pair
  66170. */
  66171. forEach(callback: (key: string, val: T) => void): void;
  66172. /**
  66173. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  66174. * If the callback returns null or undefined the method will iterate to the next key/value pair
  66175. * Note that you can remove any element in this dictionary in the callback implementation
  66176. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  66177. * @returns the first item
  66178. */
  66179. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  66180. private _count;
  66181. private _data;
  66182. }
  66183. }
  66184. declare module BABYLON {
  66185. /**
  66186. * Class used to store gfx data (like WebGLBuffer)
  66187. */
  66188. export class DataBuffer {
  66189. /**
  66190. * Gets or sets the number of objects referencing this buffer
  66191. */
  66192. references: number;
  66193. /** Gets or sets the size of the underlying buffer */
  66194. capacity: number;
  66195. /**
  66196. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  66197. */
  66198. is32Bits: boolean;
  66199. /**
  66200. * Gets the underlying buffer
  66201. */
  66202. readonly underlyingResource: any;
  66203. }
  66204. }
  66205. declare module BABYLON {
  66206. /**
  66207. * Class used to store data that will be store in GPU memory
  66208. */
  66209. export class Buffer {
  66210. private _engine;
  66211. private _buffer;
  66212. /** @hidden */
  66213. _data: Nullable<DataArray>;
  66214. private _updatable;
  66215. private _instanced;
  66216. /**
  66217. * Gets the byte stride.
  66218. */
  66219. readonly byteStride: number;
  66220. /**
  66221. * Constructor
  66222. * @param engine the engine
  66223. * @param data the data to use for this buffer
  66224. * @param updatable whether the data is updatable
  66225. * @param stride the stride (optional)
  66226. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  66227. * @param instanced whether the buffer is instanced (optional)
  66228. * @param useBytes set to true if the stride in in bytes (optional)
  66229. */
  66230. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean);
  66231. /**
  66232. * Create a new VertexBuffer based on the current buffer
  66233. * @param kind defines the vertex buffer kind (position, normal, etc.)
  66234. * @param offset defines offset in the buffer (0 by default)
  66235. * @param size defines the size in floats of attributes (position is 3 for instance)
  66236. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  66237. * @param instanced defines if the vertex buffer contains indexed data
  66238. * @param useBytes defines if the offset and stride are in bytes
  66239. * @returns the new vertex buffer
  66240. */
  66241. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean): VertexBuffer;
  66242. /**
  66243. * Gets a boolean indicating if the Buffer is updatable?
  66244. * @returns true if the buffer is updatable
  66245. */
  66246. isUpdatable(): boolean;
  66247. /**
  66248. * Gets current buffer's data
  66249. * @returns a DataArray or null
  66250. */
  66251. getData(): Nullable<DataArray>;
  66252. /**
  66253. * Gets underlying native buffer
  66254. * @returns underlying native buffer
  66255. */
  66256. getBuffer(): Nullable<DataBuffer>;
  66257. /**
  66258. * Gets the stride in float32 units (i.e. byte stride / 4).
  66259. * May not be an integer if the byte stride is not divisible by 4.
  66260. * DEPRECATED. Use byteStride instead.
  66261. * @returns the stride in float32 units
  66262. */
  66263. getStrideSize(): number;
  66264. /**
  66265. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  66266. * @param data defines the data to store
  66267. */
  66268. create(data?: Nullable<DataArray>): void;
  66269. /** @hidden */
  66270. _rebuild(): void;
  66271. /**
  66272. * Update current buffer data
  66273. * @param data defines the data to store
  66274. */
  66275. update(data: DataArray): void;
  66276. /**
  66277. * Updates the data directly.
  66278. * @param data the new data
  66279. * @param offset the new offset
  66280. * @param vertexCount the vertex count (optional)
  66281. * @param useBytes set to true if the offset is in bytes
  66282. */
  66283. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  66284. /**
  66285. * Release all resources
  66286. */
  66287. dispose(): void;
  66288. }
  66289. /**
  66290. * Specialized buffer used to store vertex data
  66291. */
  66292. export class VertexBuffer {
  66293. /** @hidden */
  66294. _buffer: Buffer;
  66295. private _kind;
  66296. private _size;
  66297. private _ownsBuffer;
  66298. private _instanced;
  66299. private _instanceDivisor;
  66300. /**
  66301. * The byte type.
  66302. */
  66303. static readonly BYTE: number;
  66304. /**
  66305. * The unsigned byte type.
  66306. */
  66307. static readonly UNSIGNED_BYTE: number;
  66308. /**
  66309. * The short type.
  66310. */
  66311. static readonly SHORT: number;
  66312. /**
  66313. * The unsigned short type.
  66314. */
  66315. static readonly UNSIGNED_SHORT: number;
  66316. /**
  66317. * The integer type.
  66318. */
  66319. static readonly INT: number;
  66320. /**
  66321. * The unsigned integer type.
  66322. */
  66323. static readonly UNSIGNED_INT: number;
  66324. /**
  66325. * The float type.
  66326. */
  66327. static readonly FLOAT: number;
  66328. /**
  66329. * Gets or sets the instance divisor when in instanced mode
  66330. */
  66331. instanceDivisor: number;
  66332. /**
  66333. * Gets the byte stride.
  66334. */
  66335. readonly byteStride: number;
  66336. /**
  66337. * Gets the byte offset.
  66338. */
  66339. readonly byteOffset: number;
  66340. /**
  66341. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  66342. */
  66343. readonly normalized: boolean;
  66344. /**
  66345. * Gets the data type of each component in the array.
  66346. */
  66347. readonly type: number;
  66348. /**
  66349. * Constructor
  66350. * @param engine the engine
  66351. * @param data the data to use for this vertex buffer
  66352. * @param kind the vertex buffer kind
  66353. * @param updatable whether the data is updatable
  66354. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  66355. * @param stride the stride (optional)
  66356. * @param instanced whether the buffer is instanced (optional)
  66357. * @param offset the offset of the data (optional)
  66358. * @param size the number of components (optional)
  66359. * @param type the type of the component (optional)
  66360. * @param normalized whether the data contains normalized data (optional)
  66361. * @param useBytes set to true if stride and offset are in bytes (optional)
  66362. */
  66363. 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);
  66364. /** @hidden */
  66365. _rebuild(): void;
  66366. /**
  66367. * Returns the kind of the VertexBuffer (string)
  66368. * @returns a string
  66369. */
  66370. getKind(): string;
  66371. /**
  66372. * Gets a boolean indicating if the VertexBuffer is updatable?
  66373. * @returns true if the buffer is updatable
  66374. */
  66375. isUpdatable(): boolean;
  66376. /**
  66377. * Gets current buffer's data
  66378. * @returns a DataArray or null
  66379. */
  66380. getData(): Nullable<DataArray>;
  66381. /**
  66382. * Gets underlying native buffer
  66383. * @returns underlying native buffer
  66384. */
  66385. getBuffer(): Nullable<DataBuffer>;
  66386. /**
  66387. * Gets the stride in float32 units (i.e. byte stride / 4).
  66388. * May not be an integer if the byte stride is not divisible by 4.
  66389. * DEPRECATED. Use byteStride instead.
  66390. * @returns the stride in float32 units
  66391. */
  66392. getStrideSize(): number;
  66393. /**
  66394. * Returns the offset as a multiple of the type byte length.
  66395. * DEPRECATED. Use byteOffset instead.
  66396. * @returns the offset in bytes
  66397. */
  66398. getOffset(): number;
  66399. /**
  66400. * Returns the number of components per vertex attribute (integer)
  66401. * @returns the size in float
  66402. */
  66403. getSize(): number;
  66404. /**
  66405. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  66406. * @returns true if this buffer is instanced
  66407. */
  66408. getIsInstanced(): boolean;
  66409. /**
  66410. * Returns the instancing divisor, zero for non-instanced (integer).
  66411. * @returns a number
  66412. */
  66413. getInstanceDivisor(): number;
  66414. /**
  66415. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  66416. * @param data defines the data to store
  66417. */
  66418. create(data?: DataArray): void;
  66419. /**
  66420. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  66421. * This function will create a new buffer if the current one is not updatable
  66422. * @param data defines the data to store
  66423. */
  66424. update(data: DataArray): void;
  66425. /**
  66426. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  66427. * Returns the directly updated WebGLBuffer.
  66428. * @param data the new data
  66429. * @param offset the new offset
  66430. * @param useBytes set to true if the offset is in bytes
  66431. */
  66432. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  66433. /**
  66434. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  66435. */
  66436. dispose(): void;
  66437. /**
  66438. * Enumerates each value of this vertex buffer as numbers.
  66439. * @param count the number of values to enumerate
  66440. * @param callback the callback function called for each value
  66441. */
  66442. forEach(count: number, callback: (value: number, index: number) => void): void;
  66443. /**
  66444. * Positions
  66445. */
  66446. static readonly PositionKind: string;
  66447. /**
  66448. * Normals
  66449. */
  66450. static readonly NormalKind: string;
  66451. /**
  66452. * Tangents
  66453. */
  66454. static readonly TangentKind: string;
  66455. /**
  66456. * Texture coordinates
  66457. */
  66458. static readonly UVKind: string;
  66459. /**
  66460. * Texture coordinates 2
  66461. */
  66462. static readonly UV2Kind: string;
  66463. /**
  66464. * Texture coordinates 3
  66465. */
  66466. static readonly UV3Kind: string;
  66467. /**
  66468. * Texture coordinates 4
  66469. */
  66470. static readonly UV4Kind: string;
  66471. /**
  66472. * Texture coordinates 5
  66473. */
  66474. static readonly UV5Kind: string;
  66475. /**
  66476. * Texture coordinates 6
  66477. */
  66478. static readonly UV6Kind: string;
  66479. /**
  66480. * Colors
  66481. */
  66482. static readonly ColorKind: string;
  66483. /**
  66484. * Matrix indices (for bones)
  66485. */
  66486. static readonly MatricesIndicesKind: string;
  66487. /**
  66488. * Matrix weights (for bones)
  66489. */
  66490. static readonly MatricesWeightsKind: string;
  66491. /**
  66492. * Additional matrix indices (for bones)
  66493. */
  66494. static readonly MatricesIndicesExtraKind: string;
  66495. /**
  66496. * Additional matrix weights (for bones)
  66497. */
  66498. static readonly MatricesWeightsExtraKind: string;
  66499. /**
  66500. * Deduces the stride given a kind.
  66501. * @param kind The kind string to deduce
  66502. * @returns The deduced stride
  66503. */
  66504. static DeduceStride(kind: string): number;
  66505. /**
  66506. * Gets the byte length of the given type.
  66507. * @param type the type
  66508. * @returns the number of bytes
  66509. */
  66510. static GetTypeByteLength(type: number): number;
  66511. /**
  66512. * Enumerates each value of the given parameters as numbers.
  66513. * @param data the data to enumerate
  66514. * @param byteOffset the byte offset of the data
  66515. * @param byteStride the byte stride of the data
  66516. * @param componentCount the number of components per element
  66517. * @param componentType the type of the component
  66518. * @param count the number of values to enumerate
  66519. * @param normalized whether the data is normalized
  66520. * @param callback the callback function called for each value
  66521. */
  66522. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  66523. private static _GetFloatValue;
  66524. }
  66525. }
  66526. declare module BABYLON {
  66527. /**
  66528. * Scalar computation library
  66529. */
  66530. export class Scalar {
  66531. /**
  66532. * Two pi constants convenient for computation.
  66533. */
  66534. static TwoPi: number;
  66535. /**
  66536. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  66537. * @param a number
  66538. * @param b number
  66539. * @param epsilon (default = 1.401298E-45)
  66540. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  66541. */
  66542. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  66543. /**
  66544. * Returns a string : the upper case translation of the number i to hexadecimal.
  66545. * @param i number
  66546. * @returns the upper case translation of the number i to hexadecimal.
  66547. */
  66548. static ToHex(i: number): string;
  66549. /**
  66550. * Returns -1 if value is negative and +1 is value is positive.
  66551. * @param value the value
  66552. * @returns the value itself if it's equal to zero.
  66553. */
  66554. static Sign(value: number): number;
  66555. /**
  66556. * Returns the value itself if it's between min and max.
  66557. * Returns min if the value is lower than min.
  66558. * Returns max if the value is greater than max.
  66559. * @param value the value to clmap
  66560. * @param min the min value to clamp to (default: 0)
  66561. * @param max the max value to clamp to (default: 1)
  66562. * @returns the clamped value
  66563. */
  66564. static Clamp(value: number, min?: number, max?: number): number;
  66565. /**
  66566. * the log2 of value.
  66567. * @param value the value to compute log2 of
  66568. * @returns the log2 of value.
  66569. */
  66570. static Log2(value: number): number;
  66571. /**
  66572. * Loops the value, so that it is never larger than length and never smaller than 0.
  66573. *
  66574. * This is similar to the modulo operator but it works with floating point numbers.
  66575. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  66576. * With t = 5 and length = 2.5, the result would be 0.0.
  66577. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  66578. * @param value the value
  66579. * @param length the length
  66580. * @returns the looped value
  66581. */
  66582. static Repeat(value: number, length: number): number;
  66583. /**
  66584. * Normalize the value between 0.0 and 1.0 using min and max values
  66585. * @param value value to normalize
  66586. * @param min max to normalize between
  66587. * @param max min to normalize between
  66588. * @returns the normalized value
  66589. */
  66590. static Normalize(value: number, min: number, max: number): number;
  66591. /**
  66592. * Denormalize the value from 0.0 and 1.0 using min and max values
  66593. * @param normalized value to denormalize
  66594. * @param min max to denormalize between
  66595. * @param max min to denormalize between
  66596. * @returns the denormalized value
  66597. */
  66598. static Denormalize(normalized: number, min: number, max: number): number;
  66599. /**
  66600. * Calculates the shortest difference between two given angles given in degrees.
  66601. * @param current current angle in degrees
  66602. * @param target target angle in degrees
  66603. * @returns the delta
  66604. */
  66605. static DeltaAngle(current: number, target: number): number;
  66606. /**
  66607. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  66608. * @param tx value
  66609. * @param length length
  66610. * @returns The returned value will move back and forth between 0 and length
  66611. */
  66612. static PingPong(tx: number, length: number): number;
  66613. /**
  66614. * Interpolates between min and max with smoothing at the limits.
  66615. *
  66616. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  66617. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  66618. * @param from from
  66619. * @param to to
  66620. * @param tx value
  66621. * @returns the smooth stepped value
  66622. */
  66623. static SmoothStep(from: number, to: number, tx: number): number;
  66624. /**
  66625. * Moves a value current towards target.
  66626. *
  66627. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  66628. * Negative values of maxDelta pushes the value away from target.
  66629. * @param current current value
  66630. * @param target target value
  66631. * @param maxDelta max distance to move
  66632. * @returns resulting value
  66633. */
  66634. static MoveTowards(current: number, target: number, maxDelta: number): number;
  66635. /**
  66636. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  66637. *
  66638. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  66639. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  66640. * @param current current value
  66641. * @param target target value
  66642. * @param maxDelta max distance to move
  66643. * @returns resulting angle
  66644. */
  66645. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  66646. /**
  66647. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  66648. * @param start start value
  66649. * @param end target value
  66650. * @param amount amount to lerp between
  66651. * @returns the lerped value
  66652. */
  66653. static Lerp(start: number, end: number, amount: number): number;
  66654. /**
  66655. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  66656. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  66657. * @param start start value
  66658. * @param end target value
  66659. * @param amount amount to lerp between
  66660. * @returns the lerped value
  66661. */
  66662. static LerpAngle(start: number, end: number, amount: number): number;
  66663. /**
  66664. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  66665. * @param a start value
  66666. * @param b target value
  66667. * @param value value between a and b
  66668. * @returns the inverseLerp value
  66669. */
  66670. static InverseLerp(a: number, b: number, value: number): number;
  66671. /**
  66672. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  66673. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  66674. * @param value1 spline value
  66675. * @param tangent1 spline value
  66676. * @param value2 spline value
  66677. * @param tangent2 spline value
  66678. * @param amount input value
  66679. * @returns hermite result
  66680. */
  66681. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  66682. /**
  66683. * Returns a random float number between and min and max values
  66684. * @param min min value of random
  66685. * @param max max value of random
  66686. * @returns random value
  66687. */
  66688. static RandomRange(min: number, max: number): number;
  66689. /**
  66690. * This function returns percentage of a number in a given range.
  66691. *
  66692. * RangeToPercent(40,20,60) will return 0.5 (50%)
  66693. * RangeToPercent(34,0,100) will return 0.34 (34%)
  66694. * @param number to convert to percentage
  66695. * @param min min range
  66696. * @param max max range
  66697. * @returns the percentage
  66698. */
  66699. static RangeToPercent(number: number, min: number, max: number): number;
  66700. /**
  66701. * This function returns number that corresponds to the percentage in a given range.
  66702. *
  66703. * PercentToRange(0.34,0,100) will return 34.
  66704. * @param percent to convert to number
  66705. * @param min min range
  66706. * @param max max range
  66707. * @returns the number
  66708. */
  66709. static PercentToRange(percent: number, min: number, max: number): number;
  66710. /**
  66711. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  66712. * @param angle The angle to normalize in radian.
  66713. * @return The converted angle.
  66714. */
  66715. static NormalizeRadians(angle: number): number;
  66716. }
  66717. }
  66718. declare module BABYLON {
  66719. /**
  66720. * Constant used to convert a value to gamma space
  66721. * @ignorenaming
  66722. */
  66723. export const ToGammaSpace: number;
  66724. /**
  66725. * Constant used to convert a value to linear space
  66726. * @ignorenaming
  66727. */
  66728. export const ToLinearSpace = 2.2;
  66729. /**
  66730. * Constant used to define the minimal number value in Babylon.js
  66731. * @ignorenaming
  66732. */
  66733. let Epsilon: number;
  66734. }
  66735. declare module BABYLON {
  66736. /**
  66737. * Class used to represent a viewport on screen
  66738. */
  66739. export class Viewport {
  66740. /** viewport left coordinate */
  66741. x: number;
  66742. /** viewport top coordinate */
  66743. y: number;
  66744. /**viewport width */
  66745. width: number;
  66746. /** viewport height */
  66747. height: number;
  66748. /**
  66749. * Creates a Viewport object located at (x, y) and sized (width, height)
  66750. * @param x defines viewport left coordinate
  66751. * @param y defines viewport top coordinate
  66752. * @param width defines the viewport width
  66753. * @param height defines the viewport height
  66754. */
  66755. constructor(
  66756. /** viewport left coordinate */
  66757. x: number,
  66758. /** viewport top coordinate */
  66759. y: number,
  66760. /**viewport width */
  66761. width: number,
  66762. /** viewport height */
  66763. height: number);
  66764. /**
  66765. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  66766. * @param renderWidth defines the rendering width
  66767. * @param renderHeight defines the rendering height
  66768. * @returns a new Viewport
  66769. */
  66770. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  66771. /**
  66772. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  66773. * @param renderWidth defines the rendering width
  66774. * @param renderHeight defines the rendering height
  66775. * @param ref defines the target viewport
  66776. * @returns the current viewport
  66777. */
  66778. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  66779. /**
  66780. * Returns a new Viewport copied from the current one
  66781. * @returns a new Viewport
  66782. */
  66783. clone(): Viewport;
  66784. }
  66785. }
  66786. declare module BABYLON {
  66787. /**
  66788. * Class containing a set of static utilities functions for arrays.
  66789. */
  66790. export class ArrayTools {
  66791. /**
  66792. * Returns an array of the given size filled with element built from the given constructor and the paramters
  66793. * @param size the number of element to construct and put in the array
  66794. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  66795. * @returns a new array filled with new objects
  66796. */
  66797. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  66798. }
  66799. }
  66800. declare module BABYLON {
  66801. /**
  66802. * @hidden
  66803. */
  66804. export interface IColor4Like {
  66805. r: float;
  66806. g: float;
  66807. b: float;
  66808. a: float;
  66809. }
  66810. /**
  66811. * @hidden
  66812. */
  66813. export interface IColor3Like {
  66814. r: float;
  66815. g: float;
  66816. b: float;
  66817. }
  66818. /**
  66819. * @hidden
  66820. */
  66821. export interface IVector4Like {
  66822. x: float;
  66823. y: float;
  66824. z: float;
  66825. w: float;
  66826. }
  66827. /**
  66828. * @hidden
  66829. */
  66830. export interface IVector3Like {
  66831. x: float;
  66832. y: float;
  66833. z: float;
  66834. }
  66835. /**
  66836. * @hidden
  66837. */
  66838. export interface IVector2Like {
  66839. x: float;
  66840. y: float;
  66841. }
  66842. /**
  66843. * @hidden
  66844. */
  66845. export interface IMatrixLike {
  66846. toArray(): DeepImmutable<Float32Array>;
  66847. updateFlag: int;
  66848. }
  66849. /**
  66850. * @hidden
  66851. */
  66852. export interface IViewportLike {
  66853. x: float;
  66854. y: float;
  66855. width: float;
  66856. height: float;
  66857. }
  66858. /**
  66859. * @hidden
  66860. */
  66861. export interface IPlaneLike {
  66862. normal: IVector3Like;
  66863. d: float;
  66864. normalize(): void;
  66865. }
  66866. }
  66867. declare module BABYLON {
  66868. /**
  66869. * Class representing a vector containing 2 coordinates
  66870. */
  66871. export class Vector2 {
  66872. /** defines the first coordinate */
  66873. x: number;
  66874. /** defines the second coordinate */
  66875. y: number;
  66876. /**
  66877. * Creates a new Vector2 from the given x and y coordinates
  66878. * @param x defines the first coordinate
  66879. * @param y defines the second coordinate
  66880. */
  66881. constructor(
  66882. /** defines the first coordinate */
  66883. x?: number,
  66884. /** defines the second coordinate */
  66885. y?: number);
  66886. /**
  66887. * Gets a string with the Vector2 coordinates
  66888. * @returns a string with the Vector2 coordinates
  66889. */
  66890. toString(): string;
  66891. /**
  66892. * Gets class name
  66893. * @returns the string "Vector2"
  66894. */
  66895. getClassName(): string;
  66896. /**
  66897. * Gets current vector hash code
  66898. * @returns the Vector2 hash code as a number
  66899. */
  66900. getHashCode(): number;
  66901. /**
  66902. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  66903. * @param array defines the source array
  66904. * @param index defines the offset in source array
  66905. * @returns the current Vector2
  66906. */
  66907. toArray(array: FloatArray, index?: number): Vector2;
  66908. /**
  66909. * Copy the current vector to an array
  66910. * @returns a new array with 2 elements: the Vector2 coordinates.
  66911. */
  66912. asArray(): number[];
  66913. /**
  66914. * Sets the Vector2 coordinates with the given Vector2 coordinates
  66915. * @param source defines the source Vector2
  66916. * @returns the current updated Vector2
  66917. */
  66918. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  66919. /**
  66920. * Sets the Vector2 coordinates with the given floats
  66921. * @param x defines the first coordinate
  66922. * @param y defines the second coordinate
  66923. * @returns the current updated Vector2
  66924. */
  66925. copyFromFloats(x: number, y: number): Vector2;
  66926. /**
  66927. * Sets the Vector2 coordinates with the given floats
  66928. * @param x defines the first coordinate
  66929. * @param y defines the second coordinate
  66930. * @returns the current updated Vector2
  66931. */
  66932. set(x: number, y: number): Vector2;
  66933. /**
  66934. * Add another vector with the current one
  66935. * @param otherVector defines the other vector
  66936. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  66937. */
  66938. add(otherVector: DeepImmutable<Vector2>): Vector2;
  66939. /**
  66940. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  66941. * @param otherVector defines the other vector
  66942. * @param result defines the target vector
  66943. * @returns the unmodified current Vector2
  66944. */
  66945. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  66946. /**
  66947. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  66948. * @param otherVector defines the other vector
  66949. * @returns the current updated Vector2
  66950. */
  66951. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  66952. /**
  66953. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  66954. * @param otherVector defines the other vector
  66955. * @returns a new Vector2
  66956. */
  66957. addVector3(otherVector: Vector3): Vector2;
  66958. /**
  66959. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  66960. * @param otherVector defines the other vector
  66961. * @returns a new Vector2
  66962. */
  66963. subtract(otherVector: Vector2): Vector2;
  66964. /**
  66965. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  66966. * @param otherVector defines the other vector
  66967. * @param result defines the target vector
  66968. * @returns the unmodified current Vector2
  66969. */
  66970. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  66971. /**
  66972. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  66973. * @param otherVector defines the other vector
  66974. * @returns the current updated Vector2
  66975. */
  66976. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  66977. /**
  66978. * Multiplies in place the current Vector2 coordinates by the given ones
  66979. * @param otherVector defines the other vector
  66980. * @returns the current updated Vector2
  66981. */
  66982. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  66983. /**
  66984. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  66985. * @param otherVector defines the other vector
  66986. * @returns a new Vector2
  66987. */
  66988. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  66989. /**
  66990. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  66991. * @param otherVector defines the other vector
  66992. * @param result defines the target vector
  66993. * @returns the unmodified current Vector2
  66994. */
  66995. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  66996. /**
  66997. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  66998. * @param x defines the first coordinate
  66999. * @param y defines the second coordinate
  67000. * @returns a new Vector2
  67001. */
  67002. multiplyByFloats(x: number, y: number): Vector2;
  67003. /**
  67004. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  67005. * @param otherVector defines the other vector
  67006. * @returns a new Vector2
  67007. */
  67008. divide(otherVector: Vector2): Vector2;
  67009. /**
  67010. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  67011. * @param otherVector defines the other vector
  67012. * @param result defines the target vector
  67013. * @returns the unmodified current Vector2
  67014. */
  67015. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  67016. /**
  67017. * Divides the current Vector2 coordinates by the given ones
  67018. * @param otherVector defines the other vector
  67019. * @returns the current updated Vector2
  67020. */
  67021. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  67022. /**
  67023. * Gets a new Vector2 with current Vector2 negated coordinates
  67024. * @returns a new Vector2
  67025. */
  67026. negate(): Vector2;
  67027. /**
  67028. * Multiply the Vector2 coordinates by scale
  67029. * @param scale defines the scaling factor
  67030. * @returns the current updated Vector2
  67031. */
  67032. scaleInPlace(scale: number): Vector2;
  67033. /**
  67034. * Returns a new Vector2 scaled by "scale" from the current Vector2
  67035. * @param scale defines the scaling factor
  67036. * @returns a new Vector2
  67037. */
  67038. scale(scale: number): Vector2;
  67039. /**
  67040. * Scale the current Vector2 values by a factor to a given Vector2
  67041. * @param scale defines the scale factor
  67042. * @param result defines the Vector2 object where to store the result
  67043. * @returns the unmodified current Vector2
  67044. */
  67045. scaleToRef(scale: number, result: Vector2): Vector2;
  67046. /**
  67047. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  67048. * @param scale defines the scale factor
  67049. * @param result defines the Vector2 object where to store the result
  67050. * @returns the unmodified current Vector2
  67051. */
  67052. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  67053. /**
  67054. * Gets a boolean if two vectors are equals
  67055. * @param otherVector defines the other vector
  67056. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  67057. */
  67058. equals(otherVector: DeepImmutable<Vector2>): boolean;
  67059. /**
  67060. * Gets a boolean if two vectors are equals (using an epsilon value)
  67061. * @param otherVector defines the other vector
  67062. * @param epsilon defines the minimal distance to consider equality
  67063. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  67064. */
  67065. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  67066. /**
  67067. * Gets a new Vector2 from current Vector2 floored values
  67068. * @returns a new Vector2
  67069. */
  67070. floor(): Vector2;
  67071. /**
  67072. * Gets a new Vector2 from current Vector2 floored values
  67073. * @returns a new Vector2
  67074. */
  67075. fract(): Vector2;
  67076. /**
  67077. * Gets the length of the vector
  67078. * @returns the vector length (float)
  67079. */
  67080. length(): number;
  67081. /**
  67082. * Gets the vector squared length
  67083. * @returns the vector squared length (float)
  67084. */
  67085. lengthSquared(): number;
  67086. /**
  67087. * Normalize the vector
  67088. * @returns the current updated Vector2
  67089. */
  67090. normalize(): Vector2;
  67091. /**
  67092. * Gets a new Vector2 copied from the Vector2
  67093. * @returns a new Vector2
  67094. */
  67095. clone(): Vector2;
  67096. /**
  67097. * Gets a new Vector2(0, 0)
  67098. * @returns a new Vector2
  67099. */
  67100. static Zero(): Vector2;
  67101. /**
  67102. * Gets a new Vector2(1, 1)
  67103. * @returns a new Vector2
  67104. */
  67105. static One(): Vector2;
  67106. /**
  67107. * Gets a new Vector2 set from the given index element of the given array
  67108. * @param array defines the data source
  67109. * @param offset defines the offset in the data source
  67110. * @returns a new Vector2
  67111. */
  67112. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  67113. /**
  67114. * Sets "result" from the given index element of the given array
  67115. * @param array defines the data source
  67116. * @param offset defines the offset in the data source
  67117. * @param result defines the target vector
  67118. */
  67119. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  67120. /**
  67121. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  67122. * @param value1 defines 1st point of control
  67123. * @param value2 defines 2nd point of control
  67124. * @param value3 defines 3rd point of control
  67125. * @param value4 defines 4th point of control
  67126. * @param amount defines the interpolation factor
  67127. * @returns a new Vector2
  67128. */
  67129. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  67130. /**
  67131. * 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".
  67132. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  67133. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  67134. * @param value defines the value to clamp
  67135. * @param min defines the lower limit
  67136. * @param max defines the upper limit
  67137. * @returns a new Vector2
  67138. */
  67139. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  67140. /**
  67141. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  67142. * @param value1 defines the 1st control point
  67143. * @param tangent1 defines the outgoing tangent
  67144. * @param value2 defines the 2nd control point
  67145. * @param tangent2 defines the incoming tangent
  67146. * @param amount defines the interpolation factor
  67147. * @returns a new Vector2
  67148. */
  67149. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  67150. /**
  67151. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  67152. * @param start defines the start vector
  67153. * @param end defines the end vector
  67154. * @param amount defines the interpolation factor
  67155. * @returns a new Vector2
  67156. */
  67157. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  67158. /**
  67159. * Gets the dot product of the vector "left" and the vector "right"
  67160. * @param left defines first vector
  67161. * @param right defines second vector
  67162. * @returns the dot product (float)
  67163. */
  67164. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  67165. /**
  67166. * Returns a new Vector2 equal to the normalized given vector
  67167. * @param vector defines the vector to normalize
  67168. * @returns a new Vector2
  67169. */
  67170. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  67171. /**
  67172. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  67173. * @param left defines 1st vector
  67174. * @param right defines 2nd vector
  67175. * @returns a new Vector2
  67176. */
  67177. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  67178. /**
  67179. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  67180. * @param left defines 1st vector
  67181. * @param right defines 2nd vector
  67182. * @returns a new Vector2
  67183. */
  67184. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  67185. /**
  67186. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  67187. * @param vector defines the vector to transform
  67188. * @param transformation defines the matrix to apply
  67189. * @returns a new Vector2
  67190. */
  67191. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  67192. /**
  67193. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  67194. * @param vector defines the vector to transform
  67195. * @param transformation defines the matrix to apply
  67196. * @param result defines the target vector
  67197. */
  67198. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  67199. /**
  67200. * Determines if a given vector is included in a triangle
  67201. * @param p defines the vector to test
  67202. * @param p0 defines 1st triangle point
  67203. * @param p1 defines 2nd triangle point
  67204. * @param p2 defines 3rd triangle point
  67205. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  67206. */
  67207. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  67208. /**
  67209. * Gets the distance between the vectors "value1" and "value2"
  67210. * @param value1 defines first vector
  67211. * @param value2 defines second vector
  67212. * @returns the distance between vectors
  67213. */
  67214. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  67215. /**
  67216. * Returns the squared distance between the vectors "value1" and "value2"
  67217. * @param value1 defines first vector
  67218. * @param value2 defines second vector
  67219. * @returns the squared distance between vectors
  67220. */
  67221. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  67222. /**
  67223. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  67224. * @param value1 defines first vector
  67225. * @param value2 defines second vector
  67226. * @returns a new Vector2
  67227. */
  67228. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  67229. /**
  67230. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  67231. * @param p defines the middle point
  67232. * @param segA defines one point of the segment
  67233. * @param segB defines the other point of the segment
  67234. * @returns the shortest distance
  67235. */
  67236. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  67237. }
  67238. /**
  67239. * Classed used to store (x,y,z) vector representation
  67240. * A Vector3 is the main object used in 3D geometry
  67241. * It can represent etiher the coordinates of a point the space, either a direction
  67242. * Reminder: js uses a left handed forward facing system
  67243. */
  67244. export class Vector3 {
  67245. /**
  67246. * Defines the first coordinates (on X axis)
  67247. */
  67248. x: number;
  67249. /**
  67250. * Defines the second coordinates (on Y axis)
  67251. */
  67252. y: number;
  67253. /**
  67254. * Defines the third coordinates (on Z axis)
  67255. */
  67256. z: number;
  67257. private static _UpReadOnly;
  67258. private static _ZeroReadOnly;
  67259. /**
  67260. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  67261. * @param x defines the first coordinates (on X axis)
  67262. * @param y defines the second coordinates (on Y axis)
  67263. * @param z defines the third coordinates (on Z axis)
  67264. */
  67265. constructor(
  67266. /**
  67267. * Defines the first coordinates (on X axis)
  67268. */
  67269. x?: number,
  67270. /**
  67271. * Defines the second coordinates (on Y axis)
  67272. */
  67273. y?: number,
  67274. /**
  67275. * Defines the third coordinates (on Z axis)
  67276. */
  67277. z?: number);
  67278. /**
  67279. * Creates a string representation of the Vector3
  67280. * @returns a string with the Vector3 coordinates.
  67281. */
  67282. toString(): string;
  67283. /**
  67284. * Gets the class name
  67285. * @returns the string "Vector3"
  67286. */
  67287. getClassName(): string;
  67288. /**
  67289. * Creates the Vector3 hash code
  67290. * @returns a number which tends to be unique between Vector3 instances
  67291. */
  67292. getHashCode(): number;
  67293. /**
  67294. * Creates an array containing three elements : the coordinates of the Vector3
  67295. * @returns a new array of numbers
  67296. */
  67297. asArray(): number[];
  67298. /**
  67299. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  67300. * @param array defines the destination array
  67301. * @param index defines the offset in the destination array
  67302. * @returns the current Vector3
  67303. */
  67304. toArray(array: FloatArray, index?: number): Vector3;
  67305. /**
  67306. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  67307. * @returns a new Quaternion object, computed from the Vector3 coordinates
  67308. */
  67309. toQuaternion(): Quaternion;
  67310. /**
  67311. * Adds the given vector to the current Vector3
  67312. * @param otherVector defines the second operand
  67313. * @returns the current updated Vector3
  67314. */
  67315. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  67316. /**
  67317. * Adds the given coordinates to the current Vector3
  67318. * @param x defines the x coordinate of the operand
  67319. * @param y defines the y coordinate of the operand
  67320. * @param z defines the z coordinate of the operand
  67321. * @returns the current updated Vector3
  67322. */
  67323. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  67324. /**
  67325. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  67326. * @param otherVector defines the second operand
  67327. * @returns the resulting Vector3
  67328. */
  67329. add(otherVector: DeepImmutable<Vector3>): Vector3;
  67330. /**
  67331. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  67332. * @param otherVector defines the second operand
  67333. * @param result defines the Vector3 object where to store the result
  67334. * @returns the current Vector3
  67335. */
  67336. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  67337. /**
  67338. * Subtract the given vector from the current Vector3
  67339. * @param otherVector defines the second operand
  67340. * @returns the current updated Vector3
  67341. */
  67342. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  67343. /**
  67344. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  67345. * @param otherVector defines the second operand
  67346. * @returns the resulting Vector3
  67347. */
  67348. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  67349. /**
  67350. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  67351. * @param otherVector defines the second operand
  67352. * @param result defines the Vector3 object where to store the result
  67353. * @returns the current Vector3
  67354. */
  67355. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  67356. /**
  67357. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  67358. * @param x defines the x coordinate of the operand
  67359. * @param y defines the y coordinate of the operand
  67360. * @param z defines the z coordinate of the operand
  67361. * @returns the resulting Vector3
  67362. */
  67363. subtractFromFloats(x: number, y: number, z: number): Vector3;
  67364. /**
  67365. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  67366. * @param x defines the x coordinate of the operand
  67367. * @param y defines the y coordinate of the operand
  67368. * @param z defines the z coordinate of the operand
  67369. * @param result defines the Vector3 object where to store the result
  67370. * @returns the current Vector3
  67371. */
  67372. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  67373. /**
  67374. * Gets a new Vector3 set with the current Vector3 negated coordinates
  67375. * @returns a new Vector3
  67376. */
  67377. negate(): Vector3;
  67378. /**
  67379. * Multiplies the Vector3 coordinates by the float "scale"
  67380. * @param scale defines the multiplier factor
  67381. * @returns the current updated Vector3
  67382. */
  67383. scaleInPlace(scale: number): Vector3;
  67384. /**
  67385. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  67386. * @param scale defines the multiplier factor
  67387. * @returns a new Vector3
  67388. */
  67389. scale(scale: number): Vector3;
  67390. /**
  67391. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  67392. * @param scale defines the multiplier factor
  67393. * @param result defines the Vector3 object where to store the result
  67394. * @returns the current Vector3
  67395. */
  67396. scaleToRef(scale: number, result: Vector3): Vector3;
  67397. /**
  67398. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  67399. * @param scale defines the scale factor
  67400. * @param result defines the Vector3 object where to store the result
  67401. * @returns the unmodified current Vector3
  67402. */
  67403. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  67404. /**
  67405. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  67406. * @param otherVector defines the second operand
  67407. * @returns true if both vectors are equals
  67408. */
  67409. equals(otherVector: DeepImmutable<Vector3>): boolean;
  67410. /**
  67411. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  67412. * @param otherVector defines the second operand
  67413. * @param epsilon defines the minimal distance to define values as equals
  67414. * @returns true if both vectors are distant less than epsilon
  67415. */
  67416. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  67417. /**
  67418. * Returns true if the current Vector3 coordinates equals the given floats
  67419. * @param x defines the x coordinate of the operand
  67420. * @param y defines the y coordinate of the operand
  67421. * @param z defines the z coordinate of the operand
  67422. * @returns true if both vectors are equals
  67423. */
  67424. equalsToFloats(x: number, y: number, z: number): boolean;
  67425. /**
  67426. * Multiplies the current Vector3 coordinates by the given ones
  67427. * @param otherVector defines the second operand
  67428. * @returns the current updated Vector3
  67429. */
  67430. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  67431. /**
  67432. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  67433. * @param otherVector defines the second operand
  67434. * @returns the new Vector3
  67435. */
  67436. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  67437. /**
  67438. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  67439. * @param otherVector defines the second operand
  67440. * @param result defines the Vector3 object where to store the result
  67441. * @returns the current Vector3
  67442. */
  67443. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  67444. /**
  67445. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  67446. * @param x defines the x coordinate of the operand
  67447. * @param y defines the y coordinate of the operand
  67448. * @param z defines the z coordinate of the operand
  67449. * @returns the new Vector3
  67450. */
  67451. multiplyByFloats(x: number, y: number, z: number): Vector3;
  67452. /**
  67453. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  67454. * @param otherVector defines the second operand
  67455. * @returns the new Vector3
  67456. */
  67457. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  67458. /**
  67459. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  67460. * @param otherVector defines the second operand
  67461. * @param result defines the Vector3 object where to store the result
  67462. * @returns the current Vector3
  67463. */
  67464. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  67465. /**
  67466. * Divides the current Vector3 coordinates by the given ones.
  67467. * @param otherVector defines the second operand
  67468. * @returns the current updated Vector3
  67469. */
  67470. divideInPlace(otherVector: Vector3): Vector3;
  67471. /**
  67472. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  67473. * @param other defines the second operand
  67474. * @returns the current updated Vector3
  67475. */
  67476. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  67477. /**
  67478. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  67479. * @param other defines the second operand
  67480. * @returns the current updated Vector3
  67481. */
  67482. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  67483. /**
  67484. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  67485. * @param x defines the x coordinate of the operand
  67486. * @param y defines the y coordinate of the operand
  67487. * @param z defines the z coordinate of the operand
  67488. * @returns the current updated Vector3
  67489. */
  67490. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  67491. /**
  67492. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  67493. * @param x defines the x coordinate of the operand
  67494. * @param y defines the y coordinate of the operand
  67495. * @param z defines the z coordinate of the operand
  67496. * @returns the current updated Vector3
  67497. */
  67498. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  67499. /**
  67500. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  67501. * Check if is non uniform within a certain amount of decimal places to account for this
  67502. * @param epsilon the amount the values can differ
  67503. * @returns if the the vector is non uniform to a certain number of decimal places
  67504. */
  67505. isNonUniformWithinEpsilon(epsilon: number): boolean;
  67506. /**
  67507. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  67508. */
  67509. readonly isNonUniform: boolean;
  67510. /**
  67511. * Gets a new Vector3 from current Vector3 floored values
  67512. * @returns a new Vector3
  67513. */
  67514. floor(): Vector3;
  67515. /**
  67516. * Gets a new Vector3 from current Vector3 floored values
  67517. * @returns a new Vector3
  67518. */
  67519. fract(): Vector3;
  67520. /**
  67521. * Gets the length of the Vector3
  67522. * @returns the length of the Vector3
  67523. */
  67524. length(): number;
  67525. /**
  67526. * Gets the squared length of the Vector3
  67527. * @returns squared length of the Vector3
  67528. */
  67529. lengthSquared(): number;
  67530. /**
  67531. * Normalize the current Vector3.
  67532. * Please note that this is an in place operation.
  67533. * @returns the current updated Vector3
  67534. */
  67535. normalize(): Vector3;
  67536. /**
  67537. * Reorders the x y z properties of the vector in place
  67538. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  67539. * @returns the current updated vector
  67540. */
  67541. reorderInPlace(order: string): this;
  67542. /**
  67543. * Rotates the vector around 0,0,0 by a quaternion
  67544. * @param quaternion the rotation quaternion
  67545. * @param result vector to store the result
  67546. * @returns the resulting vector
  67547. */
  67548. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  67549. /**
  67550. * Rotates a vector around a given point
  67551. * @param quaternion the rotation quaternion
  67552. * @param point the point to rotate around
  67553. * @param result vector to store the result
  67554. * @returns the resulting vector
  67555. */
  67556. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  67557. /**
  67558. * Normalize the current Vector3 with the given input length.
  67559. * Please note that this is an in place operation.
  67560. * @param len the length of the vector
  67561. * @returns the current updated Vector3
  67562. */
  67563. normalizeFromLength(len: number): Vector3;
  67564. /**
  67565. * Normalize the current Vector3 to a new vector
  67566. * @returns the new Vector3
  67567. */
  67568. normalizeToNew(): Vector3;
  67569. /**
  67570. * Normalize the current Vector3 to the reference
  67571. * @param reference define the Vector3 to update
  67572. * @returns the updated Vector3
  67573. */
  67574. normalizeToRef(reference: DeepImmutable<Vector3>): Vector3;
  67575. /**
  67576. * Creates a new Vector3 copied from the current Vector3
  67577. * @returns the new Vector3
  67578. */
  67579. clone(): Vector3;
  67580. /**
  67581. * Copies the given vector coordinates to the current Vector3 ones
  67582. * @param source defines the source Vector3
  67583. * @returns the current updated Vector3
  67584. */
  67585. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  67586. /**
  67587. * Copies the given floats to the current Vector3 coordinates
  67588. * @param x defines the x coordinate of the operand
  67589. * @param y defines the y coordinate of the operand
  67590. * @param z defines the z coordinate of the operand
  67591. * @returns the current updated Vector3
  67592. */
  67593. copyFromFloats(x: number, y: number, z: number): Vector3;
  67594. /**
  67595. * Copies the given floats to the current Vector3 coordinates
  67596. * @param x defines the x coordinate of the operand
  67597. * @param y defines the y coordinate of the operand
  67598. * @param z defines the z coordinate of the operand
  67599. * @returns the current updated Vector3
  67600. */
  67601. set(x: number, y: number, z: number): Vector3;
  67602. /**
  67603. * Copies the given float to the current Vector3 coordinates
  67604. * @param v defines the x, y and z coordinates of the operand
  67605. * @returns the current updated Vector3
  67606. */
  67607. setAll(v: number): Vector3;
  67608. /**
  67609. * Get the clip factor between two vectors
  67610. * @param vector0 defines the first operand
  67611. * @param vector1 defines the second operand
  67612. * @param axis defines the axis to use
  67613. * @param size defines the size along the axis
  67614. * @returns the clip factor
  67615. */
  67616. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  67617. /**
  67618. * Get angle between two vectors
  67619. * @param vector0 angle between vector0 and vector1
  67620. * @param vector1 angle between vector0 and vector1
  67621. * @param normal direction of the normal
  67622. * @return the angle between vector0 and vector1
  67623. */
  67624. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  67625. /**
  67626. * Returns a new Vector3 set from the index "offset" of the given array
  67627. * @param array defines the source array
  67628. * @param offset defines the offset in the source array
  67629. * @returns the new Vector3
  67630. */
  67631. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  67632. /**
  67633. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  67634. * This function is deprecated. Use FromArray instead
  67635. * @param array defines the source array
  67636. * @param offset defines the offset in the source array
  67637. * @returns the new Vector3
  67638. */
  67639. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  67640. /**
  67641. * Sets the given vector "result" with the element values from the index "offset" of the given array
  67642. * @param array defines the source array
  67643. * @param offset defines the offset in the source array
  67644. * @param result defines the Vector3 where to store the result
  67645. */
  67646. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  67647. /**
  67648. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  67649. * This function is deprecated. Use FromArrayToRef instead.
  67650. * @param array defines the source array
  67651. * @param offset defines the offset in the source array
  67652. * @param result defines the Vector3 where to store the result
  67653. */
  67654. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  67655. /**
  67656. * Sets the given vector "result" with the given floats.
  67657. * @param x defines the x coordinate of the source
  67658. * @param y defines the y coordinate of the source
  67659. * @param z defines the z coordinate of the source
  67660. * @param result defines the Vector3 where to store the result
  67661. */
  67662. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  67663. /**
  67664. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  67665. * @returns a new empty Vector3
  67666. */
  67667. static Zero(): Vector3;
  67668. /**
  67669. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  67670. * @returns a new unit Vector3
  67671. */
  67672. static One(): Vector3;
  67673. /**
  67674. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  67675. * @returns a new up Vector3
  67676. */
  67677. static Up(): Vector3;
  67678. /**
  67679. * Gets a up Vector3 that must not be updated
  67680. */
  67681. static readonly UpReadOnly: DeepImmutable<Vector3>;
  67682. /**
  67683. * Gets a zero Vector3 that must not be updated
  67684. */
  67685. static readonly ZeroReadOnly: DeepImmutable<Vector3>;
  67686. /**
  67687. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  67688. * @returns a new down Vector3
  67689. */
  67690. static Down(): Vector3;
  67691. /**
  67692. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  67693. * @returns a new forward Vector3
  67694. */
  67695. static Forward(): Vector3;
  67696. /**
  67697. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  67698. * @returns a new forward Vector3
  67699. */
  67700. static Backward(): Vector3;
  67701. /**
  67702. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  67703. * @returns a new right Vector3
  67704. */
  67705. static Right(): Vector3;
  67706. /**
  67707. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  67708. * @returns a new left Vector3
  67709. */
  67710. static Left(): Vector3;
  67711. /**
  67712. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  67713. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  67714. * @param vector defines the Vector3 to transform
  67715. * @param transformation defines the transformation matrix
  67716. * @returns the transformed Vector3
  67717. */
  67718. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  67719. /**
  67720. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  67721. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  67722. * @param vector defines the Vector3 to transform
  67723. * @param transformation defines the transformation matrix
  67724. * @param result defines the Vector3 where to store the result
  67725. */
  67726. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  67727. /**
  67728. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  67729. * This method computes tranformed coordinates only, not transformed direction vectors
  67730. * @param x define the x coordinate of the source vector
  67731. * @param y define the y coordinate of the source vector
  67732. * @param z define the z coordinate of the source vector
  67733. * @param transformation defines the transformation matrix
  67734. * @param result defines the Vector3 where to store the result
  67735. */
  67736. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  67737. /**
  67738. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  67739. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  67740. * @param vector defines the Vector3 to transform
  67741. * @param transformation defines the transformation matrix
  67742. * @returns the new Vector3
  67743. */
  67744. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  67745. /**
  67746. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  67747. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  67748. * @param vector defines the Vector3 to transform
  67749. * @param transformation defines the transformation matrix
  67750. * @param result defines the Vector3 where to store the result
  67751. */
  67752. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  67753. /**
  67754. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  67755. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  67756. * @param x define the x coordinate of the source vector
  67757. * @param y define the y coordinate of the source vector
  67758. * @param z define the z coordinate of the source vector
  67759. * @param transformation defines the transformation matrix
  67760. * @param result defines the Vector3 where to store the result
  67761. */
  67762. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  67763. /**
  67764. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  67765. * @param value1 defines the first control point
  67766. * @param value2 defines the second control point
  67767. * @param value3 defines the third control point
  67768. * @param value4 defines the fourth control point
  67769. * @param amount defines the amount on the spline to use
  67770. * @returns the new Vector3
  67771. */
  67772. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  67773. /**
  67774. * 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"
  67775. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  67776. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  67777. * @param value defines the current value
  67778. * @param min defines the lower range value
  67779. * @param max defines the upper range value
  67780. * @returns the new Vector3
  67781. */
  67782. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  67783. /**
  67784. * 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"
  67785. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  67786. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  67787. * @param value defines the current value
  67788. * @param min defines the lower range value
  67789. * @param max defines the upper range value
  67790. * @param result defines the Vector3 where to store the result
  67791. */
  67792. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  67793. /**
  67794. * Checks if a given vector is inside a specific range
  67795. * @param v defines the vector to test
  67796. * @param min defines the minimum range
  67797. * @param max defines the maximum range
  67798. */
  67799. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  67800. /**
  67801. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  67802. * @param value1 defines the first control point
  67803. * @param tangent1 defines the first tangent vector
  67804. * @param value2 defines the second control point
  67805. * @param tangent2 defines the second tangent vector
  67806. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  67807. * @returns the new Vector3
  67808. */
  67809. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  67810. /**
  67811. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  67812. * @param start defines the start value
  67813. * @param end defines the end value
  67814. * @param amount max defines amount between both (between 0 and 1)
  67815. * @returns the new Vector3
  67816. */
  67817. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  67818. /**
  67819. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  67820. * @param start defines the start value
  67821. * @param end defines the end value
  67822. * @param amount max defines amount between both (between 0 and 1)
  67823. * @param result defines the Vector3 where to store the result
  67824. */
  67825. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  67826. /**
  67827. * Returns the dot product (float) between the vectors "left" and "right"
  67828. * @param left defines the left operand
  67829. * @param right defines the right operand
  67830. * @returns the dot product
  67831. */
  67832. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  67833. /**
  67834. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  67835. * The cross product is then orthogonal to both "left" and "right"
  67836. * @param left defines the left operand
  67837. * @param right defines the right operand
  67838. * @returns the cross product
  67839. */
  67840. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  67841. /**
  67842. * Sets the given vector "result" with the cross product of "left" and "right"
  67843. * The cross product is then orthogonal to both "left" and "right"
  67844. * @param left defines the left operand
  67845. * @param right defines the right operand
  67846. * @param result defines the Vector3 where to store the result
  67847. */
  67848. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  67849. /**
  67850. * Returns a new Vector3 as the normalization of the given vector
  67851. * @param vector defines the Vector3 to normalize
  67852. * @returns the new Vector3
  67853. */
  67854. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  67855. /**
  67856. * Sets the given vector "result" with the normalization of the given first vector
  67857. * @param vector defines the Vector3 to normalize
  67858. * @param result defines the Vector3 where to store the result
  67859. */
  67860. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  67861. /**
  67862. * Project a Vector3 onto screen space
  67863. * @param vector defines the Vector3 to project
  67864. * @param world defines the world matrix to use
  67865. * @param transform defines the transform (view x projection) matrix to use
  67866. * @param viewport defines the screen viewport to use
  67867. * @returns the new Vector3
  67868. */
  67869. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  67870. /** @hidden */
  67871. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  67872. /**
  67873. * Unproject from screen space to object space
  67874. * @param source defines the screen space Vector3 to use
  67875. * @param viewportWidth defines the current width of the viewport
  67876. * @param viewportHeight defines the current height of the viewport
  67877. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  67878. * @param transform defines the transform (view x projection) matrix to use
  67879. * @returns the new Vector3
  67880. */
  67881. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  67882. /**
  67883. * Unproject from screen space to object space
  67884. * @param source defines the screen space Vector3 to use
  67885. * @param viewportWidth defines the current width of the viewport
  67886. * @param viewportHeight defines the current height of the viewport
  67887. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  67888. * @param view defines the view matrix to use
  67889. * @param projection defines the projection matrix to use
  67890. * @returns the new Vector3
  67891. */
  67892. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  67893. /**
  67894. * Unproject from screen space to object space
  67895. * @param source defines the screen space Vector3 to use
  67896. * @param viewportWidth defines the current width of the viewport
  67897. * @param viewportHeight defines the current height of the viewport
  67898. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  67899. * @param view defines the view matrix to use
  67900. * @param projection defines the projection matrix to use
  67901. * @param result defines the Vector3 where to store the result
  67902. */
  67903. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  67904. /**
  67905. * Unproject from screen space to object space
  67906. * @param sourceX defines the screen space x coordinate to use
  67907. * @param sourceY defines the screen space y coordinate to use
  67908. * @param sourceZ defines the screen space z coordinate to use
  67909. * @param viewportWidth defines the current width of the viewport
  67910. * @param viewportHeight defines the current height of the viewport
  67911. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  67912. * @param view defines the view matrix to use
  67913. * @param projection defines the projection matrix to use
  67914. * @param result defines the Vector3 where to store the result
  67915. */
  67916. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  67917. /**
  67918. * Gets the minimal coordinate values between two Vector3
  67919. * @param left defines the first operand
  67920. * @param right defines the second operand
  67921. * @returns the new Vector3
  67922. */
  67923. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  67924. /**
  67925. * Gets the maximal coordinate values between two Vector3
  67926. * @param left defines the first operand
  67927. * @param right defines the second operand
  67928. * @returns the new Vector3
  67929. */
  67930. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  67931. /**
  67932. * Returns the distance between the vectors "value1" and "value2"
  67933. * @param value1 defines the first operand
  67934. * @param value2 defines the second operand
  67935. * @returns the distance
  67936. */
  67937. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  67938. /**
  67939. * Returns the squared distance between the vectors "value1" and "value2"
  67940. * @param value1 defines the first operand
  67941. * @param value2 defines the second operand
  67942. * @returns the squared distance
  67943. */
  67944. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  67945. /**
  67946. * Returns a new Vector3 located at the center between "value1" and "value2"
  67947. * @param value1 defines the first operand
  67948. * @param value2 defines the second operand
  67949. * @returns the new Vector3
  67950. */
  67951. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  67952. /**
  67953. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  67954. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  67955. * to something in order to rotate it from its local system to the given target system
  67956. * Note: axis1, axis2 and axis3 are normalized during this operation
  67957. * @param axis1 defines the first axis
  67958. * @param axis2 defines the second axis
  67959. * @param axis3 defines the third axis
  67960. * @returns a new Vector3
  67961. */
  67962. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  67963. /**
  67964. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  67965. * @param axis1 defines the first axis
  67966. * @param axis2 defines the second axis
  67967. * @param axis3 defines the third axis
  67968. * @param ref defines the Vector3 where to store the result
  67969. */
  67970. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  67971. }
  67972. /**
  67973. * Vector4 class created for EulerAngle class conversion to Quaternion
  67974. */
  67975. export class Vector4 {
  67976. /** x value of the vector */
  67977. x: number;
  67978. /** y value of the vector */
  67979. y: number;
  67980. /** z value of the vector */
  67981. z: number;
  67982. /** w value of the vector */
  67983. w: number;
  67984. /**
  67985. * Creates a Vector4 object from the given floats.
  67986. * @param x x value of the vector
  67987. * @param y y value of the vector
  67988. * @param z z value of the vector
  67989. * @param w w value of the vector
  67990. */
  67991. constructor(
  67992. /** x value of the vector */
  67993. x: number,
  67994. /** y value of the vector */
  67995. y: number,
  67996. /** z value of the vector */
  67997. z: number,
  67998. /** w value of the vector */
  67999. w: number);
  68000. /**
  68001. * Returns the string with the Vector4 coordinates.
  68002. * @returns a string containing all the vector values
  68003. */
  68004. toString(): string;
  68005. /**
  68006. * Returns the string "Vector4".
  68007. * @returns "Vector4"
  68008. */
  68009. getClassName(): string;
  68010. /**
  68011. * Returns the Vector4 hash code.
  68012. * @returns a unique hash code
  68013. */
  68014. getHashCode(): number;
  68015. /**
  68016. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  68017. * @returns the resulting array
  68018. */
  68019. asArray(): number[];
  68020. /**
  68021. * Populates the given array from the given index with the Vector4 coordinates.
  68022. * @param array array to populate
  68023. * @param index index of the array to start at (default: 0)
  68024. * @returns the Vector4.
  68025. */
  68026. toArray(array: FloatArray, index?: number): Vector4;
  68027. /**
  68028. * Adds the given vector to the current Vector4.
  68029. * @param otherVector the vector to add
  68030. * @returns the updated Vector4.
  68031. */
  68032. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  68033. /**
  68034. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  68035. * @param otherVector the vector to add
  68036. * @returns the resulting vector
  68037. */
  68038. add(otherVector: DeepImmutable<Vector4>): Vector4;
  68039. /**
  68040. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  68041. * @param otherVector the vector to add
  68042. * @param result the vector to store the result
  68043. * @returns the current Vector4.
  68044. */
  68045. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  68046. /**
  68047. * Subtract in place the given vector from the current Vector4.
  68048. * @param otherVector the vector to subtract
  68049. * @returns the updated Vector4.
  68050. */
  68051. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  68052. /**
  68053. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  68054. * @param otherVector the vector to add
  68055. * @returns the new vector with the result
  68056. */
  68057. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  68058. /**
  68059. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  68060. * @param otherVector the vector to subtract
  68061. * @param result the vector to store the result
  68062. * @returns the current Vector4.
  68063. */
  68064. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  68065. /**
  68066. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  68067. */
  68068. /**
  68069. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  68070. * @param x value to subtract
  68071. * @param y value to subtract
  68072. * @param z value to subtract
  68073. * @param w value to subtract
  68074. * @returns new vector containing the result
  68075. */
  68076. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  68077. /**
  68078. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  68079. * @param x value to subtract
  68080. * @param y value to subtract
  68081. * @param z value to subtract
  68082. * @param w value to subtract
  68083. * @param result the vector to store the result in
  68084. * @returns the current Vector4.
  68085. */
  68086. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  68087. /**
  68088. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  68089. * @returns a new vector with the negated values
  68090. */
  68091. negate(): Vector4;
  68092. /**
  68093. * Multiplies the current Vector4 coordinates by scale (float).
  68094. * @param scale the number to scale with
  68095. * @returns the updated Vector4.
  68096. */
  68097. scaleInPlace(scale: number): Vector4;
  68098. /**
  68099. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  68100. * @param scale the number to scale with
  68101. * @returns a new vector with the result
  68102. */
  68103. scale(scale: number): Vector4;
  68104. /**
  68105. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  68106. * @param scale the number to scale with
  68107. * @param result a vector to store the result in
  68108. * @returns the current Vector4.
  68109. */
  68110. scaleToRef(scale: number, result: Vector4): Vector4;
  68111. /**
  68112. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  68113. * @param scale defines the scale factor
  68114. * @param result defines the Vector4 object where to store the result
  68115. * @returns the unmodified current Vector4
  68116. */
  68117. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  68118. /**
  68119. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  68120. * @param otherVector the vector to compare against
  68121. * @returns true if they are equal
  68122. */
  68123. equals(otherVector: DeepImmutable<Vector4>): boolean;
  68124. /**
  68125. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  68126. * @param otherVector vector to compare against
  68127. * @param epsilon (Default: very small number)
  68128. * @returns true if they are equal
  68129. */
  68130. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  68131. /**
  68132. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  68133. * @param x x value to compare against
  68134. * @param y y value to compare against
  68135. * @param z z value to compare against
  68136. * @param w w value to compare against
  68137. * @returns true if equal
  68138. */
  68139. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  68140. /**
  68141. * Multiplies in place the current Vector4 by the given one.
  68142. * @param otherVector vector to multiple with
  68143. * @returns the updated Vector4.
  68144. */
  68145. multiplyInPlace(otherVector: Vector4): Vector4;
  68146. /**
  68147. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  68148. * @param otherVector vector to multiple with
  68149. * @returns resulting new vector
  68150. */
  68151. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  68152. /**
  68153. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  68154. * @param otherVector vector to multiple with
  68155. * @param result vector to store the result
  68156. * @returns the current Vector4.
  68157. */
  68158. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  68159. /**
  68160. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  68161. * @param x x value multiply with
  68162. * @param y y value multiply with
  68163. * @param z z value multiply with
  68164. * @param w w value multiply with
  68165. * @returns resulting new vector
  68166. */
  68167. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  68168. /**
  68169. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  68170. * @param otherVector vector to devide with
  68171. * @returns resulting new vector
  68172. */
  68173. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  68174. /**
  68175. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  68176. * @param otherVector vector to devide with
  68177. * @param result vector to store the result
  68178. * @returns the current Vector4.
  68179. */
  68180. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  68181. /**
  68182. * Divides the current Vector3 coordinates by the given ones.
  68183. * @param otherVector vector to devide with
  68184. * @returns the updated Vector3.
  68185. */
  68186. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  68187. /**
  68188. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  68189. * @param other defines the second operand
  68190. * @returns the current updated Vector4
  68191. */
  68192. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  68193. /**
  68194. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  68195. * @param other defines the second operand
  68196. * @returns the current updated Vector4
  68197. */
  68198. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  68199. /**
  68200. * Gets a new Vector4 from current Vector4 floored values
  68201. * @returns a new Vector4
  68202. */
  68203. floor(): Vector4;
  68204. /**
  68205. * Gets a new Vector4 from current Vector3 floored values
  68206. * @returns a new Vector4
  68207. */
  68208. fract(): Vector4;
  68209. /**
  68210. * Returns the Vector4 length (float).
  68211. * @returns the length
  68212. */
  68213. length(): number;
  68214. /**
  68215. * Returns the Vector4 squared length (float).
  68216. * @returns the length squared
  68217. */
  68218. lengthSquared(): number;
  68219. /**
  68220. * Normalizes in place the Vector4.
  68221. * @returns the updated Vector4.
  68222. */
  68223. normalize(): Vector4;
  68224. /**
  68225. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  68226. * @returns this converted to a new vector3
  68227. */
  68228. toVector3(): Vector3;
  68229. /**
  68230. * Returns a new Vector4 copied from the current one.
  68231. * @returns the new cloned vector
  68232. */
  68233. clone(): Vector4;
  68234. /**
  68235. * Updates the current Vector4 with the given one coordinates.
  68236. * @param source the source vector to copy from
  68237. * @returns the updated Vector4.
  68238. */
  68239. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  68240. /**
  68241. * Updates the current Vector4 coordinates with the given floats.
  68242. * @param x float to copy from
  68243. * @param y float to copy from
  68244. * @param z float to copy from
  68245. * @param w float to copy from
  68246. * @returns the updated Vector4.
  68247. */
  68248. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  68249. /**
  68250. * Updates the current Vector4 coordinates with the given floats.
  68251. * @param x float to set from
  68252. * @param y float to set from
  68253. * @param z float to set from
  68254. * @param w float to set from
  68255. * @returns the updated Vector4.
  68256. */
  68257. set(x: number, y: number, z: number, w: number): Vector4;
  68258. /**
  68259. * Copies the given float to the current Vector3 coordinates
  68260. * @param v defines the x, y, z and w coordinates of the operand
  68261. * @returns the current updated Vector3
  68262. */
  68263. setAll(v: number): Vector4;
  68264. /**
  68265. * Returns a new Vector4 set from the starting index of the given array.
  68266. * @param array the array to pull values from
  68267. * @param offset the offset into the array to start at
  68268. * @returns the new vector
  68269. */
  68270. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  68271. /**
  68272. * Updates the given vector "result" from the starting index of the given array.
  68273. * @param array the array to pull values from
  68274. * @param offset the offset into the array to start at
  68275. * @param result the vector to store the result in
  68276. */
  68277. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  68278. /**
  68279. * Updates the given vector "result" from the starting index of the given Float32Array.
  68280. * @param array the array to pull values from
  68281. * @param offset the offset into the array to start at
  68282. * @param result the vector to store the result in
  68283. */
  68284. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  68285. /**
  68286. * Updates the given vector "result" coordinates from the given floats.
  68287. * @param x float to set from
  68288. * @param y float to set from
  68289. * @param z float to set from
  68290. * @param w float to set from
  68291. * @param result the vector to the floats in
  68292. */
  68293. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  68294. /**
  68295. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  68296. * @returns the new vector
  68297. */
  68298. static Zero(): Vector4;
  68299. /**
  68300. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  68301. * @returns the new vector
  68302. */
  68303. static One(): Vector4;
  68304. /**
  68305. * Returns a new normalized Vector4 from the given one.
  68306. * @param vector the vector to normalize
  68307. * @returns the vector
  68308. */
  68309. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  68310. /**
  68311. * Updates the given vector "result" from the normalization of the given one.
  68312. * @param vector the vector to normalize
  68313. * @param result the vector to store the result in
  68314. */
  68315. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  68316. /**
  68317. * Returns a vector with the minimum values from the left and right vectors
  68318. * @param left left vector to minimize
  68319. * @param right right vector to minimize
  68320. * @returns a new vector with the minimum of the left and right vector values
  68321. */
  68322. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  68323. /**
  68324. * Returns a vector with the maximum values from the left and right vectors
  68325. * @param left left vector to maximize
  68326. * @param right right vector to maximize
  68327. * @returns a new vector with the maximum of the left and right vector values
  68328. */
  68329. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  68330. /**
  68331. * Returns the distance (float) between the vectors "value1" and "value2".
  68332. * @param value1 value to calulate the distance between
  68333. * @param value2 value to calulate the distance between
  68334. * @return the distance between the two vectors
  68335. */
  68336. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  68337. /**
  68338. * Returns the squared distance (float) between the vectors "value1" and "value2".
  68339. * @param value1 value to calulate the distance between
  68340. * @param value2 value to calulate the distance between
  68341. * @return the distance between the two vectors squared
  68342. */
  68343. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  68344. /**
  68345. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  68346. * @param value1 value to calulate the center between
  68347. * @param value2 value to calulate the center between
  68348. * @return the center between the two vectors
  68349. */
  68350. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  68351. /**
  68352. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  68353. * This methods computes transformed normalized direction vectors only.
  68354. * @param vector the vector to transform
  68355. * @param transformation the transformation matrix to apply
  68356. * @returns the new vector
  68357. */
  68358. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  68359. /**
  68360. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  68361. * This methods computes transformed normalized direction vectors only.
  68362. * @param vector the vector to transform
  68363. * @param transformation the transformation matrix to apply
  68364. * @param result the vector to store the result in
  68365. */
  68366. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  68367. /**
  68368. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  68369. * This methods computes transformed normalized direction vectors only.
  68370. * @param x value to transform
  68371. * @param y value to transform
  68372. * @param z value to transform
  68373. * @param w value to transform
  68374. * @param transformation the transformation matrix to apply
  68375. * @param result the vector to store the results in
  68376. */
  68377. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  68378. /**
  68379. * Creates a new Vector4 from a Vector3
  68380. * @param source defines the source data
  68381. * @param w defines the 4th component (default is 0)
  68382. * @returns a new Vector4
  68383. */
  68384. static FromVector3(source: Vector3, w?: number): Vector4;
  68385. }
  68386. /**
  68387. * Class used to store quaternion data
  68388. * @see https://en.wikipedia.org/wiki/Quaternion
  68389. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  68390. */
  68391. export class Quaternion {
  68392. /** defines the first component (0 by default) */
  68393. x: number;
  68394. /** defines the second component (0 by default) */
  68395. y: number;
  68396. /** defines the third component (0 by default) */
  68397. z: number;
  68398. /** defines the fourth component (1.0 by default) */
  68399. w: number;
  68400. /**
  68401. * Creates a new Quaternion from the given floats
  68402. * @param x defines the first component (0 by default)
  68403. * @param y defines the second component (0 by default)
  68404. * @param z defines the third component (0 by default)
  68405. * @param w defines the fourth component (1.0 by default)
  68406. */
  68407. constructor(
  68408. /** defines the first component (0 by default) */
  68409. x?: number,
  68410. /** defines the second component (0 by default) */
  68411. y?: number,
  68412. /** defines the third component (0 by default) */
  68413. z?: number,
  68414. /** defines the fourth component (1.0 by default) */
  68415. w?: number);
  68416. /**
  68417. * Gets a string representation for the current quaternion
  68418. * @returns a string with the Quaternion coordinates
  68419. */
  68420. toString(): string;
  68421. /**
  68422. * Gets the class name of the quaternion
  68423. * @returns the string "Quaternion"
  68424. */
  68425. getClassName(): string;
  68426. /**
  68427. * Gets a hash code for this quaternion
  68428. * @returns the quaternion hash code
  68429. */
  68430. getHashCode(): number;
  68431. /**
  68432. * Copy the quaternion to an array
  68433. * @returns a new array populated with 4 elements from the quaternion coordinates
  68434. */
  68435. asArray(): number[];
  68436. /**
  68437. * Check if two quaternions are equals
  68438. * @param otherQuaternion defines the second operand
  68439. * @return true if the current quaternion and the given one coordinates are strictly equals
  68440. */
  68441. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  68442. /**
  68443. * Clone the current quaternion
  68444. * @returns a new quaternion copied from the current one
  68445. */
  68446. clone(): Quaternion;
  68447. /**
  68448. * Copy a quaternion to the current one
  68449. * @param other defines the other quaternion
  68450. * @returns the updated current quaternion
  68451. */
  68452. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  68453. /**
  68454. * Updates the current quaternion with the given float coordinates
  68455. * @param x defines the x coordinate
  68456. * @param y defines the y coordinate
  68457. * @param z defines the z coordinate
  68458. * @param w defines the w coordinate
  68459. * @returns the updated current quaternion
  68460. */
  68461. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  68462. /**
  68463. * Updates the current quaternion from the given float coordinates
  68464. * @param x defines the x coordinate
  68465. * @param y defines the y coordinate
  68466. * @param z defines the z coordinate
  68467. * @param w defines the w coordinate
  68468. * @returns the updated current quaternion
  68469. */
  68470. set(x: number, y: number, z: number, w: number): Quaternion;
  68471. /**
  68472. * Adds two quaternions
  68473. * @param other defines the second operand
  68474. * @returns a new quaternion as the addition result of the given one and the current quaternion
  68475. */
  68476. add(other: DeepImmutable<Quaternion>): Quaternion;
  68477. /**
  68478. * Add a quaternion to the current one
  68479. * @param other defines the quaternion to add
  68480. * @returns the current quaternion
  68481. */
  68482. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  68483. /**
  68484. * Subtract two quaternions
  68485. * @param other defines the second operand
  68486. * @returns a new quaternion as the subtraction result of the given one from the current one
  68487. */
  68488. subtract(other: Quaternion): Quaternion;
  68489. /**
  68490. * Multiplies the current quaternion by a scale factor
  68491. * @param value defines the scale factor
  68492. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  68493. */
  68494. scale(value: number): Quaternion;
  68495. /**
  68496. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  68497. * @param scale defines the scale factor
  68498. * @param result defines the Quaternion object where to store the result
  68499. * @returns the unmodified current quaternion
  68500. */
  68501. scaleToRef(scale: number, result: Quaternion): Quaternion;
  68502. /**
  68503. * Multiplies in place the current quaternion by a scale factor
  68504. * @param value defines the scale factor
  68505. * @returns the current modified quaternion
  68506. */
  68507. scaleInPlace(value: number): Quaternion;
  68508. /**
  68509. * Scale the current quaternion values by a factor and add the result to a given quaternion
  68510. * @param scale defines the scale factor
  68511. * @param result defines the Quaternion object where to store the result
  68512. * @returns the unmodified current quaternion
  68513. */
  68514. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  68515. /**
  68516. * Multiplies two quaternions
  68517. * @param q1 defines the second operand
  68518. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  68519. */
  68520. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  68521. /**
  68522. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  68523. * @param q1 defines the second operand
  68524. * @param result defines the target quaternion
  68525. * @returns the current quaternion
  68526. */
  68527. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  68528. /**
  68529. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  68530. * @param q1 defines the second operand
  68531. * @returns the currentupdated quaternion
  68532. */
  68533. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  68534. /**
  68535. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  68536. * @param ref defines the target quaternion
  68537. * @returns the current quaternion
  68538. */
  68539. conjugateToRef(ref: Quaternion): Quaternion;
  68540. /**
  68541. * Conjugates in place (1-q) the current quaternion
  68542. * @returns the current updated quaternion
  68543. */
  68544. conjugateInPlace(): Quaternion;
  68545. /**
  68546. * Conjugates in place (1-q) the current quaternion
  68547. * @returns a new quaternion
  68548. */
  68549. conjugate(): Quaternion;
  68550. /**
  68551. * Gets length of current quaternion
  68552. * @returns the quaternion length (float)
  68553. */
  68554. length(): number;
  68555. /**
  68556. * Normalize in place the current quaternion
  68557. * @returns the current updated quaternion
  68558. */
  68559. normalize(): Quaternion;
  68560. /**
  68561. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  68562. * @param order is a reserved parameter and is ignore for now
  68563. * @returns a new Vector3 containing the Euler angles
  68564. */
  68565. toEulerAngles(order?: string): Vector3;
  68566. /**
  68567. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  68568. * @param result defines the vector which will be filled with the Euler angles
  68569. * @param order is a reserved parameter and is ignore for now
  68570. * @returns the current unchanged quaternion
  68571. */
  68572. toEulerAnglesToRef(result: Vector3): Quaternion;
  68573. /**
  68574. * Updates the given rotation matrix with the current quaternion values
  68575. * @param result defines the target matrix
  68576. * @returns the current unchanged quaternion
  68577. */
  68578. toRotationMatrix(result: Matrix): Quaternion;
  68579. /**
  68580. * Updates the current quaternion from the given rotation matrix values
  68581. * @param matrix defines the source matrix
  68582. * @returns the current updated quaternion
  68583. */
  68584. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  68585. /**
  68586. * Creates a new quaternion from a rotation matrix
  68587. * @param matrix defines the source matrix
  68588. * @returns a new quaternion created from the given rotation matrix values
  68589. */
  68590. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  68591. /**
  68592. * Updates the given quaternion with the given rotation matrix values
  68593. * @param matrix defines the source matrix
  68594. * @param result defines the target quaternion
  68595. */
  68596. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  68597. /**
  68598. * Returns the dot product (float) between the quaternions "left" and "right"
  68599. * @param left defines the left operand
  68600. * @param right defines the right operand
  68601. * @returns the dot product
  68602. */
  68603. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  68604. /**
  68605. * Checks if the two quaternions are close to each other
  68606. * @param quat0 defines the first quaternion to check
  68607. * @param quat1 defines the second quaternion to check
  68608. * @returns true if the two quaternions are close to each other
  68609. */
  68610. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  68611. /**
  68612. * Creates an empty quaternion
  68613. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  68614. */
  68615. static Zero(): Quaternion;
  68616. /**
  68617. * Inverse a given quaternion
  68618. * @param q defines the source quaternion
  68619. * @returns a new quaternion as the inverted current quaternion
  68620. */
  68621. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  68622. /**
  68623. * Inverse a given quaternion
  68624. * @param q defines the source quaternion
  68625. * @param result the quaternion the result will be stored in
  68626. * @returns the result quaternion
  68627. */
  68628. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  68629. /**
  68630. * Creates an identity quaternion
  68631. * @returns the identity quaternion
  68632. */
  68633. static Identity(): Quaternion;
  68634. /**
  68635. * Gets a boolean indicating if the given quaternion is identity
  68636. * @param quaternion defines the quaternion to check
  68637. * @returns true if the quaternion is identity
  68638. */
  68639. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  68640. /**
  68641. * Creates a quaternion from a rotation around an axis
  68642. * @param axis defines the axis to use
  68643. * @param angle defines the angle to use
  68644. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  68645. */
  68646. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  68647. /**
  68648. * Creates a rotation around an axis and stores it into the given quaternion
  68649. * @param axis defines the axis to use
  68650. * @param angle defines the angle to use
  68651. * @param result defines the target quaternion
  68652. * @returns the target quaternion
  68653. */
  68654. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  68655. /**
  68656. * Creates a new quaternion from data stored into an array
  68657. * @param array defines the data source
  68658. * @param offset defines the offset in the source array where the data starts
  68659. * @returns a new quaternion
  68660. */
  68661. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  68662. /**
  68663. * Create a quaternion from Euler rotation angles
  68664. * @param x Pitch
  68665. * @param y Yaw
  68666. * @param z Roll
  68667. * @returns the new Quaternion
  68668. */
  68669. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  68670. /**
  68671. * Updates a quaternion from Euler rotation angles
  68672. * @param x Pitch
  68673. * @param y Yaw
  68674. * @param z Roll
  68675. * @param result the quaternion to store the result
  68676. * @returns the updated quaternion
  68677. */
  68678. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  68679. /**
  68680. * Create a quaternion from Euler rotation vector
  68681. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  68682. * @returns the new Quaternion
  68683. */
  68684. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  68685. /**
  68686. * Updates a quaternion from Euler rotation vector
  68687. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  68688. * @param result the quaternion to store the result
  68689. * @returns the updated quaternion
  68690. */
  68691. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  68692. /**
  68693. * Creates a new quaternion from the given Euler float angles (y, x, z)
  68694. * @param yaw defines the rotation around Y axis
  68695. * @param pitch defines the rotation around X axis
  68696. * @param roll defines the rotation around Z axis
  68697. * @returns the new quaternion
  68698. */
  68699. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  68700. /**
  68701. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  68702. * @param yaw defines the rotation around Y axis
  68703. * @param pitch defines the rotation around X axis
  68704. * @param roll defines the rotation around Z axis
  68705. * @param result defines the target quaternion
  68706. */
  68707. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  68708. /**
  68709. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  68710. * @param alpha defines the rotation around first axis
  68711. * @param beta defines the rotation around second axis
  68712. * @param gamma defines the rotation around third axis
  68713. * @returns the new quaternion
  68714. */
  68715. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  68716. /**
  68717. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  68718. * @param alpha defines the rotation around first axis
  68719. * @param beta defines the rotation around second axis
  68720. * @param gamma defines the rotation around third axis
  68721. * @param result defines the target quaternion
  68722. */
  68723. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  68724. /**
  68725. * 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)
  68726. * @param axis1 defines the first axis
  68727. * @param axis2 defines the second axis
  68728. * @param axis3 defines the third axis
  68729. * @returns the new quaternion
  68730. */
  68731. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  68732. /**
  68733. * 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
  68734. * @param axis1 defines the first axis
  68735. * @param axis2 defines the second axis
  68736. * @param axis3 defines the third axis
  68737. * @param ref defines the target quaternion
  68738. */
  68739. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  68740. /**
  68741. * Interpolates between two quaternions
  68742. * @param left defines first quaternion
  68743. * @param right defines second quaternion
  68744. * @param amount defines the gradient to use
  68745. * @returns the new interpolated quaternion
  68746. */
  68747. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  68748. /**
  68749. * Interpolates between two quaternions and stores it into a target quaternion
  68750. * @param left defines first quaternion
  68751. * @param right defines second quaternion
  68752. * @param amount defines the gradient to use
  68753. * @param result defines the target quaternion
  68754. */
  68755. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  68756. /**
  68757. * Interpolate between two quaternions using Hermite interpolation
  68758. * @param value1 defines first quaternion
  68759. * @param tangent1 defines the incoming tangent
  68760. * @param value2 defines second quaternion
  68761. * @param tangent2 defines the outgoing tangent
  68762. * @param amount defines the target quaternion
  68763. * @returns the new interpolated quaternion
  68764. */
  68765. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  68766. }
  68767. /**
  68768. * Class used to store matrix data (4x4)
  68769. */
  68770. export class Matrix {
  68771. private static _updateFlagSeed;
  68772. private static _identityReadOnly;
  68773. private _isIdentity;
  68774. private _isIdentityDirty;
  68775. private _isIdentity3x2;
  68776. private _isIdentity3x2Dirty;
  68777. /**
  68778. * Gets the update flag of the matrix which is an unique number for the matrix.
  68779. * It will be incremented every time the matrix data change.
  68780. * You can use it to speed the comparison between two versions of the same matrix.
  68781. */
  68782. updateFlag: number;
  68783. private readonly _m;
  68784. /**
  68785. * Gets the internal data of the matrix
  68786. */
  68787. readonly m: DeepImmutable<Float32Array>;
  68788. /** @hidden */
  68789. _markAsUpdated(): void;
  68790. /** @hidden */
  68791. private _updateIdentityStatus;
  68792. /**
  68793. * Creates an empty matrix (filled with zeros)
  68794. */
  68795. constructor();
  68796. /**
  68797. * Check if the current matrix is identity
  68798. * @returns true is the matrix is the identity matrix
  68799. */
  68800. isIdentity(): boolean;
  68801. /**
  68802. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  68803. * @returns true is the matrix is the identity matrix
  68804. */
  68805. isIdentityAs3x2(): boolean;
  68806. /**
  68807. * Gets the determinant of the matrix
  68808. * @returns the matrix determinant
  68809. */
  68810. determinant(): number;
  68811. /**
  68812. * Returns the matrix as a Float32Array
  68813. * @returns the matrix underlying array
  68814. */
  68815. toArray(): DeepImmutable<Float32Array>;
  68816. /**
  68817. * Returns the matrix as a Float32Array
  68818. * @returns the matrix underlying array.
  68819. */
  68820. asArray(): DeepImmutable<Float32Array>;
  68821. /**
  68822. * Inverts the current matrix in place
  68823. * @returns the current inverted matrix
  68824. */
  68825. invert(): Matrix;
  68826. /**
  68827. * Sets all the matrix elements to zero
  68828. * @returns the current matrix
  68829. */
  68830. reset(): Matrix;
  68831. /**
  68832. * Adds the current matrix with a second one
  68833. * @param other defines the matrix to add
  68834. * @returns a new matrix as the addition of the current matrix and the given one
  68835. */
  68836. add(other: DeepImmutable<Matrix>): Matrix;
  68837. /**
  68838. * Sets the given matrix "result" to the addition of the current matrix and the given one
  68839. * @param other defines the matrix to add
  68840. * @param result defines the target matrix
  68841. * @returns the current matrix
  68842. */
  68843. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  68844. /**
  68845. * Adds in place the given matrix to the current matrix
  68846. * @param other defines the second operand
  68847. * @returns the current updated matrix
  68848. */
  68849. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  68850. /**
  68851. * Sets the given matrix to the current inverted Matrix
  68852. * @param other defines the target matrix
  68853. * @returns the unmodified current matrix
  68854. */
  68855. invertToRef(other: Matrix): Matrix;
  68856. /**
  68857. * add a value at the specified position in the current Matrix
  68858. * @param index the index of the value within the matrix. between 0 and 15.
  68859. * @param value the value to be added
  68860. * @returns the current updated matrix
  68861. */
  68862. addAtIndex(index: number, value: number): Matrix;
  68863. /**
  68864. * mutiply the specified position in the current Matrix by a value
  68865. * @param index the index of the value within the matrix. between 0 and 15.
  68866. * @param value the value to be added
  68867. * @returns the current updated matrix
  68868. */
  68869. multiplyAtIndex(index: number, value: number): Matrix;
  68870. /**
  68871. * Inserts the translation vector (using 3 floats) in the current matrix
  68872. * @param x defines the 1st component of the translation
  68873. * @param y defines the 2nd component of the translation
  68874. * @param z defines the 3rd component of the translation
  68875. * @returns the current updated matrix
  68876. */
  68877. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  68878. /**
  68879. * Adds the translation vector (using 3 floats) in the current matrix
  68880. * @param x defines the 1st component of the translation
  68881. * @param y defines the 2nd component of the translation
  68882. * @param z defines the 3rd component of the translation
  68883. * @returns the current updated matrix
  68884. */
  68885. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  68886. /**
  68887. * Inserts the translation vector in the current matrix
  68888. * @param vector3 defines the translation to insert
  68889. * @returns the current updated matrix
  68890. */
  68891. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  68892. /**
  68893. * Gets the translation value of the current matrix
  68894. * @returns a new Vector3 as the extracted translation from the matrix
  68895. */
  68896. getTranslation(): Vector3;
  68897. /**
  68898. * Fill a Vector3 with the extracted translation from the matrix
  68899. * @param result defines the Vector3 where to store the translation
  68900. * @returns the current matrix
  68901. */
  68902. getTranslationToRef(result: Vector3): Matrix;
  68903. /**
  68904. * Remove rotation and scaling part from the matrix
  68905. * @returns the updated matrix
  68906. */
  68907. removeRotationAndScaling(): Matrix;
  68908. /**
  68909. * Multiply two matrices
  68910. * @param other defines the second operand
  68911. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  68912. */
  68913. multiply(other: DeepImmutable<Matrix>): Matrix;
  68914. /**
  68915. * Copy the current matrix from the given one
  68916. * @param other defines the source matrix
  68917. * @returns the current updated matrix
  68918. */
  68919. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  68920. /**
  68921. * Populates the given array from the starting index with the current matrix values
  68922. * @param array defines the target array
  68923. * @param offset defines the offset in the target array where to start storing values
  68924. * @returns the current matrix
  68925. */
  68926. copyToArray(array: Float32Array, offset?: number): Matrix;
  68927. /**
  68928. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  68929. * @param other defines the second operand
  68930. * @param result defines the matrix where to store the multiplication
  68931. * @returns the current matrix
  68932. */
  68933. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  68934. /**
  68935. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  68936. * @param other defines the second operand
  68937. * @param result defines the array where to store the multiplication
  68938. * @param offset defines the offset in the target array where to start storing values
  68939. * @returns the current matrix
  68940. */
  68941. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  68942. /**
  68943. * Check equality between this matrix and a second one
  68944. * @param value defines the second matrix to compare
  68945. * @returns true is the current matrix and the given one values are strictly equal
  68946. */
  68947. equals(value: DeepImmutable<Matrix>): boolean;
  68948. /**
  68949. * Clone the current matrix
  68950. * @returns a new matrix from the current matrix
  68951. */
  68952. clone(): Matrix;
  68953. /**
  68954. * Returns the name of the current matrix class
  68955. * @returns the string "Matrix"
  68956. */
  68957. getClassName(): string;
  68958. /**
  68959. * Gets the hash code of the current matrix
  68960. * @returns the hash code
  68961. */
  68962. getHashCode(): number;
  68963. /**
  68964. * Decomposes the current Matrix into a translation, rotation and scaling components
  68965. * @param scale defines the scale vector3 given as a reference to update
  68966. * @param rotation defines the rotation quaternion given as a reference to update
  68967. * @param translation defines the translation vector3 given as a reference to update
  68968. * @returns true if operation was successful
  68969. */
  68970. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  68971. /**
  68972. * Gets specific row of the matrix
  68973. * @param index defines the number of the row to get
  68974. * @returns the index-th row of the current matrix as a new Vector4
  68975. */
  68976. getRow(index: number): Nullable<Vector4>;
  68977. /**
  68978. * Sets the index-th row of the current matrix to the vector4 values
  68979. * @param index defines the number of the row to set
  68980. * @param row defines the target vector4
  68981. * @returns the updated current matrix
  68982. */
  68983. setRow(index: number, row: Vector4): Matrix;
  68984. /**
  68985. * Compute the transpose of the matrix
  68986. * @returns the new transposed matrix
  68987. */
  68988. transpose(): Matrix;
  68989. /**
  68990. * Compute the transpose of the matrix and store it in a given matrix
  68991. * @param result defines the target matrix
  68992. * @returns the current matrix
  68993. */
  68994. transposeToRef(result: Matrix): Matrix;
  68995. /**
  68996. * Sets the index-th row of the current matrix with the given 4 x float values
  68997. * @param index defines the row index
  68998. * @param x defines the x component to set
  68999. * @param y defines the y component to set
  69000. * @param z defines the z component to set
  69001. * @param w defines the w component to set
  69002. * @returns the updated current matrix
  69003. */
  69004. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  69005. /**
  69006. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  69007. * @param scale defines the scale factor
  69008. * @returns a new matrix
  69009. */
  69010. scale(scale: number): Matrix;
  69011. /**
  69012. * Scale the current matrix values by a factor to a given result matrix
  69013. * @param scale defines the scale factor
  69014. * @param result defines the matrix to store the result
  69015. * @returns the current matrix
  69016. */
  69017. scaleToRef(scale: number, result: Matrix): Matrix;
  69018. /**
  69019. * Scale the current matrix values by a factor and add the result to a given matrix
  69020. * @param scale defines the scale factor
  69021. * @param result defines the Matrix to store the result
  69022. * @returns the current matrix
  69023. */
  69024. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  69025. /**
  69026. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  69027. * @param ref matrix to store the result
  69028. */
  69029. toNormalMatrix(ref: Matrix): void;
  69030. /**
  69031. * Gets only rotation part of the current matrix
  69032. * @returns a new matrix sets to the extracted rotation matrix from the current one
  69033. */
  69034. getRotationMatrix(): Matrix;
  69035. /**
  69036. * Extracts the rotation matrix from the current one and sets it as the given "result"
  69037. * @param result defines the target matrix to store data to
  69038. * @returns the current matrix
  69039. */
  69040. getRotationMatrixToRef(result: Matrix): Matrix;
  69041. /**
  69042. * Toggles model matrix from being right handed to left handed in place and vice versa
  69043. */
  69044. toggleModelMatrixHandInPlace(): void;
  69045. /**
  69046. * Toggles projection matrix from being right handed to left handed in place and vice versa
  69047. */
  69048. toggleProjectionMatrixHandInPlace(): void;
  69049. /**
  69050. * Creates a matrix from an array
  69051. * @param array defines the source array
  69052. * @param offset defines an offset in the source array
  69053. * @returns a new Matrix set from the starting index of the given array
  69054. */
  69055. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  69056. /**
  69057. * Copy the content of an array into a given matrix
  69058. * @param array defines the source array
  69059. * @param offset defines an offset in the source array
  69060. * @param result defines the target matrix
  69061. */
  69062. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  69063. /**
  69064. * Stores an array into a matrix after having multiplied each component by a given factor
  69065. * @param array defines the source array
  69066. * @param offset defines the offset in the source array
  69067. * @param scale defines the scaling factor
  69068. * @param result defines the target matrix
  69069. */
  69070. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  69071. /**
  69072. * Gets an identity matrix that must not be updated
  69073. */
  69074. static readonly IdentityReadOnly: DeepImmutable<Matrix>;
  69075. /**
  69076. * Stores a list of values (16) inside a given matrix
  69077. * @param initialM11 defines 1st value of 1st row
  69078. * @param initialM12 defines 2nd value of 1st row
  69079. * @param initialM13 defines 3rd value of 1st row
  69080. * @param initialM14 defines 4th value of 1st row
  69081. * @param initialM21 defines 1st value of 2nd row
  69082. * @param initialM22 defines 2nd value of 2nd row
  69083. * @param initialM23 defines 3rd value of 2nd row
  69084. * @param initialM24 defines 4th value of 2nd row
  69085. * @param initialM31 defines 1st value of 3rd row
  69086. * @param initialM32 defines 2nd value of 3rd row
  69087. * @param initialM33 defines 3rd value of 3rd row
  69088. * @param initialM34 defines 4th value of 3rd row
  69089. * @param initialM41 defines 1st value of 4th row
  69090. * @param initialM42 defines 2nd value of 4th row
  69091. * @param initialM43 defines 3rd value of 4th row
  69092. * @param initialM44 defines 4th value of 4th row
  69093. * @param result defines the target matrix
  69094. */
  69095. 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;
  69096. /**
  69097. * Creates new matrix from a list of values (16)
  69098. * @param initialM11 defines 1st value of 1st row
  69099. * @param initialM12 defines 2nd value of 1st row
  69100. * @param initialM13 defines 3rd value of 1st row
  69101. * @param initialM14 defines 4th value of 1st row
  69102. * @param initialM21 defines 1st value of 2nd row
  69103. * @param initialM22 defines 2nd value of 2nd row
  69104. * @param initialM23 defines 3rd value of 2nd row
  69105. * @param initialM24 defines 4th value of 2nd row
  69106. * @param initialM31 defines 1st value of 3rd row
  69107. * @param initialM32 defines 2nd value of 3rd row
  69108. * @param initialM33 defines 3rd value of 3rd row
  69109. * @param initialM34 defines 4th value of 3rd row
  69110. * @param initialM41 defines 1st value of 4th row
  69111. * @param initialM42 defines 2nd value of 4th row
  69112. * @param initialM43 defines 3rd value of 4th row
  69113. * @param initialM44 defines 4th value of 4th row
  69114. * @returns the new matrix
  69115. */
  69116. 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;
  69117. /**
  69118. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  69119. * @param scale defines the scale vector3
  69120. * @param rotation defines the rotation quaternion
  69121. * @param translation defines the translation vector3
  69122. * @returns a new matrix
  69123. */
  69124. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  69125. /**
  69126. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  69127. * @param scale defines the scale vector3
  69128. * @param rotation defines the rotation quaternion
  69129. * @param translation defines the translation vector3
  69130. * @param result defines the target matrix
  69131. */
  69132. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  69133. /**
  69134. * Creates a new identity matrix
  69135. * @returns a new identity matrix
  69136. */
  69137. static Identity(): Matrix;
  69138. /**
  69139. * Creates a new identity matrix and stores the result in a given matrix
  69140. * @param result defines the target matrix
  69141. */
  69142. static IdentityToRef(result: Matrix): void;
  69143. /**
  69144. * Creates a new zero matrix
  69145. * @returns a new zero matrix
  69146. */
  69147. static Zero(): Matrix;
  69148. /**
  69149. * Creates a new rotation matrix for "angle" radians around the X axis
  69150. * @param angle defines the angle (in radians) to use
  69151. * @return the new matrix
  69152. */
  69153. static RotationX(angle: number): Matrix;
  69154. /**
  69155. * Creates a new matrix as the invert of a given matrix
  69156. * @param source defines the source matrix
  69157. * @returns the new matrix
  69158. */
  69159. static Invert(source: DeepImmutable<Matrix>): Matrix;
  69160. /**
  69161. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  69162. * @param angle defines the angle (in radians) to use
  69163. * @param result defines the target matrix
  69164. */
  69165. static RotationXToRef(angle: number, result: Matrix): void;
  69166. /**
  69167. * Creates a new rotation matrix for "angle" radians around the Y axis
  69168. * @param angle defines the angle (in radians) to use
  69169. * @return the new matrix
  69170. */
  69171. static RotationY(angle: number): Matrix;
  69172. /**
  69173. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  69174. * @param angle defines the angle (in radians) to use
  69175. * @param result defines the target matrix
  69176. */
  69177. static RotationYToRef(angle: number, result: Matrix): void;
  69178. /**
  69179. * Creates a new rotation matrix for "angle" radians around the Z axis
  69180. * @param angle defines the angle (in radians) to use
  69181. * @return the new matrix
  69182. */
  69183. static RotationZ(angle: number): Matrix;
  69184. /**
  69185. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  69186. * @param angle defines the angle (in radians) to use
  69187. * @param result defines the target matrix
  69188. */
  69189. static RotationZToRef(angle: number, result: Matrix): void;
  69190. /**
  69191. * Creates a new rotation matrix for "angle" radians around the given axis
  69192. * @param axis defines the axis to use
  69193. * @param angle defines the angle (in radians) to use
  69194. * @return the new matrix
  69195. */
  69196. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  69197. /**
  69198. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  69199. * @param axis defines the axis to use
  69200. * @param angle defines the angle (in radians) to use
  69201. * @param result defines the target matrix
  69202. */
  69203. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  69204. /**
  69205. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  69206. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  69207. * @param from defines the vector to align
  69208. * @param to defines the vector to align to
  69209. * @param result defines the target matrix
  69210. */
  69211. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  69212. /**
  69213. * Creates a rotation matrix
  69214. * @param yaw defines the yaw angle in radians (Y axis)
  69215. * @param pitch defines the pitch angle in radians (X axis)
  69216. * @param roll defines the roll angle in radians (X axis)
  69217. * @returns the new rotation matrix
  69218. */
  69219. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  69220. /**
  69221. * Creates a rotation matrix and stores it in a given matrix
  69222. * @param yaw defines the yaw angle in radians (Y axis)
  69223. * @param pitch defines the pitch angle in radians (X axis)
  69224. * @param roll defines the roll angle in radians (X axis)
  69225. * @param result defines the target matrix
  69226. */
  69227. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  69228. /**
  69229. * Creates a scaling matrix
  69230. * @param x defines the scale factor on X axis
  69231. * @param y defines the scale factor on Y axis
  69232. * @param z defines the scale factor on Z axis
  69233. * @returns the new matrix
  69234. */
  69235. static Scaling(x: number, y: number, z: number): Matrix;
  69236. /**
  69237. * Creates a scaling matrix and stores it in a given matrix
  69238. * @param x defines the scale factor on X axis
  69239. * @param y defines the scale factor on Y axis
  69240. * @param z defines the scale factor on Z axis
  69241. * @param result defines the target matrix
  69242. */
  69243. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  69244. /**
  69245. * Creates a translation matrix
  69246. * @param x defines the translation on X axis
  69247. * @param y defines the translation on Y axis
  69248. * @param z defines the translationon Z axis
  69249. * @returns the new matrix
  69250. */
  69251. static Translation(x: number, y: number, z: number): Matrix;
  69252. /**
  69253. * Creates a translation matrix and stores it in a given matrix
  69254. * @param x defines the translation on X axis
  69255. * @param y defines the translation on Y axis
  69256. * @param z defines the translationon Z axis
  69257. * @param result defines the target matrix
  69258. */
  69259. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  69260. /**
  69261. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  69262. * @param startValue defines the start value
  69263. * @param endValue defines the end value
  69264. * @param gradient defines the gradient factor
  69265. * @returns the new matrix
  69266. */
  69267. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  69268. /**
  69269. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  69270. * @param startValue defines the start value
  69271. * @param endValue defines the end value
  69272. * @param gradient defines the gradient factor
  69273. * @param result defines the Matrix object where to store data
  69274. */
  69275. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  69276. /**
  69277. * Builds a new matrix whose values are computed by:
  69278. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  69279. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  69280. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  69281. * @param startValue defines the first matrix
  69282. * @param endValue defines the second matrix
  69283. * @param gradient defines the gradient between the two matrices
  69284. * @returns the new matrix
  69285. */
  69286. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  69287. /**
  69288. * Update a matrix to values which are computed by:
  69289. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  69290. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  69291. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  69292. * @param startValue defines the first matrix
  69293. * @param endValue defines the second matrix
  69294. * @param gradient defines the gradient between the two matrices
  69295. * @param result defines the target matrix
  69296. */
  69297. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  69298. /**
  69299. * 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"
  69300. * This function works in left handed mode
  69301. * @param eye defines the final position of the entity
  69302. * @param target defines where the entity should look at
  69303. * @param up defines the up vector for the entity
  69304. * @returns the new matrix
  69305. */
  69306. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  69307. /**
  69308. * 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".
  69309. * This function works in left handed mode
  69310. * @param eye defines the final position of the entity
  69311. * @param target defines where the entity should look at
  69312. * @param up defines the up vector for the entity
  69313. * @param result defines the target matrix
  69314. */
  69315. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  69316. /**
  69317. * 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"
  69318. * This function works in right handed mode
  69319. * @param eye defines the final position of the entity
  69320. * @param target defines where the entity should look at
  69321. * @param up defines the up vector for the entity
  69322. * @returns the new matrix
  69323. */
  69324. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  69325. /**
  69326. * 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".
  69327. * This function works in right handed mode
  69328. * @param eye defines the final position of the entity
  69329. * @param target defines where the entity should look at
  69330. * @param up defines the up vector for the entity
  69331. * @param result defines the target matrix
  69332. */
  69333. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  69334. /**
  69335. * Create a left-handed orthographic projection matrix
  69336. * @param width defines the viewport width
  69337. * @param height defines the viewport height
  69338. * @param znear defines the near clip plane
  69339. * @param zfar defines the far clip plane
  69340. * @returns a new matrix as a left-handed orthographic projection matrix
  69341. */
  69342. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  69343. /**
  69344. * Store a left-handed orthographic projection to a given matrix
  69345. * @param width defines the viewport width
  69346. * @param height defines the viewport height
  69347. * @param znear defines the near clip plane
  69348. * @param zfar defines the far clip plane
  69349. * @param result defines the target matrix
  69350. */
  69351. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  69352. /**
  69353. * Create a left-handed orthographic projection matrix
  69354. * @param left defines the viewport left coordinate
  69355. * @param right defines the viewport right coordinate
  69356. * @param bottom defines the viewport bottom coordinate
  69357. * @param top defines the viewport top coordinate
  69358. * @param znear defines the near clip plane
  69359. * @param zfar defines the far clip plane
  69360. * @returns a new matrix as a left-handed orthographic projection matrix
  69361. */
  69362. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  69363. /**
  69364. * Stores a left-handed orthographic projection into a given matrix
  69365. * @param left defines the viewport left coordinate
  69366. * @param right defines the viewport right coordinate
  69367. * @param bottom defines the viewport bottom coordinate
  69368. * @param top defines the viewport top coordinate
  69369. * @param znear defines the near clip plane
  69370. * @param zfar defines the far clip plane
  69371. * @param result defines the target matrix
  69372. */
  69373. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  69374. /**
  69375. * Creates a right-handed orthographic projection matrix
  69376. * @param left defines the viewport left coordinate
  69377. * @param right defines the viewport right coordinate
  69378. * @param bottom defines the viewport bottom coordinate
  69379. * @param top defines the viewport top coordinate
  69380. * @param znear defines the near clip plane
  69381. * @param zfar defines the far clip plane
  69382. * @returns a new matrix as a right-handed orthographic projection matrix
  69383. */
  69384. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  69385. /**
  69386. * Stores a right-handed orthographic projection into a given matrix
  69387. * @param left defines the viewport left coordinate
  69388. * @param right defines the viewport right coordinate
  69389. * @param bottom defines the viewport bottom coordinate
  69390. * @param top defines the viewport top coordinate
  69391. * @param znear defines the near clip plane
  69392. * @param zfar defines the far clip plane
  69393. * @param result defines the target matrix
  69394. */
  69395. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  69396. /**
  69397. * Creates a left-handed perspective projection matrix
  69398. * @param width defines the viewport width
  69399. * @param height defines the viewport height
  69400. * @param znear defines the near clip plane
  69401. * @param zfar defines the far clip plane
  69402. * @returns a new matrix as a left-handed perspective projection matrix
  69403. */
  69404. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  69405. /**
  69406. * Creates a left-handed perspective projection matrix
  69407. * @param fov defines the horizontal field of view
  69408. * @param aspect defines the aspect ratio
  69409. * @param znear defines the near clip plane
  69410. * @param zfar defines the far clip plane
  69411. * @returns a new matrix as a left-handed perspective projection matrix
  69412. */
  69413. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  69414. /**
  69415. * Stores a left-handed perspective projection into a given matrix
  69416. * @param fov defines the horizontal field of view
  69417. * @param aspect defines the aspect ratio
  69418. * @param znear defines the near clip plane
  69419. * @param zfar defines the far clip plane
  69420. * @param result defines the target matrix
  69421. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  69422. */
  69423. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  69424. /**
  69425. * Creates a right-handed perspective projection matrix
  69426. * @param fov defines the horizontal field of view
  69427. * @param aspect defines the aspect ratio
  69428. * @param znear defines the near clip plane
  69429. * @param zfar defines the far clip plane
  69430. * @returns a new matrix as a right-handed perspective projection matrix
  69431. */
  69432. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  69433. /**
  69434. * Stores a right-handed perspective projection into a given matrix
  69435. * @param fov defines the horizontal field of view
  69436. * @param aspect defines the aspect ratio
  69437. * @param znear defines the near clip plane
  69438. * @param zfar defines the far clip plane
  69439. * @param result defines the target matrix
  69440. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  69441. */
  69442. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  69443. /**
  69444. * Stores a perspective projection for WebVR info a given matrix
  69445. * @param fov defines the field of view
  69446. * @param znear defines the near clip plane
  69447. * @param zfar defines the far clip plane
  69448. * @param result defines the target matrix
  69449. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  69450. */
  69451. static PerspectiveFovWebVRToRef(fov: {
  69452. upDegrees: number;
  69453. downDegrees: number;
  69454. leftDegrees: number;
  69455. rightDegrees: number;
  69456. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  69457. /**
  69458. * Computes a complete transformation matrix
  69459. * @param viewport defines the viewport to use
  69460. * @param world defines the world matrix
  69461. * @param view defines the view matrix
  69462. * @param projection defines the projection matrix
  69463. * @param zmin defines the near clip plane
  69464. * @param zmax defines the far clip plane
  69465. * @returns the transformation matrix
  69466. */
  69467. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  69468. /**
  69469. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  69470. * @param matrix defines the matrix to use
  69471. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  69472. */
  69473. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  69474. /**
  69475. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  69476. * @param matrix defines the matrix to use
  69477. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  69478. */
  69479. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  69480. /**
  69481. * Compute the transpose of a given matrix
  69482. * @param matrix defines the matrix to transpose
  69483. * @returns the new matrix
  69484. */
  69485. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  69486. /**
  69487. * Compute the transpose of a matrix and store it in a target matrix
  69488. * @param matrix defines the matrix to transpose
  69489. * @param result defines the target matrix
  69490. */
  69491. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  69492. /**
  69493. * Computes a reflection matrix from a plane
  69494. * @param plane defines the reflection plane
  69495. * @returns a new matrix
  69496. */
  69497. static Reflection(plane: DeepImmutable<IPlaneLike>): Matrix;
  69498. /**
  69499. * Computes a reflection matrix from a plane
  69500. * @param plane defines the reflection plane
  69501. * @param result defines the target matrix
  69502. */
  69503. static ReflectionToRef(plane: DeepImmutable<IPlaneLike>, result: Matrix): void;
  69504. /**
  69505. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  69506. * @param xaxis defines the value of the 1st axis
  69507. * @param yaxis defines the value of the 2nd axis
  69508. * @param zaxis defines the value of the 3rd axis
  69509. * @param result defines the target matrix
  69510. */
  69511. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  69512. /**
  69513. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  69514. * @param quat defines the quaternion to use
  69515. * @param result defines the target matrix
  69516. */
  69517. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  69518. }
  69519. /**
  69520. * @hidden
  69521. */
  69522. export class TmpVectors {
  69523. static Vector2: Vector2[];
  69524. static Vector3: Vector3[];
  69525. static Vector4: Vector4[];
  69526. static Quaternion: Quaternion[];
  69527. static Matrix: Matrix[];
  69528. }
  69529. }
  69530. declare module BABYLON {
  69531. /** Defines the cross module used constants to avoid circular dependncies */
  69532. export class Constants {
  69533. /** Defines that alpha blending is disabled */
  69534. static readonly ALPHA_DISABLE: number;
  69535. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  69536. static readonly ALPHA_ADD: number;
  69537. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  69538. static readonly ALPHA_COMBINE: number;
  69539. /** Defines that alpha blending to DEST - SRC * DEST */
  69540. static readonly ALPHA_SUBTRACT: number;
  69541. /** Defines that alpha blending to SRC * DEST */
  69542. static readonly ALPHA_MULTIPLY: number;
  69543. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  69544. static readonly ALPHA_MAXIMIZED: number;
  69545. /** Defines that alpha blending to SRC + DEST */
  69546. static readonly ALPHA_ONEONE: number;
  69547. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  69548. static readonly ALPHA_PREMULTIPLIED: number;
  69549. /**
  69550. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  69551. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  69552. */
  69553. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  69554. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  69555. static readonly ALPHA_INTERPOLATE: number;
  69556. /**
  69557. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  69558. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  69559. */
  69560. static readonly ALPHA_SCREENMODE: number;
  69561. /** Defines that the ressource is not delayed*/
  69562. static readonly DELAYLOADSTATE_NONE: number;
  69563. /** Defines that the ressource was successfully delay loaded */
  69564. static readonly DELAYLOADSTATE_LOADED: number;
  69565. /** Defines that the ressource is currently delay loading */
  69566. static readonly DELAYLOADSTATE_LOADING: number;
  69567. /** Defines that the ressource is delayed and has not started loading */
  69568. static readonly DELAYLOADSTATE_NOTLOADED: number;
  69569. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  69570. static readonly NEVER: number;
  69571. /** 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 */
  69572. static readonly ALWAYS: number;
  69573. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  69574. static readonly LESS: number;
  69575. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  69576. static readonly EQUAL: number;
  69577. /** 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 */
  69578. static readonly LEQUAL: number;
  69579. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  69580. static readonly GREATER: number;
  69581. /** 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 */
  69582. static readonly GEQUAL: number;
  69583. /** 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 */
  69584. static readonly NOTEQUAL: number;
  69585. /** Passed to stencilOperation to specify that stencil value must be kept */
  69586. static readonly KEEP: number;
  69587. /** Passed to stencilOperation to specify that stencil value must be replaced */
  69588. static readonly REPLACE: number;
  69589. /** Passed to stencilOperation to specify that stencil value must be incremented */
  69590. static readonly INCR: number;
  69591. /** Passed to stencilOperation to specify that stencil value must be decremented */
  69592. static readonly DECR: number;
  69593. /** Passed to stencilOperation to specify that stencil value must be inverted */
  69594. static readonly INVERT: number;
  69595. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  69596. static readonly INCR_WRAP: number;
  69597. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  69598. static readonly DECR_WRAP: number;
  69599. /** Texture is not repeating outside of 0..1 UVs */
  69600. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  69601. /** Texture is repeating outside of 0..1 UVs */
  69602. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  69603. /** Texture is repeating and mirrored */
  69604. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  69605. /** ALPHA */
  69606. static readonly TEXTUREFORMAT_ALPHA: number;
  69607. /** LUMINANCE */
  69608. static readonly TEXTUREFORMAT_LUMINANCE: number;
  69609. /** LUMINANCE_ALPHA */
  69610. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  69611. /** RGB */
  69612. static readonly TEXTUREFORMAT_RGB: number;
  69613. /** RGBA */
  69614. static readonly TEXTUREFORMAT_RGBA: number;
  69615. /** RED */
  69616. static readonly TEXTUREFORMAT_RED: number;
  69617. /** RED (2nd reference) */
  69618. static readonly TEXTUREFORMAT_R: number;
  69619. /** RG */
  69620. static readonly TEXTUREFORMAT_RG: number;
  69621. /** RED_INTEGER */
  69622. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  69623. /** RED_INTEGER (2nd reference) */
  69624. static readonly TEXTUREFORMAT_R_INTEGER: number;
  69625. /** RG_INTEGER */
  69626. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  69627. /** RGB_INTEGER */
  69628. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  69629. /** RGBA_INTEGER */
  69630. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  69631. /** UNSIGNED_BYTE */
  69632. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  69633. /** UNSIGNED_BYTE (2nd reference) */
  69634. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  69635. /** FLOAT */
  69636. static readonly TEXTURETYPE_FLOAT: number;
  69637. /** HALF_FLOAT */
  69638. static readonly TEXTURETYPE_HALF_FLOAT: number;
  69639. /** BYTE */
  69640. static readonly TEXTURETYPE_BYTE: number;
  69641. /** SHORT */
  69642. static readonly TEXTURETYPE_SHORT: number;
  69643. /** UNSIGNED_SHORT */
  69644. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  69645. /** INT */
  69646. static readonly TEXTURETYPE_INT: number;
  69647. /** UNSIGNED_INT */
  69648. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  69649. /** UNSIGNED_SHORT_4_4_4_4 */
  69650. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  69651. /** UNSIGNED_SHORT_5_5_5_1 */
  69652. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  69653. /** UNSIGNED_SHORT_5_6_5 */
  69654. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  69655. /** UNSIGNED_INT_2_10_10_10_REV */
  69656. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  69657. /** UNSIGNED_INT_24_8 */
  69658. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  69659. /** UNSIGNED_INT_10F_11F_11F_REV */
  69660. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  69661. /** UNSIGNED_INT_5_9_9_9_REV */
  69662. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  69663. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  69664. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  69665. /** nearest is mag = nearest and min = nearest and mip = linear */
  69666. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  69667. /** Bilinear is mag = linear and min = linear and mip = nearest */
  69668. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  69669. /** Trilinear is mag = linear and min = linear and mip = linear */
  69670. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  69671. /** nearest is mag = nearest and min = nearest and mip = linear */
  69672. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  69673. /** Bilinear is mag = linear and min = linear and mip = nearest */
  69674. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  69675. /** Trilinear is mag = linear and min = linear and mip = linear */
  69676. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  69677. /** mag = nearest and min = nearest and mip = nearest */
  69678. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  69679. /** mag = nearest and min = linear and mip = nearest */
  69680. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  69681. /** mag = nearest and min = linear and mip = linear */
  69682. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  69683. /** mag = nearest and min = linear and mip = none */
  69684. static readonly TEXTURE_NEAREST_LINEAR: number;
  69685. /** mag = nearest and min = nearest and mip = none */
  69686. static readonly TEXTURE_NEAREST_NEAREST: number;
  69687. /** mag = linear and min = nearest and mip = nearest */
  69688. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  69689. /** mag = linear and min = nearest and mip = linear */
  69690. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  69691. /** mag = linear and min = linear and mip = none */
  69692. static readonly TEXTURE_LINEAR_LINEAR: number;
  69693. /** mag = linear and min = nearest and mip = none */
  69694. static readonly TEXTURE_LINEAR_NEAREST: number;
  69695. /** Explicit coordinates mode */
  69696. static readonly TEXTURE_EXPLICIT_MODE: number;
  69697. /** Spherical coordinates mode */
  69698. static readonly TEXTURE_SPHERICAL_MODE: number;
  69699. /** Planar coordinates mode */
  69700. static readonly TEXTURE_PLANAR_MODE: number;
  69701. /** Cubic coordinates mode */
  69702. static readonly TEXTURE_CUBIC_MODE: number;
  69703. /** Projection coordinates mode */
  69704. static readonly TEXTURE_PROJECTION_MODE: number;
  69705. /** Skybox coordinates mode */
  69706. static readonly TEXTURE_SKYBOX_MODE: number;
  69707. /** Inverse Cubic coordinates mode */
  69708. static readonly TEXTURE_INVCUBIC_MODE: number;
  69709. /** Equirectangular coordinates mode */
  69710. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  69711. /** Equirectangular Fixed coordinates mode */
  69712. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  69713. /** Equirectangular Fixed Mirrored coordinates mode */
  69714. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  69715. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  69716. static readonly SCALEMODE_FLOOR: number;
  69717. /** Defines that texture rescaling will look for the nearest power of 2 size */
  69718. static readonly SCALEMODE_NEAREST: number;
  69719. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  69720. static readonly SCALEMODE_CEILING: number;
  69721. /**
  69722. * The dirty texture flag value
  69723. */
  69724. static readonly MATERIAL_TextureDirtyFlag: number;
  69725. /**
  69726. * The dirty light flag value
  69727. */
  69728. static readonly MATERIAL_LightDirtyFlag: number;
  69729. /**
  69730. * The dirty fresnel flag value
  69731. */
  69732. static readonly MATERIAL_FresnelDirtyFlag: number;
  69733. /**
  69734. * The dirty attribute flag value
  69735. */
  69736. static readonly MATERIAL_AttributesDirtyFlag: number;
  69737. /**
  69738. * The dirty misc flag value
  69739. */
  69740. static readonly MATERIAL_MiscDirtyFlag: number;
  69741. /**
  69742. * The all dirty flag value
  69743. */
  69744. static readonly MATERIAL_AllDirtyFlag: number;
  69745. /**
  69746. * Returns the triangle fill mode
  69747. */
  69748. static readonly MATERIAL_TriangleFillMode: number;
  69749. /**
  69750. * Returns the wireframe mode
  69751. */
  69752. static readonly MATERIAL_WireFrameFillMode: number;
  69753. /**
  69754. * Returns the point fill mode
  69755. */
  69756. static readonly MATERIAL_PointFillMode: number;
  69757. /**
  69758. * Returns the point list draw mode
  69759. */
  69760. static readonly MATERIAL_PointListDrawMode: number;
  69761. /**
  69762. * Returns the line list draw mode
  69763. */
  69764. static readonly MATERIAL_LineListDrawMode: number;
  69765. /**
  69766. * Returns the line loop draw mode
  69767. */
  69768. static readonly MATERIAL_LineLoopDrawMode: number;
  69769. /**
  69770. * Returns the line strip draw mode
  69771. */
  69772. static readonly MATERIAL_LineStripDrawMode: number;
  69773. /**
  69774. * Returns the triangle strip draw mode
  69775. */
  69776. static readonly MATERIAL_TriangleStripDrawMode: number;
  69777. /**
  69778. * Returns the triangle fan draw mode
  69779. */
  69780. static readonly MATERIAL_TriangleFanDrawMode: number;
  69781. /**
  69782. * Stores the clock-wise side orientation
  69783. */
  69784. static readonly MATERIAL_ClockWiseSideOrientation: number;
  69785. /**
  69786. * Stores the counter clock-wise side orientation
  69787. */
  69788. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  69789. /**
  69790. * Nothing
  69791. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  69792. */
  69793. static readonly ACTION_NothingTrigger: number;
  69794. /**
  69795. * On pick
  69796. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  69797. */
  69798. static readonly ACTION_OnPickTrigger: number;
  69799. /**
  69800. * On left pick
  69801. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  69802. */
  69803. static readonly ACTION_OnLeftPickTrigger: number;
  69804. /**
  69805. * On right pick
  69806. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  69807. */
  69808. static readonly ACTION_OnRightPickTrigger: number;
  69809. /**
  69810. * On center pick
  69811. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  69812. */
  69813. static readonly ACTION_OnCenterPickTrigger: number;
  69814. /**
  69815. * On pick down
  69816. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  69817. */
  69818. static readonly ACTION_OnPickDownTrigger: number;
  69819. /**
  69820. * On double pick
  69821. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  69822. */
  69823. static readonly ACTION_OnDoublePickTrigger: number;
  69824. /**
  69825. * On pick up
  69826. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  69827. */
  69828. static readonly ACTION_OnPickUpTrigger: number;
  69829. /**
  69830. * On pick out.
  69831. * This trigger will only be raised if you also declared a OnPickDown
  69832. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  69833. */
  69834. static readonly ACTION_OnPickOutTrigger: number;
  69835. /**
  69836. * On long press
  69837. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  69838. */
  69839. static readonly ACTION_OnLongPressTrigger: number;
  69840. /**
  69841. * On pointer over
  69842. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  69843. */
  69844. static readonly ACTION_OnPointerOverTrigger: number;
  69845. /**
  69846. * On pointer out
  69847. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  69848. */
  69849. static readonly ACTION_OnPointerOutTrigger: number;
  69850. /**
  69851. * On every frame
  69852. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  69853. */
  69854. static readonly ACTION_OnEveryFrameTrigger: number;
  69855. /**
  69856. * On intersection enter
  69857. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  69858. */
  69859. static readonly ACTION_OnIntersectionEnterTrigger: number;
  69860. /**
  69861. * On intersection exit
  69862. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  69863. */
  69864. static readonly ACTION_OnIntersectionExitTrigger: number;
  69865. /**
  69866. * On key down
  69867. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  69868. */
  69869. static readonly ACTION_OnKeyDownTrigger: number;
  69870. /**
  69871. * On key up
  69872. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  69873. */
  69874. static readonly ACTION_OnKeyUpTrigger: number;
  69875. /**
  69876. * Billboard mode will only apply to Y axis
  69877. */
  69878. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  69879. /**
  69880. * Billboard mode will apply to all axes
  69881. */
  69882. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  69883. /**
  69884. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  69885. */
  69886. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  69887. /**
  69888. * Gets or sets base Assets URL
  69889. */
  69890. static PARTICLES_BaseAssetsUrl: string;
  69891. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  69892. * Test order :
  69893. * Is the bounding sphere outside the frustum ?
  69894. * If not, are the bounding box vertices outside the frustum ?
  69895. * It not, then the cullable object is in the frustum.
  69896. */
  69897. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  69898. /** Culling strategy : Bounding Sphere Only.
  69899. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  69900. * It's also less accurate than the standard because some not visible objects can still be selected.
  69901. * Test : is the bounding sphere outside the frustum ?
  69902. * If not, then the cullable object is in the frustum.
  69903. */
  69904. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  69905. /** Culling strategy : Optimistic Inclusion.
  69906. * This in an inclusion test first, then the standard exclusion test.
  69907. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  69908. * 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.
  69909. * Anyway, it's as accurate as the standard strategy.
  69910. * Test :
  69911. * Is the cullable object bounding sphere center in the frustum ?
  69912. * If not, apply the default culling strategy.
  69913. */
  69914. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  69915. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  69916. * This in an inclusion test first, then the bounding sphere only exclusion test.
  69917. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  69918. * 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.
  69919. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  69920. * Test :
  69921. * Is the cullable object bounding sphere center in the frustum ?
  69922. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  69923. */
  69924. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  69925. /**
  69926. * No logging while loading
  69927. */
  69928. static readonly SCENELOADER_NO_LOGGING: number;
  69929. /**
  69930. * Minimal logging while loading
  69931. */
  69932. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  69933. /**
  69934. * Summary logging while loading
  69935. */
  69936. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  69937. /**
  69938. * Detailled logging while loading
  69939. */
  69940. static readonly SCENELOADER_DETAILED_LOGGING: number;
  69941. }
  69942. }
  69943. declare module BABYLON {
  69944. /**
  69945. * Class used to store and describe the pipeline context associated with an effect
  69946. */
  69947. export interface IPipelineContext {
  69948. /**
  69949. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  69950. */
  69951. isAsync: boolean;
  69952. /**
  69953. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  69954. */
  69955. isReady: boolean;
  69956. /** @hidden */
  69957. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  69958. }
  69959. }
  69960. declare module BABYLON {
  69961. /** @hidden */
  69962. export interface IShaderProcessor {
  69963. attributeProcessor?: (attribute: string) => string;
  69964. varyingProcessor?: (varying: string, isFragment: boolean) => string;
  69965. uniformProcessor?: (uniform: string, isFragment: boolean) => string;
  69966. uniformBufferProcessor?: (uniformBuffer: string, isFragment: boolean) => string;
  69967. endOfUniformBufferProcessor?: (closingBracketLine: string, isFragment: boolean) => string;
  69968. lineProcessor?: (line: string, isFragment: boolean) => string;
  69969. preProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  69970. postProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  69971. }
  69972. }
  69973. declare module BABYLON {
  69974. /** @hidden */
  69975. export interface ProcessingOptions {
  69976. defines: string[];
  69977. indexParameters: any;
  69978. isFragment: boolean;
  69979. shouldUseHighPrecisionShader: boolean;
  69980. supportsUniformBuffers: boolean;
  69981. shadersRepository: string;
  69982. includesShadersStore: {
  69983. [key: string]: string;
  69984. };
  69985. processor?: IShaderProcessor;
  69986. version: string;
  69987. platformName: string;
  69988. lookForClosingBracketForUniformBuffer?: boolean;
  69989. }
  69990. }
  69991. declare module BABYLON {
  69992. /**
  69993. * Helper to manipulate strings
  69994. */
  69995. export class StringTools {
  69996. /**
  69997. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  69998. * @param str Source string
  69999. * @param suffix Suffix to search for in the source string
  70000. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  70001. */
  70002. static EndsWith(str: string, suffix: string): boolean;
  70003. /**
  70004. * Checks for a matching suffix at the beginning of a string (for ES5 and lower)
  70005. * @param str Source string
  70006. * @param suffix Suffix to search for in the source string
  70007. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  70008. */
  70009. static StartsWith(str: string, suffix: string): boolean;
  70010. }
  70011. }
  70012. declare module BABYLON {
  70013. /** @hidden */
  70014. export class ShaderCodeNode {
  70015. line: string;
  70016. children: ShaderCodeNode[];
  70017. additionalDefineKey?: string;
  70018. additionalDefineValue?: string;
  70019. isValid(preprocessors: {
  70020. [key: string]: string;
  70021. }): boolean;
  70022. process(preprocessors: {
  70023. [key: string]: string;
  70024. }, options: ProcessingOptions): string;
  70025. }
  70026. }
  70027. declare module BABYLON {
  70028. /** @hidden */
  70029. export class ShaderCodeCursor {
  70030. private _lines;
  70031. lineIndex: number;
  70032. readonly currentLine: string;
  70033. readonly canRead: boolean;
  70034. lines: string[];
  70035. }
  70036. }
  70037. declare module BABYLON {
  70038. /** @hidden */
  70039. export class ShaderCodeConditionNode extends ShaderCodeNode {
  70040. process(preprocessors: {
  70041. [key: string]: string;
  70042. }, options: ProcessingOptions): string;
  70043. }
  70044. }
  70045. declare module BABYLON {
  70046. /** @hidden */
  70047. export class ShaderDefineExpression {
  70048. isTrue(preprocessors: {
  70049. [key: string]: string;
  70050. }): boolean;
  70051. }
  70052. }
  70053. declare module BABYLON {
  70054. /** @hidden */
  70055. export class ShaderCodeTestNode extends ShaderCodeNode {
  70056. testExpression: ShaderDefineExpression;
  70057. isValid(preprocessors: {
  70058. [key: string]: string;
  70059. }): boolean;
  70060. }
  70061. }
  70062. declare module BABYLON {
  70063. /** @hidden */
  70064. export class ShaderDefineIsDefinedOperator extends ShaderDefineExpression {
  70065. define: string;
  70066. not: boolean;
  70067. constructor(define: string, not?: boolean);
  70068. isTrue(preprocessors: {
  70069. [key: string]: string;
  70070. }): boolean;
  70071. }
  70072. }
  70073. declare module BABYLON {
  70074. /** @hidden */
  70075. export class ShaderDefineOrOperator extends ShaderDefineExpression {
  70076. leftOperand: ShaderDefineExpression;
  70077. rightOperand: ShaderDefineExpression;
  70078. isTrue(preprocessors: {
  70079. [key: string]: string;
  70080. }): boolean;
  70081. }
  70082. }
  70083. declare module BABYLON {
  70084. /** @hidden */
  70085. export class ShaderDefineAndOperator extends ShaderDefineExpression {
  70086. leftOperand: ShaderDefineExpression;
  70087. rightOperand: ShaderDefineExpression;
  70088. isTrue(preprocessors: {
  70089. [key: string]: string;
  70090. }): boolean;
  70091. }
  70092. }
  70093. declare module BABYLON {
  70094. /** @hidden */
  70095. export class ShaderDefineArithmeticOperator extends ShaderDefineExpression {
  70096. define: string;
  70097. operand: string;
  70098. testValue: string;
  70099. constructor(define: string, operand: string, testValue: string);
  70100. isTrue(preprocessors: {
  70101. [key: string]: string;
  70102. }): boolean;
  70103. }
  70104. }
  70105. declare module BABYLON {
  70106. /**
  70107. * @ignore
  70108. * Application error to support additional information when loading a file
  70109. */
  70110. export class LoadFileError extends Error {
  70111. /** defines the optional web request */
  70112. request?: WebRequest | undefined;
  70113. private static _setPrototypeOf;
  70114. /**
  70115. * Creates a new LoadFileError
  70116. * @param message defines the message of the error
  70117. * @param request defines the optional web request
  70118. */
  70119. constructor(message: string,
  70120. /** defines the optional web request */
  70121. request?: WebRequest | undefined);
  70122. }
  70123. }
  70124. declare module BABYLON {
  70125. /**
  70126. * Class used to enable access to offline support
  70127. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  70128. */
  70129. export interface IOfflineProvider {
  70130. /**
  70131. * Gets a boolean indicating if scene must be saved in the database
  70132. */
  70133. enableSceneOffline: boolean;
  70134. /**
  70135. * Gets a boolean indicating if textures must be saved in the database
  70136. */
  70137. enableTexturesOffline: boolean;
  70138. /**
  70139. * Open the offline support and make it available
  70140. * @param successCallback defines the callback to call on success
  70141. * @param errorCallback defines the callback to call on error
  70142. */
  70143. open(successCallback: () => void, errorCallback: () => void): void;
  70144. /**
  70145. * Loads an image from the offline support
  70146. * @param url defines the url to load from
  70147. * @param image defines the target DOM image
  70148. */
  70149. loadImage(url: string, image: HTMLImageElement): void;
  70150. /**
  70151. * Loads a file from offline support
  70152. * @param url defines the URL to load from
  70153. * @param sceneLoaded defines a callback to call on success
  70154. * @param progressCallBack defines a callback to call when progress changed
  70155. * @param errorCallback defines a callback to call on error
  70156. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  70157. */
  70158. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  70159. }
  70160. }
  70161. declare module BABYLON {
  70162. /**
  70163. * Class used to help managing file picking and drag'n'drop
  70164. * File Storage
  70165. */
  70166. export class FilesInputStore {
  70167. /**
  70168. * List of files ready to be loaded
  70169. */
  70170. static FilesToLoad: {
  70171. [key: string]: File;
  70172. };
  70173. }
  70174. }
  70175. declare module BABYLON {
  70176. /**
  70177. * Class used to define a retry strategy when error happens while loading assets
  70178. */
  70179. export class RetryStrategy {
  70180. /**
  70181. * Function used to defines an exponential back off strategy
  70182. * @param maxRetries defines the maximum number of retries (3 by default)
  70183. * @param baseInterval defines the interval between retries
  70184. * @returns the strategy function to use
  70185. */
  70186. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  70187. }
  70188. }
  70189. declare module BABYLON {
  70190. /**
  70191. * @hidden
  70192. */
  70193. export class FileTools {
  70194. /**
  70195. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  70196. */
  70197. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  70198. /**
  70199. * Gets or sets the base URL to use to load assets
  70200. */
  70201. static BaseUrl: string;
  70202. /**
  70203. * Default behaviour for cors in the application.
  70204. * It can be a string if the expected behavior is identical in the entire app.
  70205. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  70206. */
  70207. static CorsBehavior: string | ((url: string | string[]) => string);
  70208. /**
  70209. * Gets or sets a function used to pre-process url before using them to load assets
  70210. */
  70211. static PreprocessUrl: (url: string) => string;
  70212. /**
  70213. * Removes unwanted characters from an url
  70214. * @param url defines the url to clean
  70215. * @returns the cleaned url
  70216. */
  70217. private static _CleanUrl;
  70218. /**
  70219. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  70220. * @param url define the url we are trying
  70221. * @param element define the dom element where to configure the cors policy
  70222. */
  70223. static SetCorsBehavior(url: string | string[], element: {
  70224. crossOrigin: string | null;
  70225. }): void;
  70226. /**
  70227. * Loads an image as an HTMLImageElement.
  70228. * @param input url string, ArrayBuffer, or Blob to load
  70229. * @param onLoad callback called when the image successfully loads
  70230. * @param onError callback called when the image fails to load
  70231. * @param offlineProvider offline provider for caching
  70232. * @returns the HTMLImageElement of the loaded image
  70233. */
  70234. static LoadImage(input: string | ArrayBuffer | ArrayBufferView | Blob, onLoad: (img: HTMLImageElement) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>): HTMLImageElement;
  70235. /**
  70236. * Loads a file
  70237. * @param fileToLoad defines the file to load
  70238. * @param callback defines the callback to call when data is loaded
  70239. * @param progressCallBack defines the callback to call during loading process
  70240. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  70241. * @returns a file request object
  70242. */
  70243. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  70244. /**
  70245. * Loads a file
  70246. * @param url url string, ArrayBuffer, or Blob to load
  70247. * @param onSuccess callback called when the file successfully loads
  70248. * @param onProgress callback called while file is loading (if the server supports this mode)
  70249. * @param offlineProvider defines the offline provider for caching
  70250. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  70251. * @param onError callback called when the file fails to load
  70252. * @returns a file request object
  70253. */
  70254. 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;
  70255. /**
  70256. * Checks if the loaded document was accessed via `file:`-Protocol.
  70257. * @returns boolean
  70258. */
  70259. static IsFileURL(): boolean;
  70260. }
  70261. }
  70262. declare module BABYLON {
  70263. /** @hidden */
  70264. export class ShaderProcessor {
  70265. static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void): void;
  70266. private static _ProcessPrecision;
  70267. private static _ExtractOperation;
  70268. private static _BuildSubExpression;
  70269. private static _BuildExpression;
  70270. private static _MoveCursorWithinIf;
  70271. private static _MoveCursor;
  70272. private static _EvaluatePreProcessors;
  70273. private static _PreparePreProcessors;
  70274. private static _ProcessShaderConversion;
  70275. private static _ProcessIncludes;
  70276. }
  70277. }
  70278. declare module BABYLON {
  70279. /**
  70280. * Class used to hold a RBG color
  70281. */
  70282. export class Color3 {
  70283. /**
  70284. * Defines the red component (between 0 and 1, default is 0)
  70285. */
  70286. r: number;
  70287. /**
  70288. * Defines the green component (between 0 and 1, default is 0)
  70289. */
  70290. g: number;
  70291. /**
  70292. * Defines the blue component (between 0 and 1, default is 0)
  70293. */
  70294. b: number;
  70295. /**
  70296. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  70297. * @param r defines the red component (between 0 and 1, default is 0)
  70298. * @param g defines the green component (between 0 and 1, default is 0)
  70299. * @param b defines the blue component (between 0 and 1, default is 0)
  70300. */
  70301. constructor(
  70302. /**
  70303. * Defines the red component (between 0 and 1, default is 0)
  70304. */
  70305. r?: number,
  70306. /**
  70307. * Defines the green component (between 0 and 1, default is 0)
  70308. */
  70309. g?: number,
  70310. /**
  70311. * Defines the blue component (between 0 and 1, default is 0)
  70312. */
  70313. b?: number);
  70314. /**
  70315. * Creates a string with the Color3 current values
  70316. * @returns the string representation of the Color3 object
  70317. */
  70318. toString(): string;
  70319. /**
  70320. * Returns the string "Color3"
  70321. * @returns "Color3"
  70322. */
  70323. getClassName(): string;
  70324. /**
  70325. * Compute the Color3 hash code
  70326. * @returns an unique number that can be used to hash Color3 objects
  70327. */
  70328. getHashCode(): number;
  70329. /**
  70330. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  70331. * @param array defines the array where to store the r,g,b components
  70332. * @param index defines an optional index in the target array to define where to start storing values
  70333. * @returns the current Color3 object
  70334. */
  70335. toArray(array: FloatArray, index?: number): Color3;
  70336. /**
  70337. * Returns a new Color4 object from the current Color3 and the given alpha
  70338. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  70339. * @returns a new Color4 object
  70340. */
  70341. toColor4(alpha?: number): Color4;
  70342. /**
  70343. * Returns a new array populated with 3 numeric elements : red, green and blue values
  70344. * @returns the new array
  70345. */
  70346. asArray(): number[];
  70347. /**
  70348. * Returns the luminance value
  70349. * @returns a float value
  70350. */
  70351. toLuminance(): number;
  70352. /**
  70353. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  70354. * @param otherColor defines the second operand
  70355. * @returns the new Color3 object
  70356. */
  70357. multiply(otherColor: DeepImmutable<Color3>): Color3;
  70358. /**
  70359. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  70360. * @param otherColor defines the second operand
  70361. * @param result defines the Color3 object where to store the result
  70362. * @returns the current Color3
  70363. */
  70364. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  70365. /**
  70366. * Determines equality between Color3 objects
  70367. * @param otherColor defines the second operand
  70368. * @returns true if the rgb values are equal to the given ones
  70369. */
  70370. equals(otherColor: DeepImmutable<Color3>): boolean;
  70371. /**
  70372. * Determines equality between the current Color3 object and a set of r,b,g values
  70373. * @param r defines the red component to check
  70374. * @param g defines the green component to check
  70375. * @param b defines the blue component to check
  70376. * @returns true if the rgb values are equal to the given ones
  70377. */
  70378. equalsFloats(r: number, g: number, b: number): boolean;
  70379. /**
  70380. * Multiplies in place each rgb value by scale
  70381. * @param scale defines the scaling factor
  70382. * @returns the updated Color3
  70383. */
  70384. scale(scale: number): Color3;
  70385. /**
  70386. * Multiplies the rgb values by scale and stores the result into "result"
  70387. * @param scale defines the scaling factor
  70388. * @param result defines the Color3 object where to store the result
  70389. * @returns the unmodified current Color3
  70390. */
  70391. scaleToRef(scale: number, result: Color3): Color3;
  70392. /**
  70393. * Scale the current Color3 values by a factor and add the result to a given Color3
  70394. * @param scale defines the scale factor
  70395. * @param result defines color to store the result into
  70396. * @returns the unmodified current Color3
  70397. */
  70398. scaleAndAddToRef(scale: number, result: Color3): Color3;
  70399. /**
  70400. * Clamps the rgb values by the min and max values and stores the result into "result"
  70401. * @param min defines minimum clamping value (default is 0)
  70402. * @param max defines maximum clamping value (default is 1)
  70403. * @param result defines color to store the result into
  70404. * @returns the original Color3
  70405. */
  70406. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  70407. /**
  70408. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  70409. * @param otherColor defines the second operand
  70410. * @returns the new Color3
  70411. */
  70412. add(otherColor: DeepImmutable<Color3>): Color3;
  70413. /**
  70414. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  70415. * @param otherColor defines the second operand
  70416. * @param result defines Color3 object to store the result into
  70417. * @returns the unmodified current Color3
  70418. */
  70419. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  70420. /**
  70421. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  70422. * @param otherColor defines the second operand
  70423. * @returns the new Color3
  70424. */
  70425. subtract(otherColor: DeepImmutable<Color3>): Color3;
  70426. /**
  70427. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  70428. * @param otherColor defines the second operand
  70429. * @param result defines Color3 object to store the result into
  70430. * @returns the unmodified current Color3
  70431. */
  70432. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  70433. /**
  70434. * Copy the current object
  70435. * @returns a new Color3 copied the current one
  70436. */
  70437. clone(): Color3;
  70438. /**
  70439. * Copies the rgb values from the source in the current Color3
  70440. * @param source defines the source Color3 object
  70441. * @returns the updated Color3 object
  70442. */
  70443. copyFrom(source: DeepImmutable<Color3>): Color3;
  70444. /**
  70445. * Updates the Color3 rgb values from the given floats
  70446. * @param r defines the red component to read from
  70447. * @param g defines the green component to read from
  70448. * @param b defines the blue component to read from
  70449. * @returns the current Color3 object
  70450. */
  70451. copyFromFloats(r: number, g: number, b: number): Color3;
  70452. /**
  70453. * Updates the Color3 rgb values from the given floats
  70454. * @param r defines the red component to read from
  70455. * @param g defines the green component to read from
  70456. * @param b defines the blue component to read from
  70457. * @returns the current Color3 object
  70458. */
  70459. set(r: number, g: number, b: number): Color3;
  70460. /**
  70461. * Compute the Color3 hexadecimal code as a string
  70462. * @returns a string containing the hexadecimal representation of the Color3 object
  70463. */
  70464. toHexString(): string;
  70465. /**
  70466. * Computes a new Color3 converted from the current one to linear space
  70467. * @returns a new Color3 object
  70468. */
  70469. toLinearSpace(): Color3;
  70470. /**
  70471. * Converts current color in rgb space to HSV values
  70472. * @returns a new color3 representing the HSV values
  70473. */
  70474. toHSV(): Color3;
  70475. /**
  70476. * Converts current color in rgb space to HSV values
  70477. * @param result defines the Color3 where to store the HSV values
  70478. */
  70479. toHSVToRef(result: Color3): void;
  70480. /**
  70481. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  70482. * @param convertedColor defines the Color3 object where to store the linear space version
  70483. * @returns the unmodified Color3
  70484. */
  70485. toLinearSpaceToRef(convertedColor: Color3): Color3;
  70486. /**
  70487. * Computes a new Color3 converted from the current one to gamma space
  70488. * @returns a new Color3 object
  70489. */
  70490. toGammaSpace(): Color3;
  70491. /**
  70492. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  70493. * @param convertedColor defines the Color3 object where to store the gamma space version
  70494. * @returns the unmodified Color3
  70495. */
  70496. toGammaSpaceToRef(convertedColor: Color3): Color3;
  70497. private static _BlackReadOnly;
  70498. /**
  70499. * Convert Hue, saturation and value to a Color3 (RGB)
  70500. * @param hue defines the hue
  70501. * @param saturation defines the saturation
  70502. * @param value defines the value
  70503. * @param result defines the Color3 where to store the RGB values
  70504. */
  70505. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  70506. /**
  70507. * Creates a new Color3 from the string containing valid hexadecimal values
  70508. * @param hex defines a string containing valid hexadecimal values
  70509. * @returns a new Color3 object
  70510. */
  70511. static FromHexString(hex: string): Color3;
  70512. /**
  70513. * Creates a new Color3 from the starting index of the given array
  70514. * @param array defines the source array
  70515. * @param offset defines an offset in the source array
  70516. * @returns a new Color3 object
  70517. */
  70518. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  70519. /**
  70520. * Creates a new Color3 from integer values (< 256)
  70521. * @param r defines the red component to read from (value between 0 and 255)
  70522. * @param g defines the green component to read from (value between 0 and 255)
  70523. * @param b defines the blue component to read from (value between 0 and 255)
  70524. * @returns a new Color3 object
  70525. */
  70526. static FromInts(r: number, g: number, b: number): Color3;
  70527. /**
  70528. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  70529. * @param start defines the start Color3 value
  70530. * @param end defines the end Color3 value
  70531. * @param amount defines the gradient value between start and end
  70532. * @returns a new Color3 object
  70533. */
  70534. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  70535. /**
  70536. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  70537. * @param left defines the start value
  70538. * @param right defines the end value
  70539. * @param amount defines the gradient factor
  70540. * @param result defines the Color3 object where to store the result
  70541. */
  70542. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  70543. /**
  70544. * Returns a Color3 value containing a red color
  70545. * @returns a new Color3 object
  70546. */
  70547. static Red(): Color3;
  70548. /**
  70549. * Returns a Color3 value containing a green color
  70550. * @returns a new Color3 object
  70551. */
  70552. static Green(): Color3;
  70553. /**
  70554. * Returns a Color3 value containing a blue color
  70555. * @returns a new Color3 object
  70556. */
  70557. static Blue(): Color3;
  70558. /**
  70559. * Returns a Color3 value containing a black color
  70560. * @returns a new Color3 object
  70561. */
  70562. static Black(): Color3;
  70563. /**
  70564. * Gets a Color3 value containing a black color that must not be updated
  70565. */
  70566. static readonly BlackReadOnly: DeepImmutable<Color3>;
  70567. /**
  70568. * Returns a Color3 value containing a white color
  70569. * @returns a new Color3 object
  70570. */
  70571. static White(): Color3;
  70572. /**
  70573. * Returns a Color3 value containing a purple color
  70574. * @returns a new Color3 object
  70575. */
  70576. static Purple(): Color3;
  70577. /**
  70578. * Returns a Color3 value containing a magenta color
  70579. * @returns a new Color3 object
  70580. */
  70581. static Magenta(): Color3;
  70582. /**
  70583. * Returns a Color3 value containing a yellow color
  70584. * @returns a new Color3 object
  70585. */
  70586. static Yellow(): Color3;
  70587. /**
  70588. * Returns a Color3 value containing a gray color
  70589. * @returns a new Color3 object
  70590. */
  70591. static Gray(): Color3;
  70592. /**
  70593. * Returns a Color3 value containing a teal color
  70594. * @returns a new Color3 object
  70595. */
  70596. static Teal(): Color3;
  70597. /**
  70598. * Returns a Color3 value containing a random color
  70599. * @returns a new Color3 object
  70600. */
  70601. static Random(): Color3;
  70602. }
  70603. /**
  70604. * Class used to hold a RBGA color
  70605. */
  70606. export class Color4 {
  70607. /**
  70608. * Defines the red component (between 0 and 1, default is 0)
  70609. */
  70610. r: number;
  70611. /**
  70612. * Defines the green component (between 0 and 1, default is 0)
  70613. */
  70614. g: number;
  70615. /**
  70616. * Defines the blue component (between 0 and 1, default is 0)
  70617. */
  70618. b: number;
  70619. /**
  70620. * Defines the alpha component (between 0 and 1, default is 1)
  70621. */
  70622. a: number;
  70623. /**
  70624. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  70625. * @param r defines the red component (between 0 and 1, default is 0)
  70626. * @param g defines the green component (between 0 and 1, default is 0)
  70627. * @param b defines the blue component (between 0 and 1, default is 0)
  70628. * @param a defines the alpha component (between 0 and 1, default is 1)
  70629. */
  70630. constructor(
  70631. /**
  70632. * Defines the red component (between 0 and 1, default is 0)
  70633. */
  70634. r?: number,
  70635. /**
  70636. * Defines the green component (between 0 and 1, default is 0)
  70637. */
  70638. g?: number,
  70639. /**
  70640. * Defines the blue component (between 0 and 1, default is 0)
  70641. */
  70642. b?: number,
  70643. /**
  70644. * Defines the alpha component (between 0 and 1, default is 1)
  70645. */
  70646. a?: number);
  70647. /**
  70648. * Adds in place the given Color4 values to the current Color4 object
  70649. * @param right defines the second operand
  70650. * @returns the current updated Color4 object
  70651. */
  70652. addInPlace(right: DeepImmutable<Color4>): Color4;
  70653. /**
  70654. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  70655. * @returns the new array
  70656. */
  70657. asArray(): number[];
  70658. /**
  70659. * Stores from the starting index in the given array the Color4 successive values
  70660. * @param array defines the array where to store the r,g,b components
  70661. * @param index defines an optional index in the target array to define where to start storing values
  70662. * @returns the current Color4 object
  70663. */
  70664. toArray(array: number[], index?: number): Color4;
  70665. /**
  70666. * Determines equality between Color4 objects
  70667. * @param otherColor defines the second operand
  70668. * @returns true if the rgba values are equal to the given ones
  70669. */
  70670. equals(otherColor: DeepImmutable<Color4>): boolean;
  70671. /**
  70672. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  70673. * @param right defines the second operand
  70674. * @returns a new Color4 object
  70675. */
  70676. add(right: DeepImmutable<Color4>): Color4;
  70677. /**
  70678. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  70679. * @param right defines the second operand
  70680. * @returns a new Color4 object
  70681. */
  70682. subtract(right: DeepImmutable<Color4>): Color4;
  70683. /**
  70684. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  70685. * @param right defines the second operand
  70686. * @param result defines the Color4 object where to store the result
  70687. * @returns the current Color4 object
  70688. */
  70689. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  70690. /**
  70691. * Creates a new Color4 with the current Color4 values multiplied by scale
  70692. * @param scale defines the scaling factor to apply
  70693. * @returns a new Color4 object
  70694. */
  70695. scale(scale: number): Color4;
  70696. /**
  70697. * Multiplies the current Color4 values by scale and stores the result in "result"
  70698. * @param scale defines the scaling factor to apply
  70699. * @param result defines the Color4 object where to store the result
  70700. * @returns the current unmodified Color4
  70701. */
  70702. scaleToRef(scale: number, result: Color4): Color4;
  70703. /**
  70704. * Scale the current Color4 values by a factor and add the result to a given Color4
  70705. * @param scale defines the scale factor
  70706. * @param result defines the Color4 object where to store the result
  70707. * @returns the unmodified current Color4
  70708. */
  70709. scaleAndAddToRef(scale: number, result: Color4): Color4;
  70710. /**
  70711. * Clamps the rgb values by the min and max values and stores the result into "result"
  70712. * @param min defines minimum clamping value (default is 0)
  70713. * @param max defines maximum clamping value (default is 1)
  70714. * @param result defines color to store the result into.
  70715. * @returns the cuurent Color4
  70716. */
  70717. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  70718. /**
  70719. * Multipy an Color4 value by another and return a new Color4 object
  70720. * @param color defines the Color4 value to multiply by
  70721. * @returns a new Color4 object
  70722. */
  70723. multiply(color: Color4): Color4;
  70724. /**
  70725. * Multipy a Color4 value by another and push the result in a reference value
  70726. * @param color defines the Color4 value to multiply by
  70727. * @param result defines the Color4 to fill the result in
  70728. * @returns the result Color4
  70729. */
  70730. multiplyToRef(color: Color4, result: Color4): Color4;
  70731. /**
  70732. * Creates a string with the Color4 current values
  70733. * @returns the string representation of the Color4 object
  70734. */
  70735. toString(): string;
  70736. /**
  70737. * Returns the string "Color4"
  70738. * @returns "Color4"
  70739. */
  70740. getClassName(): string;
  70741. /**
  70742. * Compute the Color4 hash code
  70743. * @returns an unique number that can be used to hash Color4 objects
  70744. */
  70745. getHashCode(): number;
  70746. /**
  70747. * Creates a new Color4 copied from the current one
  70748. * @returns a new Color4 object
  70749. */
  70750. clone(): Color4;
  70751. /**
  70752. * Copies the given Color4 values into the current one
  70753. * @param source defines the source Color4 object
  70754. * @returns the current updated Color4 object
  70755. */
  70756. copyFrom(source: Color4): Color4;
  70757. /**
  70758. * Copies the given float values into the current one
  70759. * @param r defines the red component to read from
  70760. * @param g defines the green component to read from
  70761. * @param b defines the blue component to read from
  70762. * @param a defines the alpha component to read from
  70763. * @returns the current updated Color4 object
  70764. */
  70765. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  70766. /**
  70767. * Copies the given float values into the current one
  70768. * @param r defines the red component to read from
  70769. * @param g defines the green component to read from
  70770. * @param b defines the blue component to read from
  70771. * @param a defines the alpha component to read from
  70772. * @returns the current updated Color4 object
  70773. */
  70774. set(r: number, g: number, b: number, a: number): Color4;
  70775. /**
  70776. * Compute the Color4 hexadecimal code as a string
  70777. * @returns a string containing the hexadecimal representation of the Color4 object
  70778. */
  70779. toHexString(): string;
  70780. /**
  70781. * Computes a new Color4 converted from the current one to linear space
  70782. * @returns a new Color4 object
  70783. */
  70784. toLinearSpace(): Color4;
  70785. /**
  70786. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  70787. * @param convertedColor defines the Color4 object where to store the linear space version
  70788. * @returns the unmodified Color4
  70789. */
  70790. toLinearSpaceToRef(convertedColor: Color4): Color4;
  70791. /**
  70792. * Computes a new Color4 converted from the current one to gamma space
  70793. * @returns a new Color4 object
  70794. */
  70795. toGammaSpace(): Color4;
  70796. /**
  70797. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  70798. * @param convertedColor defines the Color4 object where to store the gamma space version
  70799. * @returns the unmodified Color4
  70800. */
  70801. toGammaSpaceToRef(convertedColor: Color4): Color4;
  70802. /**
  70803. * Creates a new Color4 from the string containing valid hexadecimal values
  70804. * @param hex defines a string containing valid hexadecimal values
  70805. * @returns a new Color4 object
  70806. */
  70807. static FromHexString(hex: string): Color4;
  70808. /**
  70809. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  70810. * @param left defines the start value
  70811. * @param right defines the end value
  70812. * @param amount defines the gradient factor
  70813. * @returns a new Color4 object
  70814. */
  70815. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  70816. /**
  70817. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  70818. * @param left defines the start value
  70819. * @param right defines the end value
  70820. * @param amount defines the gradient factor
  70821. * @param result defines the Color4 object where to store data
  70822. */
  70823. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  70824. /**
  70825. * Creates a new Color4 from a Color3 and an alpha value
  70826. * @param color3 defines the source Color3 to read from
  70827. * @param alpha defines the alpha component (1.0 by default)
  70828. * @returns a new Color4 object
  70829. */
  70830. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  70831. /**
  70832. * Creates a new Color4 from the starting index element of the given array
  70833. * @param array defines the source array to read from
  70834. * @param offset defines the offset in the source array
  70835. * @returns a new Color4 object
  70836. */
  70837. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  70838. /**
  70839. * Creates a new Color3 from integer values (< 256)
  70840. * @param r defines the red component to read from (value between 0 and 255)
  70841. * @param g defines the green component to read from (value between 0 and 255)
  70842. * @param b defines the blue component to read from (value between 0 and 255)
  70843. * @param a defines the alpha component to read from (value between 0 and 255)
  70844. * @returns a new Color3 object
  70845. */
  70846. static FromInts(r: number, g: number, b: number, a: number): Color4;
  70847. /**
  70848. * Check the content of a given array and convert it to an array containing RGBA data
  70849. * If the original array was already containing count * 4 values then it is returned directly
  70850. * @param colors defines the array to check
  70851. * @param count defines the number of RGBA data to expect
  70852. * @returns an array containing count * 4 values (RGBA)
  70853. */
  70854. static CheckColors4(colors: number[], count: number): number[];
  70855. }
  70856. /**
  70857. * @hidden
  70858. */
  70859. export class TmpColors {
  70860. static Color3: Color3[];
  70861. static Color4: Color4[];
  70862. }
  70863. }
  70864. declare module BABYLON {
  70865. /**
  70866. * Class representing spherical harmonics coefficients to the 3rd degree
  70867. */
  70868. export class SphericalHarmonics {
  70869. /**
  70870. * Defines whether or not the harmonics have been prescaled for rendering.
  70871. */
  70872. preScaled: boolean;
  70873. /**
  70874. * The l0,0 coefficients of the spherical harmonics
  70875. */
  70876. l00: Vector3;
  70877. /**
  70878. * The l1,-1 coefficients of the spherical harmonics
  70879. */
  70880. l1_1: Vector3;
  70881. /**
  70882. * The l1,0 coefficients of the spherical harmonics
  70883. */
  70884. l10: Vector3;
  70885. /**
  70886. * The l1,1 coefficients of the spherical harmonics
  70887. */
  70888. l11: Vector3;
  70889. /**
  70890. * The l2,-2 coefficients of the spherical harmonics
  70891. */
  70892. l2_2: Vector3;
  70893. /**
  70894. * The l2,-1 coefficients of the spherical harmonics
  70895. */
  70896. l2_1: Vector3;
  70897. /**
  70898. * The l2,0 coefficients of the spherical harmonics
  70899. */
  70900. l20: Vector3;
  70901. /**
  70902. * The l2,1 coefficients of the spherical harmonics
  70903. */
  70904. l21: Vector3;
  70905. /**
  70906. * The l2,2 coefficients of the spherical harmonics
  70907. */
  70908. l22: Vector3;
  70909. /**
  70910. * Adds a light to the spherical harmonics
  70911. * @param direction the direction of the light
  70912. * @param color the color of the light
  70913. * @param deltaSolidAngle the delta solid angle of the light
  70914. */
  70915. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  70916. /**
  70917. * Scales the spherical harmonics by the given amount
  70918. * @param scale the amount to scale
  70919. */
  70920. scaleInPlace(scale: number): void;
  70921. /**
  70922. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  70923. *
  70924. * ```
  70925. * E_lm = A_l * L_lm
  70926. * ```
  70927. *
  70928. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  70929. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  70930. * the scaling factors are given in equation 9.
  70931. */
  70932. convertIncidentRadianceToIrradiance(): void;
  70933. /**
  70934. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  70935. *
  70936. * ```
  70937. * L = (1/pi) * E * rho
  70938. * ```
  70939. *
  70940. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  70941. */
  70942. convertIrradianceToLambertianRadiance(): void;
  70943. /**
  70944. * Integrates the reconstruction coefficients directly in to the SH preventing further
  70945. * required operations at run time.
  70946. *
  70947. * This is simply done by scaling back the SH with Ylm constants parameter.
  70948. * The trigonometric part being applied by the shader at run time.
  70949. */
  70950. preScaleForRendering(): void;
  70951. /**
  70952. * Constructs a spherical harmonics from an array.
  70953. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  70954. * @returns the spherical harmonics
  70955. */
  70956. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  70957. /**
  70958. * Gets the spherical harmonics from polynomial
  70959. * @param polynomial the spherical polynomial
  70960. * @returns the spherical harmonics
  70961. */
  70962. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  70963. }
  70964. /**
  70965. * Class representing spherical polynomial coefficients to the 3rd degree
  70966. */
  70967. export class SphericalPolynomial {
  70968. private _harmonics;
  70969. /**
  70970. * The spherical harmonics used to create the polynomials.
  70971. */
  70972. readonly preScaledHarmonics: SphericalHarmonics;
  70973. /**
  70974. * The x coefficients of the spherical polynomial
  70975. */
  70976. x: Vector3;
  70977. /**
  70978. * The y coefficients of the spherical polynomial
  70979. */
  70980. y: Vector3;
  70981. /**
  70982. * The z coefficients of the spherical polynomial
  70983. */
  70984. z: Vector3;
  70985. /**
  70986. * The xx coefficients of the spherical polynomial
  70987. */
  70988. xx: Vector3;
  70989. /**
  70990. * The yy coefficients of the spherical polynomial
  70991. */
  70992. yy: Vector3;
  70993. /**
  70994. * The zz coefficients of the spherical polynomial
  70995. */
  70996. zz: Vector3;
  70997. /**
  70998. * The xy coefficients of the spherical polynomial
  70999. */
  71000. xy: Vector3;
  71001. /**
  71002. * The yz coefficients of the spherical polynomial
  71003. */
  71004. yz: Vector3;
  71005. /**
  71006. * The zx coefficients of the spherical polynomial
  71007. */
  71008. zx: Vector3;
  71009. /**
  71010. * Adds an ambient color to the spherical polynomial
  71011. * @param color the color to add
  71012. */
  71013. addAmbient(color: Color3): void;
  71014. /**
  71015. * Scales the spherical polynomial by the given amount
  71016. * @param scale the amount to scale
  71017. */
  71018. scaleInPlace(scale: number): void;
  71019. /**
  71020. * Gets the spherical polynomial from harmonics
  71021. * @param harmonics the spherical harmonics
  71022. * @returns the spherical polynomial
  71023. */
  71024. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  71025. /**
  71026. * Constructs a spherical polynomial from an array.
  71027. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  71028. * @returns the spherical polynomial
  71029. */
  71030. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  71031. }
  71032. }
  71033. declare module BABYLON {
  71034. /**
  71035. * Define options used to create a render target texture
  71036. */
  71037. export class RenderTargetCreationOptions {
  71038. /**
  71039. * Specifies is mipmaps must be generated
  71040. */
  71041. generateMipMaps?: boolean;
  71042. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  71043. generateDepthBuffer?: boolean;
  71044. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  71045. generateStencilBuffer?: boolean;
  71046. /** Defines texture type (int by default) */
  71047. type?: number;
  71048. /** Defines sampling mode (trilinear by default) */
  71049. samplingMode?: number;
  71050. /** Defines format (RGBA by default) */
  71051. format?: number;
  71052. }
  71053. }
  71054. declare module BABYLON {
  71055. /**
  71056. * @hidden
  71057. **/
  71058. export class _AlphaState {
  71059. private _isAlphaBlendDirty;
  71060. private _isBlendFunctionParametersDirty;
  71061. private _isBlendEquationParametersDirty;
  71062. private _isBlendConstantsDirty;
  71063. private _alphaBlend;
  71064. private _blendFunctionParameters;
  71065. private _blendEquationParameters;
  71066. private _blendConstants;
  71067. /**
  71068. * Initializes the state.
  71069. */
  71070. constructor();
  71071. readonly isDirty: boolean;
  71072. alphaBlend: boolean;
  71073. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  71074. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  71075. setAlphaEquationParameters(rgb: number, alpha: number): void;
  71076. reset(): void;
  71077. apply(gl: WebGLRenderingContext): void;
  71078. }
  71079. }
  71080. declare module BABYLON {
  71081. /**
  71082. * @hidden
  71083. **/
  71084. export class _DepthCullingState {
  71085. private _isDepthTestDirty;
  71086. private _isDepthMaskDirty;
  71087. private _isDepthFuncDirty;
  71088. private _isCullFaceDirty;
  71089. private _isCullDirty;
  71090. private _isZOffsetDirty;
  71091. private _isFrontFaceDirty;
  71092. private _depthTest;
  71093. private _depthMask;
  71094. private _depthFunc;
  71095. private _cull;
  71096. private _cullFace;
  71097. private _zOffset;
  71098. private _frontFace;
  71099. /**
  71100. * Initializes the state.
  71101. */
  71102. constructor();
  71103. readonly isDirty: boolean;
  71104. zOffset: number;
  71105. cullFace: Nullable<number>;
  71106. cull: Nullable<boolean>;
  71107. depthFunc: Nullable<number>;
  71108. depthMask: boolean;
  71109. depthTest: boolean;
  71110. frontFace: Nullable<number>;
  71111. reset(): void;
  71112. apply(gl: WebGLRenderingContext): void;
  71113. }
  71114. }
  71115. declare module BABYLON {
  71116. /**
  71117. * @hidden
  71118. **/
  71119. export class _StencilState {
  71120. /** 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 */
  71121. static readonly ALWAYS: number;
  71122. /** Passed to stencilOperation to specify that stencil value must be kept */
  71123. static readonly KEEP: number;
  71124. /** Passed to stencilOperation to specify that stencil value must be replaced */
  71125. static readonly REPLACE: number;
  71126. private _isStencilTestDirty;
  71127. private _isStencilMaskDirty;
  71128. private _isStencilFuncDirty;
  71129. private _isStencilOpDirty;
  71130. private _stencilTest;
  71131. private _stencilMask;
  71132. private _stencilFunc;
  71133. private _stencilFuncRef;
  71134. private _stencilFuncMask;
  71135. private _stencilOpStencilFail;
  71136. private _stencilOpDepthFail;
  71137. private _stencilOpStencilDepthPass;
  71138. readonly isDirty: boolean;
  71139. stencilFunc: number;
  71140. stencilFuncRef: number;
  71141. stencilFuncMask: number;
  71142. stencilOpStencilFail: number;
  71143. stencilOpDepthFail: number;
  71144. stencilOpStencilDepthPass: number;
  71145. stencilMask: number;
  71146. stencilTest: boolean;
  71147. constructor();
  71148. reset(): void;
  71149. apply(gl: WebGLRenderingContext): void;
  71150. }
  71151. }
  71152. declare module BABYLON {
  71153. /**
  71154. * @hidden
  71155. **/
  71156. export class _TimeToken {
  71157. _startTimeQuery: Nullable<WebGLQuery>;
  71158. _endTimeQuery: Nullable<WebGLQuery>;
  71159. _timeElapsedQuery: Nullable<WebGLQuery>;
  71160. _timeElapsedQueryEnded: boolean;
  71161. }
  71162. }
  71163. declare module BABYLON {
  71164. /**
  71165. * Class used to evalaute queries containing `and` and `or` operators
  71166. */
  71167. export class AndOrNotEvaluator {
  71168. /**
  71169. * Evaluate a query
  71170. * @param query defines the query to evaluate
  71171. * @param evaluateCallback defines the callback used to filter result
  71172. * @returns true if the query matches
  71173. */
  71174. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  71175. private static _HandleParenthesisContent;
  71176. private static _SimplifyNegation;
  71177. }
  71178. }
  71179. declare module BABYLON {
  71180. /**
  71181. * Class used to store custom tags
  71182. */
  71183. export class Tags {
  71184. /**
  71185. * Adds support for tags on the given object
  71186. * @param obj defines the object to use
  71187. */
  71188. static EnableFor(obj: any): void;
  71189. /**
  71190. * Removes tags support
  71191. * @param obj defines the object to use
  71192. */
  71193. static DisableFor(obj: any): void;
  71194. /**
  71195. * Gets a boolean indicating if the given object has tags
  71196. * @param obj defines the object to use
  71197. * @returns a boolean
  71198. */
  71199. static HasTags(obj: any): boolean;
  71200. /**
  71201. * Gets the tags available on a given object
  71202. * @param obj defines the object to use
  71203. * @param asString defines if the tags must be returned as a string instead of an array of strings
  71204. * @returns the tags
  71205. */
  71206. static GetTags(obj: any, asString?: boolean): any;
  71207. /**
  71208. * Adds tags to an object
  71209. * @param obj defines the object to use
  71210. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  71211. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  71212. */
  71213. static AddTagsTo(obj: any, tagsString: string): void;
  71214. /**
  71215. * @hidden
  71216. */
  71217. static _AddTagTo(obj: any, tag: string): void;
  71218. /**
  71219. * Removes specific tags from a specific object
  71220. * @param obj defines the object to use
  71221. * @param tagsString defines the tags to remove
  71222. */
  71223. static RemoveTagsFrom(obj: any, tagsString: string): void;
  71224. /**
  71225. * @hidden
  71226. */
  71227. static _RemoveTagFrom(obj: any, tag: string): void;
  71228. /**
  71229. * Defines if tags hosted on an object match a given query
  71230. * @param obj defines the object to use
  71231. * @param tagsQuery defines the tag query
  71232. * @returns a boolean
  71233. */
  71234. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  71235. }
  71236. }
  71237. declare module BABYLON {
  71238. /**
  71239. * Defines potential orientation for back face culling
  71240. */
  71241. export enum Orientation {
  71242. /**
  71243. * Clockwise
  71244. */
  71245. CW = 0,
  71246. /** Counter clockwise */
  71247. CCW = 1
  71248. }
  71249. /** Class used to represent a Bezier curve */
  71250. export class BezierCurve {
  71251. /**
  71252. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  71253. * @param t defines the time
  71254. * @param x1 defines the left coordinate on X axis
  71255. * @param y1 defines the left coordinate on Y axis
  71256. * @param x2 defines the right coordinate on X axis
  71257. * @param y2 defines the right coordinate on Y axis
  71258. * @returns the interpolated value
  71259. */
  71260. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  71261. }
  71262. /**
  71263. * Defines angle representation
  71264. */
  71265. export class Angle {
  71266. private _radians;
  71267. /**
  71268. * Creates an Angle object of "radians" radians (float).
  71269. * @param radians the angle in radians
  71270. */
  71271. constructor(radians: number);
  71272. /**
  71273. * Get value in degrees
  71274. * @returns the Angle value in degrees (float)
  71275. */
  71276. degrees(): number;
  71277. /**
  71278. * Get value in radians
  71279. * @returns the Angle value in radians (float)
  71280. */
  71281. radians(): number;
  71282. /**
  71283. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  71284. * @param a defines first vector
  71285. * @param b defines second vector
  71286. * @returns a new Angle
  71287. */
  71288. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  71289. /**
  71290. * Gets a new Angle object from the given float in radians
  71291. * @param radians defines the angle value in radians
  71292. * @returns a new Angle
  71293. */
  71294. static FromRadians(radians: number): Angle;
  71295. /**
  71296. * Gets a new Angle object from the given float in degrees
  71297. * @param degrees defines the angle value in degrees
  71298. * @returns a new Angle
  71299. */
  71300. static FromDegrees(degrees: number): Angle;
  71301. }
  71302. /**
  71303. * This represents an arc in a 2d space.
  71304. */
  71305. export class Arc2 {
  71306. /** Defines the start point of the arc */
  71307. startPoint: Vector2;
  71308. /** Defines the mid point of the arc */
  71309. midPoint: Vector2;
  71310. /** Defines the end point of the arc */
  71311. endPoint: Vector2;
  71312. /**
  71313. * Defines the center point of the arc.
  71314. */
  71315. centerPoint: Vector2;
  71316. /**
  71317. * Defines the radius of the arc.
  71318. */
  71319. radius: number;
  71320. /**
  71321. * Defines the angle of the arc (from mid point to end point).
  71322. */
  71323. angle: Angle;
  71324. /**
  71325. * Defines the start angle of the arc (from start point to middle point).
  71326. */
  71327. startAngle: Angle;
  71328. /**
  71329. * Defines the orientation of the arc (clock wise/counter clock wise).
  71330. */
  71331. orientation: Orientation;
  71332. /**
  71333. * Creates an Arc object from the three given points : start, middle and end.
  71334. * @param startPoint Defines the start point of the arc
  71335. * @param midPoint Defines the midlle point of the arc
  71336. * @param endPoint Defines the end point of the arc
  71337. */
  71338. constructor(
  71339. /** Defines the start point of the arc */
  71340. startPoint: Vector2,
  71341. /** Defines the mid point of the arc */
  71342. midPoint: Vector2,
  71343. /** Defines the end point of the arc */
  71344. endPoint: Vector2);
  71345. }
  71346. /**
  71347. * Represents a 2D path made up of multiple 2D points
  71348. */
  71349. export class Path2 {
  71350. private _points;
  71351. private _length;
  71352. /**
  71353. * If the path start and end point are the same
  71354. */
  71355. closed: boolean;
  71356. /**
  71357. * Creates a Path2 object from the starting 2D coordinates x and y.
  71358. * @param x the starting points x value
  71359. * @param y the starting points y value
  71360. */
  71361. constructor(x: number, y: number);
  71362. /**
  71363. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  71364. * @param x the added points x value
  71365. * @param y the added points y value
  71366. * @returns the updated Path2.
  71367. */
  71368. addLineTo(x: number, y: number): Path2;
  71369. /**
  71370. * 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.
  71371. * @param midX middle point x value
  71372. * @param midY middle point y value
  71373. * @param endX end point x value
  71374. * @param endY end point y value
  71375. * @param numberOfSegments (default: 36)
  71376. * @returns the updated Path2.
  71377. */
  71378. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  71379. /**
  71380. * Closes the Path2.
  71381. * @returns the Path2.
  71382. */
  71383. close(): Path2;
  71384. /**
  71385. * Gets the sum of the distance between each sequential point in the path
  71386. * @returns the Path2 total length (float).
  71387. */
  71388. length(): number;
  71389. /**
  71390. * Gets the points which construct the path
  71391. * @returns the Path2 internal array of points.
  71392. */
  71393. getPoints(): Vector2[];
  71394. /**
  71395. * Retreives the point at the distance aways from the starting point
  71396. * @param normalizedLengthPosition the length along the path to retreive the point from
  71397. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  71398. */
  71399. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  71400. /**
  71401. * Creates a new path starting from an x and y position
  71402. * @param x starting x value
  71403. * @param y starting y value
  71404. * @returns a new Path2 starting at the coordinates (x, y).
  71405. */
  71406. static StartingAt(x: number, y: number): Path2;
  71407. }
  71408. /**
  71409. * Represents a 3D path made up of multiple 3D points
  71410. */
  71411. export class Path3D {
  71412. /**
  71413. * an array of Vector3, the curve axis of the Path3D
  71414. */
  71415. path: Vector3[];
  71416. private _curve;
  71417. private _distances;
  71418. private _tangents;
  71419. private _normals;
  71420. private _binormals;
  71421. private _raw;
  71422. /**
  71423. * new Path3D(path, normal, raw)
  71424. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  71425. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  71426. * @param path an array of Vector3, the curve axis of the Path3D
  71427. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  71428. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  71429. */
  71430. constructor(
  71431. /**
  71432. * an array of Vector3, the curve axis of the Path3D
  71433. */
  71434. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean);
  71435. /**
  71436. * Returns the Path3D array of successive Vector3 designing its curve.
  71437. * @returns the Path3D array of successive Vector3 designing its curve.
  71438. */
  71439. getCurve(): Vector3[];
  71440. /**
  71441. * Returns an array populated with tangent vectors on each Path3D curve point.
  71442. * @returns an array populated with tangent vectors on each Path3D curve point.
  71443. */
  71444. getTangents(): Vector3[];
  71445. /**
  71446. * Returns an array populated with normal vectors on each Path3D curve point.
  71447. * @returns an array populated with normal vectors on each Path3D curve point.
  71448. */
  71449. getNormals(): Vector3[];
  71450. /**
  71451. * Returns an array populated with binormal vectors on each Path3D curve point.
  71452. * @returns an array populated with binormal vectors on each Path3D curve point.
  71453. */
  71454. getBinormals(): Vector3[];
  71455. /**
  71456. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  71457. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  71458. */
  71459. getDistances(): number[];
  71460. /**
  71461. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  71462. * @param path path which all values are copied into the curves points
  71463. * @param firstNormal which should be projected onto the curve
  71464. * @returns the same object updated.
  71465. */
  71466. update(path: Vector3[], firstNormal?: Nullable<Vector3>): Path3D;
  71467. private _compute;
  71468. private _getFirstNonNullVector;
  71469. private _getLastNonNullVector;
  71470. private _normalVector;
  71471. }
  71472. /**
  71473. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  71474. * A Curve3 is designed from a series of successive Vector3.
  71475. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  71476. */
  71477. export class Curve3 {
  71478. private _points;
  71479. private _length;
  71480. /**
  71481. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  71482. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  71483. * @param v1 (Vector3) the control point
  71484. * @param v2 (Vector3) the end point of the Quadratic Bezier
  71485. * @param nbPoints (integer) the wanted number of points in the curve
  71486. * @returns the created Curve3
  71487. */
  71488. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  71489. /**
  71490. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  71491. * @param v0 (Vector3) the origin point of the Cubic Bezier
  71492. * @param v1 (Vector3) the first control point
  71493. * @param v2 (Vector3) the second control point
  71494. * @param v3 (Vector3) the end point of the Cubic Bezier
  71495. * @param nbPoints (integer) the wanted number of points in the curve
  71496. * @returns the created Curve3
  71497. */
  71498. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  71499. /**
  71500. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  71501. * @param p1 (Vector3) the origin point of the Hermite Spline
  71502. * @param t1 (Vector3) the tangent vector at the origin point
  71503. * @param p2 (Vector3) the end point of the Hermite Spline
  71504. * @param t2 (Vector3) the tangent vector at the end point
  71505. * @param nbPoints (integer) the wanted number of points in the curve
  71506. * @returns the created Curve3
  71507. */
  71508. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  71509. /**
  71510. * Returns a Curve3 object along a CatmullRom Spline curve :
  71511. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  71512. * @param nbPoints (integer) the wanted number of points between each curve control points
  71513. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  71514. * @returns the created Curve3
  71515. */
  71516. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  71517. /**
  71518. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  71519. * A Curve3 is designed from a series of successive Vector3.
  71520. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  71521. * @param points points which make up the curve
  71522. */
  71523. constructor(points: Vector3[]);
  71524. /**
  71525. * @returns the Curve3 stored array of successive Vector3
  71526. */
  71527. getPoints(): Vector3[];
  71528. /**
  71529. * @returns the computed length (float) of the curve.
  71530. */
  71531. length(): number;
  71532. /**
  71533. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  71534. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  71535. * curveA and curveB keep unchanged.
  71536. * @param curve the curve to continue from this curve
  71537. * @returns the newly constructed curve
  71538. */
  71539. continue(curve: DeepImmutable<Curve3>): Curve3;
  71540. private _computeLength;
  71541. }
  71542. }
  71543. declare module BABYLON {
  71544. /**
  71545. * This represents the main contract an easing function should follow.
  71546. * Easing functions are used throughout the animation system.
  71547. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  71548. */
  71549. export interface IEasingFunction {
  71550. /**
  71551. * Given an input gradient between 0 and 1, this returns the corrseponding value
  71552. * of the easing function.
  71553. * The link below provides some of the most common examples of easing functions.
  71554. * @see https://easings.net/
  71555. * @param gradient Defines the value between 0 and 1 we want the easing value for
  71556. * @returns the corresponding value on the curve defined by the easing function
  71557. */
  71558. ease(gradient: number): number;
  71559. }
  71560. /**
  71561. * Base class used for every default easing function.
  71562. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  71563. */
  71564. export class EasingFunction implements IEasingFunction {
  71565. /**
  71566. * Interpolation follows the mathematical formula associated with the easing function.
  71567. */
  71568. static readonly EASINGMODE_EASEIN: number;
  71569. /**
  71570. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  71571. */
  71572. static readonly EASINGMODE_EASEOUT: number;
  71573. /**
  71574. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  71575. */
  71576. static readonly EASINGMODE_EASEINOUT: number;
  71577. private _easingMode;
  71578. /**
  71579. * Sets the easing mode of the current function.
  71580. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  71581. */
  71582. setEasingMode(easingMode: number): void;
  71583. /**
  71584. * Gets the current easing mode.
  71585. * @returns the easing mode
  71586. */
  71587. getEasingMode(): number;
  71588. /**
  71589. * @hidden
  71590. */
  71591. easeInCore(gradient: number): number;
  71592. /**
  71593. * Given an input gradient between 0 and 1, this returns the corresponding value
  71594. * of the easing function.
  71595. * @param gradient Defines the value between 0 and 1 we want the easing value for
  71596. * @returns the corresponding value on the curve defined by the easing function
  71597. */
  71598. ease(gradient: number): number;
  71599. }
  71600. /**
  71601. * Easing function with a circle shape (see link below).
  71602. * @see https://easings.net/#easeInCirc
  71603. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  71604. */
  71605. export class CircleEase extends EasingFunction implements IEasingFunction {
  71606. /** @hidden */
  71607. easeInCore(gradient: number): number;
  71608. }
  71609. /**
  71610. * Easing function with a ease back shape (see link below).
  71611. * @see https://easings.net/#easeInBack
  71612. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  71613. */
  71614. export class BackEase extends EasingFunction implements IEasingFunction {
  71615. /** Defines the amplitude of the function */
  71616. amplitude: number;
  71617. /**
  71618. * Instantiates a back ease easing
  71619. * @see https://easings.net/#easeInBack
  71620. * @param amplitude Defines the amplitude of the function
  71621. */
  71622. constructor(
  71623. /** Defines the amplitude of the function */
  71624. amplitude?: number);
  71625. /** @hidden */
  71626. easeInCore(gradient: number): number;
  71627. }
  71628. /**
  71629. * Easing function with a bouncing shape (see link below).
  71630. * @see https://easings.net/#easeInBounce
  71631. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  71632. */
  71633. export class BounceEase extends EasingFunction implements IEasingFunction {
  71634. /** Defines the number of bounces */
  71635. bounces: number;
  71636. /** Defines the amplitude of the bounce */
  71637. bounciness: number;
  71638. /**
  71639. * Instantiates a bounce easing
  71640. * @see https://easings.net/#easeInBounce
  71641. * @param bounces Defines the number of bounces
  71642. * @param bounciness Defines the amplitude of the bounce
  71643. */
  71644. constructor(
  71645. /** Defines the number of bounces */
  71646. bounces?: number,
  71647. /** Defines the amplitude of the bounce */
  71648. bounciness?: number);
  71649. /** @hidden */
  71650. easeInCore(gradient: number): number;
  71651. }
  71652. /**
  71653. * Easing function with a power of 3 shape (see link below).
  71654. * @see https://easings.net/#easeInCubic
  71655. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  71656. */
  71657. export class CubicEase extends EasingFunction implements IEasingFunction {
  71658. /** @hidden */
  71659. easeInCore(gradient: number): number;
  71660. }
  71661. /**
  71662. * Easing function with an elastic shape (see link below).
  71663. * @see https://easings.net/#easeInElastic
  71664. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  71665. */
  71666. export class ElasticEase extends EasingFunction implements IEasingFunction {
  71667. /** Defines the number of oscillations*/
  71668. oscillations: number;
  71669. /** Defines the amplitude of the oscillations*/
  71670. springiness: number;
  71671. /**
  71672. * Instantiates an elastic easing function
  71673. * @see https://easings.net/#easeInElastic
  71674. * @param oscillations Defines the number of oscillations
  71675. * @param springiness Defines the amplitude of the oscillations
  71676. */
  71677. constructor(
  71678. /** Defines the number of oscillations*/
  71679. oscillations?: number,
  71680. /** Defines the amplitude of the oscillations*/
  71681. springiness?: number);
  71682. /** @hidden */
  71683. easeInCore(gradient: number): number;
  71684. }
  71685. /**
  71686. * Easing function with an exponential shape (see link below).
  71687. * @see https://easings.net/#easeInExpo
  71688. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  71689. */
  71690. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  71691. /** Defines the exponent of the function */
  71692. exponent: number;
  71693. /**
  71694. * Instantiates an exponential easing function
  71695. * @see https://easings.net/#easeInExpo
  71696. * @param exponent Defines the exponent of the function
  71697. */
  71698. constructor(
  71699. /** Defines the exponent of the function */
  71700. exponent?: number);
  71701. /** @hidden */
  71702. easeInCore(gradient: number): number;
  71703. }
  71704. /**
  71705. * Easing function with a power shape (see link below).
  71706. * @see https://easings.net/#easeInQuad
  71707. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  71708. */
  71709. export class PowerEase extends EasingFunction implements IEasingFunction {
  71710. /** Defines the power of the function */
  71711. power: number;
  71712. /**
  71713. * Instantiates an power base easing function
  71714. * @see https://easings.net/#easeInQuad
  71715. * @param power Defines the power of the function
  71716. */
  71717. constructor(
  71718. /** Defines the power of the function */
  71719. power?: number);
  71720. /** @hidden */
  71721. easeInCore(gradient: number): number;
  71722. }
  71723. /**
  71724. * Easing function with a power of 2 shape (see link below).
  71725. * @see https://easings.net/#easeInQuad
  71726. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  71727. */
  71728. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  71729. /** @hidden */
  71730. easeInCore(gradient: number): number;
  71731. }
  71732. /**
  71733. * Easing function with a power of 4 shape (see link below).
  71734. * @see https://easings.net/#easeInQuart
  71735. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  71736. */
  71737. export class QuarticEase extends EasingFunction implements IEasingFunction {
  71738. /** @hidden */
  71739. easeInCore(gradient: number): number;
  71740. }
  71741. /**
  71742. * Easing function with a power of 5 shape (see link below).
  71743. * @see https://easings.net/#easeInQuint
  71744. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  71745. */
  71746. export class QuinticEase extends EasingFunction implements IEasingFunction {
  71747. /** @hidden */
  71748. easeInCore(gradient: number): number;
  71749. }
  71750. /**
  71751. * Easing function with a sin shape (see link below).
  71752. * @see https://easings.net/#easeInSine
  71753. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  71754. */
  71755. export class SineEase extends EasingFunction implements IEasingFunction {
  71756. /** @hidden */
  71757. easeInCore(gradient: number): number;
  71758. }
  71759. /**
  71760. * Easing function with a bezier shape (see link below).
  71761. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  71762. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  71763. */
  71764. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  71765. /** Defines the x component of the start tangent in the bezier curve */
  71766. x1: number;
  71767. /** Defines the y component of the start tangent in the bezier curve */
  71768. y1: number;
  71769. /** Defines the x component of the end tangent in the bezier curve */
  71770. x2: number;
  71771. /** Defines the y component of the end tangent in the bezier curve */
  71772. y2: number;
  71773. /**
  71774. * Instantiates a bezier function
  71775. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  71776. * @param x1 Defines the x component of the start tangent in the bezier curve
  71777. * @param y1 Defines the y component of the start tangent in the bezier curve
  71778. * @param x2 Defines the x component of the end tangent in the bezier curve
  71779. * @param y2 Defines the y component of the end tangent in the bezier curve
  71780. */
  71781. constructor(
  71782. /** Defines the x component of the start tangent in the bezier curve */
  71783. x1?: number,
  71784. /** Defines the y component of the start tangent in the bezier curve */
  71785. y1?: number,
  71786. /** Defines the x component of the end tangent in the bezier curve */
  71787. x2?: number,
  71788. /** Defines the y component of the end tangent in the bezier curve */
  71789. y2?: number);
  71790. /** @hidden */
  71791. easeInCore(gradient: number): number;
  71792. }
  71793. }
  71794. declare module BABYLON {
  71795. /**
  71796. * Defines an interface which represents an animation key frame
  71797. */
  71798. export interface IAnimationKey {
  71799. /**
  71800. * Frame of the key frame
  71801. */
  71802. frame: number;
  71803. /**
  71804. * Value at the specifies key frame
  71805. */
  71806. value: any;
  71807. /**
  71808. * The input tangent for the cubic hermite spline
  71809. */
  71810. inTangent?: any;
  71811. /**
  71812. * The output tangent for the cubic hermite spline
  71813. */
  71814. outTangent?: any;
  71815. /**
  71816. * The animation interpolation type
  71817. */
  71818. interpolation?: AnimationKeyInterpolation;
  71819. }
  71820. /**
  71821. * Enum for the animation key frame interpolation type
  71822. */
  71823. export enum AnimationKeyInterpolation {
  71824. /**
  71825. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  71826. */
  71827. STEP = 1
  71828. }
  71829. }
  71830. declare module BABYLON {
  71831. /**
  71832. * Represents the range of an animation
  71833. */
  71834. export class AnimationRange {
  71835. /**The name of the animation range**/
  71836. name: string;
  71837. /**The starting frame of the animation */
  71838. from: number;
  71839. /**The ending frame of the animation*/
  71840. to: number;
  71841. /**
  71842. * Initializes the range of an animation
  71843. * @param name The name of the animation range
  71844. * @param from The starting frame of the animation
  71845. * @param to The ending frame of the animation
  71846. */
  71847. constructor(
  71848. /**The name of the animation range**/
  71849. name: string,
  71850. /**The starting frame of the animation */
  71851. from: number,
  71852. /**The ending frame of the animation*/
  71853. to: number);
  71854. /**
  71855. * Makes a copy of the animation range
  71856. * @returns A copy of the animation range
  71857. */
  71858. clone(): AnimationRange;
  71859. }
  71860. }
  71861. declare module BABYLON {
  71862. /**
  71863. * Composed of a frame, and an action function
  71864. */
  71865. export class AnimationEvent {
  71866. /** The frame for which the event is triggered **/
  71867. frame: number;
  71868. /** The event to perform when triggered **/
  71869. action: (currentFrame: number) => void;
  71870. /** Specifies if the event should be triggered only once**/
  71871. onlyOnce?: boolean | undefined;
  71872. /**
  71873. * Specifies if the animation event is done
  71874. */
  71875. isDone: boolean;
  71876. /**
  71877. * Initializes the animation event
  71878. * @param frame The frame for which the event is triggered
  71879. * @param action The event to perform when triggered
  71880. * @param onlyOnce Specifies if the event should be triggered only once
  71881. */
  71882. constructor(
  71883. /** The frame for which the event is triggered **/
  71884. frame: number,
  71885. /** The event to perform when triggered **/
  71886. action: (currentFrame: number) => void,
  71887. /** Specifies if the event should be triggered only once**/
  71888. onlyOnce?: boolean | undefined);
  71889. /** @hidden */
  71890. _clone(): AnimationEvent;
  71891. }
  71892. }
  71893. declare module BABYLON {
  71894. /**
  71895. * Interface used to define a behavior
  71896. */
  71897. export interface Behavior<T> {
  71898. /** gets or sets behavior's name */
  71899. name: string;
  71900. /**
  71901. * Function called when the behavior needs to be initialized (after attaching it to a target)
  71902. */
  71903. init(): void;
  71904. /**
  71905. * Called when the behavior is attached to a target
  71906. * @param target defines the target where the behavior is attached to
  71907. */
  71908. attach(target: T): void;
  71909. /**
  71910. * Called when the behavior is detached from its target
  71911. */
  71912. detach(): void;
  71913. }
  71914. /**
  71915. * Interface implemented by classes supporting behaviors
  71916. */
  71917. export interface IBehaviorAware<T> {
  71918. /**
  71919. * Attach a behavior
  71920. * @param behavior defines the behavior to attach
  71921. * @returns the current host
  71922. */
  71923. addBehavior(behavior: Behavior<T>): T;
  71924. /**
  71925. * Remove a behavior from the current object
  71926. * @param behavior defines the behavior to detach
  71927. * @returns the current host
  71928. */
  71929. removeBehavior(behavior: Behavior<T>): T;
  71930. /**
  71931. * Gets a behavior using its name to search
  71932. * @param name defines the name to search
  71933. * @returns the behavior or null if not found
  71934. */
  71935. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  71936. }
  71937. }
  71938. declare module BABYLON {
  71939. /**
  71940. * Defines an array and its length.
  71941. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  71942. */
  71943. export interface ISmartArrayLike<T> {
  71944. /**
  71945. * The data of the array.
  71946. */
  71947. data: Array<T>;
  71948. /**
  71949. * The active length of the array.
  71950. */
  71951. length: number;
  71952. }
  71953. /**
  71954. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  71955. */
  71956. export class SmartArray<T> implements ISmartArrayLike<T> {
  71957. /**
  71958. * The full set of data from the array.
  71959. */
  71960. data: Array<T>;
  71961. /**
  71962. * The active length of the array.
  71963. */
  71964. length: number;
  71965. protected _id: number;
  71966. /**
  71967. * Instantiates a Smart Array.
  71968. * @param capacity defines the default capacity of the array.
  71969. */
  71970. constructor(capacity: number);
  71971. /**
  71972. * Pushes a value at the end of the active data.
  71973. * @param value defines the object to push in the array.
  71974. */
  71975. push(value: T): void;
  71976. /**
  71977. * Iterates over the active data and apply the lambda to them.
  71978. * @param func defines the action to apply on each value.
  71979. */
  71980. forEach(func: (content: T) => void): void;
  71981. /**
  71982. * Sorts the full sets of data.
  71983. * @param compareFn defines the comparison function to apply.
  71984. */
  71985. sort(compareFn: (a: T, b: T) => number): void;
  71986. /**
  71987. * Resets the active data to an empty array.
  71988. */
  71989. reset(): void;
  71990. /**
  71991. * Releases all the data from the array as well as the array.
  71992. */
  71993. dispose(): void;
  71994. /**
  71995. * Concats the active data with a given array.
  71996. * @param array defines the data to concatenate with.
  71997. */
  71998. concat(array: any): void;
  71999. /**
  72000. * Returns the position of a value in the active data.
  72001. * @param value defines the value to find the index for
  72002. * @returns the index if found in the active data otherwise -1
  72003. */
  72004. indexOf(value: T): number;
  72005. /**
  72006. * Returns whether an element is part of the active data.
  72007. * @param value defines the value to look for
  72008. * @returns true if found in the active data otherwise false
  72009. */
  72010. contains(value: T): boolean;
  72011. private static _GlobalId;
  72012. }
  72013. /**
  72014. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  72015. * The data in this array can only be present once
  72016. */
  72017. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  72018. private _duplicateId;
  72019. /**
  72020. * Pushes a value at the end of the active data.
  72021. * THIS DOES NOT PREVENT DUPPLICATE DATA
  72022. * @param value defines the object to push in the array.
  72023. */
  72024. push(value: T): void;
  72025. /**
  72026. * Pushes a value at the end of the active data.
  72027. * If the data is already present, it won t be added again
  72028. * @param value defines the object to push in the array.
  72029. * @returns true if added false if it was already present
  72030. */
  72031. pushNoDuplicate(value: T): boolean;
  72032. /**
  72033. * Resets the active data to an empty array.
  72034. */
  72035. reset(): void;
  72036. /**
  72037. * Concats the active data with a given array.
  72038. * This ensures no dupplicate will be present in the result.
  72039. * @param array defines the data to concatenate with.
  72040. */
  72041. concatWithNoDuplicate(array: any): void;
  72042. }
  72043. }
  72044. declare module BABYLON {
  72045. /**
  72046. * @ignore
  72047. * This is a list of all the different input types that are available in the application.
  72048. * Fo instance: ArcRotateCameraGamepadInput...
  72049. */
  72050. export var CameraInputTypes: {};
  72051. /**
  72052. * This is the contract to implement in order to create a new input class.
  72053. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  72054. */
  72055. export interface ICameraInput<TCamera extends Camera> {
  72056. /**
  72057. * Defines the camera the input is attached to.
  72058. */
  72059. camera: Nullable<TCamera>;
  72060. /**
  72061. * Gets the class name of the current intput.
  72062. * @returns the class name
  72063. */
  72064. getClassName(): string;
  72065. /**
  72066. * Get the friendly name associated with the input class.
  72067. * @returns the input friendly name
  72068. */
  72069. getSimpleName(): string;
  72070. /**
  72071. * Attach the input controls to a specific dom element to get the input from.
  72072. * @param element Defines the element the controls should be listened from
  72073. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  72074. */
  72075. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  72076. /**
  72077. * Detach the current controls from the specified dom element.
  72078. * @param element Defines the element to stop listening the inputs from
  72079. */
  72080. detachControl(element: Nullable<HTMLElement>): void;
  72081. /**
  72082. * Update the current camera state depending on the inputs that have been used this frame.
  72083. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  72084. */
  72085. checkInputs?: () => void;
  72086. }
  72087. /**
  72088. * Represents a map of input types to input instance or input index to input instance.
  72089. */
  72090. export interface CameraInputsMap<TCamera extends Camera> {
  72091. /**
  72092. * Accessor to the input by input type.
  72093. */
  72094. [name: string]: ICameraInput<TCamera>;
  72095. /**
  72096. * Accessor to the input by input index.
  72097. */
  72098. [idx: number]: ICameraInput<TCamera>;
  72099. }
  72100. /**
  72101. * This represents the input manager used within a camera.
  72102. * It helps dealing with all the different kind of input attached to a camera.
  72103. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  72104. */
  72105. export class CameraInputsManager<TCamera extends Camera> {
  72106. /**
  72107. * Defines the list of inputs attahed to the camera.
  72108. */
  72109. attached: CameraInputsMap<TCamera>;
  72110. /**
  72111. * Defines the dom element the camera is collecting inputs from.
  72112. * This is null if the controls have not been attached.
  72113. */
  72114. attachedElement: Nullable<HTMLElement>;
  72115. /**
  72116. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  72117. */
  72118. noPreventDefault: boolean;
  72119. /**
  72120. * Defined the camera the input manager belongs to.
  72121. */
  72122. camera: TCamera;
  72123. /**
  72124. * Update the current camera state depending on the inputs that have been used this frame.
  72125. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  72126. */
  72127. checkInputs: () => void;
  72128. /**
  72129. * Instantiate a new Camera Input Manager.
  72130. * @param camera Defines the camera the input manager blongs to
  72131. */
  72132. constructor(camera: TCamera);
  72133. /**
  72134. * Add an input method to a camera
  72135. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  72136. * @param input camera input method
  72137. */
  72138. add(input: ICameraInput<TCamera>): void;
  72139. /**
  72140. * Remove a specific input method from a camera
  72141. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  72142. * @param inputToRemove camera input method
  72143. */
  72144. remove(inputToRemove: ICameraInput<TCamera>): void;
  72145. /**
  72146. * Remove a specific input type from a camera
  72147. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  72148. * @param inputType the type of the input to remove
  72149. */
  72150. removeByType(inputType: string): void;
  72151. private _addCheckInputs;
  72152. /**
  72153. * Attach the input controls to the currently attached dom element to listen the events from.
  72154. * @param input Defines the input to attach
  72155. */
  72156. attachInput(input: ICameraInput<TCamera>): void;
  72157. /**
  72158. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  72159. * @param element Defines the dom element to collect the events from
  72160. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  72161. */
  72162. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  72163. /**
  72164. * Detach the current manager inputs controls from a specific dom element.
  72165. * @param element Defines the dom element to collect the events from
  72166. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  72167. */
  72168. detachElement(element: HTMLElement, disconnect?: boolean): void;
  72169. /**
  72170. * Rebuild the dynamic inputCheck function from the current list of
  72171. * defined inputs in the manager.
  72172. */
  72173. rebuildInputCheck(): void;
  72174. /**
  72175. * Remove all attached input methods from a camera
  72176. */
  72177. clear(): void;
  72178. /**
  72179. * Serialize the current input manager attached to a camera.
  72180. * This ensures than once parsed,
  72181. * the input associated to the camera will be identical to the current ones
  72182. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  72183. */
  72184. serialize(serializedCamera: any): void;
  72185. /**
  72186. * Parses an input manager serialized JSON to restore the previous list of inputs
  72187. * and states associated to a camera.
  72188. * @param parsedCamera Defines the JSON to parse
  72189. */
  72190. parse(parsedCamera: any): void;
  72191. }
  72192. }
  72193. declare module BABYLON {
  72194. /**
  72195. * @hidden
  72196. */
  72197. export class IntersectionInfo {
  72198. bu: Nullable<number>;
  72199. bv: Nullable<number>;
  72200. distance: number;
  72201. faceId: number;
  72202. subMeshId: number;
  72203. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  72204. }
  72205. }
  72206. declare module BABYLON {
  72207. /**
  72208. * Represens a plane by the equation ax + by + cz + d = 0
  72209. */
  72210. export class Plane {
  72211. private static _TmpMatrix;
  72212. /**
  72213. * Normal of the plane (a,b,c)
  72214. */
  72215. normal: Vector3;
  72216. /**
  72217. * d component of the plane
  72218. */
  72219. d: number;
  72220. /**
  72221. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  72222. * @param a a component of the plane
  72223. * @param b b component of the plane
  72224. * @param c c component of the plane
  72225. * @param d d component of the plane
  72226. */
  72227. constructor(a: number, b: number, c: number, d: number);
  72228. /**
  72229. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  72230. */
  72231. asArray(): number[];
  72232. /**
  72233. * @returns a new plane copied from the current Plane.
  72234. */
  72235. clone(): Plane;
  72236. /**
  72237. * @returns the string "Plane".
  72238. */
  72239. getClassName(): string;
  72240. /**
  72241. * @returns the Plane hash code.
  72242. */
  72243. getHashCode(): number;
  72244. /**
  72245. * Normalize the current Plane in place.
  72246. * @returns the updated Plane.
  72247. */
  72248. normalize(): Plane;
  72249. /**
  72250. * Applies a transformation the plane and returns the result
  72251. * @param transformation the transformation matrix to be applied to the plane
  72252. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  72253. */
  72254. transform(transformation: DeepImmutable<Matrix>): Plane;
  72255. /**
  72256. * Calcualtte the dot product between the point and the plane normal
  72257. * @param point point to calculate the dot product with
  72258. * @returns the dot product (float) of the point coordinates and the plane normal.
  72259. */
  72260. dotCoordinate(point: DeepImmutable<Vector3>): number;
  72261. /**
  72262. * Updates the current Plane from the plane defined by the three given points.
  72263. * @param point1 one of the points used to contruct the plane
  72264. * @param point2 one of the points used to contruct the plane
  72265. * @param point3 one of the points used to contruct the plane
  72266. * @returns the updated Plane.
  72267. */
  72268. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  72269. /**
  72270. * Checks if the plane is facing a given direction
  72271. * @param direction the direction to check if the plane is facing
  72272. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  72273. * @returns True is the vector "direction" is the same side than the plane normal.
  72274. */
  72275. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  72276. /**
  72277. * Calculates the distance to a point
  72278. * @param point point to calculate distance to
  72279. * @returns the signed distance (float) from the given point to the Plane.
  72280. */
  72281. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  72282. /**
  72283. * Creates a plane from an array
  72284. * @param array the array to create a plane from
  72285. * @returns a new Plane from the given array.
  72286. */
  72287. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  72288. /**
  72289. * Creates a plane from three points
  72290. * @param point1 point used to create the plane
  72291. * @param point2 point used to create the plane
  72292. * @param point3 point used to create the plane
  72293. * @returns a new Plane defined by the three given points.
  72294. */
  72295. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  72296. /**
  72297. * Creates a plane from an origin point and a normal
  72298. * @param origin origin of the plane to be constructed
  72299. * @param normal normal of the plane to be constructed
  72300. * @returns a new Plane the normal vector to this plane at the given origin point.
  72301. * Note : the vector "normal" is updated because normalized.
  72302. */
  72303. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): Plane;
  72304. /**
  72305. * Calculates the distance from a plane and a point
  72306. * @param origin origin of the plane to be constructed
  72307. * @param normal normal of the plane to be constructed
  72308. * @param point point to calculate distance to
  72309. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  72310. */
  72311. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  72312. }
  72313. }
  72314. declare module BABYLON {
  72315. /**
  72316. * Class used to store bounding sphere information
  72317. */
  72318. export class BoundingSphere {
  72319. /**
  72320. * Gets the center of the bounding sphere in local space
  72321. */
  72322. readonly center: Vector3;
  72323. /**
  72324. * Radius of the bounding sphere in local space
  72325. */
  72326. radius: number;
  72327. /**
  72328. * Gets the center of the bounding sphere in world space
  72329. */
  72330. readonly centerWorld: Vector3;
  72331. /**
  72332. * Radius of the bounding sphere in world space
  72333. */
  72334. radiusWorld: number;
  72335. /**
  72336. * Gets the minimum vector in local space
  72337. */
  72338. readonly minimum: Vector3;
  72339. /**
  72340. * Gets the maximum vector in local space
  72341. */
  72342. readonly maximum: Vector3;
  72343. private _worldMatrix;
  72344. private static readonly TmpVector3;
  72345. /**
  72346. * Creates a new bounding sphere
  72347. * @param min defines the minimum vector (in local space)
  72348. * @param max defines the maximum vector (in local space)
  72349. * @param worldMatrix defines the new world matrix
  72350. */
  72351. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  72352. /**
  72353. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  72354. * @param min defines the new minimum vector (in local space)
  72355. * @param max defines the new maximum vector (in local space)
  72356. * @param worldMatrix defines the new world matrix
  72357. */
  72358. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  72359. /**
  72360. * Scale the current bounding sphere by applying a scale factor
  72361. * @param factor defines the scale factor to apply
  72362. * @returns the current bounding box
  72363. */
  72364. scale(factor: number): BoundingSphere;
  72365. /**
  72366. * Gets the world matrix of the bounding box
  72367. * @returns a matrix
  72368. */
  72369. getWorldMatrix(): DeepImmutable<Matrix>;
  72370. /** @hidden */
  72371. _update(worldMatrix: DeepImmutable<Matrix>): void;
  72372. /**
  72373. * Tests if the bounding sphere is intersecting the frustum planes
  72374. * @param frustumPlanes defines the frustum planes to test
  72375. * @returns true if there is an intersection
  72376. */
  72377. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  72378. /**
  72379. * Tests if the bounding sphere center is in between the frustum planes.
  72380. * Used for optimistic fast inclusion.
  72381. * @param frustumPlanes defines the frustum planes to test
  72382. * @returns true if the sphere center is in between the frustum planes
  72383. */
  72384. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  72385. /**
  72386. * Tests if a point is inside the bounding sphere
  72387. * @param point defines the point to test
  72388. * @returns true if the point is inside the bounding sphere
  72389. */
  72390. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  72391. /**
  72392. * Checks if two sphere intersct
  72393. * @param sphere0 sphere 0
  72394. * @param sphere1 sphere 1
  72395. * @returns true if the speres intersect
  72396. */
  72397. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  72398. }
  72399. }
  72400. declare module BABYLON {
  72401. /**
  72402. * Class used to store bounding box information
  72403. */
  72404. export class BoundingBox implements ICullable {
  72405. /**
  72406. * Gets the 8 vectors representing the bounding box in local space
  72407. */
  72408. readonly vectors: Vector3[];
  72409. /**
  72410. * Gets the center of the bounding box in local space
  72411. */
  72412. readonly center: Vector3;
  72413. /**
  72414. * Gets the center of the bounding box in world space
  72415. */
  72416. readonly centerWorld: Vector3;
  72417. /**
  72418. * Gets the extend size in local space
  72419. */
  72420. readonly extendSize: Vector3;
  72421. /**
  72422. * Gets the extend size in world space
  72423. */
  72424. readonly extendSizeWorld: Vector3;
  72425. /**
  72426. * Gets the OBB (object bounding box) directions
  72427. */
  72428. readonly directions: Vector3[];
  72429. /**
  72430. * Gets the 8 vectors representing the bounding box in world space
  72431. */
  72432. readonly vectorsWorld: Vector3[];
  72433. /**
  72434. * Gets the minimum vector in world space
  72435. */
  72436. readonly minimumWorld: Vector3;
  72437. /**
  72438. * Gets the maximum vector in world space
  72439. */
  72440. readonly maximumWorld: Vector3;
  72441. /**
  72442. * Gets the minimum vector in local space
  72443. */
  72444. readonly minimum: Vector3;
  72445. /**
  72446. * Gets the maximum vector in local space
  72447. */
  72448. readonly maximum: Vector3;
  72449. private _worldMatrix;
  72450. private static readonly TmpVector3;
  72451. /**
  72452. * @hidden
  72453. */
  72454. _tag: number;
  72455. /**
  72456. * Creates a new bounding box
  72457. * @param min defines the minimum vector (in local space)
  72458. * @param max defines the maximum vector (in local space)
  72459. * @param worldMatrix defines the new world matrix
  72460. */
  72461. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  72462. /**
  72463. * Recreates the entire bounding box from scratch as if we call the constructor in place
  72464. * @param min defines the new minimum vector (in local space)
  72465. * @param max defines the new maximum vector (in local space)
  72466. * @param worldMatrix defines the new world matrix
  72467. */
  72468. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  72469. /**
  72470. * Scale the current bounding box by applying a scale factor
  72471. * @param factor defines the scale factor to apply
  72472. * @returns the current bounding box
  72473. */
  72474. scale(factor: number): BoundingBox;
  72475. /**
  72476. * Gets the world matrix of the bounding box
  72477. * @returns a matrix
  72478. */
  72479. getWorldMatrix(): DeepImmutable<Matrix>;
  72480. /** @hidden */
  72481. _update(world: DeepImmutable<Matrix>): void;
  72482. /**
  72483. * Tests if the bounding box is intersecting the frustum planes
  72484. * @param frustumPlanes defines the frustum planes to test
  72485. * @returns true if there is an intersection
  72486. */
  72487. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  72488. /**
  72489. * Tests if the bounding box is entirely inside the frustum planes
  72490. * @param frustumPlanes defines the frustum planes to test
  72491. * @returns true if there is an inclusion
  72492. */
  72493. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  72494. /**
  72495. * Tests if a point is inside the bounding box
  72496. * @param point defines the point to test
  72497. * @returns true if the point is inside the bounding box
  72498. */
  72499. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  72500. /**
  72501. * Tests if the bounding box intersects with a bounding sphere
  72502. * @param sphere defines the sphere to test
  72503. * @returns true if there is an intersection
  72504. */
  72505. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  72506. /**
  72507. * Tests if the bounding box intersects with a box defined by a min and max vectors
  72508. * @param min defines the min vector to use
  72509. * @param max defines the max vector to use
  72510. * @returns true if there is an intersection
  72511. */
  72512. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  72513. /**
  72514. * Tests if two bounding boxes are intersections
  72515. * @param box0 defines the first box to test
  72516. * @param box1 defines the second box to test
  72517. * @returns true if there is an intersection
  72518. */
  72519. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  72520. /**
  72521. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  72522. * @param minPoint defines the minimum vector of the bounding box
  72523. * @param maxPoint defines the maximum vector of the bounding box
  72524. * @param sphereCenter defines the sphere center
  72525. * @param sphereRadius defines the sphere radius
  72526. * @returns true if there is an intersection
  72527. */
  72528. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  72529. /**
  72530. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  72531. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  72532. * @param frustumPlanes defines the frustum planes to test
  72533. * @return true if there is an inclusion
  72534. */
  72535. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  72536. /**
  72537. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  72538. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  72539. * @param frustumPlanes defines the frustum planes to test
  72540. * @return true if there is an intersection
  72541. */
  72542. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  72543. }
  72544. }
  72545. declare module BABYLON {
  72546. /** @hidden */
  72547. export class Collider {
  72548. /** Define if a collision was found */
  72549. collisionFound: boolean;
  72550. /**
  72551. * Define last intersection point in local space
  72552. */
  72553. intersectionPoint: Vector3;
  72554. /**
  72555. * Define last collided mesh
  72556. */
  72557. collidedMesh: Nullable<AbstractMesh>;
  72558. private _collisionPoint;
  72559. private _planeIntersectionPoint;
  72560. private _tempVector;
  72561. private _tempVector2;
  72562. private _tempVector3;
  72563. private _tempVector4;
  72564. private _edge;
  72565. private _baseToVertex;
  72566. private _destinationPoint;
  72567. private _slidePlaneNormal;
  72568. private _displacementVector;
  72569. /** @hidden */
  72570. _radius: Vector3;
  72571. /** @hidden */
  72572. _retry: number;
  72573. private _velocity;
  72574. private _basePoint;
  72575. private _epsilon;
  72576. /** @hidden */
  72577. _velocityWorldLength: number;
  72578. /** @hidden */
  72579. _basePointWorld: Vector3;
  72580. private _velocityWorld;
  72581. private _normalizedVelocity;
  72582. /** @hidden */
  72583. _initialVelocity: Vector3;
  72584. /** @hidden */
  72585. _initialPosition: Vector3;
  72586. private _nearestDistance;
  72587. private _collisionMask;
  72588. collisionMask: number;
  72589. /**
  72590. * Gets the plane normal used to compute the sliding response (in local space)
  72591. */
  72592. readonly slidePlaneNormal: Vector3;
  72593. /** @hidden */
  72594. _initialize(source: Vector3, dir: Vector3, e: number): void;
  72595. /** @hidden */
  72596. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  72597. /** @hidden */
  72598. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  72599. /** @hidden */
  72600. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  72601. /** @hidden */
  72602. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  72603. /** @hidden */
  72604. _getResponse(pos: Vector3, vel: Vector3): void;
  72605. }
  72606. }
  72607. declare module BABYLON {
  72608. /**
  72609. * Interface for cullable objects
  72610. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  72611. */
  72612. export interface ICullable {
  72613. /**
  72614. * Checks if the object or part of the object is in the frustum
  72615. * @param frustumPlanes Camera near/planes
  72616. * @returns true if the object is in frustum otherwise false
  72617. */
  72618. isInFrustum(frustumPlanes: Plane[]): boolean;
  72619. /**
  72620. * Checks if a cullable object (mesh...) is in the camera frustum
  72621. * Unlike isInFrustum this cheks the full bounding box
  72622. * @param frustumPlanes Camera near/planes
  72623. * @returns true if the object is in frustum otherwise false
  72624. */
  72625. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  72626. }
  72627. /**
  72628. * Info for a bounding data of a mesh
  72629. */
  72630. export class BoundingInfo implements ICullable {
  72631. /**
  72632. * Bounding box for the mesh
  72633. */
  72634. readonly boundingBox: BoundingBox;
  72635. /**
  72636. * Bounding sphere for the mesh
  72637. */
  72638. readonly boundingSphere: BoundingSphere;
  72639. private _isLocked;
  72640. private static readonly TmpVector3;
  72641. /**
  72642. * Constructs bounding info
  72643. * @param minimum min vector of the bounding box/sphere
  72644. * @param maximum max vector of the bounding box/sphere
  72645. * @param worldMatrix defines the new world matrix
  72646. */
  72647. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  72648. /**
  72649. * Recreates the entire bounding info from scratch as if we call the constructor in place
  72650. * @param min defines the new minimum vector (in local space)
  72651. * @param max defines the new maximum vector (in local space)
  72652. * @param worldMatrix defines the new world matrix
  72653. */
  72654. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  72655. /**
  72656. * min vector of the bounding box/sphere
  72657. */
  72658. readonly minimum: Vector3;
  72659. /**
  72660. * max vector of the bounding box/sphere
  72661. */
  72662. readonly maximum: Vector3;
  72663. /**
  72664. * If the info is locked and won't be updated to avoid perf overhead
  72665. */
  72666. isLocked: boolean;
  72667. /**
  72668. * Updates the bounding sphere and box
  72669. * @param world world matrix to be used to update
  72670. */
  72671. update(world: DeepImmutable<Matrix>): void;
  72672. /**
  72673. * Recreate the bounding info to be centered around a specific point given a specific extend.
  72674. * @param center New center of the bounding info
  72675. * @param extend New extend of the bounding info
  72676. * @returns the current bounding info
  72677. */
  72678. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  72679. /**
  72680. * Scale the current bounding info by applying a scale factor
  72681. * @param factor defines the scale factor to apply
  72682. * @returns the current bounding info
  72683. */
  72684. scale(factor: number): BoundingInfo;
  72685. /**
  72686. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  72687. * @param frustumPlanes defines the frustum to test
  72688. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  72689. * @returns true if the bounding info is in the frustum planes
  72690. */
  72691. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  72692. /**
  72693. * Gets the world distance between the min and max points of the bounding box
  72694. */
  72695. readonly diagonalLength: number;
  72696. /**
  72697. * Checks if a cullable object (mesh...) is in the camera frustum
  72698. * Unlike isInFrustum this cheks the full bounding box
  72699. * @param frustumPlanes Camera near/planes
  72700. * @returns true if the object is in frustum otherwise false
  72701. */
  72702. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  72703. /** @hidden */
  72704. _checkCollision(collider: Collider): boolean;
  72705. /**
  72706. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  72707. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  72708. * @param point the point to check intersection with
  72709. * @returns if the point intersects
  72710. */
  72711. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  72712. /**
  72713. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  72714. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  72715. * @param boundingInfo the bounding info to check intersection with
  72716. * @param precise if the intersection should be done using OBB
  72717. * @returns if the bounding info intersects
  72718. */
  72719. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  72720. }
  72721. }
  72722. declare module BABYLON {
  72723. /**
  72724. * Extracts minimum and maximum values from a list of indexed positions
  72725. * @param positions defines the positions to use
  72726. * @param indices defines the indices to the positions
  72727. * @param indexStart defines the start index
  72728. * @param indexCount defines the end index
  72729. * @param bias defines bias value to add to the result
  72730. * @return minimum and maximum values
  72731. */
  72732. export function extractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  72733. minimum: Vector3;
  72734. maximum: Vector3;
  72735. };
  72736. /**
  72737. * Extracts minimum and maximum values from a list of positions
  72738. * @param positions defines the positions to use
  72739. * @param start defines the start index in the positions array
  72740. * @param count defines the number of positions to handle
  72741. * @param bias defines bias value to add to the result
  72742. * @param stride defines the stride size to use (distance between two positions in the positions array)
  72743. * @return minimum and maximum values
  72744. */
  72745. export function extractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  72746. minimum: Vector3;
  72747. maximum: Vector3;
  72748. };
  72749. }
  72750. declare module BABYLON {
  72751. /**
  72752. * Enum that determines the text-wrapping mode to use.
  72753. */
  72754. export enum InspectableType {
  72755. /**
  72756. * Checkbox for booleans
  72757. */
  72758. Checkbox = 0,
  72759. /**
  72760. * Sliders for numbers
  72761. */
  72762. Slider = 1,
  72763. /**
  72764. * Vector3
  72765. */
  72766. Vector3 = 2,
  72767. /**
  72768. * Quaternions
  72769. */
  72770. Quaternion = 3,
  72771. /**
  72772. * Color3
  72773. */
  72774. Color3 = 4,
  72775. /**
  72776. * String
  72777. */
  72778. String = 5
  72779. }
  72780. /**
  72781. * Interface used to define custom inspectable properties.
  72782. * This interface is used by the inspector to display custom property grids
  72783. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  72784. */
  72785. export interface IInspectable {
  72786. /**
  72787. * Gets the label to display
  72788. */
  72789. label: string;
  72790. /**
  72791. * Gets the name of the property to edit
  72792. */
  72793. propertyName: string;
  72794. /**
  72795. * Gets the type of the editor to use
  72796. */
  72797. type: InspectableType;
  72798. /**
  72799. * Gets the minimum value of the property when using in "slider" mode
  72800. */
  72801. min?: number;
  72802. /**
  72803. * Gets the maximum value of the property when using in "slider" mode
  72804. */
  72805. max?: number;
  72806. /**
  72807. * Gets the setp to use when using in "slider" mode
  72808. */
  72809. step?: number;
  72810. }
  72811. }
  72812. declare module BABYLON {
  72813. /**
  72814. * Class used to provide helper for timing
  72815. */
  72816. export class TimingTools {
  72817. /**
  72818. * Polyfill for setImmediate
  72819. * @param action defines the action to execute after the current execution block
  72820. */
  72821. static SetImmediate(action: () => void): void;
  72822. }
  72823. }
  72824. declare module BABYLON {
  72825. /**
  72826. * Class used to enable instatition of objects by class name
  72827. */
  72828. export class InstantiationTools {
  72829. /**
  72830. * Use this object to register external classes like custom textures or material
  72831. * to allow the laoders to instantiate them
  72832. */
  72833. static RegisteredExternalClasses: {
  72834. [key: string]: Object;
  72835. };
  72836. /**
  72837. * Tries to instantiate a new object from a given class name
  72838. * @param className defines the class name to instantiate
  72839. * @returns the new object or null if the system was not able to do the instantiation
  72840. */
  72841. static Instantiate(className: string): any;
  72842. }
  72843. }
  72844. declare module BABYLON {
  72845. /**
  72846. * This represents the required contract to create a new type of texture loader.
  72847. */
  72848. export interface IInternalTextureLoader {
  72849. /**
  72850. * Defines wether the loader supports cascade loading the different faces.
  72851. */
  72852. supportCascades: boolean;
  72853. /**
  72854. * This returns if the loader support the current file information.
  72855. * @param extension defines the file extension of the file being loaded
  72856. * @param textureFormatInUse defines the current compressed format in use iun the engine
  72857. * @param fallback defines the fallback internal texture if any
  72858. * @param isBase64 defines whether the texture is encoded as a base64
  72859. * @param isBuffer defines whether the texture data are stored as a buffer
  72860. * @returns true if the loader can load the specified file
  72861. */
  72862. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  72863. /**
  72864. * Transform the url before loading if required.
  72865. * @param rootUrl the url of the texture
  72866. * @param textureFormatInUse defines the current compressed format in use iun the engine
  72867. * @returns the transformed texture
  72868. */
  72869. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  72870. /**
  72871. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  72872. * @param rootUrl the url of the texture
  72873. * @param textureFormatInUse defines the current compressed format in use iun the engine
  72874. * @returns the fallback texture
  72875. */
  72876. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  72877. /**
  72878. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  72879. * @param data contains the texture data
  72880. * @param texture defines the BabylonJS internal texture
  72881. * @param createPolynomials will be true if polynomials have been requested
  72882. * @param onLoad defines the callback to trigger once the texture is ready
  72883. * @param onError defines the callback to trigger in case of error
  72884. */
  72885. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  72886. /**
  72887. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  72888. * @param data contains the texture data
  72889. * @param texture defines the BabylonJS internal texture
  72890. * @param callback defines the method to call once ready to upload
  72891. */
  72892. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  72893. }
  72894. }
  72895. declare module BABYLON {
  72896. interface Engine {
  72897. /**
  72898. * Creates a depth stencil cube texture.
  72899. * This is only available in WebGL 2.
  72900. * @param size The size of face edge in the cube texture.
  72901. * @param options The options defining the cube texture.
  72902. * @returns The cube texture
  72903. */
  72904. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  72905. /**
  72906. * Creates a cube texture
  72907. * @param rootUrl defines the url where the files to load is located
  72908. * @param scene defines the current scene
  72909. * @param files defines the list of files to load (1 per face)
  72910. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  72911. * @param onLoad defines an optional callback raised when the texture is loaded
  72912. * @param onError defines an optional callback raised if there is an issue to load the texture
  72913. * @param format defines the format of the data
  72914. * @param forcedExtension defines the extension to use to pick the right loader
  72915. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  72916. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  72917. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  72918. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  72919. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (defualt: empty array)
  72920. * @returns the cube texture as an InternalTexture
  72921. */
  72922. 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;
  72923. /**
  72924. * Creates a cube texture
  72925. * @param rootUrl defines the url where the files to load is located
  72926. * @param scene defines the current scene
  72927. * @param files defines the list of files to load (1 per face)
  72928. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  72929. * @param onLoad defines an optional callback raised when the texture is loaded
  72930. * @param onError defines an optional callback raised if there is an issue to load the texture
  72931. * @param format defines the format of the data
  72932. * @param forcedExtension defines the extension to use to pick the right loader
  72933. * @returns the cube texture as an InternalTexture
  72934. */
  72935. 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;
  72936. /**
  72937. * Creates a cube texture
  72938. * @param rootUrl defines the url where the files to load is located
  72939. * @param scene defines the current scene
  72940. * @param files defines the list of files to load (1 per face)
  72941. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  72942. * @param onLoad defines an optional callback raised when the texture is loaded
  72943. * @param onError defines an optional callback raised if there is an issue to load the texture
  72944. * @param format defines the format of the data
  72945. * @param forcedExtension defines the extension to use to pick the right loader
  72946. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  72947. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  72948. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  72949. * @returns the cube texture as an InternalTexture
  72950. */
  72951. 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;
  72952. /** @hidden */
  72953. _partialLoadFile(url: string, index: number, loadedFiles: (string | ArrayBuffer)[], onfinish: (files: (string | ArrayBuffer)[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  72954. /** @hidden */
  72955. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: (string | ArrayBuffer)[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  72956. /** @hidden */
  72957. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  72958. /** @hidden */
  72959. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  72960. }
  72961. }
  72962. declare module BABYLON {
  72963. /**
  72964. * Class for creating a cube texture
  72965. */
  72966. export class CubeTexture extends BaseTexture {
  72967. private _delayedOnLoad;
  72968. /**
  72969. * The url of the texture
  72970. */
  72971. url: string;
  72972. /**
  72973. * Gets or sets the center of the bounding box associated with the cube texture.
  72974. * It must define where the camera used to render the texture was set
  72975. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  72976. */
  72977. boundingBoxPosition: Vector3;
  72978. private _boundingBoxSize;
  72979. /**
  72980. * Gets or sets the size of the bounding box associated with the cube texture
  72981. * When defined, the cubemap will switch to local mode
  72982. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  72983. * @example https://www.babylonjs-playground.com/#RNASML
  72984. */
  72985. /**
  72986. * Returns the bounding box size
  72987. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  72988. */
  72989. boundingBoxSize: Vector3;
  72990. protected _rotationY: number;
  72991. /**
  72992. * Sets texture matrix rotation angle around Y axis in radians.
  72993. */
  72994. /**
  72995. * Gets texture matrix rotation angle around Y axis radians.
  72996. */
  72997. rotationY: number;
  72998. /**
  72999. * Are mip maps generated for this texture or not.
  73000. */
  73001. readonly noMipmap: boolean;
  73002. private _noMipmap;
  73003. private _files;
  73004. private _extensions;
  73005. private _textureMatrix;
  73006. private _format;
  73007. private _createPolynomials;
  73008. /** @hidden */
  73009. _prefiltered: boolean;
  73010. /**
  73011. * Creates a cube texture from an array of image urls
  73012. * @param files defines an array of image urls
  73013. * @param scene defines the hosting scene
  73014. * @param noMipmap specifies if mip maps are not used
  73015. * @returns a cube texture
  73016. */
  73017. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  73018. /**
  73019. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  73020. * @param url defines the url of the prefiltered texture
  73021. * @param scene defines the scene the texture is attached to
  73022. * @param forcedExtension defines the extension of the file if different from the url
  73023. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  73024. * @return the prefiltered texture
  73025. */
  73026. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  73027. /**
  73028. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  73029. * as prefiltered data.
  73030. * @param rootUrl defines the url of the texture or the root name of the six images
  73031. * @param scene defines the scene the texture is attached to
  73032. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  73033. * @param noMipmap defines if mipmaps should be created or not
  73034. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  73035. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  73036. * @param onError defines a callback triggered in case of error during load
  73037. * @param format defines the internal format to use for the texture once loaded
  73038. * @param prefiltered defines whether or not the texture is created from prefiltered data
  73039. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  73040. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  73041. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  73042. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  73043. * @return the cube texture
  73044. */
  73045. 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);
  73046. /**
  73047. * Gets a boolean indicating if the cube texture contains prefiltered mips (used to simulate roughness with PBR)
  73048. */
  73049. readonly isPrefiltered: boolean;
  73050. /**
  73051. * Get the current class name of the texture useful for serialization or dynamic coding.
  73052. * @returns "CubeTexture"
  73053. */
  73054. getClassName(): string;
  73055. /**
  73056. * Update the url (and optional buffer) of this texture if url was null during construction.
  73057. * @param url the url of the texture
  73058. * @param forcedExtension defines the extension to use
  73059. * @param onLoad callback called when the texture is loaded (defaults to null)
  73060. */
  73061. updateURL(url: string, forcedExtension?: string, onLoad?: () => void): void;
  73062. /**
  73063. * Delays loading of the cube texture
  73064. * @param forcedExtension defines the extension to use
  73065. */
  73066. delayLoad(forcedExtension?: string): void;
  73067. /**
  73068. * Returns the reflection texture matrix
  73069. * @returns the reflection texture matrix
  73070. */
  73071. getReflectionTextureMatrix(): Matrix;
  73072. /**
  73073. * Sets the reflection texture matrix
  73074. * @param value Reflection texture matrix
  73075. */
  73076. setReflectionTextureMatrix(value: Matrix): void;
  73077. /**
  73078. * Parses text to create a cube texture
  73079. * @param parsedTexture define the serialized text to read from
  73080. * @param scene defines the hosting scene
  73081. * @param rootUrl defines the root url of the cube texture
  73082. * @returns a cube texture
  73083. */
  73084. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  73085. /**
  73086. * Makes a clone, or deep copy, of the cube texture
  73087. * @returns a new cube texture
  73088. */
  73089. clone(): CubeTexture;
  73090. }
  73091. }
  73092. declare module BABYLON {
  73093. /**
  73094. * Manages the defines for the Material
  73095. */
  73096. export class MaterialDefines {
  73097. /** @hidden */
  73098. protected _keys: string[];
  73099. private _isDirty;
  73100. /** @hidden */
  73101. _renderId: number;
  73102. /** @hidden */
  73103. _areLightsDirty: boolean;
  73104. /** @hidden */
  73105. _areLightsDisposed: boolean;
  73106. /** @hidden */
  73107. _areAttributesDirty: boolean;
  73108. /** @hidden */
  73109. _areTexturesDirty: boolean;
  73110. /** @hidden */
  73111. _areFresnelDirty: boolean;
  73112. /** @hidden */
  73113. _areMiscDirty: boolean;
  73114. /** @hidden */
  73115. _areImageProcessingDirty: boolean;
  73116. /** @hidden */
  73117. _normals: boolean;
  73118. /** @hidden */
  73119. _uvs: boolean;
  73120. /** @hidden */
  73121. _needNormals: boolean;
  73122. /** @hidden */
  73123. _needUVs: boolean;
  73124. [id: string]: any;
  73125. /**
  73126. * Specifies if the material needs to be re-calculated
  73127. */
  73128. readonly isDirty: boolean;
  73129. /**
  73130. * Marks the material to indicate that it has been re-calculated
  73131. */
  73132. markAsProcessed(): void;
  73133. /**
  73134. * Marks the material to indicate that it needs to be re-calculated
  73135. */
  73136. markAsUnprocessed(): void;
  73137. /**
  73138. * Marks the material to indicate all of its defines need to be re-calculated
  73139. */
  73140. markAllAsDirty(): void;
  73141. /**
  73142. * Marks the material to indicate that image processing needs to be re-calculated
  73143. */
  73144. markAsImageProcessingDirty(): void;
  73145. /**
  73146. * Marks the material to indicate the lights need to be re-calculated
  73147. * @param disposed Defines whether the light is dirty due to dispose or not
  73148. */
  73149. markAsLightDirty(disposed?: boolean): void;
  73150. /**
  73151. * Marks the attribute state as changed
  73152. */
  73153. markAsAttributesDirty(): void;
  73154. /**
  73155. * Marks the texture state as changed
  73156. */
  73157. markAsTexturesDirty(): void;
  73158. /**
  73159. * Marks the fresnel state as changed
  73160. */
  73161. markAsFresnelDirty(): void;
  73162. /**
  73163. * Marks the misc state as changed
  73164. */
  73165. markAsMiscDirty(): void;
  73166. /**
  73167. * Rebuilds the material defines
  73168. */
  73169. rebuild(): void;
  73170. /**
  73171. * Specifies if two material defines are equal
  73172. * @param other - A material define instance to compare to
  73173. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  73174. */
  73175. isEqual(other: MaterialDefines): boolean;
  73176. /**
  73177. * Clones this instance's defines to another instance
  73178. * @param other - material defines to clone values to
  73179. */
  73180. cloneTo(other: MaterialDefines): void;
  73181. /**
  73182. * Resets the material define values
  73183. */
  73184. reset(): void;
  73185. /**
  73186. * Converts the material define values to a string
  73187. * @returns - String of material define information
  73188. */
  73189. toString(): string;
  73190. }
  73191. }
  73192. declare module BABYLON {
  73193. /**
  73194. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  73195. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  73196. * 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;
  73197. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  73198. */
  73199. export class ColorCurves {
  73200. private _dirty;
  73201. private _tempColor;
  73202. private _globalCurve;
  73203. private _highlightsCurve;
  73204. private _midtonesCurve;
  73205. private _shadowsCurve;
  73206. private _positiveCurve;
  73207. private _negativeCurve;
  73208. private _globalHue;
  73209. private _globalDensity;
  73210. private _globalSaturation;
  73211. private _globalExposure;
  73212. /**
  73213. * Gets the global Hue value.
  73214. * 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).
  73215. */
  73216. /**
  73217. * Sets the global Hue value.
  73218. * 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).
  73219. */
  73220. globalHue: number;
  73221. /**
  73222. * Gets the global Density value.
  73223. * 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.
  73224. * Values less than zero provide a filter of opposite hue.
  73225. */
  73226. /**
  73227. * Sets the global Density value.
  73228. * 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.
  73229. * Values less than zero provide a filter of opposite hue.
  73230. */
  73231. globalDensity: number;
  73232. /**
  73233. * Gets the global Saturation value.
  73234. * 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.
  73235. */
  73236. /**
  73237. * Sets the global Saturation value.
  73238. * 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.
  73239. */
  73240. globalSaturation: number;
  73241. /**
  73242. * Gets the global Exposure value.
  73243. * 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.
  73244. */
  73245. /**
  73246. * Sets the global Exposure value.
  73247. * 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.
  73248. */
  73249. globalExposure: number;
  73250. private _highlightsHue;
  73251. private _highlightsDensity;
  73252. private _highlightsSaturation;
  73253. private _highlightsExposure;
  73254. /**
  73255. * Gets the highlights Hue value.
  73256. * 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).
  73257. */
  73258. /**
  73259. * Sets the highlights Hue value.
  73260. * 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).
  73261. */
  73262. highlightsHue: number;
  73263. /**
  73264. * Gets the highlights Density value.
  73265. * 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.
  73266. * Values less than zero provide a filter of opposite hue.
  73267. */
  73268. /**
  73269. * Sets the highlights Density value.
  73270. * 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.
  73271. * Values less than zero provide a filter of opposite hue.
  73272. */
  73273. highlightsDensity: number;
  73274. /**
  73275. * Gets the highlights Saturation value.
  73276. * 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.
  73277. */
  73278. /**
  73279. * Sets the highlights Saturation value.
  73280. * 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.
  73281. */
  73282. highlightsSaturation: number;
  73283. /**
  73284. * Gets the highlights Exposure value.
  73285. * 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.
  73286. */
  73287. /**
  73288. * Sets the highlights Exposure value.
  73289. * 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.
  73290. */
  73291. highlightsExposure: number;
  73292. private _midtonesHue;
  73293. private _midtonesDensity;
  73294. private _midtonesSaturation;
  73295. private _midtonesExposure;
  73296. /**
  73297. * Gets the midtones Hue value.
  73298. * 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).
  73299. */
  73300. /**
  73301. * Sets the midtones Hue value.
  73302. * 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).
  73303. */
  73304. midtonesHue: number;
  73305. /**
  73306. * Gets the midtones Density value.
  73307. * 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.
  73308. * Values less than zero provide a filter of opposite hue.
  73309. */
  73310. /**
  73311. * Sets the midtones Density value.
  73312. * 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.
  73313. * Values less than zero provide a filter of opposite hue.
  73314. */
  73315. midtonesDensity: number;
  73316. /**
  73317. * Gets the midtones Saturation value.
  73318. * 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.
  73319. */
  73320. /**
  73321. * Sets the midtones Saturation value.
  73322. * 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.
  73323. */
  73324. midtonesSaturation: number;
  73325. /**
  73326. * Gets the midtones Exposure value.
  73327. * 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.
  73328. */
  73329. /**
  73330. * Sets the midtones Exposure value.
  73331. * 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.
  73332. */
  73333. midtonesExposure: number;
  73334. private _shadowsHue;
  73335. private _shadowsDensity;
  73336. private _shadowsSaturation;
  73337. private _shadowsExposure;
  73338. /**
  73339. * Gets the shadows Hue value.
  73340. * 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).
  73341. */
  73342. /**
  73343. * Sets the shadows Hue value.
  73344. * 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).
  73345. */
  73346. shadowsHue: number;
  73347. /**
  73348. * Gets the shadows Density value.
  73349. * 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.
  73350. * Values less than zero provide a filter of opposite hue.
  73351. */
  73352. /**
  73353. * Sets the shadows Density value.
  73354. * 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.
  73355. * Values less than zero provide a filter of opposite hue.
  73356. */
  73357. shadowsDensity: number;
  73358. /**
  73359. * Gets the shadows Saturation value.
  73360. * 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.
  73361. */
  73362. /**
  73363. * Sets the shadows Saturation value.
  73364. * 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.
  73365. */
  73366. shadowsSaturation: number;
  73367. /**
  73368. * Gets the shadows Exposure value.
  73369. * 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.
  73370. */
  73371. /**
  73372. * Sets the shadows Exposure value.
  73373. * 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.
  73374. */
  73375. shadowsExposure: number;
  73376. /**
  73377. * Returns the class name
  73378. * @returns The class name
  73379. */
  73380. getClassName(): string;
  73381. /**
  73382. * Binds the color curves to the shader.
  73383. * @param colorCurves The color curve to bind
  73384. * @param effect The effect to bind to
  73385. * @param positiveUniform The positive uniform shader parameter
  73386. * @param neutralUniform The neutral uniform shader parameter
  73387. * @param negativeUniform The negative uniform shader parameter
  73388. */
  73389. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  73390. /**
  73391. * Prepare the list of uniforms associated with the ColorCurves effects.
  73392. * @param uniformsList The list of uniforms used in the effect
  73393. */
  73394. static PrepareUniforms(uniformsList: string[]): void;
  73395. /**
  73396. * Returns color grading data based on a hue, density, saturation and exposure value.
  73397. * @param filterHue The hue of the color filter.
  73398. * @param filterDensity The density of the color filter.
  73399. * @param saturation The saturation.
  73400. * @param exposure The exposure.
  73401. * @param result The result data container.
  73402. */
  73403. private getColorGradingDataToRef;
  73404. /**
  73405. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  73406. * @param value The input slider value in range [-100,100].
  73407. * @returns Adjusted value.
  73408. */
  73409. private static applyColorGradingSliderNonlinear;
  73410. /**
  73411. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  73412. * @param hue The hue (H) input.
  73413. * @param saturation The saturation (S) input.
  73414. * @param brightness The brightness (B) input.
  73415. * @result An RGBA color represented as Vector4.
  73416. */
  73417. private static fromHSBToRef;
  73418. /**
  73419. * Returns a value clamped between min and max
  73420. * @param value The value to clamp
  73421. * @param min The minimum of value
  73422. * @param max The maximum of value
  73423. * @returns The clamped value.
  73424. */
  73425. private static clamp;
  73426. /**
  73427. * Clones the current color curve instance.
  73428. * @return The cloned curves
  73429. */
  73430. clone(): ColorCurves;
  73431. /**
  73432. * Serializes the current color curve instance to a json representation.
  73433. * @return a JSON representation
  73434. */
  73435. serialize(): any;
  73436. /**
  73437. * Parses the color curve from a json representation.
  73438. * @param source the JSON source to parse
  73439. * @return The parsed curves
  73440. */
  73441. static Parse(source: any): ColorCurves;
  73442. }
  73443. }
  73444. declare module BABYLON {
  73445. /**
  73446. * Interface to follow in your material defines to integrate easily the
  73447. * Image proccessing functions.
  73448. * @hidden
  73449. */
  73450. export interface IImageProcessingConfigurationDefines {
  73451. IMAGEPROCESSING: boolean;
  73452. VIGNETTE: boolean;
  73453. VIGNETTEBLENDMODEMULTIPLY: boolean;
  73454. VIGNETTEBLENDMODEOPAQUE: boolean;
  73455. TONEMAPPING: boolean;
  73456. TONEMAPPING_ACES: boolean;
  73457. CONTRAST: boolean;
  73458. EXPOSURE: boolean;
  73459. COLORCURVES: boolean;
  73460. COLORGRADING: boolean;
  73461. COLORGRADING3D: boolean;
  73462. SAMPLER3DGREENDEPTH: boolean;
  73463. SAMPLER3DBGRMAP: boolean;
  73464. IMAGEPROCESSINGPOSTPROCESS: boolean;
  73465. }
  73466. /**
  73467. * @hidden
  73468. */
  73469. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  73470. IMAGEPROCESSING: boolean;
  73471. VIGNETTE: boolean;
  73472. VIGNETTEBLENDMODEMULTIPLY: boolean;
  73473. VIGNETTEBLENDMODEOPAQUE: boolean;
  73474. TONEMAPPING: boolean;
  73475. TONEMAPPING_ACES: boolean;
  73476. CONTRAST: boolean;
  73477. COLORCURVES: boolean;
  73478. COLORGRADING: boolean;
  73479. COLORGRADING3D: boolean;
  73480. SAMPLER3DGREENDEPTH: boolean;
  73481. SAMPLER3DBGRMAP: boolean;
  73482. IMAGEPROCESSINGPOSTPROCESS: boolean;
  73483. EXPOSURE: boolean;
  73484. constructor();
  73485. }
  73486. /**
  73487. * This groups together the common properties used for image processing either in direct forward pass
  73488. * or through post processing effect depending on the use of the image processing pipeline in your scene
  73489. * or not.
  73490. */
  73491. export class ImageProcessingConfiguration {
  73492. /**
  73493. * Default tone mapping applied in BabylonJS.
  73494. */
  73495. static readonly TONEMAPPING_STANDARD: number;
  73496. /**
  73497. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  73498. * to other engines rendering to increase portability.
  73499. */
  73500. static readonly TONEMAPPING_ACES: number;
  73501. /**
  73502. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  73503. */
  73504. colorCurves: Nullable<ColorCurves>;
  73505. private _colorCurvesEnabled;
  73506. /**
  73507. * Gets wether the color curves effect is enabled.
  73508. */
  73509. /**
  73510. * Sets wether the color curves effect is enabled.
  73511. */
  73512. colorCurvesEnabled: boolean;
  73513. private _colorGradingTexture;
  73514. /**
  73515. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  73516. */
  73517. /**
  73518. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  73519. */
  73520. colorGradingTexture: Nullable<BaseTexture>;
  73521. private _colorGradingEnabled;
  73522. /**
  73523. * Gets wether the color grading effect is enabled.
  73524. */
  73525. /**
  73526. * Sets wether the color grading effect is enabled.
  73527. */
  73528. colorGradingEnabled: boolean;
  73529. private _colorGradingWithGreenDepth;
  73530. /**
  73531. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  73532. */
  73533. /**
  73534. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  73535. */
  73536. colorGradingWithGreenDepth: boolean;
  73537. private _colorGradingBGR;
  73538. /**
  73539. * Gets wether the color grading texture contains BGR values.
  73540. */
  73541. /**
  73542. * Sets wether the color grading texture contains BGR values.
  73543. */
  73544. colorGradingBGR: boolean;
  73545. /** @hidden */
  73546. _exposure: number;
  73547. /**
  73548. * Gets the Exposure used in the effect.
  73549. */
  73550. /**
  73551. * Sets the Exposure used in the effect.
  73552. */
  73553. exposure: number;
  73554. private _toneMappingEnabled;
  73555. /**
  73556. * Gets wether the tone mapping effect is enabled.
  73557. */
  73558. /**
  73559. * Sets wether the tone mapping effect is enabled.
  73560. */
  73561. toneMappingEnabled: boolean;
  73562. private _toneMappingType;
  73563. /**
  73564. * Gets the type of tone mapping effect.
  73565. */
  73566. /**
  73567. * Sets the type of tone mapping effect used in BabylonJS.
  73568. */
  73569. toneMappingType: number;
  73570. protected _contrast: number;
  73571. /**
  73572. * Gets the contrast used in the effect.
  73573. */
  73574. /**
  73575. * Sets the contrast used in the effect.
  73576. */
  73577. contrast: number;
  73578. /**
  73579. * Vignette stretch size.
  73580. */
  73581. vignetteStretch: number;
  73582. /**
  73583. * Vignette centre X Offset.
  73584. */
  73585. vignetteCentreX: number;
  73586. /**
  73587. * Vignette centre Y Offset.
  73588. */
  73589. vignetteCentreY: number;
  73590. /**
  73591. * Vignette weight or intensity of the vignette effect.
  73592. */
  73593. vignetteWeight: number;
  73594. /**
  73595. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  73596. * if vignetteEnabled is set to true.
  73597. */
  73598. vignetteColor: Color4;
  73599. /**
  73600. * Camera field of view used by the Vignette effect.
  73601. */
  73602. vignetteCameraFov: number;
  73603. private _vignetteBlendMode;
  73604. /**
  73605. * Gets the vignette blend mode allowing different kind of effect.
  73606. */
  73607. /**
  73608. * Sets the vignette blend mode allowing different kind of effect.
  73609. */
  73610. vignetteBlendMode: number;
  73611. private _vignetteEnabled;
  73612. /**
  73613. * Gets wether the vignette effect is enabled.
  73614. */
  73615. /**
  73616. * Sets wether the vignette effect is enabled.
  73617. */
  73618. vignetteEnabled: boolean;
  73619. private _applyByPostProcess;
  73620. /**
  73621. * Gets wether the image processing is applied through a post process or not.
  73622. */
  73623. /**
  73624. * Sets wether the image processing is applied through a post process or not.
  73625. */
  73626. applyByPostProcess: boolean;
  73627. private _isEnabled;
  73628. /**
  73629. * Gets wether the image processing is enabled or not.
  73630. */
  73631. /**
  73632. * Sets wether the image processing is enabled or not.
  73633. */
  73634. isEnabled: boolean;
  73635. /**
  73636. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  73637. */
  73638. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  73639. /**
  73640. * Method called each time the image processing information changes requires to recompile the effect.
  73641. */
  73642. protected _updateParameters(): void;
  73643. /**
  73644. * Gets the current class name.
  73645. * @return "ImageProcessingConfiguration"
  73646. */
  73647. getClassName(): string;
  73648. /**
  73649. * Prepare the list of uniforms associated with the Image Processing effects.
  73650. * @param uniforms The list of uniforms used in the effect
  73651. * @param defines the list of defines currently in use
  73652. */
  73653. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  73654. /**
  73655. * Prepare the list of samplers associated with the Image Processing effects.
  73656. * @param samplersList The list of uniforms used in the effect
  73657. * @param defines the list of defines currently in use
  73658. */
  73659. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  73660. /**
  73661. * Prepare the list of defines associated to the shader.
  73662. * @param defines the list of defines to complete
  73663. * @param forPostProcess Define if we are currently in post process mode or not
  73664. */
  73665. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  73666. /**
  73667. * Returns true if all the image processing information are ready.
  73668. * @returns True if ready, otherwise, false
  73669. */
  73670. isReady(): boolean;
  73671. /**
  73672. * Binds the image processing to the shader.
  73673. * @param effect The effect to bind to
  73674. * @param aspectRatio Define the current aspect ratio of the effect
  73675. */
  73676. bind(effect: Effect, aspectRatio?: number): void;
  73677. /**
  73678. * Clones the current image processing instance.
  73679. * @return The cloned image processing
  73680. */
  73681. clone(): ImageProcessingConfiguration;
  73682. /**
  73683. * Serializes the current image processing instance to a json representation.
  73684. * @return a JSON representation
  73685. */
  73686. serialize(): any;
  73687. /**
  73688. * Parses the image processing from a json representation.
  73689. * @param source the JSON source to parse
  73690. * @return The parsed image processing
  73691. */
  73692. static Parse(source: any): ImageProcessingConfiguration;
  73693. private static _VIGNETTEMODE_MULTIPLY;
  73694. private static _VIGNETTEMODE_OPAQUE;
  73695. /**
  73696. * Used to apply the vignette as a mix with the pixel color.
  73697. */
  73698. static readonly VIGNETTEMODE_MULTIPLY: number;
  73699. /**
  73700. * Used to apply the vignette as a replacement of the pixel color.
  73701. */
  73702. static readonly VIGNETTEMODE_OPAQUE: number;
  73703. }
  73704. }
  73705. declare module BABYLON {
  73706. /** @hidden */
  73707. export var postprocessVertexShader: {
  73708. name: string;
  73709. shader: string;
  73710. };
  73711. }
  73712. declare module BABYLON {
  73713. /** Defines supported spaces */
  73714. export enum Space {
  73715. /** Local (object) space */
  73716. LOCAL = 0,
  73717. /** World space */
  73718. WORLD = 1,
  73719. /** Bone space */
  73720. BONE = 2
  73721. }
  73722. /** Defines the 3 main axes */
  73723. export class Axis {
  73724. /** X axis */
  73725. static X: Vector3;
  73726. /** Y axis */
  73727. static Y: Vector3;
  73728. /** Z axis */
  73729. static Z: Vector3;
  73730. }
  73731. }
  73732. declare module BABYLON {
  73733. /**
  73734. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  73735. * This is the base of the follow, arc rotate cameras and Free camera
  73736. * @see http://doc.babylonjs.com/features/cameras
  73737. */
  73738. export class TargetCamera extends Camera {
  73739. private static _RigCamTransformMatrix;
  73740. private static _TargetTransformMatrix;
  73741. private static _TargetFocalPoint;
  73742. /**
  73743. * Define the current direction the camera is moving to
  73744. */
  73745. cameraDirection: Vector3;
  73746. /**
  73747. * Define the current rotation the camera is rotating to
  73748. */
  73749. cameraRotation: Vector2;
  73750. /**
  73751. * When set, the up vector of the camera will be updated by the rotation of the camera
  73752. */
  73753. updateUpVectorFromRotation: boolean;
  73754. private _tmpQuaternion;
  73755. /**
  73756. * Define the current rotation of the camera
  73757. */
  73758. rotation: Vector3;
  73759. /**
  73760. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  73761. */
  73762. rotationQuaternion: Quaternion;
  73763. /**
  73764. * Define the current speed of the camera
  73765. */
  73766. speed: number;
  73767. /**
  73768. * Add cconstraint to the camera to prevent it to move freely in all directions and
  73769. * around all axis.
  73770. */
  73771. noRotationConstraint: boolean;
  73772. /**
  73773. * Define the current target of the camera as an object or a position.
  73774. */
  73775. lockedTarget: any;
  73776. /** @hidden */
  73777. _currentTarget: Vector3;
  73778. /** @hidden */
  73779. _initialFocalDistance: number;
  73780. /** @hidden */
  73781. _viewMatrix: Matrix;
  73782. /** @hidden */
  73783. _camMatrix: Matrix;
  73784. /** @hidden */
  73785. _cameraTransformMatrix: Matrix;
  73786. /** @hidden */
  73787. _cameraRotationMatrix: Matrix;
  73788. /** @hidden */
  73789. _referencePoint: Vector3;
  73790. /** @hidden */
  73791. _transformedReferencePoint: Vector3;
  73792. protected _globalCurrentTarget: Vector3;
  73793. protected _globalCurrentUpVector: Vector3;
  73794. /** @hidden */
  73795. _reset: () => void;
  73796. private _defaultUp;
  73797. /**
  73798. * Instantiates a target camera that takes a mesh or position as a target and continues to look at it while it moves.
  73799. * This is the base of the follow, arc rotate cameras and Free camera
  73800. * @see http://doc.babylonjs.com/features/cameras
  73801. * @param name Defines the name of the camera in the scene
  73802. * @param position Defines the start position of the camera in the scene
  73803. * @param scene Defines the scene the camera belongs to
  73804. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  73805. */
  73806. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  73807. /**
  73808. * Gets the position in front of the camera at a given distance.
  73809. * @param distance The distance from the camera we want the position to be
  73810. * @returns the position
  73811. */
  73812. getFrontPosition(distance: number): Vector3;
  73813. /** @hidden */
  73814. _getLockedTargetPosition(): Nullable<Vector3>;
  73815. private _storedPosition;
  73816. private _storedRotation;
  73817. private _storedRotationQuaternion;
  73818. /**
  73819. * Store current camera state of the camera (fov, position, rotation, etc..)
  73820. * @returns the camera
  73821. */
  73822. storeState(): Camera;
  73823. /**
  73824. * Restored camera state. You must call storeState() first
  73825. * @returns whether it was successful or not
  73826. * @hidden
  73827. */
  73828. _restoreStateValues(): boolean;
  73829. /** @hidden */
  73830. _initCache(): void;
  73831. /** @hidden */
  73832. _updateCache(ignoreParentClass?: boolean): void;
  73833. /** @hidden */
  73834. _isSynchronizedViewMatrix(): boolean;
  73835. /** @hidden */
  73836. _computeLocalCameraSpeed(): number;
  73837. /**
  73838. * Defines the target the camera should look at.
  73839. * @param target Defines the new target as a Vector or a mesh
  73840. */
  73841. setTarget(target: Vector3): void;
  73842. /**
  73843. * Return the current target position of the camera. This value is expressed in local space.
  73844. * @returns the target position
  73845. */
  73846. getTarget(): Vector3;
  73847. /** @hidden */
  73848. _decideIfNeedsToMove(): boolean;
  73849. /** @hidden */
  73850. _updatePosition(): void;
  73851. /** @hidden */
  73852. _checkInputs(): void;
  73853. protected _updateCameraRotationMatrix(): void;
  73854. /**
  73855. * 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)
  73856. * @returns the current camera
  73857. */
  73858. private _rotateUpVectorWithCameraRotationMatrix;
  73859. private _cachedRotationZ;
  73860. private _cachedQuaternionRotationZ;
  73861. /** @hidden */
  73862. _getViewMatrix(): Matrix;
  73863. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  73864. /**
  73865. * @hidden
  73866. */
  73867. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  73868. /**
  73869. * @hidden
  73870. */
  73871. _updateRigCameras(): void;
  73872. private _getRigCamPositionAndTarget;
  73873. /**
  73874. * Gets the current object class name.
  73875. * @return the class name
  73876. */
  73877. getClassName(): string;
  73878. }
  73879. }
  73880. declare module BABYLON {
  73881. /**
  73882. * Gather the list of keyboard event types as constants.
  73883. */
  73884. export class KeyboardEventTypes {
  73885. /**
  73886. * The keydown event is fired when a key becomes active (pressed).
  73887. */
  73888. static readonly KEYDOWN: number;
  73889. /**
  73890. * The keyup event is fired when a key has been released.
  73891. */
  73892. static readonly KEYUP: number;
  73893. }
  73894. /**
  73895. * This class is used to store keyboard related info for the onKeyboardObservable event.
  73896. */
  73897. export class KeyboardInfo {
  73898. /**
  73899. * Defines the type of event (KeyboardEventTypes)
  73900. */
  73901. type: number;
  73902. /**
  73903. * Defines the related dom event
  73904. */
  73905. event: KeyboardEvent;
  73906. /**
  73907. * Instantiates a new keyboard info.
  73908. * This class is used to store keyboard related info for the onKeyboardObservable event.
  73909. * @param type Defines the type of event (KeyboardEventTypes)
  73910. * @param event Defines the related dom event
  73911. */
  73912. constructor(
  73913. /**
  73914. * Defines the type of event (KeyboardEventTypes)
  73915. */
  73916. type: number,
  73917. /**
  73918. * Defines the related dom event
  73919. */
  73920. event: KeyboardEvent);
  73921. }
  73922. /**
  73923. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  73924. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  73925. */
  73926. export class KeyboardInfoPre extends KeyboardInfo {
  73927. /**
  73928. * Defines the type of event (KeyboardEventTypes)
  73929. */
  73930. type: number;
  73931. /**
  73932. * Defines the related dom event
  73933. */
  73934. event: KeyboardEvent;
  73935. /**
  73936. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  73937. */
  73938. skipOnPointerObservable: boolean;
  73939. /**
  73940. * Instantiates a new keyboard pre info.
  73941. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  73942. * @param type Defines the type of event (KeyboardEventTypes)
  73943. * @param event Defines the related dom event
  73944. */
  73945. constructor(
  73946. /**
  73947. * Defines the type of event (KeyboardEventTypes)
  73948. */
  73949. type: number,
  73950. /**
  73951. * Defines the related dom event
  73952. */
  73953. event: KeyboardEvent);
  73954. }
  73955. }
  73956. declare module BABYLON {
  73957. /**
  73958. * Manage the keyboard inputs to control the movement of a free camera.
  73959. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  73960. */
  73961. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  73962. /**
  73963. * Defines the camera the input is attached to.
  73964. */
  73965. camera: FreeCamera;
  73966. /**
  73967. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  73968. */
  73969. keysUp: number[];
  73970. /**
  73971. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  73972. */
  73973. keysDown: number[];
  73974. /**
  73975. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  73976. */
  73977. keysLeft: number[];
  73978. /**
  73979. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  73980. */
  73981. keysRight: number[];
  73982. private _keys;
  73983. private _onCanvasBlurObserver;
  73984. private _onKeyboardObserver;
  73985. private _engine;
  73986. private _scene;
  73987. /**
  73988. * Attach the input controls to a specific dom element to get the input from.
  73989. * @param element Defines the element the controls should be listened from
  73990. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  73991. */
  73992. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  73993. /**
  73994. * Detach the current controls from the specified dom element.
  73995. * @param element Defines the element to stop listening the inputs from
  73996. */
  73997. detachControl(element: Nullable<HTMLElement>): void;
  73998. /**
  73999. * Update the current camera state depending on the inputs that have been used this frame.
  74000. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  74001. */
  74002. checkInputs(): void;
  74003. /**
  74004. * Gets the class name of the current intput.
  74005. * @returns the class name
  74006. */
  74007. getClassName(): string;
  74008. /** @hidden */
  74009. _onLostFocus(): void;
  74010. /**
  74011. * Get the friendly name associated with the input class.
  74012. * @returns the input friendly name
  74013. */
  74014. getSimpleName(): string;
  74015. }
  74016. }
  74017. declare module BABYLON {
  74018. /**
  74019. * Interface describing all the common properties and methods a shadow light needs to implement.
  74020. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  74021. * as well as binding the different shadow properties to the effects.
  74022. */
  74023. export interface IShadowLight extends Light {
  74024. /**
  74025. * The light id in the scene (used in scene.findLighById for instance)
  74026. */
  74027. id: string;
  74028. /**
  74029. * The position the shdow will be casted from.
  74030. */
  74031. position: Vector3;
  74032. /**
  74033. * In 2d mode (needCube being false), the direction used to cast the shadow.
  74034. */
  74035. direction: Vector3;
  74036. /**
  74037. * The transformed position. Position of the light in world space taking parenting in account.
  74038. */
  74039. transformedPosition: Vector3;
  74040. /**
  74041. * The transformed direction. Direction of the light in world space taking parenting in account.
  74042. */
  74043. transformedDirection: Vector3;
  74044. /**
  74045. * The friendly name of the light in the scene.
  74046. */
  74047. name: string;
  74048. /**
  74049. * Defines the shadow projection clipping minimum z value.
  74050. */
  74051. shadowMinZ: number;
  74052. /**
  74053. * Defines the shadow projection clipping maximum z value.
  74054. */
  74055. shadowMaxZ: number;
  74056. /**
  74057. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  74058. * @returns true if the information has been computed, false if it does not need to (no parenting)
  74059. */
  74060. computeTransformedInformation(): boolean;
  74061. /**
  74062. * Gets the scene the light belongs to.
  74063. * @returns The scene
  74064. */
  74065. getScene(): Scene;
  74066. /**
  74067. * Callback defining a custom Projection Matrix Builder.
  74068. * This can be used to override the default projection matrix computation.
  74069. */
  74070. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  74071. /**
  74072. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  74073. * @param matrix The materix to updated with the projection information
  74074. * @param viewMatrix The transform matrix of the light
  74075. * @param renderList The list of mesh to render in the map
  74076. * @returns The current light
  74077. */
  74078. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  74079. /**
  74080. * Gets the current depth scale used in ESM.
  74081. * @returns The scale
  74082. */
  74083. getDepthScale(): number;
  74084. /**
  74085. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  74086. * @returns true if a cube texture needs to be use
  74087. */
  74088. needCube(): boolean;
  74089. /**
  74090. * Detects if the projection matrix requires to be recomputed this frame.
  74091. * @returns true if it requires to be recomputed otherwise, false.
  74092. */
  74093. needProjectionMatrixCompute(): boolean;
  74094. /**
  74095. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  74096. */
  74097. forceProjectionMatrixCompute(): void;
  74098. /**
  74099. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  74100. * @param faceIndex The index of the face we are computed the direction to generate shadow
  74101. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  74102. */
  74103. getShadowDirection(faceIndex?: number): Vector3;
  74104. /**
  74105. * Gets the minZ used for shadow according to both the scene and the light.
  74106. * @param activeCamera The camera we are returning the min for
  74107. * @returns the depth min z
  74108. */
  74109. getDepthMinZ(activeCamera: Camera): number;
  74110. /**
  74111. * Gets the maxZ used for shadow according to both the scene and the light.
  74112. * @param activeCamera The camera we are returning the max for
  74113. * @returns the depth max z
  74114. */
  74115. getDepthMaxZ(activeCamera: Camera): number;
  74116. }
  74117. /**
  74118. * Base implementation IShadowLight
  74119. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  74120. */
  74121. export abstract class ShadowLight extends Light implements IShadowLight {
  74122. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  74123. protected _position: Vector3;
  74124. protected _setPosition(value: Vector3): void;
  74125. /**
  74126. * Sets the position the shadow will be casted from. Also use as the light position for both
  74127. * point and spot lights.
  74128. */
  74129. /**
  74130. * Sets the position the shadow will be casted from. Also use as the light position for both
  74131. * point and spot lights.
  74132. */
  74133. position: Vector3;
  74134. protected _direction: Vector3;
  74135. protected _setDirection(value: Vector3): void;
  74136. /**
  74137. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  74138. * Also use as the light direction on spot and directional lights.
  74139. */
  74140. /**
  74141. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  74142. * Also use as the light direction on spot and directional lights.
  74143. */
  74144. direction: Vector3;
  74145. private _shadowMinZ;
  74146. /**
  74147. * Gets the shadow projection clipping minimum z value.
  74148. */
  74149. /**
  74150. * Sets the shadow projection clipping minimum z value.
  74151. */
  74152. shadowMinZ: number;
  74153. private _shadowMaxZ;
  74154. /**
  74155. * Sets the shadow projection clipping maximum z value.
  74156. */
  74157. /**
  74158. * Gets the shadow projection clipping maximum z value.
  74159. */
  74160. shadowMaxZ: number;
  74161. /**
  74162. * Callback defining a custom Projection Matrix Builder.
  74163. * This can be used to override the default projection matrix computation.
  74164. */
  74165. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  74166. /**
  74167. * The transformed position. Position of the light in world space taking parenting in account.
  74168. */
  74169. transformedPosition: Vector3;
  74170. /**
  74171. * The transformed direction. Direction of the light in world space taking parenting in account.
  74172. */
  74173. transformedDirection: Vector3;
  74174. private _needProjectionMatrixCompute;
  74175. /**
  74176. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  74177. * @returns true if the information has been computed, false if it does not need to (no parenting)
  74178. */
  74179. computeTransformedInformation(): boolean;
  74180. /**
  74181. * Return the depth scale used for the shadow map.
  74182. * @returns the depth scale.
  74183. */
  74184. getDepthScale(): number;
  74185. /**
  74186. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  74187. * @param faceIndex The index of the face we are computed the direction to generate shadow
  74188. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  74189. */
  74190. getShadowDirection(faceIndex?: number): Vector3;
  74191. /**
  74192. * Returns the ShadowLight absolute position in the World.
  74193. * @returns the position vector in world space
  74194. */
  74195. getAbsolutePosition(): Vector3;
  74196. /**
  74197. * Sets the ShadowLight direction toward the passed target.
  74198. * @param target The point to target in local space
  74199. * @returns the updated ShadowLight direction
  74200. */
  74201. setDirectionToTarget(target: Vector3): Vector3;
  74202. /**
  74203. * Returns the light rotation in euler definition.
  74204. * @returns the x y z rotation in local space.
  74205. */
  74206. getRotation(): Vector3;
  74207. /**
  74208. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  74209. * @returns true if a cube texture needs to be use
  74210. */
  74211. needCube(): boolean;
  74212. /**
  74213. * Detects if the projection matrix requires to be recomputed this frame.
  74214. * @returns true if it requires to be recomputed otherwise, false.
  74215. */
  74216. needProjectionMatrixCompute(): boolean;
  74217. /**
  74218. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  74219. */
  74220. forceProjectionMatrixCompute(): void;
  74221. /** @hidden */
  74222. _initCache(): void;
  74223. /** @hidden */
  74224. _isSynchronized(): boolean;
  74225. /**
  74226. * Computes the world matrix of the node
  74227. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  74228. * @returns the world matrix
  74229. */
  74230. computeWorldMatrix(force?: boolean): Matrix;
  74231. /**
  74232. * Gets the minZ used for shadow according to both the scene and the light.
  74233. * @param activeCamera The camera we are returning the min for
  74234. * @returns the depth min z
  74235. */
  74236. getDepthMinZ(activeCamera: Camera): number;
  74237. /**
  74238. * Gets the maxZ used for shadow according to both the scene and the light.
  74239. * @param activeCamera The camera we are returning the max for
  74240. * @returns the depth max z
  74241. */
  74242. getDepthMaxZ(activeCamera: Camera): number;
  74243. /**
  74244. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  74245. * @param matrix The materix to updated with the projection information
  74246. * @param viewMatrix The transform matrix of the light
  74247. * @param renderList The list of mesh to render in the map
  74248. * @returns The current light
  74249. */
  74250. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  74251. }
  74252. }
  74253. declare module BABYLON {
  74254. /**
  74255. * "Static Class" containing the most commonly used helper while dealing with material for
  74256. * rendering purpose.
  74257. *
  74258. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  74259. *
  74260. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  74261. */
  74262. export class MaterialHelper {
  74263. /**
  74264. * Bind the current view position to an effect.
  74265. * @param effect The effect to be bound
  74266. * @param scene The scene the eyes position is used from
  74267. */
  74268. static BindEyePosition(effect: Effect, scene: Scene): void;
  74269. /**
  74270. * Helps preparing the defines values about the UVs in used in the effect.
  74271. * UVs are shared as much as we can accross channels in the shaders.
  74272. * @param texture The texture we are preparing the UVs for
  74273. * @param defines The defines to update
  74274. * @param key The channel key "diffuse", "specular"... used in the shader
  74275. */
  74276. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  74277. /**
  74278. * Binds a texture matrix value to its corrsponding uniform
  74279. * @param texture The texture to bind the matrix for
  74280. * @param uniformBuffer The uniform buffer receivin the data
  74281. * @param key The channel key "diffuse", "specular"... used in the shader
  74282. */
  74283. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  74284. /**
  74285. * Gets the current status of the fog (should it be enabled?)
  74286. * @param mesh defines the mesh to evaluate for fog support
  74287. * @param scene defines the hosting scene
  74288. * @returns true if fog must be enabled
  74289. */
  74290. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  74291. /**
  74292. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  74293. * @param mesh defines the current mesh
  74294. * @param scene defines the current scene
  74295. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  74296. * @param pointsCloud defines if point cloud rendering has to be turned on
  74297. * @param fogEnabled defines if fog has to be turned on
  74298. * @param alphaTest defines if alpha testing has to be turned on
  74299. * @param defines defines the current list of defines
  74300. */
  74301. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  74302. /**
  74303. * Helper used to prepare the list of defines associated with frame values for shader compilation
  74304. * @param scene defines the current scene
  74305. * @param engine defines the current engine
  74306. * @param defines specifies the list of active defines
  74307. * @param useInstances defines if instances have to be turned on
  74308. * @param useClipPlane defines if clip plane have to be turned on
  74309. */
  74310. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  74311. /**
  74312. * Prepares the defines for bones
  74313. * @param mesh The mesh containing the geometry data we will draw
  74314. * @param defines The defines to update
  74315. */
  74316. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  74317. /**
  74318. * Prepares the defines for morph targets
  74319. * @param mesh The mesh containing the geometry data we will draw
  74320. * @param defines The defines to update
  74321. */
  74322. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  74323. /**
  74324. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  74325. * @param mesh The mesh containing the geometry data we will draw
  74326. * @param defines The defines to update
  74327. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  74328. * @param useBones Precise whether bones should be used or not (override mesh info)
  74329. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  74330. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  74331. * @returns false if defines are considered not dirty and have not been checked
  74332. */
  74333. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  74334. /**
  74335. * Prepares the defines related to multiview
  74336. * @param scene The scene we are intending to draw
  74337. * @param defines The defines to update
  74338. */
  74339. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  74340. /**
  74341. * Prepares the defines related to the light information passed in parameter
  74342. * @param scene The scene we are intending to draw
  74343. * @param mesh The mesh the effect is compiling for
  74344. * @param light The light the effect is compiling for
  74345. * @param lightIndex The index of the light
  74346. * @param defines The defines to update
  74347. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  74348. * @param state Defines the current state regarding what is needed (normals, etc...)
  74349. */
  74350. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  74351. needNormals: boolean;
  74352. needRebuild: boolean;
  74353. shadowEnabled: boolean;
  74354. specularEnabled: boolean;
  74355. lightmapMode: boolean;
  74356. }): void;
  74357. /**
  74358. * Prepares the defines related to the light information passed in parameter
  74359. * @param scene The scene we are intending to draw
  74360. * @param mesh The mesh the effect is compiling for
  74361. * @param defines The defines to update
  74362. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  74363. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  74364. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  74365. * @returns true if normals will be required for the rest of the effect
  74366. */
  74367. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  74368. /**
  74369. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  74370. * @param lightIndex defines the light index
  74371. * @param uniformsList The uniform list
  74372. * @param samplersList The sampler list
  74373. * @param projectedLightTexture defines if projected texture must be used
  74374. * @param uniformBuffersList defines an optional list of uniform buffers
  74375. */
  74376. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  74377. /**
  74378. * Prepares the uniforms and samplers list to be used in the effect
  74379. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  74380. * @param samplersList The sampler list
  74381. * @param defines The defines helping in the list generation
  74382. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  74383. */
  74384. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | EffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  74385. /**
  74386. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  74387. * @param defines The defines to update while falling back
  74388. * @param fallbacks The authorized effect fallbacks
  74389. * @param maxSimultaneousLights The maximum number of lights allowed
  74390. * @param rank the current rank of the Effect
  74391. * @returns The newly affected rank
  74392. */
  74393. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  74394. private static _TmpMorphInfluencers;
  74395. /**
  74396. * Prepares the list of attributes required for morph targets according to the effect defines.
  74397. * @param attribs The current list of supported attribs
  74398. * @param mesh The mesh to prepare the morph targets attributes for
  74399. * @param influencers The number of influencers
  74400. */
  74401. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  74402. /**
  74403. * Prepares the list of attributes required for morph targets according to the effect defines.
  74404. * @param attribs The current list of supported attribs
  74405. * @param mesh The mesh to prepare the morph targets attributes for
  74406. * @param defines The current Defines of the effect
  74407. */
  74408. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  74409. /**
  74410. * Prepares the list of attributes required for bones according to the effect defines.
  74411. * @param attribs The current list of supported attribs
  74412. * @param mesh The mesh to prepare the bones attributes for
  74413. * @param defines The current Defines of the effect
  74414. * @param fallbacks The current efffect fallback strategy
  74415. */
  74416. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  74417. /**
  74418. * Check and prepare the list of attributes required for instances according to the effect defines.
  74419. * @param attribs The current list of supported attribs
  74420. * @param defines The current MaterialDefines of the effect
  74421. */
  74422. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  74423. /**
  74424. * Add the list of attributes required for instances to the attribs array.
  74425. * @param attribs The current list of supported attribs
  74426. */
  74427. static PushAttributesForInstances(attribs: string[]): void;
  74428. /**
  74429. * Binds the light shadow information to the effect for the given mesh.
  74430. * @param light The light containing the generator
  74431. * @param scene The scene the lights belongs to
  74432. * @param mesh The mesh we are binding the information to render
  74433. * @param lightIndex The light index in the effect used to render the mesh
  74434. * @param effect The effect we are binding the data to
  74435. */
  74436. static BindLightShadow(light: Light, mesh: AbstractMesh, lightIndex: string, effect: Effect): void;
  74437. /**
  74438. * Binds the light information to the effect.
  74439. * @param light The light containing the generator
  74440. * @param effect The effect we are binding the data to
  74441. * @param lightIndex The light index in the effect used to render
  74442. */
  74443. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  74444. /**
  74445. * Binds the lights information from the scene to the effect for the given mesh.
  74446. * @param light Light to bind
  74447. * @param lightIndex Light index
  74448. * @param scene The scene where the light belongs to
  74449. * @param mesh The mesh we are binding the information to render
  74450. * @param effect The effect we are binding the data to
  74451. * @param useSpecular Defines if specular is supported
  74452. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  74453. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  74454. */
  74455. static BindLight(light: Light, lightIndex: number, scene: Scene, mesh: AbstractMesh, effect: Effect, useSpecular: boolean, usePhysicalLightFalloff?: boolean, rebuildInParallel?: boolean): void;
  74456. /**
  74457. * Binds the lights information from the scene to the effect for the given mesh.
  74458. * @param scene The scene the lights belongs to
  74459. * @param mesh The mesh we are binding the information to render
  74460. * @param effect The effect we are binding the data to
  74461. * @param defines The generated defines for the effect
  74462. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  74463. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  74464. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  74465. */
  74466. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, usePhysicalLightFalloff?: boolean, rebuildInParallel?: boolean): void;
  74467. private static _tempFogColor;
  74468. /**
  74469. * Binds the fog information from the scene to the effect for the given mesh.
  74470. * @param scene The scene the lights belongs to
  74471. * @param mesh The mesh we are binding the information to render
  74472. * @param effect The effect we are binding the data to
  74473. * @param linearSpace Defines if the fog effect is applied in linear space
  74474. */
  74475. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  74476. /**
  74477. * Binds the bones information from the mesh to the effect.
  74478. * @param mesh The mesh we are binding the information to render
  74479. * @param effect The effect we are binding the data to
  74480. */
  74481. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  74482. /**
  74483. * Binds the morph targets information from the mesh to the effect.
  74484. * @param abstractMesh The mesh we are binding the information to render
  74485. * @param effect The effect we are binding the data to
  74486. */
  74487. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  74488. /**
  74489. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  74490. * @param defines The generated defines used in the effect
  74491. * @param effect The effect we are binding the data to
  74492. * @param scene The scene we are willing to render with logarithmic scale for
  74493. */
  74494. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  74495. /**
  74496. * Binds the clip plane information from the scene to the effect.
  74497. * @param scene The scene the clip plane information are extracted from
  74498. * @param effect The effect we are binding the data to
  74499. */
  74500. static BindClipPlane(effect: Effect, scene: Scene): void;
  74501. }
  74502. }
  74503. declare module BABYLON {
  74504. /** @hidden */
  74505. export var packingFunctions: {
  74506. name: string;
  74507. shader: string;
  74508. };
  74509. }
  74510. declare module BABYLON {
  74511. /** @hidden */
  74512. export var shadowMapPixelShader: {
  74513. name: string;
  74514. shader: string;
  74515. };
  74516. }
  74517. declare module BABYLON {
  74518. /** @hidden */
  74519. export var bonesDeclaration: {
  74520. name: string;
  74521. shader: string;
  74522. };
  74523. }
  74524. declare module BABYLON {
  74525. /** @hidden */
  74526. export var morphTargetsVertexGlobalDeclaration: {
  74527. name: string;
  74528. shader: string;
  74529. };
  74530. }
  74531. declare module BABYLON {
  74532. /** @hidden */
  74533. export var morphTargetsVertexDeclaration: {
  74534. name: string;
  74535. shader: string;
  74536. };
  74537. }
  74538. declare module BABYLON {
  74539. /** @hidden */
  74540. export var instancesDeclaration: {
  74541. name: string;
  74542. shader: string;
  74543. };
  74544. }
  74545. declare module BABYLON {
  74546. /** @hidden */
  74547. export var helperFunctions: {
  74548. name: string;
  74549. shader: string;
  74550. };
  74551. }
  74552. declare module BABYLON {
  74553. /** @hidden */
  74554. export var morphTargetsVertex: {
  74555. name: string;
  74556. shader: string;
  74557. };
  74558. }
  74559. declare module BABYLON {
  74560. /** @hidden */
  74561. export var instancesVertex: {
  74562. name: string;
  74563. shader: string;
  74564. };
  74565. }
  74566. declare module BABYLON {
  74567. /** @hidden */
  74568. export var bonesVertex: {
  74569. name: string;
  74570. shader: string;
  74571. };
  74572. }
  74573. declare module BABYLON {
  74574. /** @hidden */
  74575. export var shadowMapVertexShader: {
  74576. name: string;
  74577. shader: string;
  74578. };
  74579. }
  74580. declare module BABYLON {
  74581. /** @hidden */
  74582. export var depthBoxBlurPixelShader: {
  74583. name: string;
  74584. shader: string;
  74585. };
  74586. }
  74587. declare module BABYLON {
  74588. /**
  74589. * Defines the options associated with the creation of a custom shader for a shadow generator.
  74590. */
  74591. export interface ICustomShaderOptions {
  74592. /**
  74593. * Gets or sets the custom shader name to use
  74594. */
  74595. shaderName: string;
  74596. /**
  74597. * The list of attribute names used in the shader
  74598. */
  74599. attributes?: string[];
  74600. /**
  74601. * The list of unifrom names used in the shader
  74602. */
  74603. uniforms?: string[];
  74604. /**
  74605. * The list of sampler names used in the shader
  74606. */
  74607. samplers?: string[];
  74608. /**
  74609. * The list of defines used in the shader
  74610. */
  74611. defines?: string[];
  74612. }
  74613. /**
  74614. * Interface to implement to create a shadow generator compatible with BJS.
  74615. */
  74616. export interface IShadowGenerator {
  74617. /**
  74618. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  74619. * @returns The render target texture if present otherwise, null
  74620. */
  74621. getShadowMap(): Nullable<RenderTargetTexture>;
  74622. /**
  74623. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  74624. * @returns The render target texture if the shadow map is present otherwise, null
  74625. */
  74626. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  74627. /**
  74628. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  74629. * @param subMesh The submesh we want to render in the shadow map
  74630. * @param useInstances Defines wether will draw in the map using instances
  74631. * @returns true if ready otherwise, false
  74632. */
  74633. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  74634. /**
  74635. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  74636. * @param defines Defines of the material we want to update
  74637. * @param lightIndex Index of the light in the enabled light list of the material
  74638. */
  74639. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  74640. /**
  74641. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  74642. * defined in the generator but impacting the effect).
  74643. * It implies the unifroms available on the materials are the standard BJS ones.
  74644. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  74645. * @param effect The effect we are binfing the information for
  74646. */
  74647. bindShadowLight(lightIndex: string, effect: Effect): void;
  74648. /**
  74649. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  74650. * (eq to shadow prjection matrix * light transform matrix)
  74651. * @returns The transform matrix used to create the shadow map
  74652. */
  74653. getTransformMatrix(): Matrix;
  74654. /**
  74655. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  74656. * Cube and 2D textures for instance.
  74657. */
  74658. recreateShadowMap(): void;
  74659. /**
  74660. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  74661. * @param onCompiled Callback triggered at the and of the effects compilation
  74662. * @param options Sets of optional options forcing the compilation with different modes
  74663. */
  74664. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  74665. useInstances: boolean;
  74666. }>): void;
  74667. /**
  74668. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  74669. * @param options Sets of optional options forcing the compilation with different modes
  74670. * @returns A promise that resolves when the compilation completes
  74671. */
  74672. forceCompilationAsync(options?: Partial<{
  74673. useInstances: boolean;
  74674. }>): Promise<void>;
  74675. /**
  74676. * Serializes the shadow generator setup to a json object.
  74677. * @returns The serialized JSON object
  74678. */
  74679. serialize(): any;
  74680. /**
  74681. * Disposes the Shadow map and related Textures and effects.
  74682. */
  74683. dispose(): void;
  74684. }
  74685. /**
  74686. * Default implementation IShadowGenerator.
  74687. * This is the main object responsible of generating shadows in the framework.
  74688. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  74689. */
  74690. export class ShadowGenerator implements IShadowGenerator {
  74691. /**
  74692. * Shadow generator mode None: no filtering applied.
  74693. */
  74694. static readonly FILTER_NONE: number;
  74695. /**
  74696. * Shadow generator mode ESM: Exponential Shadow Mapping.
  74697. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  74698. */
  74699. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  74700. /**
  74701. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  74702. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  74703. */
  74704. static readonly FILTER_POISSONSAMPLING: number;
  74705. /**
  74706. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  74707. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  74708. */
  74709. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  74710. /**
  74711. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  74712. * edge artifacts on steep falloff.
  74713. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  74714. */
  74715. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  74716. /**
  74717. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  74718. * edge artifacts on steep falloff.
  74719. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  74720. */
  74721. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  74722. /**
  74723. * Shadow generator mode PCF: Percentage Closer Filtering
  74724. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  74725. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  74726. */
  74727. static readonly FILTER_PCF: number;
  74728. /**
  74729. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  74730. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  74731. * Contact Hardening
  74732. */
  74733. static readonly FILTER_PCSS: number;
  74734. /**
  74735. * Reserved for PCF and PCSS
  74736. * Highest Quality.
  74737. *
  74738. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  74739. *
  74740. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  74741. */
  74742. static readonly QUALITY_HIGH: number;
  74743. /**
  74744. * Reserved for PCF and PCSS
  74745. * Good tradeoff for quality/perf cross devices
  74746. *
  74747. * Execute PCF on a 3*3 kernel.
  74748. *
  74749. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  74750. */
  74751. static readonly QUALITY_MEDIUM: number;
  74752. /**
  74753. * Reserved for PCF and PCSS
  74754. * The lowest quality but the fastest.
  74755. *
  74756. * Execute PCF on a 1*1 kernel.
  74757. *
  74758. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  74759. */
  74760. static readonly QUALITY_LOW: number;
  74761. /** Gets or sets the custom shader name to use */
  74762. customShaderOptions: ICustomShaderOptions;
  74763. /**
  74764. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  74765. */
  74766. onBeforeShadowMapRenderObservable: Observable<Effect>;
  74767. /**
  74768. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  74769. */
  74770. onAfterShadowMapRenderObservable: Observable<Effect>;
  74771. /**
  74772. * Observable triggered before a mesh is rendered in the shadow map.
  74773. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  74774. */
  74775. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  74776. /**
  74777. * Observable triggered after a mesh is rendered in the shadow map.
  74778. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  74779. */
  74780. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  74781. private _bias;
  74782. /**
  74783. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  74784. */
  74785. /**
  74786. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  74787. */
  74788. bias: number;
  74789. private _normalBias;
  74790. /**
  74791. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  74792. */
  74793. /**
  74794. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  74795. */
  74796. normalBias: number;
  74797. private _blurBoxOffset;
  74798. /**
  74799. * Gets the blur box offset: offset applied during the blur pass.
  74800. * Only useful if useKernelBlur = false
  74801. */
  74802. /**
  74803. * Sets the blur box offset: offset applied during the blur pass.
  74804. * Only useful if useKernelBlur = false
  74805. */
  74806. blurBoxOffset: number;
  74807. private _blurScale;
  74808. /**
  74809. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  74810. * 2 means half of the size.
  74811. */
  74812. /**
  74813. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  74814. * 2 means half of the size.
  74815. */
  74816. blurScale: number;
  74817. private _blurKernel;
  74818. /**
  74819. * Gets the blur kernel: kernel size of the blur pass.
  74820. * Only useful if useKernelBlur = true
  74821. */
  74822. /**
  74823. * Sets the blur kernel: kernel size of the blur pass.
  74824. * Only useful if useKernelBlur = true
  74825. */
  74826. blurKernel: number;
  74827. private _useKernelBlur;
  74828. /**
  74829. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  74830. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  74831. */
  74832. /**
  74833. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  74834. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  74835. */
  74836. useKernelBlur: boolean;
  74837. private _depthScale;
  74838. /**
  74839. * Gets the depth scale used in ESM mode.
  74840. */
  74841. /**
  74842. * Sets the depth scale used in ESM mode.
  74843. * This can override the scale stored on the light.
  74844. */
  74845. depthScale: number;
  74846. private _filter;
  74847. /**
  74848. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  74849. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  74850. */
  74851. /**
  74852. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  74853. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  74854. */
  74855. filter: number;
  74856. /**
  74857. * Gets if the current filter is set to Poisson Sampling.
  74858. */
  74859. /**
  74860. * Sets the current filter to Poisson Sampling.
  74861. */
  74862. usePoissonSampling: boolean;
  74863. /**
  74864. * Gets if the current filter is set to ESM.
  74865. */
  74866. /**
  74867. * Sets the current filter is to ESM.
  74868. */
  74869. useExponentialShadowMap: boolean;
  74870. /**
  74871. * Gets if the current filter is set to filtered ESM.
  74872. */
  74873. /**
  74874. * Gets if the current filter is set to filtered ESM.
  74875. */
  74876. useBlurExponentialShadowMap: boolean;
  74877. /**
  74878. * Gets if the current filter is set to "close ESM" (using the inverse of the
  74879. * exponential to prevent steep falloff artifacts).
  74880. */
  74881. /**
  74882. * Sets the current filter to "close ESM" (using the inverse of the
  74883. * exponential to prevent steep falloff artifacts).
  74884. */
  74885. useCloseExponentialShadowMap: boolean;
  74886. /**
  74887. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  74888. * exponential to prevent steep falloff artifacts).
  74889. */
  74890. /**
  74891. * Sets the current filter to filtered "close ESM" (using the inverse of the
  74892. * exponential to prevent steep falloff artifacts).
  74893. */
  74894. useBlurCloseExponentialShadowMap: boolean;
  74895. /**
  74896. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  74897. */
  74898. /**
  74899. * Sets the current filter to "PCF" (percentage closer filtering).
  74900. */
  74901. usePercentageCloserFiltering: boolean;
  74902. private _filteringQuality;
  74903. /**
  74904. * Gets the PCF or PCSS Quality.
  74905. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  74906. */
  74907. /**
  74908. * Sets the PCF or PCSS Quality.
  74909. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  74910. */
  74911. filteringQuality: number;
  74912. /**
  74913. * Gets if the current filter is set to "PCSS" (contact hardening).
  74914. */
  74915. /**
  74916. * Sets the current filter to "PCSS" (contact hardening).
  74917. */
  74918. useContactHardeningShadow: boolean;
  74919. private _contactHardeningLightSizeUVRatio;
  74920. /**
  74921. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  74922. * Using a ratio helps keeping shape stability independently of the map size.
  74923. *
  74924. * It does not account for the light projection as it was having too much
  74925. * instability during the light setup or during light position changes.
  74926. *
  74927. * Only valid if useContactHardeningShadow is true.
  74928. */
  74929. /**
  74930. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  74931. * Using a ratio helps keeping shape stability independently of the map size.
  74932. *
  74933. * It does not account for the light projection as it was having too much
  74934. * instability during the light setup or during light position changes.
  74935. *
  74936. * Only valid if useContactHardeningShadow is true.
  74937. */
  74938. contactHardeningLightSizeUVRatio: number;
  74939. private _darkness;
  74940. /** Gets or sets the actual darkness of a shadow */
  74941. darkness: number;
  74942. /**
  74943. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  74944. * 0 means strongest and 1 would means no shadow.
  74945. * @returns the darkness.
  74946. */
  74947. getDarkness(): number;
  74948. /**
  74949. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  74950. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  74951. * @returns the shadow generator allowing fluent coding.
  74952. */
  74953. setDarkness(darkness: number): ShadowGenerator;
  74954. private _transparencyShadow;
  74955. /** Gets or sets the ability to have transparent shadow */
  74956. transparencyShadow: boolean;
  74957. /**
  74958. * Sets the ability to have transparent shadow (boolean).
  74959. * @param transparent True if transparent else False
  74960. * @returns the shadow generator allowing fluent coding
  74961. */
  74962. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  74963. private _shadowMap;
  74964. private _shadowMap2;
  74965. /**
  74966. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  74967. * @returns The render target texture if present otherwise, null
  74968. */
  74969. getShadowMap(): Nullable<RenderTargetTexture>;
  74970. /**
  74971. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  74972. * @returns The render target texture if the shadow map is present otherwise, null
  74973. */
  74974. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  74975. /**
  74976. * Gets the class name of that object
  74977. * @returns "ShadowGenerator"
  74978. */
  74979. getClassName(): string;
  74980. /**
  74981. * Helper function to add a mesh and its descendants to the list of shadow casters.
  74982. * @param mesh Mesh to add
  74983. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  74984. * @returns the Shadow Generator itself
  74985. */
  74986. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  74987. /**
  74988. * Helper function to remove a mesh and its descendants from the list of shadow casters
  74989. * @param mesh Mesh to remove
  74990. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  74991. * @returns the Shadow Generator itself
  74992. */
  74993. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  74994. /**
  74995. * Controls the extent to which the shadows fade out at the edge of the frustum
  74996. * Used only by directionals and spots
  74997. */
  74998. frustumEdgeFalloff: number;
  74999. private _light;
  75000. /**
  75001. * Returns the associated light object.
  75002. * @returns the light generating the shadow
  75003. */
  75004. getLight(): IShadowLight;
  75005. /**
  75006. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  75007. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  75008. * It might on the other hand introduce peter panning.
  75009. */
  75010. forceBackFacesOnly: boolean;
  75011. private _scene;
  75012. private _lightDirection;
  75013. private _effect;
  75014. private _viewMatrix;
  75015. private _projectionMatrix;
  75016. private _transformMatrix;
  75017. private _cachedPosition;
  75018. private _cachedDirection;
  75019. private _cachedDefines;
  75020. private _currentRenderID;
  75021. private _boxBlurPostprocess;
  75022. private _kernelBlurXPostprocess;
  75023. private _kernelBlurYPostprocess;
  75024. private _blurPostProcesses;
  75025. private _mapSize;
  75026. private _currentFaceIndex;
  75027. private _currentFaceIndexCache;
  75028. private _textureType;
  75029. private _defaultTextureMatrix;
  75030. /** @hidden */
  75031. static _SceneComponentInitialization: (scene: Scene) => void;
  75032. /**
  75033. * Creates a ShadowGenerator object.
  75034. * A ShadowGenerator is the required tool to use the shadows.
  75035. * Each light casting shadows needs to use its own ShadowGenerator.
  75036. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  75037. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  75038. * @param light The light object generating the shadows.
  75039. * @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.
  75040. */
  75041. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  75042. private _initializeGenerator;
  75043. private _initializeShadowMap;
  75044. private _initializeBlurRTTAndPostProcesses;
  75045. private _renderForShadowMap;
  75046. private _renderSubMeshForShadowMap;
  75047. private _applyFilterValues;
  75048. /**
  75049. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  75050. * @param onCompiled Callback triggered at the and of the effects compilation
  75051. * @param options Sets of optional options forcing the compilation with different modes
  75052. */
  75053. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  75054. useInstances: boolean;
  75055. }>): void;
  75056. /**
  75057. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  75058. * @param options Sets of optional options forcing the compilation with different modes
  75059. * @returns A promise that resolves when the compilation completes
  75060. */
  75061. forceCompilationAsync(options?: Partial<{
  75062. useInstances: boolean;
  75063. }>): Promise<void>;
  75064. /**
  75065. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  75066. * @param subMesh The submesh we want to render in the shadow map
  75067. * @param useInstances Defines wether will draw in the map using instances
  75068. * @returns true if ready otherwise, false
  75069. */
  75070. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  75071. /**
  75072. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  75073. * @param defines Defines of the material we want to update
  75074. * @param lightIndex Index of the light in the enabled light list of the material
  75075. */
  75076. prepareDefines(defines: any, lightIndex: number): void;
  75077. /**
  75078. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  75079. * defined in the generator but impacting the effect).
  75080. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  75081. * @param effect The effect we are binfing the information for
  75082. */
  75083. bindShadowLight(lightIndex: string, effect: Effect): void;
  75084. /**
  75085. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  75086. * (eq to shadow prjection matrix * light transform matrix)
  75087. * @returns The transform matrix used to create the shadow map
  75088. */
  75089. getTransformMatrix(): Matrix;
  75090. /**
  75091. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  75092. * Cube and 2D textures for instance.
  75093. */
  75094. recreateShadowMap(): void;
  75095. private _disposeBlurPostProcesses;
  75096. private _disposeRTTandPostProcesses;
  75097. /**
  75098. * Disposes the ShadowGenerator.
  75099. * Returns nothing.
  75100. */
  75101. dispose(): void;
  75102. /**
  75103. * Serializes the shadow generator setup to a json object.
  75104. * @returns The serialized JSON object
  75105. */
  75106. serialize(): any;
  75107. /**
  75108. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  75109. * @param parsedShadowGenerator The JSON object to parse
  75110. * @param scene The scene to create the shadow map for
  75111. * @returns The parsed shadow generator
  75112. */
  75113. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  75114. }
  75115. }
  75116. declare module BABYLON {
  75117. /**
  75118. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  75119. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  75120. * 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.
  75121. */
  75122. export abstract class Light extends Node {
  75123. /**
  75124. * Falloff Default: light is falling off following the material specification:
  75125. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  75126. */
  75127. static readonly FALLOFF_DEFAULT: number;
  75128. /**
  75129. * Falloff Physical: light is falling off following the inverse squared distance law.
  75130. */
  75131. static readonly FALLOFF_PHYSICAL: number;
  75132. /**
  75133. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  75134. * to enhance interoperability with other engines.
  75135. */
  75136. static readonly FALLOFF_GLTF: number;
  75137. /**
  75138. * Falloff Standard: light is falling off like in the standard material
  75139. * to enhance interoperability with other materials.
  75140. */
  75141. static readonly FALLOFF_STANDARD: number;
  75142. /**
  75143. * If every light affecting the material is in this lightmapMode,
  75144. * material.lightmapTexture adds or multiplies
  75145. * (depends on material.useLightmapAsShadowmap)
  75146. * after every other light calculations.
  75147. */
  75148. static readonly LIGHTMAP_DEFAULT: number;
  75149. /**
  75150. * material.lightmapTexture as only diffuse lighting from this light
  75151. * adds only specular lighting from this light
  75152. * adds dynamic shadows
  75153. */
  75154. static readonly LIGHTMAP_SPECULAR: number;
  75155. /**
  75156. * material.lightmapTexture as only lighting
  75157. * no light calculation from this light
  75158. * only adds dynamic shadows from this light
  75159. */
  75160. static readonly LIGHTMAP_SHADOWSONLY: number;
  75161. /**
  75162. * Each light type uses the default quantity according to its type:
  75163. * point/spot lights use luminous intensity
  75164. * directional lights use illuminance
  75165. */
  75166. static readonly INTENSITYMODE_AUTOMATIC: number;
  75167. /**
  75168. * lumen (lm)
  75169. */
  75170. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  75171. /**
  75172. * candela (lm/sr)
  75173. */
  75174. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  75175. /**
  75176. * lux (lm/m^2)
  75177. */
  75178. static readonly INTENSITYMODE_ILLUMINANCE: number;
  75179. /**
  75180. * nit (cd/m^2)
  75181. */
  75182. static readonly INTENSITYMODE_LUMINANCE: number;
  75183. /**
  75184. * Light type const id of the point light.
  75185. */
  75186. static readonly LIGHTTYPEID_POINTLIGHT: number;
  75187. /**
  75188. * Light type const id of the directional light.
  75189. */
  75190. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  75191. /**
  75192. * Light type const id of the spot light.
  75193. */
  75194. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  75195. /**
  75196. * Light type const id of the hemispheric light.
  75197. */
  75198. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  75199. /**
  75200. * Diffuse gives the basic color to an object.
  75201. */
  75202. diffuse: Color3;
  75203. /**
  75204. * Specular produces a highlight color on an object.
  75205. * Note: This is note affecting PBR materials.
  75206. */
  75207. specular: Color3;
  75208. /**
  75209. * Defines the falloff type for this light. This lets overrriding how punctual light are
  75210. * falling off base on range or angle.
  75211. * This can be set to any values in Light.FALLOFF_x.
  75212. *
  75213. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  75214. * other types of materials.
  75215. */
  75216. falloffType: number;
  75217. /**
  75218. * Strength of the light.
  75219. * Note: By default it is define in the framework own unit.
  75220. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  75221. */
  75222. intensity: number;
  75223. private _range;
  75224. protected _inverseSquaredRange: number;
  75225. /**
  75226. * Defines how far from the source the light is impacting in scene units.
  75227. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  75228. */
  75229. /**
  75230. * Defines how far from the source the light is impacting in scene units.
  75231. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  75232. */
  75233. range: number;
  75234. /**
  75235. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  75236. * of light.
  75237. */
  75238. private _photometricScale;
  75239. private _intensityMode;
  75240. /**
  75241. * Gets the photometric scale used to interpret the intensity.
  75242. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  75243. */
  75244. /**
  75245. * Sets the photometric scale used to interpret the intensity.
  75246. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  75247. */
  75248. intensityMode: number;
  75249. private _radius;
  75250. /**
  75251. * Gets the light radius used by PBR Materials to simulate soft area lights.
  75252. */
  75253. /**
  75254. * sets the light radius used by PBR Materials to simulate soft area lights.
  75255. */
  75256. radius: number;
  75257. private _renderPriority;
  75258. /**
  75259. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  75260. * exceeding the number allowed of the materials.
  75261. */
  75262. renderPriority: number;
  75263. private _shadowEnabled;
  75264. /**
  75265. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  75266. * the current shadow generator.
  75267. */
  75268. /**
  75269. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  75270. * the current shadow generator.
  75271. */
  75272. shadowEnabled: boolean;
  75273. private _includedOnlyMeshes;
  75274. /**
  75275. * Gets the only meshes impacted by this light.
  75276. */
  75277. /**
  75278. * Sets the only meshes impacted by this light.
  75279. */
  75280. includedOnlyMeshes: AbstractMesh[];
  75281. private _excludedMeshes;
  75282. /**
  75283. * Gets the meshes not impacted by this light.
  75284. */
  75285. /**
  75286. * Sets the meshes not impacted by this light.
  75287. */
  75288. excludedMeshes: AbstractMesh[];
  75289. private _excludeWithLayerMask;
  75290. /**
  75291. * Gets the layer id use to find what meshes are not impacted by the light.
  75292. * Inactive if 0
  75293. */
  75294. /**
  75295. * Sets the layer id use to find what meshes are not impacted by the light.
  75296. * Inactive if 0
  75297. */
  75298. excludeWithLayerMask: number;
  75299. private _includeOnlyWithLayerMask;
  75300. /**
  75301. * Gets the layer id use to find what meshes are impacted by the light.
  75302. * Inactive if 0
  75303. */
  75304. /**
  75305. * Sets the layer id use to find what meshes are impacted by the light.
  75306. * Inactive if 0
  75307. */
  75308. includeOnlyWithLayerMask: number;
  75309. private _lightmapMode;
  75310. /**
  75311. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  75312. */
  75313. /**
  75314. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  75315. */
  75316. lightmapMode: number;
  75317. /**
  75318. * Shadow generator associted to the light.
  75319. * @hidden Internal use only.
  75320. */
  75321. _shadowGenerator: Nullable<IShadowGenerator>;
  75322. /**
  75323. * @hidden Internal use only.
  75324. */
  75325. _excludedMeshesIds: string[];
  75326. /**
  75327. * @hidden Internal use only.
  75328. */
  75329. _includedOnlyMeshesIds: string[];
  75330. /**
  75331. * The current light unifom buffer.
  75332. * @hidden Internal use only.
  75333. */
  75334. _uniformBuffer: UniformBuffer;
  75335. /**
  75336. * Creates a Light object in the scene.
  75337. * Documentation : https://doc.babylonjs.com/babylon101/lights
  75338. * @param name The firendly name of the light
  75339. * @param scene The scene the light belongs too
  75340. */
  75341. constructor(name: string, scene: Scene);
  75342. protected abstract _buildUniformLayout(): void;
  75343. /**
  75344. * Sets the passed Effect "effect" with the Light information.
  75345. * @param effect The effect to update
  75346. * @param lightIndex The index of the light in the effect to update
  75347. * @returns The light
  75348. */
  75349. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  75350. /**
  75351. * Sets the passed Effect "effect" with the Light information.
  75352. * @param effect The effect to update
  75353. * @param lightDataUniformName The uniform used to store light data (position or direction)
  75354. * @returns The light
  75355. */
  75356. abstract transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  75357. /**
  75358. * Returns the string "Light".
  75359. * @returns the class name
  75360. */
  75361. getClassName(): string;
  75362. /** @hidden */
  75363. readonly _isLight: boolean;
  75364. /**
  75365. * Converts the light information to a readable string for debug purpose.
  75366. * @param fullDetails Supports for multiple levels of logging within scene loading
  75367. * @returns the human readable light info
  75368. */
  75369. toString(fullDetails?: boolean): string;
  75370. /** @hidden */
  75371. protected _syncParentEnabledState(): void;
  75372. /**
  75373. * Set the enabled state of this node.
  75374. * @param value - the new enabled state
  75375. */
  75376. setEnabled(value: boolean): void;
  75377. /**
  75378. * Returns the Light associated shadow generator if any.
  75379. * @return the associated shadow generator.
  75380. */
  75381. getShadowGenerator(): Nullable<IShadowGenerator>;
  75382. /**
  75383. * Returns a Vector3, the absolute light position in the World.
  75384. * @returns the world space position of the light
  75385. */
  75386. getAbsolutePosition(): Vector3;
  75387. /**
  75388. * Specifies if the light will affect the passed mesh.
  75389. * @param mesh The mesh to test against the light
  75390. * @return true the mesh is affected otherwise, false.
  75391. */
  75392. canAffectMesh(mesh: AbstractMesh): boolean;
  75393. /**
  75394. * Sort function to order lights for rendering.
  75395. * @param a First Light object to compare to second.
  75396. * @param b Second Light object to compare first.
  75397. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  75398. */
  75399. static CompareLightsPriority(a: Light, b: Light): number;
  75400. /**
  75401. * Releases resources associated with this node.
  75402. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  75403. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  75404. */
  75405. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  75406. /**
  75407. * Returns the light type ID (integer).
  75408. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  75409. */
  75410. getTypeID(): number;
  75411. /**
  75412. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  75413. * @returns the scaled intensity in intensity mode unit
  75414. */
  75415. getScaledIntensity(): number;
  75416. /**
  75417. * Returns a new Light object, named "name", from the current one.
  75418. * @param name The name of the cloned light
  75419. * @returns the new created light
  75420. */
  75421. clone(name: string): Nullable<Light>;
  75422. /**
  75423. * Serializes the current light into a Serialization object.
  75424. * @returns the serialized object.
  75425. */
  75426. serialize(): any;
  75427. /**
  75428. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  75429. * This new light is named "name" and added to the passed scene.
  75430. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  75431. * @param name The friendly name of the light
  75432. * @param scene The scene the new light will belong to
  75433. * @returns the constructor function
  75434. */
  75435. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  75436. /**
  75437. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  75438. * @param parsedLight The JSON representation of the light
  75439. * @param scene The scene to create the parsed light in
  75440. * @returns the created light after parsing
  75441. */
  75442. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  75443. private _hookArrayForExcluded;
  75444. private _hookArrayForIncludedOnly;
  75445. private _resyncMeshes;
  75446. /**
  75447. * Forces the meshes to update their light related information in their rendering used effects
  75448. * @hidden Internal Use Only
  75449. */
  75450. _markMeshesAsLightDirty(): void;
  75451. /**
  75452. * Recomputes the cached photometric scale if needed.
  75453. */
  75454. private _computePhotometricScale;
  75455. /**
  75456. * Returns the Photometric Scale according to the light type and intensity mode.
  75457. */
  75458. private _getPhotometricScale;
  75459. /**
  75460. * Reorder the light in the scene according to their defined priority.
  75461. * @hidden Internal Use Only
  75462. */
  75463. _reorderLightsInScene(): void;
  75464. /**
  75465. * Prepares the list of defines specific to the light type.
  75466. * @param defines the list of defines
  75467. * @param lightIndex defines the index of the light for the effect
  75468. */
  75469. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  75470. }
  75471. }
  75472. declare module BABYLON {
  75473. /**
  75474. * Interface used to define Action
  75475. */
  75476. export interface IAction {
  75477. /**
  75478. * Trigger for the action
  75479. */
  75480. trigger: number;
  75481. /** Options of the trigger */
  75482. triggerOptions: any;
  75483. /**
  75484. * Gets the trigger parameters
  75485. * @returns the trigger parameters
  75486. */
  75487. getTriggerParameter(): any;
  75488. /**
  75489. * Internal only - executes current action event
  75490. * @hidden
  75491. */
  75492. _executeCurrent(evt?: ActionEvent): void;
  75493. /**
  75494. * Serialize placeholder for child classes
  75495. * @param parent of child
  75496. * @returns the serialized object
  75497. */
  75498. serialize(parent: any): any;
  75499. /**
  75500. * Internal only
  75501. * @hidden
  75502. */
  75503. _prepare(): void;
  75504. /**
  75505. * Internal only - manager for action
  75506. * @hidden
  75507. */
  75508. _actionManager: AbstractActionManager;
  75509. /**
  75510. * Adds action to chain of actions, may be a DoNothingAction
  75511. * @param action defines the next action to execute
  75512. * @returns The action passed in
  75513. * @see https://www.babylonjs-playground.com/#1T30HR#0
  75514. */
  75515. then(action: IAction): IAction;
  75516. }
  75517. /**
  75518. * The action to be carried out following a trigger
  75519. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  75520. */
  75521. export class Action implements IAction {
  75522. /** the trigger, with or without parameters, for the action */
  75523. triggerOptions: any;
  75524. /**
  75525. * Trigger for the action
  75526. */
  75527. trigger: number;
  75528. /**
  75529. * Internal only - manager for action
  75530. * @hidden
  75531. */
  75532. _actionManager: ActionManager;
  75533. private _nextActiveAction;
  75534. private _child;
  75535. private _condition?;
  75536. private _triggerParameter;
  75537. /**
  75538. * An event triggered prior to action being executed.
  75539. */
  75540. onBeforeExecuteObservable: Observable<Action>;
  75541. /**
  75542. * Creates a new Action
  75543. * @param triggerOptions the trigger, with or without parameters, for the action
  75544. * @param condition an optional determinant of action
  75545. */
  75546. constructor(
  75547. /** the trigger, with or without parameters, for the action */
  75548. triggerOptions: any, condition?: Condition);
  75549. /**
  75550. * Internal only
  75551. * @hidden
  75552. */
  75553. _prepare(): void;
  75554. /**
  75555. * Gets the trigger parameters
  75556. * @returns the trigger parameters
  75557. */
  75558. getTriggerParameter(): any;
  75559. /**
  75560. * Internal only - executes current action event
  75561. * @hidden
  75562. */
  75563. _executeCurrent(evt?: ActionEvent): void;
  75564. /**
  75565. * Execute placeholder for child classes
  75566. * @param evt optional action event
  75567. */
  75568. execute(evt?: ActionEvent): void;
  75569. /**
  75570. * Skips to next active action
  75571. */
  75572. skipToNextActiveAction(): void;
  75573. /**
  75574. * Adds action to chain of actions, may be a DoNothingAction
  75575. * @param action defines the next action to execute
  75576. * @returns The action passed in
  75577. * @see https://www.babylonjs-playground.com/#1T30HR#0
  75578. */
  75579. then(action: Action): Action;
  75580. /**
  75581. * Internal only
  75582. * @hidden
  75583. */
  75584. _getProperty(propertyPath: string): string;
  75585. /**
  75586. * Internal only
  75587. * @hidden
  75588. */
  75589. _getEffectiveTarget(target: any, propertyPath: string): any;
  75590. /**
  75591. * Serialize placeholder for child classes
  75592. * @param parent of child
  75593. * @returns the serialized object
  75594. */
  75595. serialize(parent: any): any;
  75596. /**
  75597. * Internal only called by serialize
  75598. * @hidden
  75599. */
  75600. protected _serialize(serializedAction: any, parent?: any): any;
  75601. /**
  75602. * Internal only
  75603. * @hidden
  75604. */
  75605. static _SerializeValueAsString: (value: any) => string;
  75606. /**
  75607. * Internal only
  75608. * @hidden
  75609. */
  75610. static _GetTargetProperty: (target: Node | Scene) => {
  75611. name: string;
  75612. targetType: string;
  75613. value: string;
  75614. };
  75615. }
  75616. }
  75617. declare module BABYLON {
  75618. /**
  75619. * A Condition applied to an Action
  75620. */
  75621. export class Condition {
  75622. /**
  75623. * Internal only - manager for action
  75624. * @hidden
  75625. */
  75626. _actionManager: ActionManager;
  75627. /**
  75628. * Internal only
  75629. * @hidden
  75630. */
  75631. _evaluationId: number;
  75632. /**
  75633. * Internal only
  75634. * @hidden
  75635. */
  75636. _currentResult: boolean;
  75637. /**
  75638. * Creates a new Condition
  75639. * @param actionManager the manager of the action the condition is applied to
  75640. */
  75641. constructor(actionManager: ActionManager);
  75642. /**
  75643. * Check if the current condition is valid
  75644. * @returns a boolean
  75645. */
  75646. isValid(): boolean;
  75647. /**
  75648. * Internal only
  75649. * @hidden
  75650. */
  75651. _getProperty(propertyPath: string): string;
  75652. /**
  75653. * Internal only
  75654. * @hidden
  75655. */
  75656. _getEffectiveTarget(target: any, propertyPath: string): any;
  75657. /**
  75658. * Serialize placeholder for child classes
  75659. * @returns the serialized object
  75660. */
  75661. serialize(): any;
  75662. /**
  75663. * Internal only
  75664. * @hidden
  75665. */
  75666. protected _serialize(serializedCondition: any): any;
  75667. }
  75668. /**
  75669. * Defines specific conditional operators as extensions of Condition
  75670. */
  75671. export class ValueCondition extends Condition {
  75672. /** path to specify the property of the target the conditional operator uses */
  75673. propertyPath: string;
  75674. /** the value compared by the conditional operator against the current value of the property */
  75675. value: any;
  75676. /** the conditional operator, default ValueCondition.IsEqual */
  75677. operator: number;
  75678. /**
  75679. * Internal only
  75680. * @hidden
  75681. */
  75682. private static _IsEqual;
  75683. /**
  75684. * Internal only
  75685. * @hidden
  75686. */
  75687. private static _IsDifferent;
  75688. /**
  75689. * Internal only
  75690. * @hidden
  75691. */
  75692. private static _IsGreater;
  75693. /**
  75694. * Internal only
  75695. * @hidden
  75696. */
  75697. private static _IsLesser;
  75698. /**
  75699. * returns the number for IsEqual
  75700. */
  75701. static readonly IsEqual: number;
  75702. /**
  75703. * Returns the number for IsDifferent
  75704. */
  75705. static readonly IsDifferent: number;
  75706. /**
  75707. * Returns the number for IsGreater
  75708. */
  75709. static readonly IsGreater: number;
  75710. /**
  75711. * Returns the number for IsLesser
  75712. */
  75713. static readonly IsLesser: number;
  75714. /**
  75715. * Internal only The action manager for the condition
  75716. * @hidden
  75717. */
  75718. _actionManager: ActionManager;
  75719. /**
  75720. * Internal only
  75721. * @hidden
  75722. */
  75723. private _target;
  75724. /**
  75725. * Internal only
  75726. * @hidden
  75727. */
  75728. private _effectiveTarget;
  75729. /**
  75730. * Internal only
  75731. * @hidden
  75732. */
  75733. private _property;
  75734. /**
  75735. * Creates a new ValueCondition
  75736. * @param actionManager manager for the action the condition applies to
  75737. * @param target for the action
  75738. * @param propertyPath path to specify the property of the target the conditional operator uses
  75739. * @param value the value compared by the conditional operator against the current value of the property
  75740. * @param operator the conditional operator, default ValueCondition.IsEqual
  75741. */
  75742. constructor(actionManager: ActionManager, target: any,
  75743. /** path to specify the property of the target the conditional operator uses */
  75744. propertyPath: string,
  75745. /** the value compared by the conditional operator against the current value of the property */
  75746. value: any,
  75747. /** the conditional operator, default ValueCondition.IsEqual */
  75748. operator?: number);
  75749. /**
  75750. * Compares the given value with the property value for the specified conditional operator
  75751. * @returns the result of the comparison
  75752. */
  75753. isValid(): boolean;
  75754. /**
  75755. * Serialize the ValueCondition into a JSON compatible object
  75756. * @returns serialization object
  75757. */
  75758. serialize(): any;
  75759. /**
  75760. * Gets the name of the conditional operator for the ValueCondition
  75761. * @param operator the conditional operator
  75762. * @returns the name
  75763. */
  75764. static GetOperatorName(operator: number): string;
  75765. }
  75766. /**
  75767. * Defines a predicate condition as an extension of Condition
  75768. */
  75769. export class PredicateCondition extends Condition {
  75770. /** defines the predicate function used to validate the condition */
  75771. predicate: () => boolean;
  75772. /**
  75773. * Internal only - manager for action
  75774. * @hidden
  75775. */
  75776. _actionManager: ActionManager;
  75777. /**
  75778. * Creates a new PredicateCondition
  75779. * @param actionManager manager for the action the condition applies to
  75780. * @param predicate defines the predicate function used to validate the condition
  75781. */
  75782. constructor(actionManager: ActionManager,
  75783. /** defines the predicate function used to validate the condition */
  75784. predicate: () => boolean);
  75785. /**
  75786. * @returns the validity of the predicate condition
  75787. */
  75788. isValid(): boolean;
  75789. }
  75790. /**
  75791. * Defines a state condition as an extension of Condition
  75792. */
  75793. export class StateCondition extends Condition {
  75794. /** Value to compare with target state */
  75795. value: string;
  75796. /**
  75797. * Internal only - manager for action
  75798. * @hidden
  75799. */
  75800. _actionManager: ActionManager;
  75801. /**
  75802. * Internal only
  75803. * @hidden
  75804. */
  75805. private _target;
  75806. /**
  75807. * Creates a new StateCondition
  75808. * @param actionManager manager for the action the condition applies to
  75809. * @param target of the condition
  75810. * @param value to compare with target state
  75811. */
  75812. constructor(actionManager: ActionManager, target: any,
  75813. /** Value to compare with target state */
  75814. value: string);
  75815. /**
  75816. * Gets a boolean indicating if the current condition is met
  75817. * @returns the validity of the state
  75818. */
  75819. isValid(): boolean;
  75820. /**
  75821. * Serialize the StateCondition into a JSON compatible object
  75822. * @returns serialization object
  75823. */
  75824. serialize(): any;
  75825. }
  75826. }
  75827. declare module BABYLON {
  75828. /**
  75829. * This defines an action responsible to toggle a boolean once triggered.
  75830. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  75831. */
  75832. export class SwitchBooleanAction extends Action {
  75833. /**
  75834. * The path to the boolean property in the target object
  75835. */
  75836. propertyPath: string;
  75837. private _target;
  75838. private _effectiveTarget;
  75839. private _property;
  75840. /**
  75841. * Instantiate the action
  75842. * @param triggerOptions defines the trigger options
  75843. * @param target defines the object containing the boolean
  75844. * @param propertyPath defines the path to the boolean property in the target object
  75845. * @param condition defines the trigger related conditions
  75846. */
  75847. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  75848. /** @hidden */
  75849. _prepare(): void;
  75850. /**
  75851. * Execute the action toggle the boolean value.
  75852. */
  75853. execute(): void;
  75854. /**
  75855. * Serializes the actions and its related information.
  75856. * @param parent defines the object to serialize in
  75857. * @returns the serialized object
  75858. */
  75859. serialize(parent: any): any;
  75860. }
  75861. /**
  75862. * This defines an action responsible to set a the state field of the target
  75863. * to a desired value once triggered.
  75864. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  75865. */
  75866. export class SetStateAction extends Action {
  75867. /**
  75868. * The value to store in the state field.
  75869. */
  75870. value: string;
  75871. private _target;
  75872. /**
  75873. * Instantiate the action
  75874. * @param triggerOptions defines the trigger options
  75875. * @param target defines the object containing the state property
  75876. * @param value defines the value to store in the state field
  75877. * @param condition defines the trigger related conditions
  75878. */
  75879. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  75880. /**
  75881. * Execute the action and store the value on the target state property.
  75882. */
  75883. execute(): void;
  75884. /**
  75885. * Serializes the actions and its related information.
  75886. * @param parent defines the object to serialize in
  75887. * @returns the serialized object
  75888. */
  75889. serialize(parent: any): any;
  75890. }
  75891. /**
  75892. * This defines an action responsible to set a property of the target
  75893. * to a desired value once triggered.
  75894. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  75895. */
  75896. export class SetValueAction extends Action {
  75897. /**
  75898. * The path of the property to set in the target.
  75899. */
  75900. propertyPath: string;
  75901. /**
  75902. * The value to set in the property
  75903. */
  75904. value: any;
  75905. private _target;
  75906. private _effectiveTarget;
  75907. private _property;
  75908. /**
  75909. * Instantiate the action
  75910. * @param triggerOptions defines the trigger options
  75911. * @param target defines the object containing the property
  75912. * @param propertyPath defines the path of the property to set in the target
  75913. * @param value defines the value to set in the property
  75914. * @param condition defines the trigger related conditions
  75915. */
  75916. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  75917. /** @hidden */
  75918. _prepare(): void;
  75919. /**
  75920. * Execute the action and set the targetted property to the desired value.
  75921. */
  75922. execute(): void;
  75923. /**
  75924. * Serializes the actions and its related information.
  75925. * @param parent defines the object to serialize in
  75926. * @returns the serialized object
  75927. */
  75928. serialize(parent: any): any;
  75929. }
  75930. /**
  75931. * This defines an action responsible to increment the target value
  75932. * to a desired value once triggered.
  75933. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  75934. */
  75935. export class IncrementValueAction extends Action {
  75936. /**
  75937. * The path of the property to increment in the target.
  75938. */
  75939. propertyPath: string;
  75940. /**
  75941. * The value we should increment the property by.
  75942. */
  75943. value: any;
  75944. private _target;
  75945. private _effectiveTarget;
  75946. private _property;
  75947. /**
  75948. * Instantiate the action
  75949. * @param triggerOptions defines the trigger options
  75950. * @param target defines the object containing the property
  75951. * @param propertyPath defines the path of the property to increment in the target
  75952. * @param value defines the value value we should increment the property by
  75953. * @param condition defines the trigger related conditions
  75954. */
  75955. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  75956. /** @hidden */
  75957. _prepare(): void;
  75958. /**
  75959. * Execute the action and increment the target of the value amount.
  75960. */
  75961. execute(): void;
  75962. /**
  75963. * Serializes the actions and its related information.
  75964. * @param parent defines the object to serialize in
  75965. * @returns the serialized object
  75966. */
  75967. serialize(parent: any): any;
  75968. }
  75969. /**
  75970. * This defines an action responsible to start an animation once triggered.
  75971. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  75972. */
  75973. export class PlayAnimationAction extends Action {
  75974. /**
  75975. * Where the animation should start (animation frame)
  75976. */
  75977. from: number;
  75978. /**
  75979. * Where the animation should stop (animation frame)
  75980. */
  75981. to: number;
  75982. /**
  75983. * Define if the animation should loop or stop after the first play.
  75984. */
  75985. loop?: boolean;
  75986. private _target;
  75987. /**
  75988. * Instantiate the action
  75989. * @param triggerOptions defines the trigger options
  75990. * @param target defines the target animation or animation name
  75991. * @param from defines from where the animation should start (animation frame)
  75992. * @param end defines where the animation should stop (animation frame)
  75993. * @param loop defines if the animation should loop or stop after the first play
  75994. * @param condition defines the trigger related conditions
  75995. */
  75996. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  75997. /** @hidden */
  75998. _prepare(): void;
  75999. /**
  76000. * Execute the action and play the animation.
  76001. */
  76002. execute(): void;
  76003. /**
  76004. * Serializes the actions and its related information.
  76005. * @param parent defines the object to serialize in
  76006. * @returns the serialized object
  76007. */
  76008. serialize(parent: any): any;
  76009. }
  76010. /**
  76011. * This defines an action responsible to stop an animation once triggered.
  76012. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  76013. */
  76014. export class StopAnimationAction extends Action {
  76015. private _target;
  76016. /**
  76017. * Instantiate the action
  76018. * @param triggerOptions defines the trigger options
  76019. * @param target defines the target animation or animation name
  76020. * @param condition defines the trigger related conditions
  76021. */
  76022. constructor(triggerOptions: any, target: any, condition?: Condition);
  76023. /** @hidden */
  76024. _prepare(): void;
  76025. /**
  76026. * Execute the action and stop the animation.
  76027. */
  76028. execute(): void;
  76029. /**
  76030. * Serializes the actions and its related information.
  76031. * @param parent defines the object to serialize in
  76032. * @returns the serialized object
  76033. */
  76034. serialize(parent: any): any;
  76035. }
  76036. /**
  76037. * This defines an action responsible that does nothing once triggered.
  76038. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  76039. */
  76040. export class DoNothingAction extends Action {
  76041. /**
  76042. * Instantiate the action
  76043. * @param triggerOptions defines the trigger options
  76044. * @param condition defines the trigger related conditions
  76045. */
  76046. constructor(triggerOptions?: any, condition?: Condition);
  76047. /**
  76048. * Execute the action and do nothing.
  76049. */
  76050. execute(): void;
  76051. /**
  76052. * Serializes the actions and its related information.
  76053. * @param parent defines the object to serialize in
  76054. * @returns the serialized object
  76055. */
  76056. serialize(parent: any): any;
  76057. }
  76058. /**
  76059. * This defines an action responsible to trigger several actions once triggered.
  76060. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  76061. */
  76062. export class CombineAction extends Action {
  76063. /**
  76064. * The list of aggregated animations to run.
  76065. */
  76066. children: Action[];
  76067. /**
  76068. * Instantiate the action
  76069. * @param triggerOptions defines the trigger options
  76070. * @param children defines the list of aggregated animations to run
  76071. * @param condition defines the trigger related conditions
  76072. */
  76073. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  76074. /** @hidden */
  76075. _prepare(): void;
  76076. /**
  76077. * Execute the action and executes all the aggregated actions.
  76078. */
  76079. execute(evt: ActionEvent): void;
  76080. /**
  76081. * Serializes the actions and its related information.
  76082. * @param parent defines the object to serialize in
  76083. * @returns the serialized object
  76084. */
  76085. serialize(parent: any): any;
  76086. }
  76087. /**
  76088. * This defines an action responsible to run code (external event) once triggered.
  76089. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  76090. */
  76091. export class ExecuteCodeAction extends Action {
  76092. /**
  76093. * The callback function to run.
  76094. */
  76095. func: (evt: ActionEvent) => void;
  76096. /**
  76097. * Instantiate the action
  76098. * @param triggerOptions defines the trigger options
  76099. * @param func defines the callback function to run
  76100. * @param condition defines the trigger related conditions
  76101. */
  76102. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  76103. /**
  76104. * Execute the action and run the attached code.
  76105. */
  76106. execute(evt: ActionEvent): void;
  76107. }
  76108. /**
  76109. * This defines an action responsible to set the parent property of the target once triggered.
  76110. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  76111. */
  76112. export class SetParentAction extends Action {
  76113. private _parent;
  76114. private _target;
  76115. /**
  76116. * Instantiate the action
  76117. * @param triggerOptions defines the trigger options
  76118. * @param target defines the target containing the parent property
  76119. * @param parent defines from where the animation should start (animation frame)
  76120. * @param condition defines the trigger related conditions
  76121. */
  76122. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  76123. /** @hidden */
  76124. _prepare(): void;
  76125. /**
  76126. * Execute the action and set the parent property.
  76127. */
  76128. execute(): void;
  76129. /**
  76130. * Serializes the actions and its related information.
  76131. * @param parent defines the object to serialize in
  76132. * @returns the serialized object
  76133. */
  76134. serialize(parent: any): any;
  76135. }
  76136. }
  76137. declare module BABYLON {
  76138. /**
  76139. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  76140. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  76141. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  76142. */
  76143. export class ActionManager extends AbstractActionManager {
  76144. /**
  76145. * Nothing
  76146. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  76147. */
  76148. static readonly NothingTrigger: number;
  76149. /**
  76150. * On pick
  76151. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  76152. */
  76153. static readonly OnPickTrigger: number;
  76154. /**
  76155. * On left pick
  76156. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  76157. */
  76158. static readonly OnLeftPickTrigger: number;
  76159. /**
  76160. * On right pick
  76161. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  76162. */
  76163. static readonly OnRightPickTrigger: number;
  76164. /**
  76165. * On center pick
  76166. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  76167. */
  76168. static readonly OnCenterPickTrigger: number;
  76169. /**
  76170. * On pick down
  76171. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  76172. */
  76173. static readonly OnPickDownTrigger: number;
  76174. /**
  76175. * On double pick
  76176. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  76177. */
  76178. static readonly OnDoublePickTrigger: number;
  76179. /**
  76180. * On pick up
  76181. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  76182. */
  76183. static readonly OnPickUpTrigger: number;
  76184. /**
  76185. * On pick out.
  76186. * This trigger will only be raised if you also declared a OnPickDown
  76187. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  76188. */
  76189. static readonly OnPickOutTrigger: number;
  76190. /**
  76191. * On long press
  76192. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  76193. */
  76194. static readonly OnLongPressTrigger: number;
  76195. /**
  76196. * On pointer over
  76197. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  76198. */
  76199. static readonly OnPointerOverTrigger: number;
  76200. /**
  76201. * On pointer out
  76202. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  76203. */
  76204. static readonly OnPointerOutTrigger: number;
  76205. /**
  76206. * On every frame
  76207. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  76208. */
  76209. static readonly OnEveryFrameTrigger: number;
  76210. /**
  76211. * On intersection enter
  76212. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  76213. */
  76214. static readonly OnIntersectionEnterTrigger: number;
  76215. /**
  76216. * On intersection exit
  76217. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  76218. */
  76219. static readonly OnIntersectionExitTrigger: number;
  76220. /**
  76221. * On key down
  76222. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  76223. */
  76224. static readonly OnKeyDownTrigger: number;
  76225. /**
  76226. * On key up
  76227. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  76228. */
  76229. static readonly OnKeyUpTrigger: number;
  76230. private _scene;
  76231. /**
  76232. * Creates a new action manager
  76233. * @param scene defines the hosting scene
  76234. */
  76235. constructor(scene: Scene);
  76236. /**
  76237. * Releases all associated resources
  76238. */
  76239. dispose(): void;
  76240. /**
  76241. * Gets hosting scene
  76242. * @returns the hosting scene
  76243. */
  76244. getScene(): Scene;
  76245. /**
  76246. * Does this action manager handles actions of any of the given triggers
  76247. * @param triggers defines the triggers to be tested
  76248. * @return a boolean indicating whether one (or more) of the triggers is handled
  76249. */
  76250. hasSpecificTriggers(triggers: number[]): boolean;
  76251. /**
  76252. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  76253. * speed.
  76254. * @param triggerA defines the trigger to be tested
  76255. * @param triggerB defines the trigger to be tested
  76256. * @return a boolean indicating whether one (or more) of the triggers is handled
  76257. */
  76258. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  76259. /**
  76260. * Does this action manager handles actions of a given trigger
  76261. * @param trigger defines the trigger to be tested
  76262. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  76263. * @return whether the trigger is handled
  76264. */
  76265. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  76266. /**
  76267. * Does this action manager has pointer triggers
  76268. */
  76269. readonly hasPointerTriggers: boolean;
  76270. /**
  76271. * Does this action manager has pick triggers
  76272. */
  76273. readonly hasPickTriggers: boolean;
  76274. /**
  76275. * Registers an action to this action manager
  76276. * @param action defines the action to be registered
  76277. * @return the action amended (prepared) after registration
  76278. */
  76279. registerAction(action: IAction): Nullable<IAction>;
  76280. /**
  76281. * Unregisters an action to this action manager
  76282. * @param action defines the action to be unregistered
  76283. * @return a boolean indicating whether the action has been unregistered
  76284. */
  76285. unregisterAction(action: IAction): Boolean;
  76286. /**
  76287. * Process a specific trigger
  76288. * @param trigger defines the trigger to process
  76289. * @param evt defines the event details to be processed
  76290. */
  76291. processTrigger(trigger: number, evt?: IActionEvent): void;
  76292. /** @hidden */
  76293. _getEffectiveTarget(target: any, propertyPath: string): any;
  76294. /** @hidden */
  76295. _getProperty(propertyPath: string): string;
  76296. /**
  76297. * Serialize this manager to a JSON object
  76298. * @param name defines the property name to store this manager
  76299. * @returns a JSON representation of this manager
  76300. */
  76301. serialize(name: string): any;
  76302. /**
  76303. * Creates a new ActionManager from a JSON data
  76304. * @param parsedActions defines the JSON data to read from
  76305. * @param object defines the hosting mesh
  76306. * @param scene defines the hosting scene
  76307. */
  76308. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  76309. /**
  76310. * Get a trigger name by index
  76311. * @param trigger defines the trigger index
  76312. * @returns a trigger name
  76313. */
  76314. static GetTriggerName(trigger: number): string;
  76315. }
  76316. }
  76317. declare module BABYLON {
  76318. /**
  76319. * Class representing a ray with position and direction
  76320. */
  76321. export class Ray {
  76322. /** origin point */
  76323. origin: Vector3;
  76324. /** direction */
  76325. direction: Vector3;
  76326. /** length of the ray */
  76327. length: number;
  76328. private static readonly TmpVector3;
  76329. private _tmpRay;
  76330. /**
  76331. * Creates a new ray
  76332. * @param origin origin point
  76333. * @param direction direction
  76334. * @param length length of the ray
  76335. */
  76336. constructor(
  76337. /** origin point */
  76338. origin: Vector3,
  76339. /** direction */
  76340. direction: Vector3,
  76341. /** length of the ray */
  76342. length?: number);
  76343. /**
  76344. * Checks if the ray intersects a box
  76345. * @param minimum bound of the box
  76346. * @param maximum bound of the box
  76347. * @param intersectionTreshold extra extend to be added to the box in all direction
  76348. * @returns if the box was hit
  76349. */
  76350. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  76351. /**
  76352. * Checks if the ray intersects a box
  76353. * @param box the bounding box to check
  76354. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  76355. * @returns if the box was hit
  76356. */
  76357. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  76358. /**
  76359. * If the ray hits a sphere
  76360. * @param sphere the bounding sphere to check
  76361. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  76362. * @returns true if it hits the sphere
  76363. */
  76364. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  76365. /**
  76366. * If the ray hits a triange
  76367. * @param vertex0 triangle vertex
  76368. * @param vertex1 triangle vertex
  76369. * @param vertex2 triangle vertex
  76370. * @returns intersection information if hit
  76371. */
  76372. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  76373. /**
  76374. * Checks if ray intersects a plane
  76375. * @param plane the plane to check
  76376. * @returns the distance away it was hit
  76377. */
  76378. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  76379. /**
  76380. * Calculate the intercept of a ray on a given axis
  76381. * @param axis to check 'x' | 'y' | 'z'
  76382. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  76383. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  76384. */
  76385. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  76386. /**
  76387. * Checks if ray intersects a mesh
  76388. * @param mesh the mesh to check
  76389. * @param fastCheck if only the bounding box should checked
  76390. * @returns picking info of the intersecton
  76391. */
  76392. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  76393. /**
  76394. * Checks if ray intersects a mesh
  76395. * @param meshes the meshes to check
  76396. * @param fastCheck if only the bounding box should checked
  76397. * @param results array to store result in
  76398. * @returns Array of picking infos
  76399. */
  76400. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  76401. private _comparePickingInfo;
  76402. private static smallnum;
  76403. private static rayl;
  76404. /**
  76405. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  76406. * @param sega the first point of the segment to test the intersection against
  76407. * @param segb the second point of the segment to test the intersection against
  76408. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  76409. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  76410. */
  76411. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  76412. /**
  76413. * Update the ray from viewport position
  76414. * @param x position
  76415. * @param y y position
  76416. * @param viewportWidth viewport width
  76417. * @param viewportHeight viewport height
  76418. * @param world world matrix
  76419. * @param view view matrix
  76420. * @param projection projection matrix
  76421. * @returns this ray updated
  76422. */
  76423. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  76424. /**
  76425. * Creates a ray with origin and direction of 0,0,0
  76426. * @returns the new ray
  76427. */
  76428. static Zero(): Ray;
  76429. /**
  76430. * Creates a new ray from screen space and viewport
  76431. * @param x position
  76432. * @param y y position
  76433. * @param viewportWidth viewport width
  76434. * @param viewportHeight viewport height
  76435. * @param world world matrix
  76436. * @param view view matrix
  76437. * @param projection projection matrix
  76438. * @returns new ray
  76439. */
  76440. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  76441. /**
  76442. * 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
  76443. * transformed to the given world matrix.
  76444. * @param origin The origin point
  76445. * @param end The end point
  76446. * @param world a matrix to transform the ray to. Default is the identity matrix.
  76447. * @returns the new ray
  76448. */
  76449. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  76450. /**
  76451. * Transforms a ray by a matrix
  76452. * @param ray ray to transform
  76453. * @param matrix matrix to apply
  76454. * @returns the resulting new ray
  76455. */
  76456. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  76457. /**
  76458. * Transforms a ray by a matrix
  76459. * @param ray ray to transform
  76460. * @param matrix matrix to apply
  76461. * @param result ray to store result in
  76462. */
  76463. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  76464. /**
  76465. * Unproject a ray from screen space to object space
  76466. * @param sourceX defines the screen space x coordinate to use
  76467. * @param sourceY defines the screen space y coordinate to use
  76468. * @param viewportWidth defines the current width of the viewport
  76469. * @param viewportHeight defines the current height of the viewport
  76470. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  76471. * @param view defines the view matrix to use
  76472. * @param projection defines the projection matrix to use
  76473. */
  76474. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  76475. }
  76476. /**
  76477. * Type used to define predicate used to select faces when a mesh intersection is detected
  76478. */
  76479. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  76480. interface Scene {
  76481. /** @hidden */
  76482. _tempPickingRay: Nullable<Ray>;
  76483. /** @hidden */
  76484. _cachedRayForTransform: Ray;
  76485. /** @hidden */
  76486. _pickWithRayInverseMatrix: Matrix;
  76487. /** @hidden */
  76488. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  76489. /** @hidden */
  76490. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  76491. }
  76492. }
  76493. declare module BABYLON {
  76494. /**
  76495. * Groups all the scene component constants in one place to ease maintenance.
  76496. * @hidden
  76497. */
  76498. export class SceneComponentConstants {
  76499. static readonly NAME_EFFECTLAYER: string;
  76500. static readonly NAME_LAYER: string;
  76501. static readonly NAME_LENSFLARESYSTEM: string;
  76502. static readonly NAME_BOUNDINGBOXRENDERER: string;
  76503. static readonly NAME_PARTICLESYSTEM: string;
  76504. static readonly NAME_GAMEPAD: string;
  76505. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  76506. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  76507. static readonly NAME_DEPTHRENDERER: string;
  76508. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  76509. static readonly NAME_SPRITE: string;
  76510. static readonly NAME_OUTLINERENDERER: string;
  76511. static readonly NAME_PROCEDURALTEXTURE: string;
  76512. static readonly NAME_SHADOWGENERATOR: string;
  76513. static readonly NAME_OCTREE: string;
  76514. static readonly NAME_PHYSICSENGINE: string;
  76515. static readonly NAME_AUDIO: string;
  76516. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  76517. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  76518. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  76519. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  76520. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  76521. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  76522. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  76523. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  76524. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  76525. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  76526. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  76527. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  76528. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  76529. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  76530. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  76531. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  76532. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  76533. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  76534. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  76535. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  76536. static readonly STEP_AFTERRENDER_AUDIO: number;
  76537. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  76538. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  76539. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  76540. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  76541. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  76542. static readonly STEP_POINTERMOVE_SPRITE: number;
  76543. static readonly STEP_POINTERDOWN_SPRITE: number;
  76544. static readonly STEP_POINTERUP_SPRITE: number;
  76545. }
  76546. /**
  76547. * This represents a scene component.
  76548. *
  76549. * This is used to decouple the dependency the scene is having on the different workloads like
  76550. * layers, post processes...
  76551. */
  76552. export interface ISceneComponent {
  76553. /**
  76554. * The name of the component. Each component must have a unique name.
  76555. */
  76556. name: string;
  76557. /**
  76558. * The scene the component belongs to.
  76559. */
  76560. scene: Scene;
  76561. /**
  76562. * Register the component to one instance of a scene.
  76563. */
  76564. register(): void;
  76565. /**
  76566. * Rebuilds the elements related to this component in case of
  76567. * context lost for instance.
  76568. */
  76569. rebuild(): void;
  76570. /**
  76571. * Disposes the component and the associated ressources.
  76572. */
  76573. dispose(): void;
  76574. }
  76575. /**
  76576. * This represents a SERIALIZABLE scene component.
  76577. *
  76578. * This extends Scene Component to add Serialization methods on top.
  76579. */
  76580. export interface ISceneSerializableComponent extends ISceneComponent {
  76581. /**
  76582. * Adds all the elements from the container to the scene
  76583. * @param container the container holding the elements
  76584. */
  76585. addFromContainer(container: AbstractScene): void;
  76586. /**
  76587. * Removes all the elements in the container from the scene
  76588. * @param container contains the elements to remove
  76589. * @param dispose if the removed element should be disposed (default: false)
  76590. */
  76591. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  76592. /**
  76593. * Serializes the component data to the specified json object
  76594. * @param serializationObject The object to serialize to
  76595. */
  76596. serialize(serializationObject: any): void;
  76597. }
  76598. /**
  76599. * Strong typing of a Mesh related stage step action
  76600. */
  76601. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  76602. /**
  76603. * Strong typing of a Evaluate Sub Mesh related stage step action
  76604. */
  76605. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  76606. /**
  76607. * Strong typing of a Active Mesh related stage step action
  76608. */
  76609. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  76610. /**
  76611. * Strong typing of a Camera related stage step action
  76612. */
  76613. export type CameraStageAction = (camera: Camera) => void;
  76614. /**
  76615. * Strong typing of a Camera Frame buffer related stage step action
  76616. */
  76617. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  76618. /**
  76619. * Strong typing of a Render Target related stage step action
  76620. */
  76621. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  76622. /**
  76623. * Strong typing of a RenderingGroup related stage step action
  76624. */
  76625. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  76626. /**
  76627. * Strong typing of a Mesh Render related stage step action
  76628. */
  76629. export type RenderingMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  76630. /**
  76631. * Strong typing of a simple stage step action
  76632. */
  76633. export type SimpleStageAction = () => void;
  76634. /**
  76635. * Strong typing of a render target action.
  76636. */
  76637. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  76638. /**
  76639. * Strong typing of a pointer move action.
  76640. */
  76641. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, canvas: HTMLCanvasElement) => Nullable<PickingInfo>;
  76642. /**
  76643. * Strong typing of a pointer up/down action.
  76644. */
  76645. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  76646. /**
  76647. * Repressentation of a stage in the scene (Basically a list of ordered steps)
  76648. * @hidden
  76649. */
  76650. export class Stage<T extends Function> extends Array<{
  76651. index: number;
  76652. component: ISceneComponent;
  76653. action: T;
  76654. }> {
  76655. /**
  76656. * Hide ctor from the rest of the world.
  76657. * @param items The items to add.
  76658. */
  76659. private constructor();
  76660. /**
  76661. * Creates a new Stage.
  76662. * @returns A new instance of a Stage
  76663. */
  76664. static Create<T extends Function>(): Stage<T>;
  76665. /**
  76666. * Registers a step in an ordered way in the targeted stage.
  76667. * @param index Defines the position to register the step in
  76668. * @param component Defines the component attached to the step
  76669. * @param action Defines the action to launch during the step
  76670. */
  76671. registerStep(index: number, component: ISceneComponent, action: T): void;
  76672. /**
  76673. * Clears all the steps from the stage.
  76674. */
  76675. clear(): void;
  76676. }
  76677. }
  76678. declare module BABYLON {
  76679. interface Scene {
  76680. /** @hidden */
  76681. _pointerOverSprite: Nullable<Sprite>;
  76682. /** @hidden */
  76683. _pickedDownSprite: Nullable<Sprite>;
  76684. /** @hidden */
  76685. _tempSpritePickingRay: Nullable<Ray>;
  76686. /**
  76687. * All of the sprite managers added to this scene
  76688. * @see http://doc.babylonjs.com/babylon101/sprites
  76689. */
  76690. spriteManagers: Array<ISpriteManager>;
  76691. /**
  76692. * An event triggered when sprites rendering is about to start
  76693. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  76694. */
  76695. onBeforeSpritesRenderingObservable: Observable<Scene>;
  76696. /**
  76697. * An event triggered when sprites rendering is done
  76698. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  76699. */
  76700. onAfterSpritesRenderingObservable: Observable<Scene>;
  76701. /** @hidden */
  76702. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  76703. /** Launch a ray to try to pick a sprite in the scene
  76704. * @param x position on screen
  76705. * @param y position on screen
  76706. * @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
  76707. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  76708. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  76709. * @returns a PickingInfo
  76710. */
  76711. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  76712. /** Use the given ray to pick a sprite in the scene
  76713. * @param ray The ray (in world space) to use to pick meshes
  76714. * @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
  76715. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  76716. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  76717. * @returns a PickingInfo
  76718. */
  76719. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  76720. /** @hidden */
  76721. _internalMultiPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  76722. /** Launch a ray to try to pick sprites in the scene
  76723. * @param x position on screen
  76724. * @param y position on screen
  76725. * @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
  76726. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  76727. * @returns a PickingInfo array
  76728. */
  76729. multiPickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  76730. /** Use the given ray to pick sprites in the scene
  76731. * @param ray The ray (in world space) to use to pick meshes
  76732. * @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
  76733. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  76734. * @returns a PickingInfo array
  76735. */
  76736. multiPickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  76737. /**
  76738. * Force the sprite under the pointer
  76739. * @param sprite defines the sprite to use
  76740. */
  76741. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  76742. /**
  76743. * Gets the sprite under the pointer
  76744. * @returns a Sprite or null if no sprite is under the pointer
  76745. */
  76746. getPointerOverSprite(): Nullable<Sprite>;
  76747. }
  76748. /**
  76749. * Defines the sprite scene component responsible to manage sprites
  76750. * in a given scene.
  76751. */
  76752. export class SpriteSceneComponent implements ISceneComponent {
  76753. /**
  76754. * The component name helpfull to identify the component in the list of scene components.
  76755. */
  76756. readonly name: string;
  76757. /**
  76758. * The scene the component belongs to.
  76759. */
  76760. scene: Scene;
  76761. /** @hidden */
  76762. private _spritePredicate;
  76763. /**
  76764. * Creates a new instance of the component for the given scene
  76765. * @param scene Defines the scene to register the component in
  76766. */
  76767. constructor(scene: Scene);
  76768. /**
  76769. * Registers the component in a given scene
  76770. */
  76771. register(): void;
  76772. /**
  76773. * Rebuilds the elements related to this component in case of
  76774. * context lost for instance.
  76775. */
  76776. rebuild(): void;
  76777. /**
  76778. * Disposes the component and the associated ressources.
  76779. */
  76780. dispose(): void;
  76781. private _pickSpriteButKeepRay;
  76782. private _pointerMove;
  76783. private _pointerDown;
  76784. private _pointerUp;
  76785. }
  76786. }
  76787. declare module BABYLON {
  76788. /** @hidden */
  76789. export var fogFragmentDeclaration: {
  76790. name: string;
  76791. shader: string;
  76792. };
  76793. }
  76794. declare module BABYLON {
  76795. /** @hidden */
  76796. export var fogFragment: {
  76797. name: string;
  76798. shader: string;
  76799. };
  76800. }
  76801. declare module BABYLON {
  76802. /** @hidden */
  76803. export var spritesPixelShader: {
  76804. name: string;
  76805. shader: string;
  76806. };
  76807. }
  76808. declare module BABYLON {
  76809. /** @hidden */
  76810. export var fogVertexDeclaration: {
  76811. name: string;
  76812. shader: string;
  76813. };
  76814. }
  76815. declare module BABYLON {
  76816. /** @hidden */
  76817. export var spritesVertexShader: {
  76818. name: string;
  76819. shader: string;
  76820. };
  76821. }
  76822. declare module BABYLON {
  76823. /**
  76824. * Defines the minimum interface to fullfil in order to be a sprite manager.
  76825. */
  76826. export interface ISpriteManager extends IDisposable {
  76827. /**
  76828. * Restricts the camera to viewing objects with the same layerMask.
  76829. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  76830. */
  76831. layerMask: number;
  76832. /**
  76833. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  76834. */
  76835. isPickable: boolean;
  76836. /**
  76837. * Specifies the rendering group id for this mesh (0 by default)
  76838. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  76839. */
  76840. renderingGroupId: number;
  76841. /**
  76842. * Defines the list of sprites managed by the manager.
  76843. */
  76844. sprites: Array<Sprite>;
  76845. /**
  76846. * Tests the intersection of a sprite with a specific ray.
  76847. * @param ray The ray we are sending to test the collision
  76848. * @param camera The camera space we are sending rays in
  76849. * @param predicate A predicate allowing excluding sprites from the list of object to test
  76850. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  76851. * @returns picking info or null.
  76852. */
  76853. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  76854. /**
  76855. * Intersects the sprites with a ray
  76856. * @param ray defines the ray to intersect with
  76857. * @param camera defines the current active camera
  76858. * @param predicate defines a predicate used to select candidate sprites
  76859. * @returns null if no hit or a PickingInfo array
  76860. */
  76861. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  76862. /**
  76863. * Renders the list of sprites on screen.
  76864. */
  76865. render(): void;
  76866. }
  76867. /**
  76868. * Class used to manage multiple sprites on the same spritesheet
  76869. * @see http://doc.babylonjs.com/babylon101/sprites
  76870. */
  76871. export class SpriteManager implements ISpriteManager {
  76872. /** defines the manager's name */
  76873. name: string;
  76874. /** Gets the list of sprites */
  76875. sprites: Sprite[];
  76876. /** Gets or sets the rendering group id (0 by default) */
  76877. renderingGroupId: number;
  76878. /** Gets or sets camera layer mask */
  76879. layerMask: number;
  76880. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  76881. fogEnabled: boolean;
  76882. /** Gets or sets a boolean indicating if the sprites are pickable */
  76883. isPickable: boolean;
  76884. /** Defines the default width of a cell in the spritesheet */
  76885. cellWidth: number;
  76886. /** Defines the default height of a cell in the spritesheet */
  76887. cellHeight: number;
  76888. /** Associative array from JSON sprite data file */
  76889. private _cellData;
  76890. /** Array of sprite names from JSON sprite data file */
  76891. private _spriteMap;
  76892. /** True when packed cell data from JSON file is ready*/
  76893. private _packedAndReady;
  76894. /**
  76895. * An event triggered when the manager is disposed.
  76896. */
  76897. onDisposeObservable: Observable<SpriteManager>;
  76898. private _onDisposeObserver;
  76899. /**
  76900. * Callback called when the manager is disposed
  76901. */
  76902. onDispose: () => void;
  76903. private _capacity;
  76904. private _fromPacked;
  76905. private _spriteTexture;
  76906. private _epsilon;
  76907. private _scene;
  76908. private _vertexData;
  76909. private _buffer;
  76910. private _vertexBuffers;
  76911. private _indexBuffer;
  76912. private _effectBase;
  76913. private _effectFog;
  76914. /**
  76915. * Gets or sets the spritesheet texture
  76916. */
  76917. texture: Texture;
  76918. /**
  76919. * Creates a new sprite manager
  76920. * @param name defines the manager's name
  76921. * @param imgUrl defines the sprite sheet url
  76922. * @param capacity defines the maximum allowed number of sprites
  76923. * @param cellSize defines the size of a sprite cell
  76924. * @param scene defines the hosting scene
  76925. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  76926. * @param samplingMode defines the smapling mode to use with spritesheet
  76927. * @param fromPacked set to false; do not alter
  76928. * @param spriteJSON null otherwise a JSON object defining sprite sheet data; do not alter
  76929. */
  76930. constructor(
  76931. /** defines the manager's name */
  76932. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number, fromPacked?: boolean, spriteJSON?: string | null);
  76933. private _makePacked;
  76934. private _appendSpriteVertex;
  76935. /**
  76936. * Intersects the sprites with a ray
  76937. * @param ray defines the ray to intersect with
  76938. * @param camera defines the current active camera
  76939. * @param predicate defines a predicate used to select candidate sprites
  76940. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  76941. * @returns null if no hit or a PickingInfo
  76942. */
  76943. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  76944. /**
  76945. * Intersects the sprites with a ray
  76946. * @param ray defines the ray to intersect with
  76947. * @param camera defines the current active camera
  76948. * @param predicate defines a predicate used to select candidate sprites
  76949. * @returns null if no hit or a PickingInfo array
  76950. */
  76951. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  76952. /**
  76953. * Render all child sprites
  76954. */
  76955. render(): void;
  76956. /**
  76957. * Release associated resources
  76958. */
  76959. dispose(): void;
  76960. }
  76961. }
  76962. declare module BABYLON {
  76963. /**
  76964. * Class used to represent a sprite
  76965. * @see http://doc.babylonjs.com/babylon101/sprites
  76966. */
  76967. export class Sprite {
  76968. /** defines the name */
  76969. name: string;
  76970. /** Gets or sets the current world position */
  76971. position: Vector3;
  76972. /** Gets or sets the main color */
  76973. color: Color4;
  76974. /** Gets or sets the width */
  76975. width: number;
  76976. /** Gets or sets the height */
  76977. height: number;
  76978. /** Gets or sets rotation angle */
  76979. angle: number;
  76980. /** Gets or sets the cell index in the sprite sheet */
  76981. cellIndex: number;
  76982. /** Gets or sets the cell reference in the sprite sheet, uses sprite's filename when added to sprite sheet */
  76983. cellRef: string;
  76984. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  76985. invertU: number;
  76986. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  76987. invertV: number;
  76988. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  76989. disposeWhenFinishedAnimating: boolean;
  76990. /** Gets the list of attached animations */
  76991. animations: Animation[];
  76992. /** Gets or sets a boolean indicating if the sprite can be picked */
  76993. isPickable: boolean;
  76994. /**
  76995. * Gets or sets the associated action manager
  76996. */
  76997. actionManager: Nullable<ActionManager>;
  76998. private _animationStarted;
  76999. private _loopAnimation;
  77000. private _fromIndex;
  77001. private _toIndex;
  77002. private _delay;
  77003. private _direction;
  77004. private _manager;
  77005. private _time;
  77006. private _onAnimationEnd;
  77007. /**
  77008. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  77009. */
  77010. isVisible: boolean;
  77011. /**
  77012. * Gets or sets the sprite size
  77013. */
  77014. size: number;
  77015. /**
  77016. * Creates a new Sprite
  77017. * @param name defines the name
  77018. * @param manager defines the manager
  77019. */
  77020. constructor(
  77021. /** defines the name */
  77022. name: string, manager: ISpriteManager);
  77023. /**
  77024. * Starts an animation
  77025. * @param from defines the initial key
  77026. * @param to defines the end key
  77027. * @param loop defines if the animation must loop
  77028. * @param delay defines the start delay (in ms)
  77029. * @param onAnimationEnd defines a callback to call when animation ends
  77030. */
  77031. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  77032. /** Stops current animation (if any) */
  77033. stopAnimation(): void;
  77034. /** @hidden */
  77035. _animate(deltaTime: number): void;
  77036. /** Release associated resources */
  77037. dispose(): void;
  77038. }
  77039. }
  77040. declare module BABYLON {
  77041. /**
  77042. * Information about the result of picking within a scene
  77043. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  77044. */
  77045. export class PickingInfo {
  77046. /** @hidden */
  77047. _pickingUnavailable: boolean;
  77048. /**
  77049. * If the pick collided with an object
  77050. */
  77051. hit: boolean;
  77052. /**
  77053. * Distance away where the pick collided
  77054. */
  77055. distance: number;
  77056. /**
  77057. * The location of pick collision
  77058. */
  77059. pickedPoint: Nullable<Vector3>;
  77060. /**
  77061. * The mesh corresponding the the pick collision
  77062. */
  77063. pickedMesh: Nullable<AbstractMesh>;
  77064. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  77065. bu: number;
  77066. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  77067. bv: number;
  77068. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  77069. faceId: number;
  77070. /** Id of the the submesh that was picked */
  77071. subMeshId: number;
  77072. /** If a sprite was picked, this will be the sprite the pick collided with */
  77073. pickedSprite: Nullable<Sprite>;
  77074. /**
  77075. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  77076. */
  77077. originMesh: Nullable<AbstractMesh>;
  77078. /**
  77079. * The ray that was used to perform the picking.
  77080. */
  77081. ray: Nullable<Ray>;
  77082. /**
  77083. * Gets the normal correspodning to the face the pick collided with
  77084. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  77085. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  77086. * @returns The normal correspodning to the face the pick collided with
  77087. */
  77088. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  77089. /**
  77090. * Gets the texture coordinates of where the pick occured
  77091. * @returns the vector containing the coordnates of the texture
  77092. */
  77093. getTextureCoordinates(): Nullable<Vector2>;
  77094. }
  77095. }
  77096. declare module BABYLON {
  77097. /**
  77098. * Gather the list of pointer event types as constants.
  77099. */
  77100. export class PointerEventTypes {
  77101. /**
  77102. * 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.
  77103. */
  77104. static readonly POINTERDOWN: number;
  77105. /**
  77106. * The pointerup event is fired when a pointer is no longer active.
  77107. */
  77108. static readonly POINTERUP: number;
  77109. /**
  77110. * The pointermove event is fired when a pointer changes coordinates.
  77111. */
  77112. static readonly POINTERMOVE: number;
  77113. /**
  77114. * The pointerwheel event is fired when a mouse wheel has been rotated.
  77115. */
  77116. static readonly POINTERWHEEL: number;
  77117. /**
  77118. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  77119. */
  77120. static readonly POINTERPICK: number;
  77121. /**
  77122. * The pointertap event is fired when a the object has been touched and released without drag.
  77123. */
  77124. static readonly POINTERTAP: number;
  77125. /**
  77126. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  77127. */
  77128. static readonly POINTERDOUBLETAP: number;
  77129. }
  77130. /**
  77131. * Base class of pointer info types.
  77132. */
  77133. export class PointerInfoBase {
  77134. /**
  77135. * Defines the type of event (PointerEventTypes)
  77136. */
  77137. type: number;
  77138. /**
  77139. * Defines the related dom event
  77140. */
  77141. event: PointerEvent | MouseWheelEvent;
  77142. /**
  77143. * Instantiates the base class of pointers info.
  77144. * @param type Defines the type of event (PointerEventTypes)
  77145. * @param event Defines the related dom event
  77146. */
  77147. constructor(
  77148. /**
  77149. * Defines the type of event (PointerEventTypes)
  77150. */
  77151. type: number,
  77152. /**
  77153. * Defines the related dom event
  77154. */
  77155. event: PointerEvent | MouseWheelEvent);
  77156. }
  77157. /**
  77158. * This class is used to store pointer related info for the onPrePointerObservable event.
  77159. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  77160. */
  77161. export class PointerInfoPre extends PointerInfoBase {
  77162. /**
  77163. * Ray from a pointer if availible (eg. 6dof controller)
  77164. */
  77165. ray: Nullable<Ray>;
  77166. /**
  77167. * Defines the local position of the pointer on the canvas.
  77168. */
  77169. localPosition: Vector2;
  77170. /**
  77171. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  77172. */
  77173. skipOnPointerObservable: boolean;
  77174. /**
  77175. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  77176. * @param type Defines the type of event (PointerEventTypes)
  77177. * @param event Defines the related dom event
  77178. * @param localX Defines the local x coordinates of the pointer when the event occured
  77179. * @param localY Defines the local y coordinates of the pointer when the event occured
  77180. */
  77181. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  77182. }
  77183. /**
  77184. * This type contains all the data related to a pointer event in Babylon.js.
  77185. * 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.
  77186. */
  77187. export class PointerInfo extends PointerInfoBase {
  77188. /**
  77189. * Defines the picking info associated to the info (if any)\
  77190. */
  77191. pickInfo: Nullable<PickingInfo>;
  77192. /**
  77193. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  77194. * @param type Defines the type of event (PointerEventTypes)
  77195. * @param event Defines the related dom event
  77196. * @param pickInfo Defines the picking info associated to the info (if any)\
  77197. */
  77198. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  77199. /**
  77200. * Defines the picking info associated to the info (if any)\
  77201. */
  77202. pickInfo: Nullable<PickingInfo>);
  77203. }
  77204. /**
  77205. * Data relating to a touch event on the screen.
  77206. */
  77207. export interface PointerTouch {
  77208. /**
  77209. * X coordinate of touch.
  77210. */
  77211. x: number;
  77212. /**
  77213. * Y coordinate of touch.
  77214. */
  77215. y: number;
  77216. /**
  77217. * Id of touch. Unique for each finger.
  77218. */
  77219. pointerId: number;
  77220. /**
  77221. * Event type passed from DOM.
  77222. */
  77223. type: any;
  77224. }
  77225. }
  77226. declare module BABYLON {
  77227. /**
  77228. * Manage the mouse inputs to control the movement of a free camera.
  77229. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  77230. */
  77231. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  77232. /**
  77233. * Define if touch is enabled in the mouse input
  77234. */
  77235. touchEnabled: boolean;
  77236. /**
  77237. * Defines the camera the input is attached to.
  77238. */
  77239. camera: FreeCamera;
  77240. /**
  77241. * Defines the buttons associated with the input to handle camera move.
  77242. */
  77243. buttons: number[];
  77244. /**
  77245. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  77246. */
  77247. angularSensibility: number;
  77248. private _pointerInput;
  77249. private _onMouseMove;
  77250. private _observer;
  77251. private previousPosition;
  77252. /**
  77253. * Observable for when a pointer move event occurs containing the move offset
  77254. */
  77255. onPointerMovedObservable: Observable<{
  77256. offsetX: number;
  77257. offsetY: number;
  77258. }>;
  77259. /**
  77260. * @hidden
  77261. * If the camera should be rotated automatically based on pointer movement
  77262. */
  77263. _allowCameraRotation: boolean;
  77264. /**
  77265. * Manage the mouse inputs to control the movement of a free camera.
  77266. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  77267. * @param touchEnabled Defines if touch is enabled or not
  77268. */
  77269. constructor(
  77270. /**
  77271. * Define if touch is enabled in the mouse input
  77272. */
  77273. touchEnabled?: boolean);
  77274. /**
  77275. * Attach the input controls to a specific dom element to get the input from.
  77276. * @param element Defines the element the controls should be listened from
  77277. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  77278. */
  77279. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  77280. /**
  77281. * Called on JS contextmenu event.
  77282. * Override this method to provide functionality.
  77283. */
  77284. protected onContextMenu(evt: PointerEvent): void;
  77285. /**
  77286. * Detach the current controls from the specified dom element.
  77287. * @param element Defines the element to stop listening the inputs from
  77288. */
  77289. detachControl(element: Nullable<HTMLElement>): void;
  77290. /**
  77291. * Gets the class name of the current intput.
  77292. * @returns the class name
  77293. */
  77294. getClassName(): string;
  77295. /**
  77296. * Get the friendly name associated with the input class.
  77297. * @returns the input friendly name
  77298. */
  77299. getSimpleName(): string;
  77300. }
  77301. }
  77302. declare module BABYLON {
  77303. /**
  77304. * Manage the touch inputs to control the movement of a free camera.
  77305. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  77306. */
  77307. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  77308. /**
  77309. * Defines the camera the input is attached to.
  77310. */
  77311. camera: FreeCamera;
  77312. /**
  77313. * Defines the touch sensibility for rotation.
  77314. * The higher the faster.
  77315. */
  77316. touchAngularSensibility: number;
  77317. /**
  77318. * Defines the touch sensibility for move.
  77319. * The higher the faster.
  77320. */
  77321. touchMoveSensibility: number;
  77322. private _offsetX;
  77323. private _offsetY;
  77324. private _pointerPressed;
  77325. private _pointerInput;
  77326. private _observer;
  77327. private _onLostFocus;
  77328. /**
  77329. * Attach the input controls to a specific dom element to get the input from.
  77330. * @param element Defines the element the controls should be listened from
  77331. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  77332. */
  77333. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  77334. /**
  77335. * Detach the current controls from the specified dom element.
  77336. * @param element Defines the element to stop listening the inputs from
  77337. */
  77338. detachControl(element: Nullable<HTMLElement>): void;
  77339. /**
  77340. * Update the current camera state depending on the inputs that have been used this frame.
  77341. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  77342. */
  77343. checkInputs(): void;
  77344. /**
  77345. * Gets the class name of the current intput.
  77346. * @returns the class name
  77347. */
  77348. getClassName(): string;
  77349. /**
  77350. * Get the friendly name associated with the input class.
  77351. * @returns the input friendly name
  77352. */
  77353. getSimpleName(): string;
  77354. }
  77355. }
  77356. declare module BABYLON {
  77357. /**
  77358. * Default Inputs manager for the FreeCamera.
  77359. * It groups all the default supported inputs for ease of use.
  77360. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  77361. */
  77362. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  77363. /**
  77364. * @hidden
  77365. */
  77366. _mouseInput: Nullable<FreeCameraMouseInput>;
  77367. /**
  77368. * Instantiates a new FreeCameraInputsManager.
  77369. * @param camera Defines the camera the inputs belong to
  77370. */
  77371. constructor(camera: FreeCamera);
  77372. /**
  77373. * Add keyboard input support to the input manager.
  77374. * @returns the current input manager
  77375. */
  77376. addKeyboard(): FreeCameraInputsManager;
  77377. /**
  77378. * Add mouse input support to the input manager.
  77379. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  77380. * @returns the current input manager
  77381. */
  77382. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  77383. /**
  77384. * Removes the mouse input support from the manager
  77385. * @returns the current input manager
  77386. */
  77387. removeMouse(): FreeCameraInputsManager;
  77388. /**
  77389. * Add touch input support to the input manager.
  77390. * @returns the current input manager
  77391. */
  77392. addTouch(): FreeCameraInputsManager;
  77393. /**
  77394. * Remove all attached input methods from a camera
  77395. */
  77396. clear(): void;
  77397. }
  77398. }
  77399. declare module BABYLON {
  77400. /**
  77401. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  77402. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  77403. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  77404. */
  77405. export class FreeCamera extends TargetCamera {
  77406. /**
  77407. * Define the collision ellipsoid of the camera.
  77408. * This is helpful to simulate a camera body like the player body around the camera
  77409. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  77410. */
  77411. ellipsoid: Vector3;
  77412. /**
  77413. * Define an offset for the position of the ellipsoid around the camera.
  77414. * This can be helpful to determine the center of the body near the gravity center of the body
  77415. * instead of its head.
  77416. */
  77417. ellipsoidOffset: Vector3;
  77418. /**
  77419. * Enable or disable collisions of the camera with the rest of the scene objects.
  77420. */
  77421. checkCollisions: boolean;
  77422. /**
  77423. * Enable or disable gravity on the camera.
  77424. */
  77425. applyGravity: boolean;
  77426. /**
  77427. * Define the input manager associated to the camera.
  77428. */
  77429. inputs: FreeCameraInputsManager;
  77430. /**
  77431. * Gets the input sensibility for a mouse input. (default is 2000.0)
  77432. * Higher values reduce sensitivity.
  77433. */
  77434. /**
  77435. * Sets the input sensibility for a mouse input. (default is 2000.0)
  77436. * Higher values reduce sensitivity.
  77437. */
  77438. angularSensibility: number;
  77439. /**
  77440. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  77441. */
  77442. keysUp: number[];
  77443. /**
  77444. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  77445. */
  77446. keysDown: number[];
  77447. /**
  77448. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  77449. */
  77450. keysLeft: number[];
  77451. /**
  77452. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  77453. */
  77454. keysRight: number[];
  77455. /**
  77456. * Event raised when the camera collide with a mesh in the scene.
  77457. */
  77458. onCollide: (collidedMesh: AbstractMesh) => void;
  77459. private _collider;
  77460. private _needMoveForGravity;
  77461. private _oldPosition;
  77462. private _diffPosition;
  77463. private _newPosition;
  77464. /** @hidden */
  77465. _localDirection: Vector3;
  77466. /** @hidden */
  77467. _transformedDirection: Vector3;
  77468. /**
  77469. * Instantiates a Free Camera.
  77470. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  77471. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  77472. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  77473. * @param name Define the name of the camera in the scene
  77474. * @param position Define the start position of the camera in the scene
  77475. * @param scene Define the scene the camera belongs to
  77476. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  77477. */
  77478. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  77479. /**
  77480. * Attached controls to the current camera.
  77481. * @param element Defines the element the controls should be listened from
  77482. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  77483. */
  77484. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  77485. /**
  77486. * Detach the current controls from the camera.
  77487. * The camera will stop reacting to inputs.
  77488. * @param element Defines the element to stop listening the inputs from
  77489. */
  77490. detachControl(element: HTMLElement): void;
  77491. private _collisionMask;
  77492. /**
  77493. * Define a collision mask to limit the list of object the camera can collide with
  77494. */
  77495. collisionMask: number;
  77496. /** @hidden */
  77497. _collideWithWorld(displacement: Vector3): void;
  77498. private _onCollisionPositionChange;
  77499. /** @hidden */
  77500. _checkInputs(): void;
  77501. /** @hidden */
  77502. _decideIfNeedsToMove(): boolean;
  77503. /** @hidden */
  77504. _updatePosition(): void;
  77505. /**
  77506. * Destroy the camera and release the current resources hold by it.
  77507. */
  77508. dispose(): void;
  77509. /**
  77510. * Gets the current object class name.
  77511. * @return the class name
  77512. */
  77513. getClassName(): string;
  77514. }
  77515. }
  77516. declare module BABYLON {
  77517. /**
  77518. * Represents a gamepad control stick position
  77519. */
  77520. export class StickValues {
  77521. /**
  77522. * The x component of the control stick
  77523. */
  77524. x: number;
  77525. /**
  77526. * The y component of the control stick
  77527. */
  77528. y: number;
  77529. /**
  77530. * Initializes the gamepad x and y control stick values
  77531. * @param x The x component of the gamepad control stick value
  77532. * @param y The y component of the gamepad control stick value
  77533. */
  77534. constructor(
  77535. /**
  77536. * The x component of the control stick
  77537. */
  77538. x: number,
  77539. /**
  77540. * The y component of the control stick
  77541. */
  77542. y: number);
  77543. }
  77544. /**
  77545. * An interface which manages callbacks for gamepad button changes
  77546. */
  77547. export interface GamepadButtonChanges {
  77548. /**
  77549. * Called when a gamepad has been changed
  77550. */
  77551. changed: boolean;
  77552. /**
  77553. * Called when a gamepad press event has been triggered
  77554. */
  77555. pressChanged: boolean;
  77556. /**
  77557. * Called when a touch event has been triggered
  77558. */
  77559. touchChanged: boolean;
  77560. /**
  77561. * Called when a value has changed
  77562. */
  77563. valueChanged: boolean;
  77564. }
  77565. /**
  77566. * Represents a gamepad
  77567. */
  77568. export class Gamepad {
  77569. /**
  77570. * The id of the gamepad
  77571. */
  77572. id: string;
  77573. /**
  77574. * The index of the gamepad
  77575. */
  77576. index: number;
  77577. /**
  77578. * The browser gamepad
  77579. */
  77580. browserGamepad: any;
  77581. /**
  77582. * Specifies what type of gamepad this represents
  77583. */
  77584. type: number;
  77585. private _leftStick;
  77586. private _rightStick;
  77587. /** @hidden */
  77588. _isConnected: boolean;
  77589. private _leftStickAxisX;
  77590. private _leftStickAxisY;
  77591. private _rightStickAxisX;
  77592. private _rightStickAxisY;
  77593. /**
  77594. * Triggered when the left control stick has been changed
  77595. */
  77596. private _onleftstickchanged;
  77597. /**
  77598. * Triggered when the right control stick has been changed
  77599. */
  77600. private _onrightstickchanged;
  77601. /**
  77602. * Represents a gamepad controller
  77603. */
  77604. static GAMEPAD: number;
  77605. /**
  77606. * Represents a generic controller
  77607. */
  77608. static GENERIC: number;
  77609. /**
  77610. * Represents an XBox controller
  77611. */
  77612. static XBOX: number;
  77613. /**
  77614. * Represents a pose-enabled controller
  77615. */
  77616. static POSE_ENABLED: number;
  77617. /**
  77618. * Represents an Dual Shock controller
  77619. */
  77620. static DUALSHOCK: number;
  77621. /**
  77622. * Specifies whether the left control stick should be Y-inverted
  77623. */
  77624. protected _invertLeftStickY: boolean;
  77625. /**
  77626. * Specifies if the gamepad has been connected
  77627. */
  77628. readonly isConnected: boolean;
  77629. /**
  77630. * Initializes the gamepad
  77631. * @param id The id of the gamepad
  77632. * @param index The index of the gamepad
  77633. * @param browserGamepad The browser gamepad
  77634. * @param leftStickX The x component of the left joystick
  77635. * @param leftStickY The y component of the left joystick
  77636. * @param rightStickX The x component of the right joystick
  77637. * @param rightStickY The y component of the right joystick
  77638. */
  77639. constructor(
  77640. /**
  77641. * The id of the gamepad
  77642. */
  77643. id: string,
  77644. /**
  77645. * The index of the gamepad
  77646. */
  77647. index: number,
  77648. /**
  77649. * The browser gamepad
  77650. */
  77651. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  77652. /**
  77653. * Callback triggered when the left joystick has changed
  77654. * @param callback
  77655. */
  77656. onleftstickchanged(callback: (values: StickValues) => void): void;
  77657. /**
  77658. * Callback triggered when the right joystick has changed
  77659. * @param callback
  77660. */
  77661. onrightstickchanged(callback: (values: StickValues) => void): void;
  77662. /**
  77663. * Gets the left joystick
  77664. */
  77665. /**
  77666. * Sets the left joystick values
  77667. */
  77668. leftStick: StickValues;
  77669. /**
  77670. * Gets the right joystick
  77671. */
  77672. /**
  77673. * Sets the right joystick value
  77674. */
  77675. rightStick: StickValues;
  77676. /**
  77677. * Updates the gamepad joystick positions
  77678. */
  77679. update(): void;
  77680. /**
  77681. * Disposes the gamepad
  77682. */
  77683. dispose(): void;
  77684. }
  77685. /**
  77686. * Represents a generic gamepad
  77687. */
  77688. export class GenericPad extends Gamepad {
  77689. private _buttons;
  77690. private _onbuttondown;
  77691. private _onbuttonup;
  77692. /**
  77693. * Observable triggered when a button has been pressed
  77694. */
  77695. onButtonDownObservable: Observable<number>;
  77696. /**
  77697. * Observable triggered when a button has been released
  77698. */
  77699. onButtonUpObservable: Observable<number>;
  77700. /**
  77701. * Callback triggered when a button has been pressed
  77702. * @param callback Called when a button has been pressed
  77703. */
  77704. onbuttondown(callback: (buttonPressed: number) => void): void;
  77705. /**
  77706. * Callback triggered when a button has been released
  77707. * @param callback Called when a button has been released
  77708. */
  77709. onbuttonup(callback: (buttonReleased: number) => void): void;
  77710. /**
  77711. * Initializes the generic gamepad
  77712. * @param id The id of the generic gamepad
  77713. * @param index The index of the generic gamepad
  77714. * @param browserGamepad The browser gamepad
  77715. */
  77716. constructor(id: string, index: number, browserGamepad: any);
  77717. private _setButtonValue;
  77718. /**
  77719. * Updates the generic gamepad
  77720. */
  77721. update(): void;
  77722. /**
  77723. * Disposes the generic gamepad
  77724. */
  77725. dispose(): void;
  77726. }
  77727. }
  77728. declare module BABYLON {
  77729. interface Engine {
  77730. /**
  77731. * Creates a raw texture
  77732. * @param data defines the data to store in the texture
  77733. * @param width defines the width of the texture
  77734. * @param height defines the height of the texture
  77735. * @param format defines the format of the data
  77736. * @param generateMipMaps defines if the engine should generate the mip levels
  77737. * @param invertY defines if data must be stored with Y axis inverted
  77738. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  77739. * @param compression defines the compression used (null by default)
  77740. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  77741. * @returns the raw texture inside an InternalTexture
  77742. */
  77743. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  77744. /**
  77745. * Update a raw texture
  77746. * @param texture defines the texture to update
  77747. * @param data defines the data to store in the texture
  77748. * @param format defines the format of the data
  77749. * @param invertY defines if data must be stored with Y axis inverted
  77750. */
  77751. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  77752. /**
  77753. * Update a raw texture
  77754. * @param texture defines the texture to update
  77755. * @param data defines the data to store in the texture
  77756. * @param format defines the format of the data
  77757. * @param invertY defines if data must be stored with Y axis inverted
  77758. * @param compression defines the compression used (null by default)
  77759. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  77760. */
  77761. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  77762. /**
  77763. * Creates a new raw cube texture
  77764. * @param data defines the array of data to use to create each face
  77765. * @param size defines the size of the textures
  77766. * @param format defines the format of the data
  77767. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  77768. * @param generateMipMaps defines if the engine should generate the mip levels
  77769. * @param invertY defines if data must be stored with Y axis inverted
  77770. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  77771. * @param compression defines the compression used (null by default)
  77772. * @returns the cube texture as an InternalTexture
  77773. */
  77774. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  77775. /**
  77776. * Update a raw cube texture
  77777. * @param texture defines the texture to udpdate
  77778. * @param data defines the data to store
  77779. * @param format defines the data format
  77780. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  77781. * @param invertY defines if data must be stored with Y axis inverted
  77782. */
  77783. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  77784. /**
  77785. * Update a raw cube texture
  77786. * @param texture defines the texture to udpdate
  77787. * @param data defines the data to store
  77788. * @param format defines the data format
  77789. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  77790. * @param invertY defines if data must be stored with Y axis inverted
  77791. * @param compression defines the compression used (null by default)
  77792. */
  77793. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  77794. /**
  77795. * Update a raw cube texture
  77796. * @param texture defines the texture to udpdate
  77797. * @param data defines the data to store
  77798. * @param format defines the data format
  77799. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  77800. * @param invertY defines if data must be stored with Y axis inverted
  77801. * @param compression defines the compression used (null by default)
  77802. * @param level defines which level of the texture to update
  77803. */
  77804. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  77805. /**
  77806. * Creates a new raw cube texture from a specified url
  77807. * @param url defines the url where the data is located
  77808. * @param scene defines the current scene
  77809. * @param size defines the size of the textures
  77810. * @param format defines the format of the data
  77811. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  77812. * @param noMipmap defines if the engine should avoid generating the mip levels
  77813. * @param callback defines a callback used to extract texture data from loaded data
  77814. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  77815. * @param onLoad defines a callback called when texture is loaded
  77816. * @param onError defines a callback called if there is an error
  77817. * @returns the cube texture as an InternalTexture
  77818. */
  77819. 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;
  77820. /**
  77821. * Creates a new raw cube texture from a specified url
  77822. * @param url defines the url where the data is located
  77823. * @param scene defines the current scene
  77824. * @param size defines the size of the textures
  77825. * @param format defines the format of the data
  77826. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  77827. * @param noMipmap defines if the engine should avoid generating the mip levels
  77828. * @param callback defines a callback used to extract texture data from loaded data
  77829. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  77830. * @param onLoad defines a callback called when texture is loaded
  77831. * @param onError defines a callback called if there is an error
  77832. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  77833. * @param invertY defines if data must be stored with Y axis inverted
  77834. * @returns the cube texture as an InternalTexture
  77835. */
  77836. 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;
  77837. /**
  77838. * Creates a new raw 3D texture
  77839. * @param data defines the data used to create the texture
  77840. * @param width defines the width of the texture
  77841. * @param height defines the height of the texture
  77842. * @param depth defines the depth of the texture
  77843. * @param format defines the format of the texture
  77844. * @param generateMipMaps defines if the engine must generate mip levels
  77845. * @param invertY defines if data must be stored with Y axis inverted
  77846. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  77847. * @param compression defines the compressed used (can be null)
  77848. * @param textureType defines the compressed used (can be null)
  77849. * @returns a new raw 3D texture (stored in an InternalTexture)
  77850. */
  77851. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  77852. /**
  77853. * Update a raw 3D texture
  77854. * @param texture defines the texture to update
  77855. * @param data defines the data to store
  77856. * @param format defines the data format
  77857. * @param invertY defines if data must be stored with Y axis inverted
  77858. */
  77859. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  77860. /**
  77861. * Update a raw 3D texture
  77862. * @param texture defines the texture to update
  77863. * @param data defines the data to store
  77864. * @param format defines the data format
  77865. * @param invertY defines if data must be stored with Y axis inverted
  77866. * @param compression defines the used compression (can be null)
  77867. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  77868. */
  77869. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  77870. }
  77871. }
  77872. declare module BABYLON {
  77873. /**
  77874. * Raw texture can help creating a texture directly from an array of data.
  77875. * This can be super useful if you either get the data from an uncompressed source or
  77876. * if you wish to create your texture pixel by pixel.
  77877. */
  77878. export class RawTexture extends Texture {
  77879. /**
  77880. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  77881. */
  77882. format: number;
  77883. private _engine;
  77884. /**
  77885. * Instantiates a new RawTexture.
  77886. * Raw texture can help creating a texture directly from an array of data.
  77887. * This can be super useful if you either get the data from an uncompressed source or
  77888. * if you wish to create your texture pixel by pixel.
  77889. * @param data define the array of data to use to create the texture
  77890. * @param width define the width of the texture
  77891. * @param height define the height of the texture
  77892. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  77893. * @param scene define the scene the texture belongs to
  77894. * @param generateMipMaps define whether mip maps should be generated or not
  77895. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  77896. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  77897. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  77898. */
  77899. constructor(data: ArrayBufferView, width: number, height: number,
  77900. /**
  77901. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  77902. */
  77903. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  77904. /**
  77905. * Updates the texture underlying data.
  77906. * @param data Define the new data of the texture
  77907. */
  77908. update(data: ArrayBufferView): void;
  77909. /**
  77910. * Creates a luminance texture from some data.
  77911. * @param data Define the texture data
  77912. * @param width Define the width of the texture
  77913. * @param height Define the height of the texture
  77914. * @param scene Define the scene the texture belongs to
  77915. * @param generateMipMaps Define whether or not to create mip maps for the texture
  77916. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  77917. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  77918. * @returns the luminance texture
  77919. */
  77920. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  77921. /**
  77922. * Creates a luminance alpha texture from some data.
  77923. * @param data Define the texture data
  77924. * @param width Define the width of the texture
  77925. * @param height Define the height of the texture
  77926. * @param scene Define the scene the texture belongs to
  77927. * @param generateMipMaps Define whether or not to create mip maps for the texture
  77928. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  77929. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  77930. * @returns the luminance alpha texture
  77931. */
  77932. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  77933. /**
  77934. * Creates an alpha texture from some data.
  77935. * @param data Define the texture data
  77936. * @param width Define the width of the texture
  77937. * @param height Define the height of the texture
  77938. * @param scene Define the scene the texture belongs to
  77939. * @param generateMipMaps Define whether or not to create mip maps for the texture
  77940. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  77941. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  77942. * @returns the alpha texture
  77943. */
  77944. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  77945. /**
  77946. * Creates a RGB texture from some data.
  77947. * @param data Define the texture data
  77948. * @param width Define the width of the texture
  77949. * @param height Define the height of the texture
  77950. * @param scene Define the scene the texture belongs to
  77951. * @param generateMipMaps Define whether or not to create mip maps for the texture
  77952. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  77953. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  77954. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  77955. * @returns the RGB alpha texture
  77956. */
  77957. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  77958. /**
  77959. * Creates a RGBA texture from some data.
  77960. * @param data Define the texture data
  77961. * @param width Define the width of the texture
  77962. * @param height Define the height of the texture
  77963. * @param scene Define the scene the texture belongs to
  77964. * @param generateMipMaps Define whether or not to create mip maps for the texture
  77965. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  77966. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  77967. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  77968. * @returns the RGBA texture
  77969. */
  77970. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  77971. /**
  77972. * Creates a R texture from some data.
  77973. * @param data Define the texture data
  77974. * @param width Define the width of the texture
  77975. * @param height Define the height of the texture
  77976. * @param scene Define the scene the texture belongs to
  77977. * @param generateMipMaps Define whether or not to create mip maps for the texture
  77978. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  77979. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  77980. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  77981. * @returns the R texture
  77982. */
  77983. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  77984. }
  77985. }
  77986. declare module BABYLON {
  77987. /**
  77988. * Interface for the size containing width and height
  77989. */
  77990. export interface ISize {
  77991. /**
  77992. * Width
  77993. */
  77994. width: number;
  77995. /**
  77996. * Heighht
  77997. */
  77998. height: number;
  77999. }
  78000. /**
  78001. * Size containing widht and height
  78002. */
  78003. export class Size implements ISize {
  78004. /**
  78005. * Width
  78006. */
  78007. width: number;
  78008. /**
  78009. * Height
  78010. */
  78011. height: number;
  78012. /**
  78013. * Creates a Size object from the given width and height (floats).
  78014. * @param width width of the new size
  78015. * @param height height of the new size
  78016. */
  78017. constructor(width: number, height: number);
  78018. /**
  78019. * Returns a string with the Size width and height
  78020. * @returns a string with the Size width and height
  78021. */
  78022. toString(): string;
  78023. /**
  78024. * "Size"
  78025. * @returns the string "Size"
  78026. */
  78027. getClassName(): string;
  78028. /**
  78029. * Returns the Size hash code.
  78030. * @returns a hash code for a unique width and height
  78031. */
  78032. getHashCode(): number;
  78033. /**
  78034. * Updates the current size from the given one.
  78035. * @param src the given size
  78036. */
  78037. copyFrom(src: Size): void;
  78038. /**
  78039. * Updates in place the current Size from the given floats.
  78040. * @param width width of the new size
  78041. * @param height height of the new size
  78042. * @returns the updated Size.
  78043. */
  78044. copyFromFloats(width: number, height: number): Size;
  78045. /**
  78046. * Updates in place the current Size from the given floats.
  78047. * @param width width to set
  78048. * @param height height to set
  78049. * @returns the updated Size.
  78050. */
  78051. set(width: number, height: number): Size;
  78052. /**
  78053. * Multiplies the width and height by numbers
  78054. * @param w factor to multiple the width by
  78055. * @param h factor to multiple the height by
  78056. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  78057. */
  78058. multiplyByFloats(w: number, h: number): Size;
  78059. /**
  78060. * Clones the size
  78061. * @returns a new Size copied from the given one.
  78062. */
  78063. clone(): Size;
  78064. /**
  78065. * True if the current Size and the given one width and height are strictly equal.
  78066. * @param other the other size to compare against
  78067. * @returns True if the current Size and the given one width and height are strictly equal.
  78068. */
  78069. equals(other: Size): boolean;
  78070. /**
  78071. * The surface of the Size : width * height (float).
  78072. */
  78073. readonly surface: number;
  78074. /**
  78075. * Create a new size of zero
  78076. * @returns a new Size set to (0.0, 0.0)
  78077. */
  78078. static Zero(): Size;
  78079. /**
  78080. * Sums the width and height of two sizes
  78081. * @param otherSize size to add to this size
  78082. * @returns a new Size set as the addition result of the current Size and the given one.
  78083. */
  78084. add(otherSize: Size): Size;
  78085. /**
  78086. * Subtracts the width and height of two
  78087. * @param otherSize size to subtract to this size
  78088. * @returns a new Size set as the subtraction result of the given one from the current Size.
  78089. */
  78090. subtract(otherSize: Size): Size;
  78091. /**
  78092. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  78093. * @param start starting size to lerp between
  78094. * @param end end size to lerp between
  78095. * @param amount amount to lerp between the start and end values
  78096. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  78097. */
  78098. static Lerp(start: Size, end: Size, amount: number): Size;
  78099. }
  78100. }
  78101. declare module BABYLON {
  78102. /**
  78103. * Defines a runtime animation
  78104. */
  78105. export class RuntimeAnimation {
  78106. private _events;
  78107. /**
  78108. * The current frame of the runtime animation
  78109. */
  78110. private _currentFrame;
  78111. /**
  78112. * The animation used by the runtime animation
  78113. */
  78114. private _animation;
  78115. /**
  78116. * The target of the runtime animation
  78117. */
  78118. private _target;
  78119. /**
  78120. * The initiating animatable
  78121. */
  78122. private _host;
  78123. /**
  78124. * The original value of the runtime animation
  78125. */
  78126. private _originalValue;
  78127. /**
  78128. * The original blend value of the runtime animation
  78129. */
  78130. private _originalBlendValue;
  78131. /**
  78132. * The offsets cache of the runtime animation
  78133. */
  78134. private _offsetsCache;
  78135. /**
  78136. * The high limits cache of the runtime animation
  78137. */
  78138. private _highLimitsCache;
  78139. /**
  78140. * Specifies if the runtime animation has been stopped
  78141. */
  78142. private _stopped;
  78143. /**
  78144. * The blending factor of the runtime animation
  78145. */
  78146. private _blendingFactor;
  78147. /**
  78148. * The BabylonJS scene
  78149. */
  78150. private _scene;
  78151. /**
  78152. * The current value of the runtime animation
  78153. */
  78154. private _currentValue;
  78155. /** @hidden */
  78156. _animationState: _IAnimationState;
  78157. /**
  78158. * The active target of the runtime animation
  78159. */
  78160. private _activeTargets;
  78161. private _currentActiveTarget;
  78162. private _directTarget;
  78163. /**
  78164. * The target path of the runtime animation
  78165. */
  78166. private _targetPath;
  78167. /**
  78168. * The weight of the runtime animation
  78169. */
  78170. private _weight;
  78171. /**
  78172. * The ratio offset of the runtime animation
  78173. */
  78174. private _ratioOffset;
  78175. /**
  78176. * The previous delay of the runtime animation
  78177. */
  78178. private _previousDelay;
  78179. /**
  78180. * The previous ratio of the runtime animation
  78181. */
  78182. private _previousRatio;
  78183. private _enableBlending;
  78184. private _keys;
  78185. private _minFrame;
  78186. private _maxFrame;
  78187. private _minValue;
  78188. private _maxValue;
  78189. private _targetIsArray;
  78190. /**
  78191. * Gets the current frame of the runtime animation
  78192. */
  78193. readonly currentFrame: number;
  78194. /**
  78195. * Gets the weight of the runtime animation
  78196. */
  78197. readonly weight: number;
  78198. /**
  78199. * Gets the current value of the runtime animation
  78200. */
  78201. readonly currentValue: any;
  78202. /**
  78203. * Gets the target path of the runtime animation
  78204. */
  78205. readonly targetPath: string;
  78206. /**
  78207. * Gets the actual target of the runtime animation
  78208. */
  78209. readonly target: any;
  78210. /** @hidden */
  78211. _onLoop: () => void;
  78212. /**
  78213. * Create a new RuntimeAnimation object
  78214. * @param target defines the target of the animation
  78215. * @param animation defines the source animation object
  78216. * @param scene defines the hosting scene
  78217. * @param host defines the initiating Animatable
  78218. */
  78219. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  78220. private _preparePath;
  78221. /**
  78222. * Gets the animation from the runtime animation
  78223. */
  78224. readonly animation: Animation;
  78225. /**
  78226. * Resets the runtime animation to the beginning
  78227. * @param restoreOriginal defines whether to restore the target property to the original value
  78228. */
  78229. reset(restoreOriginal?: boolean): void;
  78230. /**
  78231. * Specifies if the runtime animation is stopped
  78232. * @returns Boolean specifying if the runtime animation is stopped
  78233. */
  78234. isStopped(): boolean;
  78235. /**
  78236. * Disposes of the runtime animation
  78237. */
  78238. dispose(): void;
  78239. /**
  78240. * Apply the interpolated value to the target
  78241. * @param currentValue defines the value computed by the animation
  78242. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  78243. */
  78244. setValue(currentValue: any, weight: number): void;
  78245. private _getOriginalValues;
  78246. private _setValue;
  78247. /**
  78248. * Gets the loop pmode of the runtime animation
  78249. * @returns Loop Mode
  78250. */
  78251. private _getCorrectLoopMode;
  78252. /**
  78253. * Move the current animation to a given frame
  78254. * @param frame defines the frame to move to
  78255. */
  78256. goToFrame(frame: number): void;
  78257. /**
  78258. * @hidden Internal use only
  78259. */
  78260. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  78261. /**
  78262. * Execute the current animation
  78263. * @param delay defines the delay to add to the current frame
  78264. * @param from defines the lower bound of the animation range
  78265. * @param to defines the upper bound of the animation range
  78266. * @param loop defines if the current animation must loop
  78267. * @param speedRatio defines the current speed ratio
  78268. * @param weight defines the weight of the animation (default is -1 so no weight)
  78269. * @param onLoop optional callback called when animation loops
  78270. * @returns a boolean indicating if the animation is running
  78271. */
  78272. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  78273. }
  78274. }
  78275. declare module BABYLON {
  78276. /**
  78277. * Class used to store an actual running animation
  78278. */
  78279. export class Animatable {
  78280. /** defines the target object */
  78281. target: any;
  78282. /** defines the starting frame number (default is 0) */
  78283. fromFrame: number;
  78284. /** defines the ending frame number (default is 100) */
  78285. toFrame: number;
  78286. /** defines if the animation must loop (default is false) */
  78287. loopAnimation: boolean;
  78288. /** defines a callback to call when animation ends if it is not looping */
  78289. onAnimationEnd?: (() => void) | null | undefined;
  78290. /** defines a callback to call when animation loops */
  78291. onAnimationLoop?: (() => void) | null | undefined;
  78292. private _localDelayOffset;
  78293. private _pausedDelay;
  78294. private _runtimeAnimations;
  78295. private _paused;
  78296. private _scene;
  78297. private _speedRatio;
  78298. private _weight;
  78299. private _syncRoot;
  78300. /**
  78301. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  78302. * This will only apply for non looping animation (default is true)
  78303. */
  78304. disposeOnEnd: boolean;
  78305. /**
  78306. * Gets a boolean indicating if the animation has started
  78307. */
  78308. animationStarted: boolean;
  78309. /**
  78310. * Observer raised when the animation ends
  78311. */
  78312. onAnimationEndObservable: Observable<Animatable>;
  78313. /**
  78314. * Observer raised when the animation loops
  78315. */
  78316. onAnimationLoopObservable: Observable<Animatable>;
  78317. /**
  78318. * Gets the root Animatable used to synchronize and normalize animations
  78319. */
  78320. readonly syncRoot: Nullable<Animatable>;
  78321. /**
  78322. * Gets the current frame of the first RuntimeAnimation
  78323. * Used to synchronize Animatables
  78324. */
  78325. readonly masterFrame: number;
  78326. /**
  78327. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  78328. */
  78329. weight: number;
  78330. /**
  78331. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  78332. */
  78333. speedRatio: number;
  78334. /**
  78335. * Creates a new Animatable
  78336. * @param scene defines the hosting scene
  78337. * @param target defines the target object
  78338. * @param fromFrame defines the starting frame number (default is 0)
  78339. * @param toFrame defines the ending frame number (default is 100)
  78340. * @param loopAnimation defines if the animation must loop (default is false)
  78341. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  78342. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  78343. * @param animations defines a group of animation to add to the new Animatable
  78344. * @param onAnimationLoop defines a callback to call when animation loops
  78345. */
  78346. constructor(scene: Scene,
  78347. /** defines the target object */
  78348. target: any,
  78349. /** defines the starting frame number (default is 0) */
  78350. fromFrame?: number,
  78351. /** defines the ending frame number (default is 100) */
  78352. toFrame?: number,
  78353. /** defines if the animation must loop (default is false) */
  78354. loopAnimation?: boolean, speedRatio?: number,
  78355. /** defines a callback to call when animation ends if it is not looping */
  78356. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  78357. /** defines a callback to call when animation loops */
  78358. onAnimationLoop?: (() => void) | null | undefined);
  78359. /**
  78360. * Synchronize and normalize current Animatable with a source Animatable
  78361. * This is useful when using animation weights and when animations are not of the same length
  78362. * @param root defines the root Animatable to synchronize with
  78363. * @returns the current Animatable
  78364. */
  78365. syncWith(root: Animatable): Animatable;
  78366. /**
  78367. * Gets the list of runtime animations
  78368. * @returns an array of RuntimeAnimation
  78369. */
  78370. getAnimations(): RuntimeAnimation[];
  78371. /**
  78372. * Adds more animations to the current animatable
  78373. * @param target defines the target of the animations
  78374. * @param animations defines the new animations to add
  78375. */
  78376. appendAnimations(target: any, animations: Animation[]): void;
  78377. /**
  78378. * Gets the source animation for a specific property
  78379. * @param property defines the propertyu to look for
  78380. * @returns null or the source animation for the given property
  78381. */
  78382. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  78383. /**
  78384. * Gets the runtime animation for a specific property
  78385. * @param property defines the propertyu to look for
  78386. * @returns null or the runtime animation for the given property
  78387. */
  78388. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  78389. /**
  78390. * Resets the animatable to its original state
  78391. */
  78392. reset(): void;
  78393. /**
  78394. * Allows the animatable to blend with current running animations
  78395. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  78396. * @param blendingSpeed defines the blending speed to use
  78397. */
  78398. enableBlending(blendingSpeed: number): void;
  78399. /**
  78400. * Disable animation blending
  78401. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  78402. */
  78403. disableBlending(): void;
  78404. /**
  78405. * Jump directly to a given frame
  78406. * @param frame defines the frame to jump to
  78407. */
  78408. goToFrame(frame: number): void;
  78409. /**
  78410. * Pause the animation
  78411. */
  78412. pause(): void;
  78413. /**
  78414. * Restart the animation
  78415. */
  78416. restart(): void;
  78417. private _raiseOnAnimationEnd;
  78418. /**
  78419. * Stop and delete the current animation
  78420. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  78421. * @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)
  78422. */
  78423. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  78424. /**
  78425. * Wait asynchronously for the animation to end
  78426. * @returns a promise which will be fullfilled when the animation ends
  78427. */
  78428. waitAsync(): Promise<Animatable>;
  78429. /** @hidden */
  78430. _animate(delay: number): boolean;
  78431. }
  78432. interface Scene {
  78433. /** @hidden */
  78434. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  78435. /** @hidden */
  78436. _processLateAnimationBindingsForMatrices(holder: {
  78437. totalWeight: number;
  78438. animations: RuntimeAnimation[];
  78439. originalValue: Matrix;
  78440. }): any;
  78441. /** @hidden */
  78442. _processLateAnimationBindingsForQuaternions(holder: {
  78443. totalWeight: number;
  78444. animations: RuntimeAnimation[];
  78445. originalValue: Quaternion;
  78446. }, refQuaternion: Quaternion): Quaternion;
  78447. /** @hidden */
  78448. _processLateAnimationBindings(): void;
  78449. /**
  78450. * Will start the animation sequence of a given target
  78451. * @param target defines the target
  78452. * @param from defines from which frame should animation start
  78453. * @param to defines until which frame should animation run.
  78454. * @param weight defines the weight to apply to the animation (1.0 by default)
  78455. * @param loop defines if the animation loops
  78456. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  78457. * @param onAnimationEnd defines the function to be executed when the animation ends
  78458. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  78459. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  78460. * @param onAnimationLoop defines the callback to call when an animation loops
  78461. * @returns the animatable object created for this animation
  78462. */
  78463. beginWeightedAnimation(target: any, from: number, to: number, weight: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  78464. /**
  78465. * Will start the animation sequence of a given target
  78466. * @param target defines the target
  78467. * @param from defines from which frame should animation start
  78468. * @param to defines until which frame should animation run.
  78469. * @param loop defines if the animation loops
  78470. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  78471. * @param onAnimationEnd defines the function to be executed when the animation ends
  78472. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  78473. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  78474. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  78475. * @param onAnimationLoop defines the callback to call when an animation loops
  78476. * @returns the animatable object created for this animation
  78477. */
  78478. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  78479. /**
  78480. * Will start the animation sequence of a given target and its hierarchy
  78481. * @param target defines the target
  78482. * @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.
  78483. * @param from defines from which frame should animation start
  78484. * @param to defines until which frame should animation run.
  78485. * @param loop defines if the animation loops
  78486. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  78487. * @param onAnimationEnd defines the function to be executed when the animation ends
  78488. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  78489. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  78490. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  78491. * @param onAnimationLoop defines the callback to call when an animation loops
  78492. * @returns the list of created animatables
  78493. */
  78494. 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[];
  78495. /**
  78496. * Begin a new animation on a given node
  78497. * @param target defines the target where the animation will take place
  78498. * @param animations defines the list of animations to start
  78499. * @param from defines the initial value
  78500. * @param to defines the final value
  78501. * @param loop defines if you want animation to loop (off by default)
  78502. * @param speedRatio defines the speed ratio to apply to all animations
  78503. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  78504. * @param onAnimationLoop defines the callback to call when an animation loops
  78505. * @returns the list of created animatables
  78506. */
  78507. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable;
  78508. /**
  78509. * Begin a new animation on a given node and its hierarchy
  78510. * @param target defines the root node where the animation will take place
  78511. * @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.
  78512. * @param animations defines the list of animations to start
  78513. * @param from defines the initial value
  78514. * @param to defines the final value
  78515. * @param loop defines if you want animation to loop (off by default)
  78516. * @param speedRatio defines the speed ratio to apply to all animations
  78517. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  78518. * @param onAnimationLoop defines the callback to call when an animation loops
  78519. * @returns the list of animatables created for all nodes
  78520. */
  78521. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable[];
  78522. /**
  78523. * Gets the animatable associated with a specific target
  78524. * @param target defines the target of the animatable
  78525. * @returns the required animatable if found
  78526. */
  78527. getAnimatableByTarget(target: any): Nullable<Animatable>;
  78528. /**
  78529. * Gets all animatables associated with a given target
  78530. * @param target defines the target to look animatables for
  78531. * @returns an array of Animatables
  78532. */
  78533. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  78534. /**
  78535. * Stops and removes all animations that have been applied to the scene
  78536. */
  78537. stopAllAnimations(): void;
  78538. }
  78539. interface Bone {
  78540. /**
  78541. * Copy an animation range from another bone
  78542. * @param source defines the source bone
  78543. * @param rangeName defines the range name to copy
  78544. * @param frameOffset defines the frame offset
  78545. * @param rescaleAsRequired defines if rescaling must be applied if required
  78546. * @param skelDimensionsRatio defines the scaling ratio
  78547. * @returns true if operation was successful
  78548. */
  78549. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  78550. }
  78551. }
  78552. declare module BABYLON {
  78553. /**
  78554. * Class used to override all child animations of a given target
  78555. */
  78556. export class AnimationPropertiesOverride {
  78557. /**
  78558. * Gets or sets a value indicating if animation blending must be used
  78559. */
  78560. enableBlending: boolean;
  78561. /**
  78562. * Gets or sets the blending speed to use when enableBlending is true
  78563. */
  78564. blendingSpeed: number;
  78565. /**
  78566. * Gets or sets the default loop mode to use
  78567. */
  78568. loopMode: number;
  78569. }
  78570. }
  78571. declare module BABYLON {
  78572. /**
  78573. * Class used to handle skinning animations
  78574. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  78575. */
  78576. export class Skeleton implements IAnimatable {
  78577. /** defines the skeleton name */
  78578. name: string;
  78579. /** defines the skeleton Id */
  78580. id: string;
  78581. /**
  78582. * Defines the list of child bones
  78583. */
  78584. bones: Bone[];
  78585. /**
  78586. * Defines an estimate of the dimension of the skeleton at rest
  78587. */
  78588. dimensionsAtRest: Vector3;
  78589. /**
  78590. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  78591. */
  78592. needInitialSkinMatrix: boolean;
  78593. /**
  78594. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  78595. */
  78596. overrideMesh: Nullable<AbstractMesh>;
  78597. /**
  78598. * Gets the list of animations attached to this skeleton
  78599. */
  78600. animations: Array<Animation>;
  78601. private _scene;
  78602. private _isDirty;
  78603. private _transformMatrices;
  78604. private _transformMatrixTexture;
  78605. private _meshesWithPoseMatrix;
  78606. private _animatables;
  78607. private _identity;
  78608. private _synchronizedWithMesh;
  78609. private _ranges;
  78610. private _lastAbsoluteTransformsUpdateId;
  78611. private _canUseTextureForBones;
  78612. private _uniqueId;
  78613. /** @hidden */
  78614. _numBonesWithLinkedTransformNode: number;
  78615. /** @hidden */
  78616. _hasWaitingData: Nullable<boolean>;
  78617. /**
  78618. * Specifies if the skeleton should be serialized
  78619. */
  78620. doNotSerialize: boolean;
  78621. private _useTextureToStoreBoneMatrices;
  78622. /**
  78623. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  78624. * Please note that this option is not available if the hardware does not support it
  78625. */
  78626. useTextureToStoreBoneMatrices: boolean;
  78627. private _animationPropertiesOverride;
  78628. /**
  78629. * Gets or sets the animation properties override
  78630. */
  78631. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  78632. /**
  78633. * List of inspectable custom properties (used by the Inspector)
  78634. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  78635. */
  78636. inspectableCustomProperties: IInspectable[];
  78637. /**
  78638. * An observable triggered before computing the skeleton's matrices
  78639. */
  78640. onBeforeComputeObservable: Observable<Skeleton>;
  78641. /**
  78642. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  78643. */
  78644. readonly isUsingTextureForMatrices: boolean;
  78645. /**
  78646. * Gets the unique ID of this skeleton
  78647. */
  78648. readonly uniqueId: number;
  78649. /**
  78650. * Creates a new skeleton
  78651. * @param name defines the skeleton name
  78652. * @param id defines the skeleton Id
  78653. * @param scene defines the hosting scene
  78654. */
  78655. constructor(
  78656. /** defines the skeleton name */
  78657. name: string,
  78658. /** defines the skeleton Id */
  78659. id: string, scene: Scene);
  78660. /**
  78661. * Gets the current object class name.
  78662. * @return the class name
  78663. */
  78664. getClassName(): string;
  78665. /**
  78666. * Returns an array containing the root bones
  78667. * @returns an array containing the root bones
  78668. */
  78669. getChildren(): Array<Bone>;
  78670. /**
  78671. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  78672. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  78673. * @returns a Float32Array containing matrices data
  78674. */
  78675. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  78676. /**
  78677. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  78678. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  78679. * @returns a raw texture containing the data
  78680. */
  78681. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  78682. /**
  78683. * Gets the current hosting scene
  78684. * @returns a scene object
  78685. */
  78686. getScene(): Scene;
  78687. /**
  78688. * Gets a string representing the current skeleton data
  78689. * @param fullDetails defines a boolean indicating if we want a verbose version
  78690. * @returns a string representing the current skeleton data
  78691. */
  78692. toString(fullDetails?: boolean): string;
  78693. /**
  78694. * Get bone's index searching by name
  78695. * @param name defines bone's name to search for
  78696. * @return the indice of the bone. Returns -1 if not found
  78697. */
  78698. getBoneIndexByName(name: string): number;
  78699. /**
  78700. * Creater a new animation range
  78701. * @param name defines the name of the range
  78702. * @param from defines the start key
  78703. * @param to defines the end key
  78704. */
  78705. createAnimationRange(name: string, from: number, to: number): void;
  78706. /**
  78707. * Delete a specific animation range
  78708. * @param name defines the name of the range
  78709. * @param deleteFrames defines if frames must be removed as well
  78710. */
  78711. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  78712. /**
  78713. * Gets a specific animation range
  78714. * @param name defines the name of the range to look for
  78715. * @returns the requested animation range or null if not found
  78716. */
  78717. getAnimationRange(name: string): Nullable<AnimationRange>;
  78718. /**
  78719. * Gets the list of all animation ranges defined on this skeleton
  78720. * @returns an array
  78721. */
  78722. getAnimationRanges(): Nullable<AnimationRange>[];
  78723. /**
  78724. * Copy animation range from a source skeleton.
  78725. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  78726. * @param source defines the source skeleton
  78727. * @param name defines the name of the range to copy
  78728. * @param rescaleAsRequired defines if rescaling must be applied if required
  78729. * @returns true if operation was successful
  78730. */
  78731. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  78732. /**
  78733. * Forces the skeleton to go to rest pose
  78734. */
  78735. returnToRest(): void;
  78736. private _getHighestAnimationFrame;
  78737. /**
  78738. * Begin a specific animation range
  78739. * @param name defines the name of the range to start
  78740. * @param loop defines if looping must be turned on (false by default)
  78741. * @param speedRatio defines the speed ratio to apply (1 by default)
  78742. * @param onAnimationEnd defines a callback which will be called when animation will end
  78743. * @returns a new animatable
  78744. */
  78745. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  78746. /** @hidden */
  78747. _markAsDirty(): void;
  78748. /** @hidden */
  78749. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  78750. /** @hidden */
  78751. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  78752. private _computeTransformMatrices;
  78753. /**
  78754. * Build all resources required to render a skeleton
  78755. */
  78756. prepare(): void;
  78757. /**
  78758. * Gets the list of animatables currently running for this skeleton
  78759. * @returns an array of animatables
  78760. */
  78761. getAnimatables(): IAnimatable[];
  78762. /**
  78763. * Clone the current skeleton
  78764. * @param name defines the name of the new skeleton
  78765. * @param id defines the id of the new skeleton
  78766. * @returns the new skeleton
  78767. */
  78768. clone(name: string, id: string): Skeleton;
  78769. /**
  78770. * Enable animation blending for this skeleton
  78771. * @param blendingSpeed defines the blending speed to apply
  78772. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  78773. */
  78774. enableBlending(blendingSpeed?: number): void;
  78775. /**
  78776. * Releases all resources associated with the current skeleton
  78777. */
  78778. dispose(): void;
  78779. /**
  78780. * Serialize the skeleton in a JSON object
  78781. * @returns a JSON object
  78782. */
  78783. serialize(): any;
  78784. /**
  78785. * Creates a new skeleton from serialized data
  78786. * @param parsedSkeleton defines the serialized data
  78787. * @param scene defines the hosting scene
  78788. * @returns a new skeleton
  78789. */
  78790. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  78791. /**
  78792. * Compute all node absolute transforms
  78793. * @param forceUpdate defines if computation must be done even if cache is up to date
  78794. */
  78795. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  78796. /**
  78797. * Gets the root pose matrix
  78798. * @returns a matrix
  78799. */
  78800. getPoseMatrix(): Nullable<Matrix>;
  78801. /**
  78802. * Sorts bones per internal index
  78803. */
  78804. sortBones(): void;
  78805. private _sortBones;
  78806. }
  78807. }
  78808. declare module BABYLON {
  78809. /**
  78810. * Class used to store bone information
  78811. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  78812. */
  78813. export class Bone extends Node {
  78814. /**
  78815. * defines the bone name
  78816. */
  78817. name: string;
  78818. private static _tmpVecs;
  78819. private static _tmpQuat;
  78820. private static _tmpMats;
  78821. /**
  78822. * Gets the list of child bones
  78823. */
  78824. children: Bone[];
  78825. /** Gets the animations associated with this bone */
  78826. animations: Animation[];
  78827. /**
  78828. * Gets or sets bone length
  78829. */
  78830. length: number;
  78831. /**
  78832. * @hidden Internal only
  78833. * Set this value to map this bone to a different index in the transform matrices
  78834. * Set this value to -1 to exclude the bone from the transform matrices
  78835. */
  78836. _index: Nullable<number>;
  78837. private _skeleton;
  78838. private _localMatrix;
  78839. private _restPose;
  78840. private _baseMatrix;
  78841. private _absoluteTransform;
  78842. private _invertedAbsoluteTransform;
  78843. private _parent;
  78844. private _scalingDeterminant;
  78845. private _worldTransform;
  78846. private _localScaling;
  78847. private _localRotation;
  78848. private _localPosition;
  78849. private _needToDecompose;
  78850. private _needToCompose;
  78851. /** @hidden */
  78852. _linkedTransformNode: Nullable<TransformNode>;
  78853. /** @hidden */
  78854. _waitingTransformNodeId: Nullable<string>;
  78855. /** @hidden */
  78856. /** @hidden */
  78857. _matrix: Matrix;
  78858. /**
  78859. * Create a new bone
  78860. * @param name defines the bone name
  78861. * @param skeleton defines the parent skeleton
  78862. * @param parentBone defines the parent (can be null if the bone is the root)
  78863. * @param localMatrix defines the local matrix
  78864. * @param restPose defines the rest pose matrix
  78865. * @param baseMatrix defines the base matrix
  78866. * @param index defines index of the bone in the hiearchy
  78867. */
  78868. constructor(
  78869. /**
  78870. * defines the bone name
  78871. */
  78872. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  78873. /**
  78874. * Gets the current object class name.
  78875. * @return the class name
  78876. */
  78877. getClassName(): string;
  78878. /**
  78879. * Gets the parent skeleton
  78880. * @returns a skeleton
  78881. */
  78882. getSkeleton(): Skeleton;
  78883. /**
  78884. * Gets parent bone
  78885. * @returns a bone or null if the bone is the root of the bone hierarchy
  78886. */
  78887. getParent(): Nullable<Bone>;
  78888. /**
  78889. * Returns an array containing the root bones
  78890. * @returns an array containing the root bones
  78891. */
  78892. getChildren(): Array<Bone>;
  78893. /**
  78894. * Sets the parent bone
  78895. * @param parent defines the parent (can be null if the bone is the root)
  78896. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  78897. */
  78898. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  78899. /**
  78900. * Gets the local matrix
  78901. * @returns a matrix
  78902. */
  78903. getLocalMatrix(): Matrix;
  78904. /**
  78905. * Gets the base matrix (initial matrix which remains unchanged)
  78906. * @returns a matrix
  78907. */
  78908. getBaseMatrix(): Matrix;
  78909. /**
  78910. * Gets the rest pose matrix
  78911. * @returns a matrix
  78912. */
  78913. getRestPose(): Matrix;
  78914. /**
  78915. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  78916. */
  78917. getWorldMatrix(): Matrix;
  78918. /**
  78919. * Sets the local matrix to rest pose matrix
  78920. */
  78921. returnToRest(): void;
  78922. /**
  78923. * Gets the inverse of the absolute transform matrix.
  78924. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  78925. * @returns a matrix
  78926. */
  78927. getInvertedAbsoluteTransform(): Matrix;
  78928. /**
  78929. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  78930. * @returns a matrix
  78931. */
  78932. getAbsoluteTransform(): Matrix;
  78933. /**
  78934. * Links with the given transform node.
  78935. * The local matrix of this bone is copied from the transform node every frame.
  78936. * @param transformNode defines the transform node to link to
  78937. */
  78938. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  78939. /**
  78940. * Gets the node used to drive the bone's transformation
  78941. * @returns a transform node or null
  78942. */
  78943. getTransformNode(): Nullable<TransformNode>;
  78944. /** Gets or sets current position (in local space) */
  78945. position: Vector3;
  78946. /** Gets or sets current rotation (in local space) */
  78947. rotation: Vector3;
  78948. /** Gets or sets current rotation quaternion (in local space) */
  78949. rotationQuaternion: Quaternion;
  78950. /** Gets or sets current scaling (in local space) */
  78951. scaling: Vector3;
  78952. /**
  78953. * Gets the animation properties override
  78954. */
  78955. readonly animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  78956. private _decompose;
  78957. private _compose;
  78958. /**
  78959. * Update the base and local matrices
  78960. * @param matrix defines the new base or local matrix
  78961. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  78962. * @param updateLocalMatrix defines if the local matrix should be updated
  78963. */
  78964. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  78965. /** @hidden */
  78966. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  78967. /**
  78968. * Flag the bone as dirty (Forcing it to update everything)
  78969. */
  78970. markAsDirty(): void;
  78971. /** @hidden */
  78972. _markAsDirtyAndCompose(): void;
  78973. private _markAsDirtyAndDecompose;
  78974. /**
  78975. * Translate the bone in local or world space
  78976. * @param vec The amount to translate the bone
  78977. * @param space The space that the translation is in
  78978. * @param mesh The mesh that this bone is attached to. This is only used in world space
  78979. */
  78980. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  78981. /**
  78982. * Set the postion of the bone in local or world space
  78983. * @param position The position to set the bone
  78984. * @param space The space that the position is in
  78985. * @param mesh The mesh that this bone is attached to. This is only used in world space
  78986. */
  78987. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  78988. /**
  78989. * Set the absolute position of the bone (world space)
  78990. * @param position The position to set the bone
  78991. * @param mesh The mesh that this bone is attached to
  78992. */
  78993. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  78994. /**
  78995. * Scale the bone on the x, y and z axes (in local space)
  78996. * @param x The amount to scale the bone on the x axis
  78997. * @param y The amount to scale the bone on the y axis
  78998. * @param z The amount to scale the bone on the z axis
  78999. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  79000. */
  79001. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  79002. /**
  79003. * Set the bone scaling in local space
  79004. * @param scale defines the scaling vector
  79005. */
  79006. setScale(scale: Vector3): void;
  79007. /**
  79008. * Gets the current scaling in local space
  79009. * @returns the current scaling vector
  79010. */
  79011. getScale(): Vector3;
  79012. /**
  79013. * Gets the current scaling in local space and stores it in a target vector
  79014. * @param result defines the target vector
  79015. */
  79016. getScaleToRef(result: Vector3): void;
  79017. /**
  79018. * Set the yaw, pitch, and roll of the bone in local or world space
  79019. * @param yaw The rotation of the bone on the y axis
  79020. * @param pitch The rotation of the bone on the x axis
  79021. * @param roll The rotation of the bone on the z axis
  79022. * @param space The space that the axes of rotation are in
  79023. * @param mesh The mesh that this bone is attached to. This is only used in world space
  79024. */
  79025. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  79026. /**
  79027. * Add a rotation to the bone on an axis in local or world space
  79028. * @param axis The axis to rotate the bone on
  79029. * @param amount The amount to rotate the bone
  79030. * @param space The space that the axis is in
  79031. * @param mesh The mesh that this bone is attached to. This is only used in world space
  79032. */
  79033. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  79034. /**
  79035. * Set the rotation of the bone to a particular axis angle in local or world space
  79036. * @param axis The axis to rotate the bone on
  79037. * @param angle The angle that the bone should be rotated to
  79038. * @param space The space that the axis is in
  79039. * @param mesh The mesh that this bone is attached to. This is only used in world space
  79040. */
  79041. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  79042. /**
  79043. * Set the euler rotation of the bone in local of world space
  79044. * @param rotation The euler rotation that the bone should be set to
  79045. * @param space The space that the rotation is in
  79046. * @param mesh The mesh that this bone is attached to. This is only used in world space
  79047. */
  79048. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  79049. /**
  79050. * Set the quaternion rotation of the bone in local of world space
  79051. * @param quat The quaternion rotation that the bone should be set to
  79052. * @param space The space that the rotation is in
  79053. * @param mesh The mesh that this bone is attached to. This is only used in world space
  79054. */
  79055. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  79056. /**
  79057. * Set the rotation matrix of the bone in local of world space
  79058. * @param rotMat The rotation matrix that the bone should be set to
  79059. * @param space The space that the rotation is in
  79060. * @param mesh The mesh that this bone is attached to. This is only used in world space
  79061. */
  79062. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  79063. private _rotateWithMatrix;
  79064. private _getNegativeRotationToRef;
  79065. /**
  79066. * Get the position of the bone in local or world space
  79067. * @param space The space that the returned position is in
  79068. * @param mesh The mesh that this bone is attached to. This is only used in world space
  79069. * @returns The position of the bone
  79070. */
  79071. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  79072. /**
  79073. * Copy the position of the bone to a vector3 in local or world space
  79074. * @param space The space that the returned position is in
  79075. * @param mesh The mesh that this bone is attached to. This is only used in world space
  79076. * @param result The vector3 to copy the position to
  79077. */
  79078. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  79079. /**
  79080. * Get the absolute position of the bone (world space)
  79081. * @param mesh The mesh that this bone is attached to
  79082. * @returns The absolute position of the bone
  79083. */
  79084. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  79085. /**
  79086. * Copy the absolute position of the bone (world space) to the result param
  79087. * @param mesh The mesh that this bone is attached to
  79088. * @param result The vector3 to copy the absolute position to
  79089. */
  79090. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  79091. /**
  79092. * Compute the absolute transforms of this bone and its children
  79093. */
  79094. computeAbsoluteTransforms(): void;
  79095. /**
  79096. * Get the world direction from an axis that is in the local space of the bone
  79097. * @param localAxis The local direction that is used to compute the world direction
  79098. * @param mesh The mesh that this bone is attached to
  79099. * @returns The world direction
  79100. */
  79101. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  79102. /**
  79103. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  79104. * @param localAxis The local direction that is used to compute the world direction
  79105. * @param mesh The mesh that this bone is attached to
  79106. * @param result The vector3 that the world direction will be copied to
  79107. */
  79108. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  79109. /**
  79110. * Get the euler rotation of the bone in local or world space
  79111. * @param space The space that the rotation should be in
  79112. * @param mesh The mesh that this bone is attached to. This is only used in world space
  79113. * @returns The euler rotation
  79114. */
  79115. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  79116. /**
  79117. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  79118. * @param space The space that the rotation should be in
  79119. * @param mesh The mesh that this bone is attached to. This is only used in world space
  79120. * @param result The vector3 that the rotation should be copied to
  79121. */
  79122. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  79123. /**
  79124. * Get the quaternion rotation of the bone in either local or world space
  79125. * @param space The space that the rotation should be in
  79126. * @param mesh The mesh that this bone is attached to. This is only used in world space
  79127. * @returns The quaternion rotation
  79128. */
  79129. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  79130. /**
  79131. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  79132. * @param space The space that the rotation should be in
  79133. * @param mesh The mesh that this bone is attached to. This is only used in world space
  79134. * @param result The quaternion that the rotation should be copied to
  79135. */
  79136. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  79137. /**
  79138. * Get the rotation matrix of the bone in local or world space
  79139. * @param space The space that the rotation should be in
  79140. * @param mesh The mesh that this bone is attached to. This is only used in world space
  79141. * @returns The rotation matrix
  79142. */
  79143. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  79144. /**
  79145. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  79146. * @param space The space that the rotation should be in
  79147. * @param mesh The mesh that this bone is attached to. This is only used in world space
  79148. * @param result The quaternion that the rotation should be copied to
  79149. */
  79150. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  79151. /**
  79152. * Get the world position of a point that is in the local space of the bone
  79153. * @param position The local position
  79154. * @param mesh The mesh that this bone is attached to
  79155. * @returns The world position
  79156. */
  79157. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  79158. /**
  79159. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  79160. * @param position The local position
  79161. * @param mesh The mesh that this bone is attached to
  79162. * @param result The vector3 that the world position should be copied to
  79163. */
  79164. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  79165. /**
  79166. * Get the local position of a point that is in world space
  79167. * @param position The world position
  79168. * @param mesh The mesh that this bone is attached to
  79169. * @returns The local position
  79170. */
  79171. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  79172. /**
  79173. * Get the local position of a point that is in world space and copy it to the result param
  79174. * @param position The world position
  79175. * @param mesh The mesh that this bone is attached to
  79176. * @param result The vector3 that the local position should be copied to
  79177. */
  79178. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  79179. }
  79180. }
  79181. declare module BABYLON {
  79182. /**
  79183. * 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.
  79184. * @see https://doc.babylonjs.com/how_to/transformnode
  79185. */
  79186. export class TransformNode extends Node {
  79187. /**
  79188. * Object will not rotate to face the camera
  79189. */
  79190. static BILLBOARDMODE_NONE: number;
  79191. /**
  79192. * Object will rotate to face the camera but only on the x axis
  79193. */
  79194. static BILLBOARDMODE_X: number;
  79195. /**
  79196. * Object will rotate to face the camera but only on the y axis
  79197. */
  79198. static BILLBOARDMODE_Y: number;
  79199. /**
  79200. * Object will rotate to face the camera but only on the z axis
  79201. */
  79202. static BILLBOARDMODE_Z: number;
  79203. /**
  79204. * Object will rotate to face the camera
  79205. */
  79206. static BILLBOARDMODE_ALL: number;
  79207. /**
  79208. * Object will rotate to face the camera's position instead of orientation
  79209. */
  79210. static BILLBOARDMODE_USE_POSITION: number;
  79211. private _forward;
  79212. private _forwardInverted;
  79213. private _up;
  79214. private _right;
  79215. private _rightInverted;
  79216. private _position;
  79217. private _rotation;
  79218. private _rotationQuaternion;
  79219. protected _scaling: Vector3;
  79220. protected _isDirty: boolean;
  79221. private _transformToBoneReferal;
  79222. private _isAbsoluteSynced;
  79223. private _billboardMode;
  79224. /**
  79225. * Gets or sets the billboard mode. Default is 0.
  79226. *
  79227. * | Value | Type | Description |
  79228. * | --- | --- | --- |
  79229. * | 0 | BILLBOARDMODE_NONE | |
  79230. * | 1 | BILLBOARDMODE_X | |
  79231. * | 2 | BILLBOARDMODE_Y | |
  79232. * | 4 | BILLBOARDMODE_Z | |
  79233. * | 7 | BILLBOARDMODE_ALL | |
  79234. *
  79235. */
  79236. billboardMode: number;
  79237. private _preserveParentRotationForBillboard;
  79238. /**
  79239. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  79240. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  79241. */
  79242. preserveParentRotationForBillboard: boolean;
  79243. /**
  79244. * 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
  79245. */
  79246. scalingDeterminant: number;
  79247. private _infiniteDistance;
  79248. /**
  79249. * Gets or sets the distance of the object to max, often used by skybox
  79250. */
  79251. infiniteDistance: boolean;
  79252. /**
  79253. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  79254. * By default the system will update normals to compensate
  79255. */
  79256. ignoreNonUniformScaling: boolean;
  79257. /**
  79258. * 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
  79259. */
  79260. reIntegrateRotationIntoRotationQuaternion: boolean;
  79261. /** @hidden */
  79262. _poseMatrix: Nullable<Matrix>;
  79263. /** @hidden */
  79264. _localMatrix: Matrix;
  79265. private _usePivotMatrix;
  79266. private _absolutePosition;
  79267. private _absoluteScaling;
  79268. private _absoluteRotationQuaternion;
  79269. private _pivotMatrix;
  79270. private _pivotMatrixInverse;
  79271. protected _postMultiplyPivotMatrix: boolean;
  79272. protected _isWorldMatrixFrozen: boolean;
  79273. /** @hidden */
  79274. _indexInSceneTransformNodesArray: number;
  79275. /**
  79276. * An event triggered after the world matrix is updated
  79277. */
  79278. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  79279. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  79280. /**
  79281. * Gets a string identifying the name of the class
  79282. * @returns "TransformNode" string
  79283. */
  79284. getClassName(): string;
  79285. /**
  79286. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  79287. */
  79288. position: Vector3;
  79289. /**
  79290. * 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)).
  79291. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  79292. */
  79293. rotation: Vector3;
  79294. /**
  79295. * 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)).
  79296. */
  79297. scaling: Vector3;
  79298. /**
  79299. * 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).
  79300. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  79301. */
  79302. rotationQuaternion: Nullable<Quaternion>;
  79303. /**
  79304. * The forward direction of that transform in world space.
  79305. */
  79306. readonly forward: Vector3;
  79307. /**
  79308. * The up direction of that transform in world space.
  79309. */
  79310. readonly up: Vector3;
  79311. /**
  79312. * The right direction of that transform in world space.
  79313. */
  79314. readonly right: Vector3;
  79315. /**
  79316. * Copies the parameter passed Matrix into the mesh Pose matrix.
  79317. * @param matrix the matrix to copy the pose from
  79318. * @returns this TransformNode.
  79319. */
  79320. updatePoseMatrix(matrix: Matrix): TransformNode;
  79321. /**
  79322. * Returns the mesh Pose matrix.
  79323. * @returns the pose matrix
  79324. */
  79325. getPoseMatrix(): Matrix;
  79326. /** @hidden */
  79327. _isSynchronized(): boolean;
  79328. /** @hidden */
  79329. _initCache(): void;
  79330. /**
  79331. * Flag the transform node as dirty (Forcing it to update everything)
  79332. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  79333. * @returns this transform node
  79334. */
  79335. markAsDirty(property: string): TransformNode;
  79336. /**
  79337. * Returns the current mesh absolute position.
  79338. * Returns a Vector3.
  79339. */
  79340. readonly absolutePosition: Vector3;
  79341. /**
  79342. * Returns the current mesh absolute scaling.
  79343. * Returns a Vector3.
  79344. */
  79345. readonly absoluteScaling: Vector3;
  79346. /**
  79347. * Returns the current mesh absolute rotation.
  79348. * Returns a Quaternion.
  79349. */
  79350. readonly absoluteRotationQuaternion: Quaternion;
  79351. /**
  79352. * Sets a new matrix to apply before all other transformation
  79353. * @param matrix defines the transform matrix
  79354. * @returns the current TransformNode
  79355. */
  79356. setPreTransformMatrix(matrix: Matrix): TransformNode;
  79357. /**
  79358. * Sets a new pivot matrix to the current node
  79359. * @param matrix defines the new pivot matrix to use
  79360. * @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
  79361. * @returns the current TransformNode
  79362. */
  79363. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  79364. /**
  79365. * Returns the mesh pivot matrix.
  79366. * Default : Identity.
  79367. * @returns the matrix
  79368. */
  79369. getPivotMatrix(): Matrix;
  79370. /**
  79371. * Instantiate (when possible) or clone that node with its hierarchy
  79372. * @param newParent defines the new parent to use for the instance (or clone)
  79373. * @returns an instance (or a clone) of the current node with its hiearchy
  79374. */
  79375. instantiateHierarychy(newParent?: Nullable<TransformNode>): Nullable<TransformNode>;
  79376. /**
  79377. * Prevents the World matrix to be computed any longer
  79378. * @param newWorldMatrix defines an optional matrix to use as world matrix
  79379. * @returns the TransformNode.
  79380. */
  79381. freezeWorldMatrix(newWorldMatrix?: Nullable<Matrix>): TransformNode;
  79382. /**
  79383. * Allows back the World matrix computation.
  79384. * @returns the TransformNode.
  79385. */
  79386. unfreezeWorldMatrix(): this;
  79387. /**
  79388. * True if the World matrix has been frozen.
  79389. */
  79390. readonly isWorldMatrixFrozen: boolean;
  79391. /**
  79392. * Retuns the mesh absolute position in the World.
  79393. * @returns a Vector3.
  79394. */
  79395. getAbsolutePosition(): Vector3;
  79396. /**
  79397. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  79398. * @param absolutePosition the absolute position to set
  79399. * @returns the TransformNode.
  79400. */
  79401. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  79402. /**
  79403. * Sets the mesh position in its local space.
  79404. * @param vector3 the position to set in localspace
  79405. * @returns the TransformNode.
  79406. */
  79407. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  79408. /**
  79409. * Returns the mesh position in the local space from the current World matrix values.
  79410. * @returns a new Vector3.
  79411. */
  79412. getPositionExpressedInLocalSpace(): Vector3;
  79413. /**
  79414. * Translates the mesh along the passed Vector3 in its local space.
  79415. * @param vector3 the distance to translate in localspace
  79416. * @returns the TransformNode.
  79417. */
  79418. locallyTranslate(vector3: Vector3): TransformNode;
  79419. private static _lookAtVectorCache;
  79420. /**
  79421. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  79422. * @param targetPoint the position (must be in same space as current mesh) to look at
  79423. * @param yawCor optional yaw (y-axis) correction in radians
  79424. * @param pitchCor optional pitch (x-axis) correction in radians
  79425. * @param rollCor optional roll (z-axis) correction in radians
  79426. * @param space the choosen space of the target
  79427. * @returns the TransformNode.
  79428. */
  79429. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  79430. /**
  79431. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  79432. * This Vector3 is expressed in the World space.
  79433. * @param localAxis axis to rotate
  79434. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  79435. */
  79436. getDirection(localAxis: Vector3): Vector3;
  79437. /**
  79438. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  79439. * localAxis is expressed in the mesh local space.
  79440. * result is computed in the Wordl space from the mesh World matrix.
  79441. * @param localAxis axis to rotate
  79442. * @param result the resulting transformnode
  79443. * @returns this TransformNode.
  79444. */
  79445. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  79446. /**
  79447. * Sets this transform node rotation to the given local axis.
  79448. * @param localAxis the axis in local space
  79449. * @param yawCor optional yaw (y-axis) correction in radians
  79450. * @param pitchCor optional pitch (x-axis) correction in radians
  79451. * @param rollCor optional roll (z-axis) correction in radians
  79452. * @returns this TransformNode
  79453. */
  79454. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  79455. /**
  79456. * Sets a new pivot point to the current node
  79457. * @param point defines the new pivot point to use
  79458. * @param space defines if the point is in world or local space (local by default)
  79459. * @returns the current TransformNode
  79460. */
  79461. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  79462. /**
  79463. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  79464. * @returns the pivot point
  79465. */
  79466. getPivotPoint(): Vector3;
  79467. /**
  79468. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  79469. * @param result the vector3 to store the result
  79470. * @returns this TransformNode.
  79471. */
  79472. getPivotPointToRef(result: Vector3): TransformNode;
  79473. /**
  79474. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  79475. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  79476. */
  79477. getAbsolutePivotPoint(): Vector3;
  79478. /**
  79479. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  79480. * @param result vector3 to store the result
  79481. * @returns this TransformNode.
  79482. */
  79483. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  79484. /**
  79485. * Defines the passed node as the parent of the current node.
  79486. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  79487. * @see https://doc.babylonjs.com/how_to/parenting
  79488. * @param node the node ot set as the parent
  79489. * @returns this TransformNode.
  79490. */
  79491. setParent(node: Nullable<Node>): TransformNode;
  79492. private _nonUniformScaling;
  79493. /**
  79494. * True if the scaling property of this object is non uniform eg. (1,2,1)
  79495. */
  79496. readonly nonUniformScaling: boolean;
  79497. /** @hidden */
  79498. _updateNonUniformScalingState(value: boolean): boolean;
  79499. /**
  79500. * Attach the current TransformNode to another TransformNode associated with a bone
  79501. * @param bone Bone affecting the TransformNode
  79502. * @param affectedTransformNode TransformNode associated with the bone
  79503. * @returns this object
  79504. */
  79505. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  79506. /**
  79507. * Detach the transform node if its associated with a bone
  79508. * @returns this object
  79509. */
  79510. detachFromBone(): TransformNode;
  79511. private static _rotationAxisCache;
  79512. /**
  79513. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  79514. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  79515. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  79516. * The passed axis is also normalized.
  79517. * @param axis the axis to rotate around
  79518. * @param amount the amount to rotate in radians
  79519. * @param space Space to rotate in (Default: local)
  79520. * @returns the TransformNode.
  79521. */
  79522. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  79523. /**
  79524. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  79525. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  79526. * The passed axis is also normalized. .
  79527. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  79528. * @param point the point to rotate around
  79529. * @param axis the axis to rotate around
  79530. * @param amount the amount to rotate in radians
  79531. * @returns the TransformNode
  79532. */
  79533. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  79534. /**
  79535. * Translates the mesh along the axis vector for the passed distance in the given space.
  79536. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  79537. * @param axis the axis to translate in
  79538. * @param distance the distance to translate
  79539. * @param space Space to rotate in (Default: local)
  79540. * @returns the TransformNode.
  79541. */
  79542. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  79543. /**
  79544. * Adds a rotation step to the mesh current rotation.
  79545. * x, y, z are Euler angles expressed in radians.
  79546. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  79547. * This means this rotation is made in the mesh local space only.
  79548. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  79549. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  79550. * ```javascript
  79551. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  79552. * ```
  79553. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  79554. * 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.
  79555. * @param x Rotation to add
  79556. * @param y Rotation to add
  79557. * @param z Rotation to add
  79558. * @returns the TransformNode.
  79559. */
  79560. addRotation(x: number, y: number, z: number): TransformNode;
  79561. /**
  79562. * @hidden
  79563. */
  79564. protected _getEffectiveParent(): Nullable<Node>;
  79565. /**
  79566. * Computes the world matrix of the node
  79567. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  79568. * @returns the world matrix
  79569. */
  79570. computeWorldMatrix(force?: boolean): Matrix;
  79571. protected _afterComputeWorldMatrix(): void;
  79572. /**
  79573. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  79574. * @param func callback function to add
  79575. *
  79576. * @returns the TransformNode.
  79577. */
  79578. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  79579. /**
  79580. * Removes a registered callback function.
  79581. * @param func callback function to remove
  79582. * @returns the TransformNode.
  79583. */
  79584. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  79585. /**
  79586. * Gets the position of the current mesh in camera space
  79587. * @param camera defines the camera to use
  79588. * @returns a position
  79589. */
  79590. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  79591. /**
  79592. * Returns the distance from the mesh to the active camera
  79593. * @param camera defines the camera to use
  79594. * @returns the distance
  79595. */
  79596. getDistanceToCamera(camera?: Nullable<Camera>): number;
  79597. /**
  79598. * Clone the current transform node
  79599. * @param name Name of the new clone
  79600. * @param newParent New parent for the clone
  79601. * @param doNotCloneChildren Do not clone children hierarchy
  79602. * @returns the new transform node
  79603. */
  79604. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  79605. /**
  79606. * Serializes the objects information.
  79607. * @param currentSerializationObject defines the object to serialize in
  79608. * @returns the serialized object
  79609. */
  79610. serialize(currentSerializationObject?: any): any;
  79611. /**
  79612. * Returns a new TransformNode object parsed from the source provided.
  79613. * @param parsedTransformNode is the source.
  79614. * @param scene the scne the object belongs to
  79615. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  79616. * @returns a new TransformNode object parsed from the source provided.
  79617. */
  79618. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  79619. /**
  79620. * Get all child-transformNodes of this node
  79621. * @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
  79622. * @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
  79623. * @returns an array of TransformNode
  79624. */
  79625. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  79626. /**
  79627. * Releases resources associated with this transform node.
  79628. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  79629. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  79630. */
  79631. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  79632. /**
  79633. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  79634. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  79635. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  79636. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  79637. * @returns the current mesh
  79638. */
  79639. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  79640. private _syncAbsoluteScalingAndRotation;
  79641. }
  79642. }
  79643. declare module BABYLON {
  79644. /**
  79645. * Defines the types of pose enabled controllers that are supported
  79646. */
  79647. export enum PoseEnabledControllerType {
  79648. /**
  79649. * HTC Vive
  79650. */
  79651. VIVE = 0,
  79652. /**
  79653. * Oculus Rift
  79654. */
  79655. OCULUS = 1,
  79656. /**
  79657. * Windows mixed reality
  79658. */
  79659. WINDOWS = 2,
  79660. /**
  79661. * Samsung gear VR
  79662. */
  79663. GEAR_VR = 3,
  79664. /**
  79665. * Google Daydream
  79666. */
  79667. DAYDREAM = 4,
  79668. /**
  79669. * Generic
  79670. */
  79671. GENERIC = 5
  79672. }
  79673. /**
  79674. * Defines the MutableGamepadButton interface for the state of a gamepad button
  79675. */
  79676. export interface MutableGamepadButton {
  79677. /**
  79678. * Value of the button/trigger
  79679. */
  79680. value: number;
  79681. /**
  79682. * If the button/trigger is currently touched
  79683. */
  79684. touched: boolean;
  79685. /**
  79686. * If the button/trigger is currently pressed
  79687. */
  79688. pressed: boolean;
  79689. }
  79690. /**
  79691. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  79692. * @hidden
  79693. */
  79694. export interface ExtendedGamepadButton extends GamepadButton {
  79695. /**
  79696. * If the button/trigger is currently pressed
  79697. */
  79698. readonly pressed: boolean;
  79699. /**
  79700. * If the button/trigger is currently touched
  79701. */
  79702. readonly touched: boolean;
  79703. /**
  79704. * Value of the button/trigger
  79705. */
  79706. readonly value: number;
  79707. }
  79708. /** @hidden */
  79709. export interface _GamePadFactory {
  79710. /**
  79711. * Returns wether or not the current gamepad can be created for this type of controller.
  79712. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  79713. * @returns true if it can be created, otherwise false
  79714. */
  79715. canCreate(gamepadInfo: any): boolean;
  79716. /**
  79717. * Creates a new instance of the Gamepad.
  79718. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  79719. * @returns the new gamepad instance
  79720. */
  79721. create(gamepadInfo: any): Gamepad;
  79722. }
  79723. /**
  79724. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  79725. */
  79726. export class PoseEnabledControllerHelper {
  79727. /** @hidden */
  79728. static _ControllerFactories: _GamePadFactory[];
  79729. /** @hidden */
  79730. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  79731. /**
  79732. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  79733. * @param vrGamepad the gamepad to initialized
  79734. * @returns a vr controller of the type the gamepad identified as
  79735. */
  79736. static InitiateController(vrGamepad: any): Gamepad;
  79737. }
  79738. /**
  79739. * Defines the PoseEnabledController object that contains state of a vr capable controller
  79740. */
  79741. export class PoseEnabledController extends Gamepad implements PoseControlled {
  79742. /**
  79743. * If the controller is used in a webXR session
  79744. */
  79745. isXR: boolean;
  79746. private _deviceRoomPosition;
  79747. private _deviceRoomRotationQuaternion;
  79748. /**
  79749. * The device position in babylon space
  79750. */
  79751. devicePosition: Vector3;
  79752. /**
  79753. * The device rotation in babylon space
  79754. */
  79755. deviceRotationQuaternion: Quaternion;
  79756. /**
  79757. * The scale factor of the device in babylon space
  79758. */
  79759. deviceScaleFactor: number;
  79760. /**
  79761. * (Likely devicePosition should be used instead) The device position in its room space
  79762. */
  79763. position: Vector3;
  79764. /**
  79765. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  79766. */
  79767. rotationQuaternion: Quaternion;
  79768. /**
  79769. * The type of controller (Eg. Windows mixed reality)
  79770. */
  79771. controllerType: PoseEnabledControllerType;
  79772. protected _calculatedPosition: Vector3;
  79773. private _calculatedRotation;
  79774. /**
  79775. * The raw pose from the device
  79776. */
  79777. rawPose: DevicePose;
  79778. private _trackPosition;
  79779. private _maxRotationDistFromHeadset;
  79780. private _draggedRoomRotation;
  79781. /**
  79782. * @hidden
  79783. */
  79784. _disableTrackPosition(fixedPosition: Vector3): void;
  79785. /**
  79786. * Internal, the mesh attached to the controller
  79787. * @hidden
  79788. */
  79789. _mesh: Nullable<AbstractMesh>;
  79790. private _poseControlledCamera;
  79791. private _leftHandSystemQuaternion;
  79792. /**
  79793. * Internal, matrix used to convert room space to babylon space
  79794. * @hidden
  79795. */
  79796. _deviceToWorld: Matrix;
  79797. /**
  79798. * Node to be used when casting a ray from the controller
  79799. * @hidden
  79800. */
  79801. _pointingPoseNode: Nullable<TransformNode>;
  79802. /**
  79803. * Name of the child mesh that can be used to cast a ray from the controller
  79804. */
  79805. static readonly POINTING_POSE: string;
  79806. /**
  79807. * Creates a new PoseEnabledController from a gamepad
  79808. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  79809. */
  79810. constructor(browserGamepad: any);
  79811. private _workingMatrix;
  79812. /**
  79813. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  79814. */
  79815. update(): void;
  79816. /**
  79817. * Updates only the pose device and mesh without doing any button event checking
  79818. */
  79819. protected _updatePoseAndMesh(): void;
  79820. /**
  79821. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  79822. * @param poseData raw pose fromthe device
  79823. */
  79824. updateFromDevice(poseData: DevicePose): void;
  79825. /**
  79826. * @hidden
  79827. */
  79828. _meshAttachedObservable: Observable<AbstractMesh>;
  79829. /**
  79830. * Attaches a mesh to the controller
  79831. * @param mesh the mesh to be attached
  79832. */
  79833. attachToMesh(mesh: AbstractMesh): void;
  79834. /**
  79835. * Attaches the controllers mesh to a camera
  79836. * @param camera the camera the mesh should be attached to
  79837. */
  79838. attachToPoseControlledCamera(camera: TargetCamera): void;
  79839. /**
  79840. * Disposes of the controller
  79841. */
  79842. dispose(): void;
  79843. /**
  79844. * The mesh that is attached to the controller
  79845. */
  79846. readonly mesh: Nullable<AbstractMesh>;
  79847. /**
  79848. * Gets the ray of the controller in the direction the controller is pointing
  79849. * @param length the length the resulting ray should be
  79850. * @returns a ray in the direction the controller is pointing
  79851. */
  79852. getForwardRay(length?: number): Ray;
  79853. }
  79854. }
  79855. declare module BABYLON {
  79856. /**
  79857. * Defines the WebVRController object that represents controllers tracked in 3D space
  79858. */
  79859. export abstract class WebVRController extends PoseEnabledController {
  79860. /**
  79861. * Internal, the default controller model for the controller
  79862. */
  79863. protected _defaultModel: AbstractMesh;
  79864. /**
  79865. * Fired when the trigger state has changed
  79866. */
  79867. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  79868. /**
  79869. * Fired when the main button state has changed
  79870. */
  79871. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  79872. /**
  79873. * Fired when the secondary button state has changed
  79874. */
  79875. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  79876. /**
  79877. * Fired when the pad state has changed
  79878. */
  79879. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  79880. /**
  79881. * Fired when controllers stick values have changed
  79882. */
  79883. onPadValuesChangedObservable: Observable<StickValues>;
  79884. /**
  79885. * Array of button availible on the controller
  79886. */
  79887. protected _buttons: Array<MutableGamepadButton>;
  79888. private _onButtonStateChange;
  79889. /**
  79890. * Fired when a controller button's state has changed
  79891. * @param callback the callback containing the button that was modified
  79892. */
  79893. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  79894. /**
  79895. * X and Y axis corresponding to the controllers joystick
  79896. */
  79897. pad: StickValues;
  79898. /**
  79899. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  79900. */
  79901. hand: string;
  79902. /**
  79903. * The default controller model for the controller
  79904. */
  79905. readonly defaultModel: AbstractMesh;
  79906. /**
  79907. * Creates a new WebVRController from a gamepad
  79908. * @param vrGamepad the gamepad that the WebVRController should be created from
  79909. */
  79910. constructor(vrGamepad: any);
  79911. /**
  79912. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  79913. */
  79914. update(): void;
  79915. /**
  79916. * Function to be called when a button is modified
  79917. */
  79918. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  79919. /**
  79920. * Loads a mesh and attaches it to the controller
  79921. * @param scene the scene the mesh should be added to
  79922. * @param meshLoaded callback for when the mesh has been loaded
  79923. */
  79924. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  79925. private _setButtonValue;
  79926. private _changes;
  79927. private _checkChanges;
  79928. /**
  79929. * Disposes of th webVRCOntroller
  79930. */
  79931. dispose(): void;
  79932. }
  79933. }
  79934. declare module BABYLON {
  79935. /**
  79936. * The HemisphericLight simulates the ambient environment light,
  79937. * so the passed direction is the light reflection direction, not the incoming direction.
  79938. */
  79939. export class HemisphericLight extends Light {
  79940. /**
  79941. * The groundColor is the light in the opposite direction to the one specified during creation.
  79942. * 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.
  79943. */
  79944. groundColor: Color3;
  79945. /**
  79946. * The light reflection direction, not the incoming direction.
  79947. */
  79948. direction: Vector3;
  79949. /**
  79950. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  79951. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  79952. * The HemisphericLight can't cast shadows.
  79953. * Documentation : https://doc.babylonjs.com/babylon101/lights
  79954. * @param name The friendly name of the light
  79955. * @param direction The direction of the light reflection
  79956. * @param scene The scene the light belongs to
  79957. */
  79958. constructor(name: string, direction: Vector3, scene: Scene);
  79959. protected _buildUniformLayout(): void;
  79960. /**
  79961. * Returns the string "HemisphericLight".
  79962. * @return The class name
  79963. */
  79964. getClassName(): string;
  79965. /**
  79966. * Sets the HemisphericLight direction towards the passed target (Vector3).
  79967. * Returns the updated direction.
  79968. * @param target The target the direction should point to
  79969. * @return The computed direction
  79970. */
  79971. setDirectionToTarget(target: Vector3): Vector3;
  79972. /**
  79973. * Returns the shadow generator associated to the light.
  79974. * @returns Always null for hemispheric lights because it does not support shadows.
  79975. */
  79976. getShadowGenerator(): Nullable<IShadowGenerator>;
  79977. /**
  79978. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  79979. * @param effect The effect to update
  79980. * @param lightIndex The index of the light in the effect to update
  79981. * @returns The hemispheric light
  79982. */
  79983. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  79984. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  79985. /**
  79986. * Computes the world matrix of the node
  79987. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  79988. * @param useWasUpdatedFlag defines a reserved property
  79989. * @returns the world matrix
  79990. */
  79991. computeWorldMatrix(): Matrix;
  79992. /**
  79993. * Returns the integer 3.
  79994. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  79995. */
  79996. getTypeID(): number;
  79997. /**
  79998. * Prepares the list of defines specific to the light type.
  79999. * @param defines the list of defines
  80000. * @param lightIndex defines the index of the light for the effect
  80001. */
  80002. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  80003. }
  80004. }
  80005. declare module BABYLON {
  80006. /** @hidden */
  80007. export var vrMultiviewToSingleviewPixelShader: {
  80008. name: string;
  80009. shader: string;
  80010. };
  80011. }
  80012. declare module BABYLON {
  80013. /**
  80014. * Renders to multiple views with a single draw call
  80015. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  80016. */
  80017. export class MultiviewRenderTarget extends RenderTargetTexture {
  80018. /**
  80019. * Creates a multiview render target
  80020. * @param scene scene used with the render target
  80021. * @param size the size of the render target (used for each view)
  80022. */
  80023. constructor(scene: Scene, size?: number | {
  80024. width: number;
  80025. height: number;
  80026. } | {
  80027. ratio: number;
  80028. });
  80029. /**
  80030. * @hidden
  80031. * @param faceIndex the face index, if its a cube texture
  80032. */
  80033. _bindFrameBuffer(faceIndex?: number): void;
  80034. /**
  80035. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  80036. * @returns the view count
  80037. */
  80038. getViewCount(): number;
  80039. }
  80040. }
  80041. declare module BABYLON {
  80042. /**
  80043. * Reprasents a camera frustum
  80044. */
  80045. export class Frustum {
  80046. /**
  80047. * Gets the planes representing the frustum
  80048. * @param transform matrix to be applied to the returned planes
  80049. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  80050. */
  80051. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  80052. /**
  80053. * Gets the near frustum plane transformed by the transform matrix
  80054. * @param transform transformation matrix to be applied to the resulting frustum plane
  80055. * @param frustumPlane the resuling frustum plane
  80056. */
  80057. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  80058. /**
  80059. * Gets the far frustum plane transformed by the transform matrix
  80060. * @param transform transformation matrix to be applied to the resulting frustum plane
  80061. * @param frustumPlane the resuling frustum plane
  80062. */
  80063. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  80064. /**
  80065. * Gets the left frustum plane transformed by the transform matrix
  80066. * @param transform transformation matrix to be applied to the resulting frustum plane
  80067. * @param frustumPlane the resuling frustum plane
  80068. */
  80069. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  80070. /**
  80071. * Gets the right frustum plane transformed by the transform matrix
  80072. * @param transform transformation matrix to be applied to the resulting frustum plane
  80073. * @param frustumPlane the resuling frustum plane
  80074. */
  80075. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  80076. /**
  80077. * Gets the top frustum plane transformed by the transform matrix
  80078. * @param transform transformation matrix to be applied to the resulting frustum plane
  80079. * @param frustumPlane the resuling frustum plane
  80080. */
  80081. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  80082. /**
  80083. * Gets the bottom frustum plane transformed by the transform matrix
  80084. * @param transform transformation matrix to be applied to the resulting frustum plane
  80085. * @param frustumPlane the resuling frustum plane
  80086. */
  80087. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  80088. /**
  80089. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  80090. * @param transform transformation matrix to be applied to the resulting frustum planes
  80091. * @param frustumPlanes the resuling frustum planes
  80092. */
  80093. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  80094. }
  80095. }
  80096. declare module BABYLON {
  80097. interface Engine {
  80098. /**
  80099. * Creates a new multiview render target
  80100. * @param width defines the width of the texture
  80101. * @param height defines the height of the texture
  80102. * @returns the created multiview texture
  80103. */
  80104. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  80105. /**
  80106. * Binds a multiview framebuffer to be drawn to
  80107. * @param multiviewTexture texture to bind
  80108. */
  80109. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  80110. }
  80111. interface Camera {
  80112. /**
  80113. * @hidden
  80114. * 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)
  80115. */
  80116. _useMultiviewToSingleView: boolean;
  80117. /**
  80118. * @hidden
  80119. * 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)
  80120. */
  80121. _multiviewTexture: Nullable<RenderTargetTexture>;
  80122. /**
  80123. * @hidden
  80124. * ensures the multiview texture of the camera exists and has the specified width/height
  80125. * @param width height to set on the multiview texture
  80126. * @param height width to set on the multiview texture
  80127. */
  80128. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  80129. }
  80130. interface Scene {
  80131. /** @hidden */
  80132. _transformMatrixR: Matrix;
  80133. /** @hidden */
  80134. _multiviewSceneUbo: Nullable<UniformBuffer>;
  80135. /** @hidden */
  80136. _createMultiviewUbo(): void;
  80137. /** @hidden */
  80138. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  80139. /** @hidden */
  80140. _renderMultiviewToSingleView(camera: Camera): void;
  80141. }
  80142. }
  80143. declare module BABYLON {
  80144. /**
  80145. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  80146. * This will not be used for webXR as it supports displaying texture arrays directly
  80147. */
  80148. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  80149. /**
  80150. * Initializes a VRMultiviewToSingleview
  80151. * @param name name of the post process
  80152. * @param camera camera to be applied to
  80153. * @param scaleFactor scaling factor to the size of the output texture
  80154. */
  80155. constructor(name: string, camera: Camera, scaleFactor: number);
  80156. }
  80157. }
  80158. declare module BABYLON {
  80159. interface Engine {
  80160. /** @hidden */
  80161. _vrDisplay: any;
  80162. /** @hidden */
  80163. _vrSupported: boolean;
  80164. /** @hidden */
  80165. _oldSize: Size;
  80166. /** @hidden */
  80167. _oldHardwareScaleFactor: number;
  80168. /** @hidden */
  80169. _vrExclusivePointerMode: boolean;
  80170. /** @hidden */
  80171. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  80172. /** @hidden */
  80173. _onVRDisplayPointerRestricted: () => void;
  80174. /** @hidden */
  80175. _onVRDisplayPointerUnrestricted: () => void;
  80176. /** @hidden */
  80177. _onVrDisplayConnect: Nullable<(display: any) => void>;
  80178. /** @hidden */
  80179. _onVrDisplayDisconnect: Nullable<() => void>;
  80180. /** @hidden */
  80181. _onVrDisplayPresentChange: Nullable<() => void>;
  80182. /**
  80183. * Observable signaled when VR display mode changes
  80184. */
  80185. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  80186. /**
  80187. * Observable signaled when VR request present is complete
  80188. */
  80189. onVRRequestPresentComplete: Observable<boolean>;
  80190. /**
  80191. * Observable signaled when VR request present starts
  80192. */
  80193. onVRRequestPresentStart: Observable<Engine>;
  80194. /**
  80195. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  80196. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  80197. */
  80198. isInVRExclusivePointerMode: boolean;
  80199. /**
  80200. * Gets a boolean indicating if a webVR device was detected
  80201. * @returns true if a webVR device was detected
  80202. */
  80203. isVRDevicePresent(): boolean;
  80204. /**
  80205. * Gets the current webVR device
  80206. * @returns the current webVR device (or null)
  80207. */
  80208. getVRDevice(): any;
  80209. /**
  80210. * Initializes a webVR display and starts listening to display change events
  80211. * The onVRDisplayChangedObservable will be notified upon these changes
  80212. * @returns A promise containing a VRDisplay and if vr is supported
  80213. */
  80214. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  80215. /** @hidden */
  80216. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  80217. /**
  80218. * Call this function to switch to webVR mode
  80219. * Will do nothing if webVR is not supported or if there is no webVR device
  80220. * @see http://doc.babylonjs.com/how_to/webvr_camera
  80221. */
  80222. enableVR(): void;
  80223. /** @hidden */
  80224. _onVRFullScreenTriggered(): void;
  80225. }
  80226. }
  80227. declare module BABYLON {
  80228. /**
  80229. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  80230. * IMPORTANT!! The data is right-hand data.
  80231. * @export
  80232. * @interface DevicePose
  80233. */
  80234. export interface DevicePose {
  80235. /**
  80236. * The position of the device, values in array are [x,y,z].
  80237. */
  80238. readonly position: Nullable<Float32Array>;
  80239. /**
  80240. * The linearVelocity of the device, values in array are [x,y,z].
  80241. */
  80242. readonly linearVelocity: Nullable<Float32Array>;
  80243. /**
  80244. * The linearAcceleration of the device, values in array are [x,y,z].
  80245. */
  80246. readonly linearAcceleration: Nullable<Float32Array>;
  80247. /**
  80248. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  80249. */
  80250. readonly orientation: Nullable<Float32Array>;
  80251. /**
  80252. * The angularVelocity of the device, values in array are [x,y,z].
  80253. */
  80254. readonly angularVelocity: Nullable<Float32Array>;
  80255. /**
  80256. * The angularAcceleration of the device, values in array are [x,y,z].
  80257. */
  80258. readonly angularAcceleration: Nullable<Float32Array>;
  80259. }
  80260. /**
  80261. * Interface representing a pose controlled object in Babylon.
  80262. * A pose controlled object has both regular pose values as well as pose values
  80263. * from an external device such as a VR head mounted display
  80264. */
  80265. export interface PoseControlled {
  80266. /**
  80267. * The position of the object in babylon space.
  80268. */
  80269. position: Vector3;
  80270. /**
  80271. * The rotation quaternion of the object in babylon space.
  80272. */
  80273. rotationQuaternion: Quaternion;
  80274. /**
  80275. * The position of the device in babylon space.
  80276. */
  80277. devicePosition?: Vector3;
  80278. /**
  80279. * The rotation quaternion of the device in babylon space.
  80280. */
  80281. deviceRotationQuaternion: Quaternion;
  80282. /**
  80283. * The raw pose coming from the device.
  80284. */
  80285. rawPose: Nullable<DevicePose>;
  80286. /**
  80287. * The scale of the device to be used when translating from device space to babylon space.
  80288. */
  80289. deviceScaleFactor: number;
  80290. /**
  80291. * Updates the poseControlled values based on the input device pose.
  80292. * @param poseData the pose data to update the object with
  80293. */
  80294. updateFromDevice(poseData: DevicePose): void;
  80295. }
  80296. /**
  80297. * Set of options to customize the webVRCamera
  80298. */
  80299. export interface WebVROptions {
  80300. /**
  80301. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  80302. */
  80303. trackPosition?: boolean;
  80304. /**
  80305. * Sets the scale of the vrDevice in babylon space. (default: 1)
  80306. */
  80307. positionScale?: number;
  80308. /**
  80309. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  80310. */
  80311. displayName?: string;
  80312. /**
  80313. * Should the native controller meshes be initialized. (default: true)
  80314. */
  80315. controllerMeshes?: boolean;
  80316. /**
  80317. * Creating a default HemiLight only on controllers. (default: true)
  80318. */
  80319. defaultLightingOnControllers?: boolean;
  80320. /**
  80321. * If you don't want to use the default VR button of the helper. (default: false)
  80322. */
  80323. useCustomVRButton?: boolean;
  80324. /**
  80325. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  80326. */
  80327. customVRButton?: HTMLButtonElement;
  80328. /**
  80329. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  80330. */
  80331. rayLength?: number;
  80332. /**
  80333. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  80334. */
  80335. defaultHeight?: number;
  80336. /**
  80337. * If multiview should be used if availible (default: false)
  80338. */
  80339. useMultiview?: boolean;
  80340. }
  80341. /**
  80342. * This represents a WebVR camera.
  80343. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  80344. * @example http://doc.babylonjs.com/how_to/webvr_camera
  80345. */
  80346. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  80347. private webVROptions;
  80348. /**
  80349. * @hidden
  80350. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  80351. */
  80352. _vrDevice: any;
  80353. /**
  80354. * The rawPose of the vrDevice.
  80355. */
  80356. rawPose: Nullable<DevicePose>;
  80357. private _onVREnabled;
  80358. private _specsVersion;
  80359. private _attached;
  80360. private _frameData;
  80361. protected _descendants: Array<Node>;
  80362. private _deviceRoomPosition;
  80363. /** @hidden */
  80364. _deviceRoomRotationQuaternion: Quaternion;
  80365. private _standingMatrix;
  80366. /**
  80367. * Represents device position in babylon space.
  80368. */
  80369. devicePosition: Vector3;
  80370. /**
  80371. * Represents device rotation in babylon space.
  80372. */
  80373. deviceRotationQuaternion: Quaternion;
  80374. /**
  80375. * The scale of the device to be used when translating from device space to babylon space.
  80376. */
  80377. deviceScaleFactor: number;
  80378. private _deviceToWorld;
  80379. private _worldToDevice;
  80380. /**
  80381. * References to the webVR controllers for the vrDevice.
  80382. */
  80383. controllers: Array<WebVRController>;
  80384. /**
  80385. * Emits an event when a controller is attached.
  80386. */
  80387. onControllersAttachedObservable: Observable<WebVRController[]>;
  80388. /**
  80389. * Emits an event when a controller's mesh has been loaded;
  80390. */
  80391. onControllerMeshLoadedObservable: Observable<WebVRController>;
  80392. /**
  80393. * Emits an event when the HMD's pose has been updated.
  80394. */
  80395. onPoseUpdatedFromDeviceObservable: Observable<any>;
  80396. private _poseSet;
  80397. /**
  80398. * If the rig cameras be used as parent instead of this camera.
  80399. */
  80400. rigParenting: boolean;
  80401. private _lightOnControllers;
  80402. private _defaultHeight?;
  80403. /**
  80404. * Instantiates a WebVRFreeCamera.
  80405. * @param name The name of the WebVRFreeCamera
  80406. * @param position The starting anchor position for the camera
  80407. * @param scene The scene the camera belongs to
  80408. * @param webVROptions a set of customizable options for the webVRCamera
  80409. */
  80410. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  80411. /**
  80412. * Gets the device distance from the ground in meters.
  80413. * @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.
  80414. */
  80415. deviceDistanceToRoomGround(): number;
  80416. /**
  80417. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  80418. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  80419. */
  80420. useStandingMatrix(callback?: (bool: boolean) => void): void;
  80421. /**
  80422. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  80423. * @returns A promise with a boolean set to if the standing matrix is supported.
  80424. */
  80425. useStandingMatrixAsync(): Promise<boolean>;
  80426. /**
  80427. * Disposes the camera
  80428. */
  80429. dispose(): void;
  80430. /**
  80431. * Gets a vrController by name.
  80432. * @param name The name of the controller to retreive
  80433. * @returns the controller matching the name specified or null if not found
  80434. */
  80435. getControllerByName(name: string): Nullable<WebVRController>;
  80436. private _leftController;
  80437. /**
  80438. * The controller corresponding to the users left hand.
  80439. */
  80440. readonly leftController: Nullable<WebVRController>;
  80441. private _rightController;
  80442. /**
  80443. * The controller corresponding to the users right hand.
  80444. */
  80445. readonly rightController: Nullable<WebVRController>;
  80446. /**
  80447. * Casts a ray forward from the vrCamera's gaze.
  80448. * @param length Length of the ray (default: 100)
  80449. * @returns the ray corresponding to the gaze
  80450. */
  80451. getForwardRay(length?: number): Ray;
  80452. /**
  80453. * @hidden
  80454. * Updates the camera based on device's frame data
  80455. */
  80456. _checkInputs(): void;
  80457. /**
  80458. * Updates the poseControlled values based on the input device pose.
  80459. * @param poseData Pose coming from the device
  80460. */
  80461. updateFromDevice(poseData: DevicePose): void;
  80462. private _htmlElementAttached;
  80463. private _detachIfAttached;
  80464. /**
  80465. * WebVR's attach control will start broadcasting frames to the device.
  80466. * Note that in certain browsers (chrome for example) this function must be called
  80467. * within a user-interaction callback. Example:
  80468. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  80469. *
  80470. * @param element html element to attach the vrDevice to
  80471. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  80472. */
  80473. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  80474. /**
  80475. * Detaches the camera from the html element and disables VR
  80476. *
  80477. * @param element html element to detach from
  80478. */
  80479. detachControl(element: HTMLElement): void;
  80480. /**
  80481. * @returns the name of this class
  80482. */
  80483. getClassName(): string;
  80484. /**
  80485. * Calls resetPose on the vrDisplay
  80486. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  80487. */
  80488. resetToCurrentRotation(): void;
  80489. /**
  80490. * @hidden
  80491. * Updates the rig cameras (left and right eye)
  80492. */
  80493. _updateRigCameras(): void;
  80494. private _workingVector;
  80495. private _oneVector;
  80496. private _workingMatrix;
  80497. private updateCacheCalled;
  80498. private _correctPositionIfNotTrackPosition;
  80499. /**
  80500. * @hidden
  80501. * Updates the cached values of the camera
  80502. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  80503. */
  80504. _updateCache(ignoreParentClass?: boolean): void;
  80505. /**
  80506. * @hidden
  80507. * Get current device position in babylon world
  80508. */
  80509. _computeDevicePosition(): void;
  80510. /**
  80511. * Updates the current device position and rotation in the babylon world
  80512. */
  80513. update(): void;
  80514. /**
  80515. * @hidden
  80516. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  80517. * @returns an identity matrix
  80518. */
  80519. _getViewMatrix(): Matrix;
  80520. private _tmpMatrix;
  80521. /**
  80522. * This function is called by the two RIG cameras.
  80523. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  80524. * @hidden
  80525. */
  80526. _getWebVRViewMatrix(): Matrix;
  80527. /** @hidden */
  80528. _getWebVRProjectionMatrix(): Matrix;
  80529. private _onGamepadConnectedObserver;
  80530. private _onGamepadDisconnectedObserver;
  80531. private _updateCacheWhenTrackingDisabledObserver;
  80532. /**
  80533. * Initializes the controllers and their meshes
  80534. */
  80535. initControllers(): void;
  80536. }
  80537. }
  80538. declare module BABYLON {
  80539. /**
  80540. * Size options for a post process
  80541. */
  80542. export type PostProcessOptions = {
  80543. width: number;
  80544. height: number;
  80545. };
  80546. /**
  80547. * PostProcess can be used to apply a shader to a texture after it has been rendered
  80548. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  80549. */
  80550. export class PostProcess {
  80551. /** Name of the PostProcess. */
  80552. name: string;
  80553. /**
  80554. * Gets or sets the unique id of the post process
  80555. */
  80556. uniqueId: number;
  80557. /**
  80558. * Width of the texture to apply the post process on
  80559. */
  80560. width: number;
  80561. /**
  80562. * Height of the texture to apply the post process on
  80563. */
  80564. height: number;
  80565. /**
  80566. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  80567. * @hidden
  80568. */
  80569. _outputTexture: Nullable<InternalTexture>;
  80570. /**
  80571. * Sampling mode used by the shader
  80572. * See https://doc.babylonjs.com/classes/3.1/texture
  80573. */
  80574. renderTargetSamplingMode: number;
  80575. /**
  80576. * Clear color to use when screen clearing
  80577. */
  80578. clearColor: Color4;
  80579. /**
  80580. * If the buffer needs to be cleared before applying the post process. (default: true)
  80581. * Should be set to false if shader will overwrite all previous pixels.
  80582. */
  80583. autoClear: boolean;
  80584. /**
  80585. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  80586. */
  80587. alphaMode: number;
  80588. /**
  80589. * Sets the setAlphaBlendConstants of the babylon engine
  80590. */
  80591. alphaConstants: Color4;
  80592. /**
  80593. * Animations to be used for the post processing
  80594. */
  80595. animations: Animation[];
  80596. /**
  80597. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  80598. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  80599. */
  80600. enablePixelPerfectMode: boolean;
  80601. /**
  80602. * Force the postprocess to be applied without taking in account viewport
  80603. */
  80604. forceFullscreenViewport: boolean;
  80605. /**
  80606. * List of inspectable custom properties (used by the Inspector)
  80607. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  80608. */
  80609. inspectableCustomProperties: IInspectable[];
  80610. /**
  80611. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  80612. *
  80613. * | Value | Type | Description |
  80614. * | ----- | ----------------------------------- | ----------- |
  80615. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  80616. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  80617. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  80618. *
  80619. */
  80620. scaleMode: number;
  80621. /**
  80622. * Force textures to be a power of two (default: false)
  80623. */
  80624. alwaysForcePOT: boolean;
  80625. private _samples;
  80626. /**
  80627. * Number of sample textures (default: 1)
  80628. */
  80629. samples: number;
  80630. /**
  80631. * Modify the scale of the post process to be the same as the viewport (default: false)
  80632. */
  80633. adaptScaleToCurrentViewport: boolean;
  80634. private _camera;
  80635. private _scene;
  80636. private _engine;
  80637. private _options;
  80638. private _reusable;
  80639. private _textureType;
  80640. /**
  80641. * Smart array of input and output textures for the post process.
  80642. * @hidden
  80643. */
  80644. _textures: SmartArray<InternalTexture>;
  80645. /**
  80646. * The index in _textures that corresponds to the output texture.
  80647. * @hidden
  80648. */
  80649. _currentRenderTextureInd: number;
  80650. private _effect;
  80651. private _samplers;
  80652. private _fragmentUrl;
  80653. private _vertexUrl;
  80654. private _parameters;
  80655. private _scaleRatio;
  80656. protected _indexParameters: any;
  80657. private _shareOutputWithPostProcess;
  80658. private _texelSize;
  80659. private _forcedOutputTexture;
  80660. /**
  80661. * Returns the fragment url or shader name used in the post process.
  80662. * @returns the fragment url or name in the shader store.
  80663. */
  80664. getEffectName(): string;
  80665. /**
  80666. * An event triggered when the postprocess is activated.
  80667. */
  80668. onActivateObservable: Observable<Camera>;
  80669. private _onActivateObserver;
  80670. /**
  80671. * A function that is added to the onActivateObservable
  80672. */
  80673. onActivate: Nullable<(camera: Camera) => void>;
  80674. /**
  80675. * An event triggered when the postprocess changes its size.
  80676. */
  80677. onSizeChangedObservable: Observable<PostProcess>;
  80678. private _onSizeChangedObserver;
  80679. /**
  80680. * A function that is added to the onSizeChangedObservable
  80681. */
  80682. onSizeChanged: (postProcess: PostProcess) => void;
  80683. /**
  80684. * An event triggered when the postprocess applies its effect.
  80685. */
  80686. onApplyObservable: Observable<Effect>;
  80687. private _onApplyObserver;
  80688. /**
  80689. * A function that is added to the onApplyObservable
  80690. */
  80691. onApply: (effect: Effect) => void;
  80692. /**
  80693. * An event triggered before rendering the postprocess
  80694. */
  80695. onBeforeRenderObservable: Observable<Effect>;
  80696. private _onBeforeRenderObserver;
  80697. /**
  80698. * A function that is added to the onBeforeRenderObservable
  80699. */
  80700. onBeforeRender: (effect: Effect) => void;
  80701. /**
  80702. * An event triggered after rendering the postprocess
  80703. */
  80704. onAfterRenderObservable: Observable<Effect>;
  80705. private _onAfterRenderObserver;
  80706. /**
  80707. * A function that is added to the onAfterRenderObservable
  80708. */
  80709. onAfterRender: (efect: Effect) => void;
  80710. /**
  80711. * 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
  80712. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  80713. */
  80714. inputTexture: InternalTexture;
  80715. /**
  80716. * Gets the camera which post process is applied to.
  80717. * @returns The camera the post process is applied to.
  80718. */
  80719. getCamera(): Camera;
  80720. /**
  80721. * Gets the texel size of the postprocess.
  80722. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  80723. */
  80724. readonly texelSize: Vector2;
  80725. /**
  80726. * Creates a new instance PostProcess
  80727. * @param name The name of the PostProcess.
  80728. * @param fragmentUrl The url of the fragment shader to be used.
  80729. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  80730. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  80731. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  80732. * @param camera The camera to apply the render pass to.
  80733. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  80734. * @param engine The engine which the post process will be applied. (default: current engine)
  80735. * @param reusable If the post process can be reused on the same frame. (default: false)
  80736. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  80737. * @param textureType Type of textures used when performing the post process. (default: 0)
  80738. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  80739. * @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
  80740. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  80741. */
  80742. constructor(
  80743. /** Name of the PostProcess. */
  80744. 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);
  80745. /**
  80746. * Gets a string idenfifying the name of the class
  80747. * @returns "PostProcess" string
  80748. */
  80749. getClassName(): string;
  80750. /**
  80751. * Gets the engine which this post process belongs to.
  80752. * @returns The engine the post process was enabled with.
  80753. */
  80754. getEngine(): Engine;
  80755. /**
  80756. * The effect that is created when initializing the post process.
  80757. * @returns The created effect corresponding the the postprocess.
  80758. */
  80759. getEffect(): Effect;
  80760. /**
  80761. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  80762. * @param postProcess The post process to share the output with.
  80763. * @returns This post process.
  80764. */
  80765. shareOutputWith(postProcess: PostProcess): PostProcess;
  80766. /**
  80767. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  80768. * This should be called if the post process that shares output with this post process is disabled/disposed.
  80769. */
  80770. useOwnOutput(): void;
  80771. /**
  80772. * Updates the effect with the current post process compile time values and recompiles the shader.
  80773. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  80774. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  80775. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  80776. * @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
  80777. * @param onCompiled Called when the shader has been compiled.
  80778. * @param onError Called if there is an error when compiling a shader.
  80779. */
  80780. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  80781. /**
  80782. * The post process is reusable if it can be used multiple times within one frame.
  80783. * @returns If the post process is reusable
  80784. */
  80785. isReusable(): boolean;
  80786. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  80787. markTextureDirty(): void;
  80788. /**
  80789. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  80790. * 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.
  80791. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  80792. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  80793. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  80794. * @returns The target texture that was bound to be written to.
  80795. */
  80796. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  80797. /**
  80798. * If the post process is supported.
  80799. */
  80800. readonly isSupported: boolean;
  80801. /**
  80802. * The aspect ratio of the output texture.
  80803. */
  80804. readonly aspectRatio: number;
  80805. /**
  80806. * Get a value indicating if the post-process is ready to be used
  80807. * @returns true if the post-process is ready (shader is compiled)
  80808. */
  80809. isReady(): boolean;
  80810. /**
  80811. * Binds all textures and uniforms to the shader, this will be run on every pass.
  80812. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  80813. */
  80814. apply(): Nullable<Effect>;
  80815. private _disposeTextures;
  80816. /**
  80817. * Disposes the post process.
  80818. * @param camera The camera to dispose the post process on.
  80819. */
  80820. dispose(camera?: Camera): void;
  80821. }
  80822. }
  80823. declare module BABYLON {
  80824. /** @hidden */
  80825. export var kernelBlurVaryingDeclaration: {
  80826. name: string;
  80827. shader: string;
  80828. };
  80829. }
  80830. declare module BABYLON {
  80831. /** @hidden */
  80832. export var kernelBlurFragment: {
  80833. name: string;
  80834. shader: string;
  80835. };
  80836. }
  80837. declare module BABYLON {
  80838. /** @hidden */
  80839. export var kernelBlurFragment2: {
  80840. name: string;
  80841. shader: string;
  80842. };
  80843. }
  80844. declare module BABYLON {
  80845. /** @hidden */
  80846. export var kernelBlurPixelShader: {
  80847. name: string;
  80848. shader: string;
  80849. };
  80850. }
  80851. declare module BABYLON {
  80852. /** @hidden */
  80853. export var kernelBlurVertex: {
  80854. name: string;
  80855. shader: string;
  80856. };
  80857. }
  80858. declare module BABYLON {
  80859. /** @hidden */
  80860. export var kernelBlurVertexShader: {
  80861. name: string;
  80862. shader: string;
  80863. };
  80864. }
  80865. declare module BABYLON {
  80866. /**
  80867. * The Blur Post Process which blurs an image based on a kernel and direction.
  80868. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  80869. */
  80870. export class BlurPostProcess extends PostProcess {
  80871. /** The direction in which to blur the image. */
  80872. direction: Vector2;
  80873. private blockCompilation;
  80874. protected _kernel: number;
  80875. protected _idealKernel: number;
  80876. protected _packedFloat: boolean;
  80877. private _staticDefines;
  80878. /**
  80879. * Sets the length in pixels of the blur sample region
  80880. */
  80881. /**
  80882. * Gets the length in pixels of the blur sample region
  80883. */
  80884. kernel: number;
  80885. /**
  80886. * Sets wether or not the blur needs to unpack/repack floats
  80887. */
  80888. /**
  80889. * Gets wether or not the blur is unpacking/repacking floats
  80890. */
  80891. packedFloat: boolean;
  80892. /**
  80893. * Creates a new instance BlurPostProcess
  80894. * @param name The name of the effect.
  80895. * @param direction The direction in which to blur the image.
  80896. * @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.
  80897. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  80898. * @param camera The camera to apply the render pass to.
  80899. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  80900. * @param engine The engine which the post process will be applied. (default: current engine)
  80901. * @param reusable If the post process can be reused on the same frame. (default: false)
  80902. * @param textureType Type of textures used when performing the post process. (default: 0)
  80903. * @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)
  80904. */
  80905. constructor(name: string,
  80906. /** The direction in which to blur the image. */
  80907. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  80908. /**
  80909. * Updates the effect with the current post process compile time values and recompiles the shader.
  80910. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  80911. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  80912. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  80913. * @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
  80914. * @param onCompiled Called when the shader has been compiled.
  80915. * @param onError Called if there is an error when compiling a shader.
  80916. */
  80917. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  80918. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  80919. /**
  80920. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  80921. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  80922. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  80923. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  80924. * The gaps between physical kernels are compensated for in the weighting of the samples
  80925. * @param idealKernel Ideal blur kernel.
  80926. * @return Nearest best kernel.
  80927. */
  80928. protected _nearestBestKernel(idealKernel: number): number;
  80929. /**
  80930. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  80931. * @param x The point on the Gaussian distribution to sample.
  80932. * @return the value of the Gaussian function at x.
  80933. */
  80934. protected _gaussianWeight(x: number): number;
  80935. /**
  80936. * Generates a string that can be used as a floating point number in GLSL.
  80937. * @param x Value to print.
  80938. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  80939. * @return GLSL float string.
  80940. */
  80941. protected _glslFloat(x: number, decimalFigures?: number): string;
  80942. }
  80943. }
  80944. declare module BABYLON {
  80945. /**
  80946. * Mirror texture can be used to simulate the view from a mirror in a scene.
  80947. * It will dynamically be rendered every frame to adapt to the camera point of view.
  80948. * You can then easily use it as a reflectionTexture on a flat surface.
  80949. * In case the surface is not a plane, please consider relying on reflection probes.
  80950. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  80951. */
  80952. export class MirrorTexture extends RenderTargetTexture {
  80953. private scene;
  80954. /**
  80955. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  80956. * 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.
  80957. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  80958. */
  80959. mirrorPlane: Plane;
  80960. /**
  80961. * Define the blur ratio used to blur the reflection if needed.
  80962. */
  80963. blurRatio: number;
  80964. /**
  80965. * Define the adaptive blur kernel used to blur the reflection if needed.
  80966. * This will autocompute the closest best match for the `blurKernel`
  80967. */
  80968. adaptiveBlurKernel: number;
  80969. /**
  80970. * Define the blur kernel used to blur the reflection if needed.
  80971. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  80972. */
  80973. blurKernel: number;
  80974. /**
  80975. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  80976. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  80977. */
  80978. blurKernelX: number;
  80979. /**
  80980. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  80981. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  80982. */
  80983. blurKernelY: number;
  80984. private _autoComputeBlurKernel;
  80985. protected _onRatioRescale(): void;
  80986. private _updateGammaSpace;
  80987. private _imageProcessingConfigChangeObserver;
  80988. private _transformMatrix;
  80989. private _mirrorMatrix;
  80990. private _savedViewMatrix;
  80991. private _blurX;
  80992. private _blurY;
  80993. private _adaptiveBlurKernel;
  80994. private _blurKernelX;
  80995. private _blurKernelY;
  80996. private _blurRatio;
  80997. /**
  80998. * Instantiates a Mirror Texture.
  80999. * Mirror texture can be used to simulate the view from a mirror in a scene.
  81000. * It will dynamically be rendered every frame to adapt to the camera point of view.
  81001. * You can then easily use it as a reflectionTexture on a flat surface.
  81002. * In case the surface is not a plane, please consider relying on reflection probes.
  81003. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  81004. * @param name
  81005. * @param size
  81006. * @param scene
  81007. * @param generateMipMaps
  81008. * @param type
  81009. * @param samplingMode
  81010. * @param generateDepthBuffer
  81011. */
  81012. constructor(name: string, size: number | {
  81013. width: number;
  81014. height: number;
  81015. } | {
  81016. ratio: number;
  81017. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  81018. private _preparePostProcesses;
  81019. /**
  81020. * Clone the mirror texture.
  81021. * @returns the cloned texture
  81022. */
  81023. clone(): MirrorTexture;
  81024. /**
  81025. * Serialize the texture to a JSON representation you could use in Parse later on
  81026. * @returns the serialized JSON representation
  81027. */
  81028. serialize(): any;
  81029. /**
  81030. * Dispose the texture and release its associated resources.
  81031. */
  81032. dispose(): void;
  81033. }
  81034. }
  81035. declare module BABYLON {
  81036. /**
  81037. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  81038. * @see http://doc.babylonjs.com/babylon101/materials#texture
  81039. */
  81040. export class Texture extends BaseTexture {
  81041. /** @hidden */
  81042. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  81043. /** @hidden */
  81044. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  81045. /** @hidden */
  81046. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  81047. /** nearest is mag = nearest and min = nearest and mip = linear */
  81048. static readonly NEAREST_SAMPLINGMODE: number;
  81049. /** nearest is mag = nearest and min = nearest and mip = linear */
  81050. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  81051. /** Bilinear is mag = linear and min = linear and mip = nearest */
  81052. static readonly BILINEAR_SAMPLINGMODE: number;
  81053. /** Bilinear is mag = linear and min = linear and mip = nearest */
  81054. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  81055. /** Trilinear is mag = linear and min = linear and mip = linear */
  81056. static readonly TRILINEAR_SAMPLINGMODE: number;
  81057. /** Trilinear is mag = linear and min = linear and mip = linear */
  81058. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  81059. /** mag = nearest and min = nearest and mip = nearest */
  81060. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  81061. /** mag = nearest and min = linear and mip = nearest */
  81062. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  81063. /** mag = nearest and min = linear and mip = linear */
  81064. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  81065. /** mag = nearest and min = linear and mip = none */
  81066. static readonly NEAREST_LINEAR: number;
  81067. /** mag = nearest and min = nearest and mip = none */
  81068. static readonly NEAREST_NEAREST: number;
  81069. /** mag = linear and min = nearest and mip = nearest */
  81070. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  81071. /** mag = linear and min = nearest and mip = linear */
  81072. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  81073. /** mag = linear and min = linear and mip = none */
  81074. static readonly LINEAR_LINEAR: number;
  81075. /** mag = linear and min = nearest and mip = none */
  81076. static readonly LINEAR_NEAREST: number;
  81077. /** Explicit coordinates mode */
  81078. static readonly EXPLICIT_MODE: number;
  81079. /** Spherical coordinates mode */
  81080. static readonly SPHERICAL_MODE: number;
  81081. /** Planar coordinates mode */
  81082. static readonly PLANAR_MODE: number;
  81083. /** Cubic coordinates mode */
  81084. static readonly CUBIC_MODE: number;
  81085. /** Projection coordinates mode */
  81086. static readonly PROJECTION_MODE: number;
  81087. /** Inverse Cubic coordinates mode */
  81088. static readonly SKYBOX_MODE: number;
  81089. /** Inverse Cubic coordinates mode */
  81090. static readonly INVCUBIC_MODE: number;
  81091. /** Equirectangular coordinates mode */
  81092. static readonly EQUIRECTANGULAR_MODE: number;
  81093. /** Equirectangular Fixed coordinates mode */
  81094. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  81095. /** Equirectangular Fixed Mirrored coordinates mode */
  81096. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  81097. /** Texture is not repeating outside of 0..1 UVs */
  81098. static readonly CLAMP_ADDRESSMODE: number;
  81099. /** Texture is repeating outside of 0..1 UVs */
  81100. static readonly WRAP_ADDRESSMODE: number;
  81101. /** Texture is repeating and mirrored */
  81102. static readonly MIRROR_ADDRESSMODE: number;
  81103. /**
  81104. * 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
  81105. */
  81106. static UseSerializedUrlIfAny: boolean;
  81107. /**
  81108. * Define the url of the texture.
  81109. */
  81110. url: Nullable<string>;
  81111. /**
  81112. * Define an offset on the texture to offset the u coordinates of the UVs
  81113. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  81114. */
  81115. uOffset: number;
  81116. /**
  81117. * Define an offset on the texture to offset the v coordinates of the UVs
  81118. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  81119. */
  81120. vOffset: number;
  81121. /**
  81122. * Define an offset on the texture to scale the u coordinates of the UVs
  81123. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  81124. */
  81125. uScale: number;
  81126. /**
  81127. * Define an offset on the texture to scale the v coordinates of the UVs
  81128. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  81129. */
  81130. vScale: number;
  81131. /**
  81132. * Define an offset on the texture to rotate around the u coordinates of the UVs
  81133. * @see http://doc.babylonjs.com/how_to/more_materials
  81134. */
  81135. uAng: number;
  81136. /**
  81137. * Define an offset on the texture to rotate around the v coordinates of the UVs
  81138. * @see http://doc.babylonjs.com/how_to/more_materials
  81139. */
  81140. vAng: number;
  81141. /**
  81142. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  81143. * @see http://doc.babylonjs.com/how_to/more_materials
  81144. */
  81145. wAng: number;
  81146. /**
  81147. * Defines the center of rotation (U)
  81148. */
  81149. uRotationCenter: number;
  81150. /**
  81151. * Defines the center of rotation (V)
  81152. */
  81153. vRotationCenter: number;
  81154. /**
  81155. * Defines the center of rotation (W)
  81156. */
  81157. wRotationCenter: number;
  81158. /**
  81159. * Are mip maps generated for this texture or not.
  81160. */
  81161. readonly noMipmap: boolean;
  81162. /**
  81163. * List of inspectable custom properties (used by the Inspector)
  81164. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  81165. */
  81166. inspectableCustomProperties: Nullable<IInspectable[]>;
  81167. private _noMipmap;
  81168. /** @hidden */
  81169. _invertY: boolean;
  81170. private _rowGenerationMatrix;
  81171. private _cachedTextureMatrix;
  81172. private _projectionModeMatrix;
  81173. private _t0;
  81174. private _t1;
  81175. private _t2;
  81176. private _cachedUOffset;
  81177. private _cachedVOffset;
  81178. private _cachedUScale;
  81179. private _cachedVScale;
  81180. private _cachedUAng;
  81181. private _cachedVAng;
  81182. private _cachedWAng;
  81183. private _cachedProjectionMatrixId;
  81184. private _cachedCoordinatesMode;
  81185. /** @hidden */
  81186. protected _initialSamplingMode: number;
  81187. /** @hidden */
  81188. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>;
  81189. private _deleteBuffer;
  81190. protected _format: Nullable<number>;
  81191. private _delayedOnLoad;
  81192. private _delayedOnError;
  81193. /**
  81194. * Observable triggered once the texture has been loaded.
  81195. */
  81196. onLoadObservable: Observable<Texture>;
  81197. protected _isBlocking: boolean;
  81198. /**
  81199. * Is the texture preventing material to render while loading.
  81200. * If false, a default texture will be used instead of the loading one during the preparation step.
  81201. */
  81202. isBlocking: boolean;
  81203. /**
  81204. * Get the current sampling mode associated with the texture.
  81205. */
  81206. readonly samplingMode: number;
  81207. /**
  81208. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  81209. */
  81210. readonly invertY: boolean;
  81211. /**
  81212. * Instantiates a new texture.
  81213. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  81214. * @see http://doc.babylonjs.com/babylon101/materials#texture
  81215. * @param url define the url of the picture to load as a texture
  81216. * @param scene define the scene or engine the texture will belong to
  81217. * @param noMipmap define if the texture will require mip maps or not
  81218. * @param invertY define if the texture needs to be inverted on the y axis during loading
  81219. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  81220. * @param onLoad define a callback triggered when the texture has been loaded
  81221. * @param onError define a callback triggered when an error occurred during the loading session
  81222. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  81223. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  81224. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  81225. */
  81226. constructor(url: Nullable<string>, sceneOrEngine: Nullable<Scene | Engine>, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, deleteBuffer?: boolean, format?: number);
  81227. /**
  81228. * Update the url (and optional buffer) of this texture if url was null during construction.
  81229. * @param url the url of the texture
  81230. * @param buffer the buffer of the texture (defaults to null)
  81231. * @param onLoad callback called when the texture is loaded (defaults to null)
  81232. */
  81233. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, onLoad?: () => void): void;
  81234. /**
  81235. * Finish the loading sequence of a texture flagged as delayed load.
  81236. * @hidden
  81237. */
  81238. delayLoad(): void;
  81239. private _prepareRowForTextureGeneration;
  81240. /**
  81241. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  81242. * @returns the transform matrix of the texture.
  81243. */
  81244. getTextureMatrix(): Matrix;
  81245. /**
  81246. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  81247. * @returns The reflection texture transform
  81248. */
  81249. getReflectionTextureMatrix(): Matrix;
  81250. /**
  81251. * Clones the texture.
  81252. * @returns the cloned texture
  81253. */
  81254. clone(): Texture;
  81255. /**
  81256. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  81257. * @returns The JSON representation of the texture
  81258. */
  81259. serialize(): any;
  81260. /**
  81261. * Get the current class name of the texture useful for serialization or dynamic coding.
  81262. * @returns "Texture"
  81263. */
  81264. getClassName(): string;
  81265. /**
  81266. * Dispose the texture and release its associated resources.
  81267. */
  81268. dispose(): void;
  81269. /**
  81270. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  81271. * @param parsedTexture Define the JSON representation of the texture
  81272. * @param scene Define the scene the parsed texture should be instantiated in
  81273. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  81274. * @returns The parsed texture if successful
  81275. */
  81276. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  81277. /**
  81278. * Creates a texture from its base 64 representation.
  81279. * @param data Define the base64 payload without the data: prefix
  81280. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  81281. * @param scene Define the scene the texture should belong to
  81282. * @param noMipmap Forces the texture to not create mip map information if true
  81283. * @param invertY define if the texture needs to be inverted on the y axis during loading
  81284. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  81285. * @param onLoad define a callback triggered when the texture has been loaded
  81286. * @param onError define a callback triggered when an error occurred during the loading session
  81287. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  81288. * @returns the created texture
  81289. */
  81290. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  81291. /**
  81292. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  81293. * @param data Define the base64 payload without the data: prefix
  81294. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  81295. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  81296. * @param scene Define the scene the texture should belong to
  81297. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  81298. * @param noMipmap Forces the texture to not create mip map information if true
  81299. * @param invertY define if the texture needs to be inverted on the y axis during loading
  81300. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  81301. * @param onLoad define a callback triggered when the texture has been loaded
  81302. * @param onError define a callback triggered when an error occurred during the loading session
  81303. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  81304. * @returns the created texture
  81305. */
  81306. 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;
  81307. }
  81308. }
  81309. declare module BABYLON {
  81310. /**
  81311. * PostProcessManager is used to manage one or more post processes or post process pipelines
  81312. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  81313. */
  81314. export class PostProcessManager {
  81315. private _scene;
  81316. private _indexBuffer;
  81317. private _vertexBuffers;
  81318. /**
  81319. * Creates a new instance PostProcess
  81320. * @param scene The scene that the post process is associated with.
  81321. */
  81322. constructor(scene: Scene);
  81323. private _prepareBuffers;
  81324. private _buildIndexBuffer;
  81325. /**
  81326. * Rebuilds the vertex buffers of the manager.
  81327. * @hidden
  81328. */
  81329. _rebuild(): void;
  81330. /**
  81331. * Prepares a frame to be run through a post process.
  81332. * @param sourceTexture The input texture to the post procesess. (default: null)
  81333. * @param postProcesses An array of post processes to be run. (default: null)
  81334. * @returns True if the post processes were able to be run.
  81335. * @hidden
  81336. */
  81337. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  81338. /**
  81339. * Manually render a set of post processes to a texture.
  81340. * @param postProcesses An array of post processes to be run.
  81341. * @param targetTexture The target texture to render to.
  81342. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  81343. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  81344. * @param lodLevel defines which lod of the texture to render to
  81345. */
  81346. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  81347. /**
  81348. * Finalize the result of the output of the postprocesses.
  81349. * @param doNotPresent If true the result will not be displayed to the screen.
  81350. * @param targetTexture The target texture to render to.
  81351. * @param faceIndex The index of the face to bind the target texture to.
  81352. * @param postProcesses The array of post processes to render.
  81353. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  81354. * @hidden
  81355. */
  81356. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  81357. /**
  81358. * Disposes of the post process manager.
  81359. */
  81360. dispose(): void;
  81361. }
  81362. }
  81363. declare module BABYLON {
  81364. /** Interface used by value gradients (color, factor, ...) */
  81365. export interface IValueGradient {
  81366. /**
  81367. * Gets or sets the gradient value (between 0 and 1)
  81368. */
  81369. gradient: number;
  81370. }
  81371. /** Class used to store color4 gradient */
  81372. export class ColorGradient implements IValueGradient {
  81373. /**
  81374. * Gets or sets the gradient value (between 0 and 1)
  81375. */
  81376. gradient: number;
  81377. /**
  81378. * Gets or sets first associated color
  81379. */
  81380. color1: Color4;
  81381. /**
  81382. * Gets or sets second associated color
  81383. */
  81384. color2?: Color4;
  81385. /**
  81386. * Will get a color picked randomly between color1 and color2.
  81387. * If color2 is undefined then color1 will be used
  81388. * @param result defines the target Color4 to store the result in
  81389. */
  81390. getColorToRef(result: Color4): void;
  81391. }
  81392. /** Class used to store color 3 gradient */
  81393. export class Color3Gradient implements IValueGradient {
  81394. /**
  81395. * Gets or sets the gradient value (between 0 and 1)
  81396. */
  81397. gradient: number;
  81398. /**
  81399. * Gets or sets the associated color
  81400. */
  81401. color: Color3;
  81402. }
  81403. /** Class used to store factor gradient */
  81404. export class FactorGradient implements IValueGradient {
  81405. /**
  81406. * Gets or sets the gradient value (between 0 and 1)
  81407. */
  81408. gradient: number;
  81409. /**
  81410. * Gets or sets first associated factor
  81411. */
  81412. factor1: number;
  81413. /**
  81414. * Gets or sets second associated factor
  81415. */
  81416. factor2?: number;
  81417. /**
  81418. * Will get a number picked randomly between factor1 and factor2.
  81419. * If factor2 is undefined then factor1 will be used
  81420. * @returns the picked number
  81421. */
  81422. getFactor(): number;
  81423. }
  81424. /**
  81425. * Helper used to simplify some generic gradient tasks
  81426. */
  81427. export class GradientHelper {
  81428. /**
  81429. * Gets the current gradient from an array of IValueGradient
  81430. * @param ratio defines the current ratio to get
  81431. * @param gradients defines the array of IValueGradient
  81432. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  81433. */
  81434. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  81435. }
  81436. }
  81437. declare module BABYLON {
  81438. interface AbstractScene {
  81439. /**
  81440. * The list of procedural textures added to the scene
  81441. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  81442. */
  81443. proceduralTextures: Array<ProceduralTexture>;
  81444. }
  81445. /**
  81446. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  81447. * in a given scene.
  81448. */
  81449. export class ProceduralTextureSceneComponent implements ISceneComponent {
  81450. /**
  81451. * The component name helpfull to identify the component in the list of scene components.
  81452. */
  81453. readonly name: string;
  81454. /**
  81455. * The scene the component belongs to.
  81456. */
  81457. scene: Scene;
  81458. /**
  81459. * Creates a new instance of the component for the given scene
  81460. * @param scene Defines the scene to register the component in
  81461. */
  81462. constructor(scene: Scene);
  81463. /**
  81464. * Registers the component in a given scene
  81465. */
  81466. register(): void;
  81467. /**
  81468. * Rebuilds the elements related to this component in case of
  81469. * context lost for instance.
  81470. */
  81471. rebuild(): void;
  81472. /**
  81473. * Disposes the component and the associated ressources.
  81474. */
  81475. dispose(): void;
  81476. private _beforeClear;
  81477. }
  81478. }
  81479. declare module BABYLON {
  81480. interface Engine {
  81481. /**
  81482. * Creates a new render target cube texture
  81483. * @param size defines the size of the texture
  81484. * @param options defines the options used to create the texture
  81485. * @returns a new render target cube texture stored in an InternalTexture
  81486. */
  81487. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  81488. }
  81489. }
  81490. declare module BABYLON {
  81491. /** @hidden */
  81492. export var proceduralVertexShader: {
  81493. name: string;
  81494. shader: string;
  81495. };
  81496. }
  81497. declare module BABYLON {
  81498. /**
  81499. * 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.
  81500. * This is the base class of any Procedural texture and contains most of the shareable code.
  81501. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  81502. */
  81503. export class ProceduralTexture extends Texture {
  81504. isCube: boolean;
  81505. /**
  81506. * Define if the texture is enabled or not (disabled texture will not render)
  81507. */
  81508. isEnabled: boolean;
  81509. /**
  81510. * Define if the texture must be cleared before rendering (default is true)
  81511. */
  81512. autoClear: boolean;
  81513. /**
  81514. * Callback called when the texture is generated
  81515. */
  81516. onGenerated: () => void;
  81517. /**
  81518. * Event raised when the texture is generated
  81519. */
  81520. onGeneratedObservable: Observable<ProceduralTexture>;
  81521. /** @hidden */
  81522. _generateMipMaps: boolean;
  81523. /** @hidden **/
  81524. _effect: Effect;
  81525. /** @hidden */
  81526. _textures: {
  81527. [key: string]: Texture;
  81528. };
  81529. private _size;
  81530. private _currentRefreshId;
  81531. private _refreshRate;
  81532. private _vertexBuffers;
  81533. private _indexBuffer;
  81534. private _uniforms;
  81535. private _samplers;
  81536. private _fragment;
  81537. private _floats;
  81538. private _ints;
  81539. private _floatsArrays;
  81540. private _colors3;
  81541. private _colors4;
  81542. private _vectors2;
  81543. private _vectors3;
  81544. private _matrices;
  81545. private _fallbackTexture;
  81546. private _fallbackTextureUsed;
  81547. private _engine;
  81548. private _cachedDefines;
  81549. private _contentUpdateId;
  81550. private _contentData;
  81551. /**
  81552. * Instantiates a new procedural texture.
  81553. * 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.
  81554. * This is the base class of any Procedural texture and contains most of the shareable code.
  81555. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  81556. * @param name Define the name of the texture
  81557. * @param size Define the size of the texture to create
  81558. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  81559. * @param scene Define the scene the texture belongs to
  81560. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  81561. * @param generateMipMaps Define if the texture should creates mip maps or not
  81562. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  81563. */
  81564. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  81565. /**
  81566. * The effect that is created when initializing the post process.
  81567. * @returns The created effect corresponding the the postprocess.
  81568. */
  81569. getEffect(): Effect;
  81570. /**
  81571. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  81572. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  81573. */
  81574. getContent(): Nullable<ArrayBufferView>;
  81575. private _createIndexBuffer;
  81576. /** @hidden */
  81577. _rebuild(): void;
  81578. /**
  81579. * Resets the texture in order to recreate its associated resources.
  81580. * This can be called in case of context loss
  81581. */
  81582. reset(): void;
  81583. protected _getDefines(): string;
  81584. /**
  81585. * Is the texture ready to be used ? (rendered at least once)
  81586. * @returns true if ready, otherwise, false.
  81587. */
  81588. isReady(): boolean;
  81589. /**
  81590. * Resets the refresh counter of the texture and start bak from scratch.
  81591. * Could be useful to regenerate the texture if it is setup to render only once.
  81592. */
  81593. resetRefreshCounter(): void;
  81594. /**
  81595. * Set the fragment shader to use in order to render the texture.
  81596. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  81597. */
  81598. setFragment(fragment: any): void;
  81599. /**
  81600. * Define the refresh rate of the texture or the rendering frequency.
  81601. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  81602. */
  81603. refreshRate: number;
  81604. /** @hidden */
  81605. _shouldRender(): boolean;
  81606. /**
  81607. * Get the size the texture is rendering at.
  81608. * @returns the size (texture is always squared)
  81609. */
  81610. getRenderSize(): number;
  81611. /**
  81612. * Resize the texture to new value.
  81613. * @param size Define the new size the texture should have
  81614. * @param generateMipMaps Define whether the new texture should create mip maps
  81615. */
  81616. resize(size: number, generateMipMaps: boolean): void;
  81617. private _checkUniform;
  81618. /**
  81619. * Set a texture in the shader program used to render.
  81620. * @param name Define the name of the uniform samplers as defined in the shader
  81621. * @param texture Define the texture to bind to this sampler
  81622. * @return the texture itself allowing "fluent" like uniform updates
  81623. */
  81624. setTexture(name: string, texture: Texture): ProceduralTexture;
  81625. /**
  81626. * Set a float in the shader.
  81627. * @param name Define the name of the uniform as defined in the shader
  81628. * @param value Define the value to give to the uniform
  81629. * @return the texture itself allowing "fluent" like uniform updates
  81630. */
  81631. setFloat(name: string, value: number): ProceduralTexture;
  81632. /**
  81633. * Set a int in the shader.
  81634. * @param name Define the name of the uniform as defined in the shader
  81635. * @param value Define the value to give to the uniform
  81636. * @return the texture itself allowing "fluent" like uniform updates
  81637. */
  81638. setInt(name: string, value: number): ProceduralTexture;
  81639. /**
  81640. * Set an array of floats in the shader.
  81641. * @param name Define the name of the uniform as defined in the shader
  81642. * @param value Define the value to give to the uniform
  81643. * @return the texture itself allowing "fluent" like uniform updates
  81644. */
  81645. setFloats(name: string, value: number[]): ProceduralTexture;
  81646. /**
  81647. * Set a vec3 in the shader from a Color3.
  81648. * @param name Define the name of the uniform as defined in the shader
  81649. * @param value Define the value to give to the uniform
  81650. * @return the texture itself allowing "fluent" like uniform updates
  81651. */
  81652. setColor3(name: string, value: Color3): ProceduralTexture;
  81653. /**
  81654. * Set a vec4 in the shader from a Color4.
  81655. * @param name Define the name of the uniform as defined in the shader
  81656. * @param value Define the value to give to the uniform
  81657. * @return the texture itself allowing "fluent" like uniform updates
  81658. */
  81659. setColor4(name: string, value: Color4): ProceduralTexture;
  81660. /**
  81661. * Set a vec2 in the shader from a Vector2.
  81662. * @param name Define the name of the uniform as defined in the shader
  81663. * @param value Define the value to give to the uniform
  81664. * @return the texture itself allowing "fluent" like uniform updates
  81665. */
  81666. setVector2(name: string, value: Vector2): ProceduralTexture;
  81667. /**
  81668. * Set a vec3 in the shader from a Vector3.
  81669. * @param name Define the name of the uniform as defined in the shader
  81670. * @param value Define the value to give to the uniform
  81671. * @return the texture itself allowing "fluent" like uniform updates
  81672. */
  81673. setVector3(name: string, value: Vector3): ProceduralTexture;
  81674. /**
  81675. * Set a mat4 in the shader from a MAtrix.
  81676. * @param name Define the name of the uniform as defined in the shader
  81677. * @param value Define the value to give to the uniform
  81678. * @return the texture itself allowing "fluent" like uniform updates
  81679. */
  81680. setMatrix(name: string, value: Matrix): ProceduralTexture;
  81681. /**
  81682. * Render the texture to its associated render target.
  81683. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  81684. */
  81685. render(useCameraPostProcess?: boolean): void;
  81686. /**
  81687. * Clone the texture.
  81688. * @returns the cloned texture
  81689. */
  81690. clone(): ProceduralTexture;
  81691. /**
  81692. * Dispose the texture and release its asoociated resources.
  81693. */
  81694. dispose(): void;
  81695. }
  81696. }
  81697. declare module BABYLON {
  81698. /**
  81699. * This represents the base class for particle system in Babylon.
  81700. * 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.
  81701. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  81702. * @example https://doc.babylonjs.com/babylon101/particles
  81703. */
  81704. export class BaseParticleSystem {
  81705. /**
  81706. * Source color is added to the destination color without alpha affecting the result
  81707. */
  81708. static BLENDMODE_ONEONE: number;
  81709. /**
  81710. * Blend current color and particle color using particle’s alpha
  81711. */
  81712. static BLENDMODE_STANDARD: number;
  81713. /**
  81714. * Add current color and particle color multiplied by particle’s alpha
  81715. */
  81716. static BLENDMODE_ADD: number;
  81717. /**
  81718. * Multiply current color with particle color
  81719. */
  81720. static BLENDMODE_MULTIPLY: number;
  81721. /**
  81722. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  81723. */
  81724. static BLENDMODE_MULTIPLYADD: number;
  81725. /**
  81726. * List of animations used by the particle system.
  81727. */
  81728. animations: Animation[];
  81729. /**
  81730. * The id of the Particle system.
  81731. */
  81732. id: string;
  81733. /**
  81734. * The friendly name of the Particle system.
  81735. */
  81736. name: string;
  81737. /**
  81738. * The rendering group used by the Particle system to chose when to render.
  81739. */
  81740. renderingGroupId: number;
  81741. /**
  81742. * The emitter represents the Mesh or position we are attaching the particle system to.
  81743. */
  81744. emitter: Nullable<AbstractMesh | Vector3>;
  81745. /**
  81746. * The maximum number of particles to emit per frame
  81747. */
  81748. emitRate: number;
  81749. /**
  81750. * If you want to launch only a few particles at once, that can be done, as well.
  81751. */
  81752. manualEmitCount: number;
  81753. /**
  81754. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  81755. */
  81756. updateSpeed: number;
  81757. /**
  81758. * The amount of time the particle system is running (depends of the overall update speed).
  81759. */
  81760. targetStopDuration: number;
  81761. /**
  81762. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  81763. */
  81764. disposeOnStop: boolean;
  81765. /**
  81766. * Minimum power of emitting particles.
  81767. */
  81768. minEmitPower: number;
  81769. /**
  81770. * Maximum power of emitting particles.
  81771. */
  81772. maxEmitPower: number;
  81773. /**
  81774. * Minimum life time of emitting particles.
  81775. */
  81776. minLifeTime: number;
  81777. /**
  81778. * Maximum life time of emitting particles.
  81779. */
  81780. maxLifeTime: number;
  81781. /**
  81782. * Minimum Size of emitting particles.
  81783. */
  81784. minSize: number;
  81785. /**
  81786. * Maximum Size of emitting particles.
  81787. */
  81788. maxSize: number;
  81789. /**
  81790. * Minimum scale of emitting particles on X axis.
  81791. */
  81792. minScaleX: number;
  81793. /**
  81794. * Maximum scale of emitting particles on X axis.
  81795. */
  81796. maxScaleX: number;
  81797. /**
  81798. * Minimum scale of emitting particles on Y axis.
  81799. */
  81800. minScaleY: number;
  81801. /**
  81802. * Maximum scale of emitting particles on Y axis.
  81803. */
  81804. maxScaleY: number;
  81805. /**
  81806. * Gets or sets the minimal initial rotation in radians.
  81807. */
  81808. minInitialRotation: number;
  81809. /**
  81810. * Gets or sets the maximal initial rotation in radians.
  81811. */
  81812. maxInitialRotation: number;
  81813. /**
  81814. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  81815. */
  81816. minAngularSpeed: number;
  81817. /**
  81818. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  81819. */
  81820. maxAngularSpeed: number;
  81821. /**
  81822. * The texture used to render each particle. (this can be a spritesheet)
  81823. */
  81824. particleTexture: Nullable<Texture>;
  81825. /**
  81826. * The layer mask we are rendering the particles through.
  81827. */
  81828. layerMask: number;
  81829. /**
  81830. * This can help using your own shader to render the particle system.
  81831. * The according effect will be created
  81832. */
  81833. customShader: any;
  81834. /**
  81835. * By default particle system starts as soon as they are created. This prevents the
  81836. * automatic start to happen and let you decide when to start emitting particles.
  81837. */
  81838. preventAutoStart: boolean;
  81839. private _noiseTexture;
  81840. /**
  81841. * Gets or sets a texture used to add random noise to particle positions
  81842. */
  81843. noiseTexture: Nullable<ProceduralTexture>;
  81844. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  81845. noiseStrength: Vector3;
  81846. /**
  81847. * Callback triggered when the particle animation is ending.
  81848. */
  81849. onAnimationEnd: Nullable<() => void>;
  81850. /**
  81851. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  81852. */
  81853. blendMode: number;
  81854. /**
  81855. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  81856. * to override the particles.
  81857. */
  81858. forceDepthWrite: boolean;
  81859. /** 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 */
  81860. preWarmCycles: number;
  81861. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  81862. preWarmStepOffset: number;
  81863. /**
  81864. * 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)
  81865. */
  81866. spriteCellChangeSpeed: number;
  81867. /**
  81868. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  81869. */
  81870. startSpriteCellID: number;
  81871. /**
  81872. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  81873. */
  81874. endSpriteCellID: number;
  81875. /**
  81876. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  81877. */
  81878. spriteCellWidth: number;
  81879. /**
  81880. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  81881. */
  81882. spriteCellHeight: number;
  81883. /**
  81884. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  81885. */
  81886. spriteRandomStartCell: boolean;
  81887. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  81888. translationPivot: Vector2;
  81889. /** @hidden */
  81890. protected _isAnimationSheetEnabled: boolean;
  81891. /**
  81892. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  81893. */
  81894. beginAnimationOnStart: boolean;
  81895. /**
  81896. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  81897. */
  81898. beginAnimationFrom: number;
  81899. /**
  81900. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  81901. */
  81902. beginAnimationTo: number;
  81903. /**
  81904. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  81905. */
  81906. beginAnimationLoop: boolean;
  81907. /**
  81908. * Gets or sets a world offset applied to all particles
  81909. */
  81910. worldOffset: Vector3;
  81911. /**
  81912. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  81913. */
  81914. isAnimationSheetEnabled: boolean;
  81915. /**
  81916. * Get hosting scene
  81917. * @returns the scene
  81918. */
  81919. getScene(): Scene;
  81920. /**
  81921. * You can use gravity if you want to give an orientation to your particles.
  81922. */
  81923. gravity: Vector3;
  81924. protected _colorGradients: Nullable<Array<ColorGradient>>;
  81925. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  81926. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  81927. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  81928. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  81929. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  81930. protected _dragGradients: Nullable<Array<FactorGradient>>;
  81931. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  81932. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  81933. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  81934. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  81935. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  81936. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  81937. /**
  81938. * Defines the delay in milliseconds before starting the system (0 by default)
  81939. */
  81940. startDelay: number;
  81941. /**
  81942. * Gets the current list of drag gradients.
  81943. * You must use addDragGradient and removeDragGradient to udpate this list
  81944. * @returns the list of drag gradients
  81945. */
  81946. getDragGradients(): Nullable<Array<FactorGradient>>;
  81947. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  81948. limitVelocityDamping: number;
  81949. /**
  81950. * Gets the current list of limit velocity gradients.
  81951. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  81952. * @returns the list of limit velocity gradients
  81953. */
  81954. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  81955. /**
  81956. * Gets the current list of color gradients.
  81957. * You must use addColorGradient and removeColorGradient to udpate this list
  81958. * @returns the list of color gradients
  81959. */
  81960. getColorGradients(): Nullable<Array<ColorGradient>>;
  81961. /**
  81962. * Gets the current list of size gradients.
  81963. * You must use addSizeGradient and removeSizeGradient to udpate this list
  81964. * @returns the list of size gradients
  81965. */
  81966. getSizeGradients(): Nullable<Array<FactorGradient>>;
  81967. /**
  81968. * Gets the current list of color remap gradients.
  81969. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  81970. * @returns the list of color remap gradients
  81971. */
  81972. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  81973. /**
  81974. * Gets the current list of alpha remap gradients.
  81975. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  81976. * @returns the list of alpha remap gradients
  81977. */
  81978. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  81979. /**
  81980. * Gets the current list of life time gradients.
  81981. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  81982. * @returns the list of life time gradients
  81983. */
  81984. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  81985. /**
  81986. * Gets the current list of angular speed gradients.
  81987. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  81988. * @returns the list of angular speed gradients
  81989. */
  81990. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  81991. /**
  81992. * Gets the current list of velocity gradients.
  81993. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  81994. * @returns the list of velocity gradients
  81995. */
  81996. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  81997. /**
  81998. * Gets the current list of start size gradients.
  81999. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  82000. * @returns the list of start size gradients
  82001. */
  82002. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  82003. /**
  82004. * Gets the current list of emit rate gradients.
  82005. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  82006. * @returns the list of emit rate gradients
  82007. */
  82008. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  82009. /**
  82010. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  82011. * This only works when particleEmitterTyps is a BoxParticleEmitter
  82012. */
  82013. direction1: Vector3;
  82014. /**
  82015. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  82016. * This only works when particleEmitterTyps is a BoxParticleEmitter
  82017. */
  82018. direction2: Vector3;
  82019. /**
  82020. * 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.
  82021. * This only works when particleEmitterTyps is a BoxParticleEmitter
  82022. */
  82023. minEmitBox: Vector3;
  82024. /**
  82025. * 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.
  82026. * This only works when particleEmitterTyps is a BoxParticleEmitter
  82027. */
  82028. maxEmitBox: Vector3;
  82029. /**
  82030. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  82031. */
  82032. color1: Color4;
  82033. /**
  82034. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  82035. */
  82036. color2: Color4;
  82037. /**
  82038. * Color the particle will have at the end of its lifetime
  82039. */
  82040. colorDead: Color4;
  82041. /**
  82042. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  82043. */
  82044. textureMask: Color4;
  82045. /**
  82046. * The particle emitter type defines the emitter used by the particle system.
  82047. * It can be for example box, sphere, or cone...
  82048. */
  82049. particleEmitterType: IParticleEmitterType;
  82050. /** @hidden */
  82051. _isSubEmitter: boolean;
  82052. /**
  82053. * Gets or sets the billboard mode to use when isBillboardBased = true.
  82054. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  82055. */
  82056. billboardMode: number;
  82057. protected _isBillboardBased: boolean;
  82058. /**
  82059. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  82060. */
  82061. isBillboardBased: boolean;
  82062. /**
  82063. * The scene the particle system belongs to.
  82064. */
  82065. protected _scene: Scene;
  82066. /**
  82067. * Local cache of defines for image processing.
  82068. */
  82069. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  82070. /**
  82071. * Default configuration related to image processing available in the standard Material.
  82072. */
  82073. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  82074. /**
  82075. * Gets the image processing configuration used either in this material.
  82076. */
  82077. /**
  82078. * Sets the Default image processing configuration used either in the this material.
  82079. *
  82080. * If sets to null, the scene one is in use.
  82081. */
  82082. imageProcessingConfiguration: ImageProcessingConfiguration;
  82083. /**
  82084. * Attaches a new image processing configuration to the Standard Material.
  82085. * @param configuration
  82086. */
  82087. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  82088. /** @hidden */
  82089. protected _reset(): void;
  82090. /** @hidden */
  82091. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  82092. /**
  82093. * Instantiates a particle system.
  82094. * 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.
  82095. * @param name The name of the particle system
  82096. */
  82097. constructor(name: string);
  82098. /**
  82099. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  82100. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  82101. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  82102. * @returns the emitter
  82103. */
  82104. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  82105. /**
  82106. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  82107. * @param radius The radius of the hemisphere to emit from
  82108. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  82109. * @returns the emitter
  82110. */
  82111. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  82112. /**
  82113. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  82114. * @param radius The radius of the sphere to emit from
  82115. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  82116. * @returns the emitter
  82117. */
  82118. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  82119. /**
  82120. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  82121. * @param radius The radius of the sphere to emit from
  82122. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  82123. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  82124. * @returns the emitter
  82125. */
  82126. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  82127. /**
  82128. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  82129. * @param radius The radius of the emission cylinder
  82130. * @param height The height of the emission cylinder
  82131. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  82132. * @param directionRandomizer How much to randomize the particle direction [0-1]
  82133. * @returns the emitter
  82134. */
  82135. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  82136. /**
  82137. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  82138. * @param radius The radius of the cylinder to emit from
  82139. * @param height The height of the emission cylinder
  82140. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  82141. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  82142. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  82143. * @returns the emitter
  82144. */
  82145. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  82146. /**
  82147. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  82148. * @param radius The radius of the cone to emit from
  82149. * @param angle The base angle of the cone
  82150. * @returns the emitter
  82151. */
  82152. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  82153. /**
  82154. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  82155. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  82156. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  82157. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  82158. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  82159. * @returns the emitter
  82160. */
  82161. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  82162. }
  82163. }
  82164. declare module BABYLON {
  82165. /**
  82166. * Type of sub emitter
  82167. */
  82168. export enum SubEmitterType {
  82169. /**
  82170. * Attached to the particle over it's lifetime
  82171. */
  82172. ATTACHED = 0,
  82173. /**
  82174. * Created when the particle dies
  82175. */
  82176. END = 1
  82177. }
  82178. /**
  82179. * Sub emitter class used to emit particles from an existing particle
  82180. */
  82181. export class SubEmitter {
  82182. /**
  82183. * the particle system to be used by the sub emitter
  82184. */
  82185. particleSystem: ParticleSystem;
  82186. /**
  82187. * Type of the submitter (Default: END)
  82188. */
  82189. type: SubEmitterType;
  82190. /**
  82191. * 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)
  82192. * Note: This only is supported when using an emitter of type Mesh
  82193. */
  82194. inheritDirection: boolean;
  82195. /**
  82196. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  82197. */
  82198. inheritedVelocityAmount: number;
  82199. /**
  82200. * Creates a sub emitter
  82201. * @param particleSystem the particle system to be used by the sub emitter
  82202. */
  82203. constructor(
  82204. /**
  82205. * the particle system to be used by the sub emitter
  82206. */
  82207. particleSystem: ParticleSystem);
  82208. /**
  82209. * Clones the sub emitter
  82210. * @returns the cloned sub emitter
  82211. */
  82212. clone(): SubEmitter;
  82213. /**
  82214. * Serialize current object to a JSON object
  82215. * @returns the serialized object
  82216. */
  82217. serialize(): any;
  82218. /** @hidden */
  82219. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  82220. /**
  82221. * Creates a new SubEmitter from a serialized JSON version
  82222. * @param serializationObject defines the JSON object to read from
  82223. * @param scene defines the hosting scene
  82224. * @param rootUrl defines the rootUrl for data loading
  82225. * @returns a new SubEmitter
  82226. */
  82227. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  82228. /** Release associated resources */
  82229. dispose(): void;
  82230. }
  82231. }
  82232. declare module BABYLON {
  82233. /** @hidden */
  82234. export var clipPlaneFragmentDeclaration: {
  82235. name: string;
  82236. shader: string;
  82237. };
  82238. }
  82239. declare module BABYLON {
  82240. /** @hidden */
  82241. export var imageProcessingDeclaration: {
  82242. name: string;
  82243. shader: string;
  82244. };
  82245. }
  82246. declare module BABYLON {
  82247. /** @hidden */
  82248. export var imageProcessingFunctions: {
  82249. name: string;
  82250. shader: string;
  82251. };
  82252. }
  82253. declare module BABYLON {
  82254. /** @hidden */
  82255. export var clipPlaneFragment: {
  82256. name: string;
  82257. shader: string;
  82258. };
  82259. }
  82260. declare module BABYLON {
  82261. /** @hidden */
  82262. export var particlesPixelShader: {
  82263. name: string;
  82264. shader: string;
  82265. };
  82266. }
  82267. declare module BABYLON {
  82268. /** @hidden */
  82269. export var clipPlaneVertexDeclaration: {
  82270. name: string;
  82271. shader: string;
  82272. };
  82273. }
  82274. declare module BABYLON {
  82275. /** @hidden */
  82276. export var clipPlaneVertex: {
  82277. name: string;
  82278. shader: string;
  82279. };
  82280. }
  82281. declare module BABYLON {
  82282. /** @hidden */
  82283. export var particlesVertexShader: {
  82284. name: string;
  82285. shader: string;
  82286. };
  82287. }
  82288. declare module BABYLON {
  82289. /**
  82290. * This represents a particle system in Babylon.
  82291. * 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.
  82292. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  82293. * @example https://doc.babylonjs.com/babylon101/particles
  82294. */
  82295. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  82296. /**
  82297. * Billboard mode will only apply to Y axis
  82298. */
  82299. static readonly BILLBOARDMODE_Y: number;
  82300. /**
  82301. * Billboard mode will apply to all axes
  82302. */
  82303. static readonly BILLBOARDMODE_ALL: number;
  82304. /**
  82305. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  82306. */
  82307. static readonly BILLBOARDMODE_STRETCHED: number;
  82308. /**
  82309. * This function can be defined to provide custom update for active particles.
  82310. * This function will be called instead of regular update (age, position, color, etc.).
  82311. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  82312. */
  82313. updateFunction: (particles: Particle[]) => void;
  82314. private _emitterWorldMatrix;
  82315. /**
  82316. * This function can be defined to specify initial direction for every new particle.
  82317. * It by default use the emitterType defined function
  82318. */
  82319. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  82320. /**
  82321. * This function can be defined to specify initial position for every new particle.
  82322. * It by default use the emitterType defined function
  82323. */
  82324. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  82325. /**
  82326. * @hidden
  82327. */
  82328. _inheritedVelocityOffset: Vector3;
  82329. /**
  82330. * An event triggered when the system is disposed
  82331. */
  82332. onDisposeObservable: Observable<ParticleSystem>;
  82333. private _onDisposeObserver;
  82334. /**
  82335. * Sets a callback that will be triggered when the system is disposed
  82336. */
  82337. onDispose: () => void;
  82338. private _particles;
  82339. private _epsilon;
  82340. private _capacity;
  82341. private _stockParticles;
  82342. private _newPartsExcess;
  82343. private _vertexData;
  82344. private _vertexBuffer;
  82345. private _vertexBuffers;
  82346. private _spriteBuffer;
  82347. private _indexBuffer;
  82348. private _effect;
  82349. private _customEffect;
  82350. private _cachedDefines;
  82351. private _scaledColorStep;
  82352. private _colorDiff;
  82353. private _scaledDirection;
  82354. private _scaledGravity;
  82355. private _currentRenderId;
  82356. private _alive;
  82357. private _useInstancing;
  82358. private _started;
  82359. private _stopped;
  82360. private _actualFrame;
  82361. private _scaledUpdateSpeed;
  82362. private _vertexBufferSize;
  82363. /** @hidden */
  82364. _currentEmitRateGradient: Nullable<FactorGradient>;
  82365. /** @hidden */
  82366. _currentEmitRate1: number;
  82367. /** @hidden */
  82368. _currentEmitRate2: number;
  82369. /** @hidden */
  82370. _currentStartSizeGradient: Nullable<FactorGradient>;
  82371. /** @hidden */
  82372. _currentStartSize1: number;
  82373. /** @hidden */
  82374. _currentStartSize2: number;
  82375. private readonly _rawTextureWidth;
  82376. private _rampGradientsTexture;
  82377. private _useRampGradients;
  82378. /** Gets or sets a boolean indicating that ramp gradients must be used
  82379. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  82380. */
  82381. useRampGradients: boolean;
  82382. /**
  82383. * 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.
  82384. * 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: [])
  82385. */
  82386. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  82387. private _subEmitters;
  82388. /**
  82389. * @hidden
  82390. * If the particle systems emitter should be disposed when the particle system is disposed
  82391. */
  82392. _disposeEmitterOnDispose: boolean;
  82393. /**
  82394. * The current active Sub-systems, this property is used by the root particle system only.
  82395. */
  82396. activeSubSystems: Array<ParticleSystem>;
  82397. private _rootParticleSystem;
  82398. /**
  82399. * Gets the current list of active particles
  82400. */
  82401. readonly particles: Particle[];
  82402. /**
  82403. * Returns the string "ParticleSystem"
  82404. * @returns a string containing the class name
  82405. */
  82406. getClassName(): string;
  82407. /**
  82408. * Instantiates a particle system.
  82409. * 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.
  82410. * @param name The name of the particle system
  82411. * @param capacity The max number of particles alive at the same time
  82412. * @param scene The scene the particle system belongs to
  82413. * @param customEffect a custom effect used to change the way particles are rendered by default
  82414. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  82415. * @param epsilon Offset used to render the particles
  82416. */
  82417. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  82418. private _addFactorGradient;
  82419. private _removeFactorGradient;
  82420. /**
  82421. * Adds a new life time gradient
  82422. * @param gradient defines the gradient to use (between 0 and 1)
  82423. * @param factor defines the life time factor to affect to the specified gradient
  82424. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  82425. * @returns the current particle system
  82426. */
  82427. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  82428. /**
  82429. * Remove a specific life time gradient
  82430. * @param gradient defines the gradient to remove
  82431. * @returns the current particle system
  82432. */
  82433. removeLifeTimeGradient(gradient: number): IParticleSystem;
  82434. /**
  82435. * Adds a new size gradient
  82436. * @param gradient defines the gradient to use (between 0 and 1)
  82437. * @param factor defines the size factor to affect to the specified gradient
  82438. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  82439. * @returns the current particle system
  82440. */
  82441. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  82442. /**
  82443. * Remove a specific size gradient
  82444. * @param gradient defines the gradient to remove
  82445. * @returns the current particle system
  82446. */
  82447. removeSizeGradient(gradient: number): IParticleSystem;
  82448. /**
  82449. * Adds a new color remap gradient
  82450. * @param gradient defines the gradient to use (between 0 and 1)
  82451. * @param min defines the color remap minimal range
  82452. * @param max defines the color remap maximal range
  82453. * @returns the current particle system
  82454. */
  82455. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  82456. /**
  82457. * Remove a specific color remap gradient
  82458. * @param gradient defines the gradient to remove
  82459. * @returns the current particle system
  82460. */
  82461. removeColorRemapGradient(gradient: number): IParticleSystem;
  82462. /**
  82463. * Adds a new alpha remap gradient
  82464. * @param gradient defines the gradient to use (between 0 and 1)
  82465. * @param min defines the alpha remap minimal range
  82466. * @param max defines the alpha remap maximal range
  82467. * @returns the current particle system
  82468. */
  82469. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  82470. /**
  82471. * Remove a specific alpha remap gradient
  82472. * @param gradient defines the gradient to remove
  82473. * @returns the current particle system
  82474. */
  82475. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  82476. /**
  82477. * Adds a new angular speed gradient
  82478. * @param gradient defines the gradient to use (between 0 and 1)
  82479. * @param factor defines the angular speed to affect to the specified gradient
  82480. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  82481. * @returns the current particle system
  82482. */
  82483. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  82484. /**
  82485. * Remove a specific angular speed gradient
  82486. * @param gradient defines the gradient to remove
  82487. * @returns the current particle system
  82488. */
  82489. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  82490. /**
  82491. * Adds a new velocity gradient
  82492. * @param gradient defines the gradient to use (between 0 and 1)
  82493. * @param factor defines the velocity to affect to the specified gradient
  82494. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  82495. * @returns the current particle system
  82496. */
  82497. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  82498. /**
  82499. * Remove a specific velocity gradient
  82500. * @param gradient defines the gradient to remove
  82501. * @returns the current particle system
  82502. */
  82503. removeVelocityGradient(gradient: number): IParticleSystem;
  82504. /**
  82505. * Adds a new limit velocity gradient
  82506. * @param gradient defines the gradient to use (between 0 and 1)
  82507. * @param factor defines the limit velocity value to affect to the specified gradient
  82508. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  82509. * @returns the current particle system
  82510. */
  82511. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  82512. /**
  82513. * Remove a specific limit velocity gradient
  82514. * @param gradient defines the gradient to remove
  82515. * @returns the current particle system
  82516. */
  82517. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  82518. /**
  82519. * Adds a new drag gradient
  82520. * @param gradient defines the gradient to use (between 0 and 1)
  82521. * @param factor defines the drag value to affect to the specified gradient
  82522. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  82523. * @returns the current particle system
  82524. */
  82525. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  82526. /**
  82527. * Remove a specific drag gradient
  82528. * @param gradient defines the gradient to remove
  82529. * @returns the current particle system
  82530. */
  82531. removeDragGradient(gradient: number): IParticleSystem;
  82532. /**
  82533. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  82534. * @param gradient defines the gradient to use (between 0 and 1)
  82535. * @param factor defines the emit rate value to affect to the specified gradient
  82536. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  82537. * @returns the current particle system
  82538. */
  82539. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  82540. /**
  82541. * Remove a specific emit rate gradient
  82542. * @param gradient defines the gradient to remove
  82543. * @returns the current particle system
  82544. */
  82545. removeEmitRateGradient(gradient: number): IParticleSystem;
  82546. /**
  82547. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  82548. * @param gradient defines the gradient to use (between 0 and 1)
  82549. * @param factor defines the start size value to affect to the specified gradient
  82550. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  82551. * @returns the current particle system
  82552. */
  82553. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  82554. /**
  82555. * Remove a specific start size gradient
  82556. * @param gradient defines the gradient to remove
  82557. * @returns the current particle system
  82558. */
  82559. removeStartSizeGradient(gradient: number): IParticleSystem;
  82560. private _createRampGradientTexture;
  82561. /**
  82562. * Gets the current list of ramp gradients.
  82563. * You must use addRampGradient and removeRampGradient to udpate this list
  82564. * @returns the list of ramp gradients
  82565. */
  82566. getRampGradients(): Nullable<Array<Color3Gradient>>;
  82567. /**
  82568. * Adds a new ramp gradient used to remap particle colors
  82569. * @param gradient defines the gradient to use (between 0 and 1)
  82570. * @param color defines the color to affect to the specified gradient
  82571. * @returns the current particle system
  82572. */
  82573. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  82574. /**
  82575. * Remove a specific ramp gradient
  82576. * @param gradient defines the gradient to remove
  82577. * @returns the current particle system
  82578. */
  82579. removeRampGradient(gradient: number): ParticleSystem;
  82580. /**
  82581. * Adds a new color gradient
  82582. * @param gradient defines the gradient to use (between 0 and 1)
  82583. * @param color1 defines the color to affect to the specified gradient
  82584. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  82585. * @returns this particle system
  82586. */
  82587. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  82588. /**
  82589. * Remove a specific color gradient
  82590. * @param gradient defines the gradient to remove
  82591. * @returns this particle system
  82592. */
  82593. removeColorGradient(gradient: number): IParticleSystem;
  82594. private _fetchR;
  82595. protected _reset(): void;
  82596. private _resetEffect;
  82597. private _createVertexBuffers;
  82598. private _createIndexBuffer;
  82599. /**
  82600. * Gets the maximum number of particles active at the same time.
  82601. * @returns The max number of active particles.
  82602. */
  82603. getCapacity(): number;
  82604. /**
  82605. * Gets whether there are still active particles in the system.
  82606. * @returns True if it is alive, otherwise false.
  82607. */
  82608. isAlive(): boolean;
  82609. /**
  82610. * Gets if the system has been started. (Note: this will still be true after stop is called)
  82611. * @returns True if it has been started, otherwise false.
  82612. */
  82613. isStarted(): boolean;
  82614. private _prepareSubEmitterInternalArray;
  82615. /**
  82616. * Starts the particle system and begins to emit
  82617. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  82618. */
  82619. start(delay?: number): void;
  82620. /**
  82621. * Stops the particle system.
  82622. * @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.
  82623. */
  82624. stop(stopSubEmitters?: boolean): void;
  82625. /**
  82626. * Remove all active particles
  82627. */
  82628. reset(): void;
  82629. /**
  82630. * @hidden (for internal use only)
  82631. */
  82632. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  82633. /**
  82634. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  82635. * Its lifetime will start back at 0.
  82636. */
  82637. recycleParticle: (particle: Particle) => void;
  82638. private _stopSubEmitters;
  82639. private _createParticle;
  82640. private _removeFromRoot;
  82641. private _emitFromParticle;
  82642. private _update;
  82643. /** @hidden */
  82644. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  82645. /** @hidden */
  82646. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  82647. /** @hidden */
  82648. private _getEffect;
  82649. /**
  82650. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  82651. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  82652. */
  82653. animate(preWarmOnly?: boolean): void;
  82654. private _appendParticleVertices;
  82655. /**
  82656. * Rebuilds the particle system.
  82657. */
  82658. rebuild(): void;
  82659. /**
  82660. * Is this system ready to be used/rendered
  82661. * @return true if the system is ready
  82662. */
  82663. isReady(): boolean;
  82664. private _render;
  82665. /**
  82666. * Renders the particle system in its current state.
  82667. * @returns the current number of particles
  82668. */
  82669. render(): number;
  82670. /**
  82671. * Disposes the particle system and free the associated resources
  82672. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  82673. */
  82674. dispose(disposeTexture?: boolean): void;
  82675. /**
  82676. * Clones the particle system.
  82677. * @param name The name of the cloned object
  82678. * @param newEmitter The new emitter to use
  82679. * @returns the cloned particle system
  82680. */
  82681. clone(name: string, newEmitter: any): ParticleSystem;
  82682. /**
  82683. * Serializes the particle system to a JSON object.
  82684. * @returns the JSON object
  82685. */
  82686. serialize(): any;
  82687. /** @hidden */
  82688. static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  82689. /** @hidden */
  82690. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  82691. /**
  82692. * Parses a JSON object to create a particle system.
  82693. * @param parsedParticleSystem The JSON object to parse
  82694. * @param scene The scene to create the particle system in
  82695. * @param rootUrl The root url to use to load external dependencies like texture
  82696. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  82697. * @returns the Parsed particle system
  82698. */
  82699. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  82700. }
  82701. }
  82702. declare module BABYLON {
  82703. /**
  82704. * A particle represents one of the element emitted by a particle system.
  82705. * This is mainly define by its coordinates, direction, velocity and age.
  82706. */
  82707. export class Particle {
  82708. /**
  82709. * The particle system the particle belongs to.
  82710. */
  82711. particleSystem: ParticleSystem;
  82712. private static _Count;
  82713. /**
  82714. * Unique ID of the particle
  82715. */
  82716. id: number;
  82717. /**
  82718. * The world position of the particle in the scene.
  82719. */
  82720. position: Vector3;
  82721. /**
  82722. * The world direction of the particle in the scene.
  82723. */
  82724. direction: Vector3;
  82725. /**
  82726. * The color of the particle.
  82727. */
  82728. color: Color4;
  82729. /**
  82730. * The color change of the particle per step.
  82731. */
  82732. colorStep: Color4;
  82733. /**
  82734. * Defines how long will the life of the particle be.
  82735. */
  82736. lifeTime: number;
  82737. /**
  82738. * The current age of the particle.
  82739. */
  82740. age: number;
  82741. /**
  82742. * The current size of the particle.
  82743. */
  82744. size: number;
  82745. /**
  82746. * The current scale of the particle.
  82747. */
  82748. scale: Vector2;
  82749. /**
  82750. * The current angle of the particle.
  82751. */
  82752. angle: number;
  82753. /**
  82754. * Defines how fast is the angle changing.
  82755. */
  82756. angularSpeed: number;
  82757. /**
  82758. * Defines the cell index used by the particle to be rendered from a sprite.
  82759. */
  82760. cellIndex: number;
  82761. /**
  82762. * The information required to support color remapping
  82763. */
  82764. remapData: Vector4;
  82765. /** @hidden */
  82766. _randomCellOffset?: number;
  82767. /** @hidden */
  82768. _initialDirection: Nullable<Vector3>;
  82769. /** @hidden */
  82770. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  82771. /** @hidden */
  82772. _initialStartSpriteCellID: number;
  82773. /** @hidden */
  82774. _initialEndSpriteCellID: number;
  82775. /** @hidden */
  82776. _currentColorGradient: Nullable<ColorGradient>;
  82777. /** @hidden */
  82778. _currentColor1: Color4;
  82779. /** @hidden */
  82780. _currentColor2: Color4;
  82781. /** @hidden */
  82782. _currentSizeGradient: Nullable<FactorGradient>;
  82783. /** @hidden */
  82784. _currentSize1: number;
  82785. /** @hidden */
  82786. _currentSize2: number;
  82787. /** @hidden */
  82788. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  82789. /** @hidden */
  82790. _currentAngularSpeed1: number;
  82791. /** @hidden */
  82792. _currentAngularSpeed2: number;
  82793. /** @hidden */
  82794. _currentVelocityGradient: Nullable<FactorGradient>;
  82795. /** @hidden */
  82796. _currentVelocity1: number;
  82797. /** @hidden */
  82798. _currentVelocity2: number;
  82799. /** @hidden */
  82800. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  82801. /** @hidden */
  82802. _currentLimitVelocity1: number;
  82803. /** @hidden */
  82804. _currentLimitVelocity2: number;
  82805. /** @hidden */
  82806. _currentDragGradient: Nullable<FactorGradient>;
  82807. /** @hidden */
  82808. _currentDrag1: number;
  82809. /** @hidden */
  82810. _currentDrag2: number;
  82811. /** @hidden */
  82812. _randomNoiseCoordinates1: Vector3;
  82813. /** @hidden */
  82814. _randomNoiseCoordinates2: Vector3;
  82815. /**
  82816. * Creates a new instance Particle
  82817. * @param particleSystem the particle system the particle belongs to
  82818. */
  82819. constructor(
  82820. /**
  82821. * The particle system the particle belongs to.
  82822. */
  82823. particleSystem: ParticleSystem);
  82824. private updateCellInfoFromSystem;
  82825. /**
  82826. * Defines how the sprite cell index is updated for the particle
  82827. */
  82828. updateCellIndex(): void;
  82829. /** @hidden */
  82830. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  82831. /** @hidden */
  82832. _inheritParticleInfoToSubEmitters(): void;
  82833. /** @hidden */
  82834. _reset(): void;
  82835. /**
  82836. * Copy the properties of particle to another one.
  82837. * @param other the particle to copy the information to.
  82838. */
  82839. copyTo(other: Particle): void;
  82840. }
  82841. }
  82842. declare module BABYLON {
  82843. /**
  82844. * Particle emitter represents a volume emitting particles.
  82845. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  82846. */
  82847. export interface IParticleEmitterType {
  82848. /**
  82849. * Called by the particle System when the direction is computed for the created particle.
  82850. * @param worldMatrix is the world matrix of the particle system
  82851. * @param directionToUpdate is the direction vector to update with the result
  82852. * @param particle is the particle we are computed the direction for
  82853. */
  82854. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  82855. /**
  82856. * Called by the particle System when the position is computed for the created particle.
  82857. * @param worldMatrix is the world matrix of the particle system
  82858. * @param positionToUpdate is the position vector to update with the result
  82859. * @param particle is the particle we are computed the position for
  82860. */
  82861. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  82862. /**
  82863. * Clones the current emitter and returns a copy of it
  82864. * @returns the new emitter
  82865. */
  82866. clone(): IParticleEmitterType;
  82867. /**
  82868. * Called by the GPUParticleSystem to setup the update shader
  82869. * @param effect defines the update shader
  82870. */
  82871. applyToShader(effect: Effect): void;
  82872. /**
  82873. * Returns a string to use to update the GPU particles update shader
  82874. * @returns the effect defines string
  82875. */
  82876. getEffectDefines(): string;
  82877. /**
  82878. * Returns a string representing the class name
  82879. * @returns a string containing the class name
  82880. */
  82881. getClassName(): string;
  82882. /**
  82883. * Serializes the particle system to a JSON object.
  82884. * @returns the JSON object
  82885. */
  82886. serialize(): any;
  82887. /**
  82888. * Parse properties from a JSON object
  82889. * @param serializationObject defines the JSON object
  82890. */
  82891. parse(serializationObject: any): void;
  82892. }
  82893. }
  82894. declare module BABYLON {
  82895. /**
  82896. * Particle emitter emitting particles from the inside of a box.
  82897. * It emits the particles randomly between 2 given directions.
  82898. */
  82899. export class BoxParticleEmitter implements IParticleEmitterType {
  82900. /**
  82901. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  82902. */
  82903. direction1: Vector3;
  82904. /**
  82905. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  82906. */
  82907. direction2: Vector3;
  82908. /**
  82909. * 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.
  82910. */
  82911. minEmitBox: Vector3;
  82912. /**
  82913. * 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.
  82914. */
  82915. maxEmitBox: Vector3;
  82916. /**
  82917. * Creates a new instance BoxParticleEmitter
  82918. */
  82919. constructor();
  82920. /**
  82921. * Called by the particle System when the direction is computed for the created particle.
  82922. * @param worldMatrix is the world matrix of the particle system
  82923. * @param directionToUpdate is the direction vector to update with the result
  82924. * @param particle is the particle we are computed the direction for
  82925. */
  82926. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  82927. /**
  82928. * Called by the particle System when the position is computed for the created particle.
  82929. * @param worldMatrix is the world matrix of the particle system
  82930. * @param positionToUpdate is the position vector to update with the result
  82931. * @param particle is the particle we are computed the position for
  82932. */
  82933. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  82934. /**
  82935. * Clones the current emitter and returns a copy of it
  82936. * @returns the new emitter
  82937. */
  82938. clone(): BoxParticleEmitter;
  82939. /**
  82940. * Called by the GPUParticleSystem to setup the update shader
  82941. * @param effect defines the update shader
  82942. */
  82943. applyToShader(effect: Effect): void;
  82944. /**
  82945. * Returns a string to use to update the GPU particles update shader
  82946. * @returns a string containng the defines string
  82947. */
  82948. getEffectDefines(): string;
  82949. /**
  82950. * Returns the string "BoxParticleEmitter"
  82951. * @returns a string containing the class name
  82952. */
  82953. getClassName(): string;
  82954. /**
  82955. * Serializes the particle system to a JSON object.
  82956. * @returns the JSON object
  82957. */
  82958. serialize(): any;
  82959. /**
  82960. * Parse properties from a JSON object
  82961. * @param serializationObject defines the JSON object
  82962. */
  82963. parse(serializationObject: any): void;
  82964. }
  82965. }
  82966. declare module BABYLON {
  82967. /**
  82968. * Particle emitter emitting particles from the inside of a cone.
  82969. * It emits the particles alongside the cone volume from the base to the particle.
  82970. * The emission direction might be randomized.
  82971. */
  82972. export class ConeParticleEmitter implements IParticleEmitterType {
  82973. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  82974. directionRandomizer: number;
  82975. private _radius;
  82976. private _angle;
  82977. private _height;
  82978. /**
  82979. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  82980. */
  82981. radiusRange: number;
  82982. /**
  82983. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  82984. */
  82985. heightRange: number;
  82986. /**
  82987. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  82988. */
  82989. emitFromSpawnPointOnly: boolean;
  82990. /**
  82991. * Gets or sets the radius of the emission cone
  82992. */
  82993. radius: number;
  82994. /**
  82995. * Gets or sets the angle of the emission cone
  82996. */
  82997. angle: number;
  82998. private _buildHeight;
  82999. /**
  83000. * Creates a new instance ConeParticleEmitter
  83001. * @param radius the radius of the emission cone (1 by default)
  83002. * @param angle the cone base angle (PI by default)
  83003. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  83004. */
  83005. constructor(radius?: number, angle?: number,
  83006. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  83007. directionRandomizer?: number);
  83008. /**
  83009. * Called by the particle System when the direction is computed for the created particle.
  83010. * @param worldMatrix is the world matrix of the particle system
  83011. * @param directionToUpdate is the direction vector to update with the result
  83012. * @param particle is the particle we are computed the direction for
  83013. */
  83014. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  83015. /**
  83016. * Called by the particle System when the position is computed for the created particle.
  83017. * @param worldMatrix is the world matrix of the particle system
  83018. * @param positionToUpdate is the position vector to update with the result
  83019. * @param particle is the particle we are computed the position for
  83020. */
  83021. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  83022. /**
  83023. * Clones the current emitter and returns a copy of it
  83024. * @returns the new emitter
  83025. */
  83026. clone(): ConeParticleEmitter;
  83027. /**
  83028. * Called by the GPUParticleSystem to setup the update shader
  83029. * @param effect defines the update shader
  83030. */
  83031. applyToShader(effect: Effect): void;
  83032. /**
  83033. * Returns a string to use to update the GPU particles update shader
  83034. * @returns a string containng the defines string
  83035. */
  83036. getEffectDefines(): string;
  83037. /**
  83038. * Returns the string "ConeParticleEmitter"
  83039. * @returns a string containing the class name
  83040. */
  83041. getClassName(): string;
  83042. /**
  83043. * Serializes the particle system to a JSON object.
  83044. * @returns the JSON object
  83045. */
  83046. serialize(): any;
  83047. /**
  83048. * Parse properties from a JSON object
  83049. * @param serializationObject defines the JSON object
  83050. */
  83051. parse(serializationObject: any): void;
  83052. }
  83053. }
  83054. declare module BABYLON {
  83055. /**
  83056. * Particle emitter emitting particles from the inside of a cylinder.
  83057. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  83058. */
  83059. export class CylinderParticleEmitter implements IParticleEmitterType {
  83060. /**
  83061. * The radius of the emission cylinder.
  83062. */
  83063. radius: number;
  83064. /**
  83065. * The height of the emission cylinder.
  83066. */
  83067. height: number;
  83068. /**
  83069. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  83070. */
  83071. radiusRange: number;
  83072. /**
  83073. * How much to randomize the particle direction [0-1].
  83074. */
  83075. directionRandomizer: number;
  83076. /**
  83077. * Creates a new instance CylinderParticleEmitter
  83078. * @param radius the radius of the emission cylinder (1 by default)
  83079. * @param height the height of the emission cylinder (1 by default)
  83080. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  83081. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  83082. */
  83083. constructor(
  83084. /**
  83085. * The radius of the emission cylinder.
  83086. */
  83087. radius?: number,
  83088. /**
  83089. * The height of the emission cylinder.
  83090. */
  83091. height?: number,
  83092. /**
  83093. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  83094. */
  83095. radiusRange?: number,
  83096. /**
  83097. * How much to randomize the particle direction [0-1].
  83098. */
  83099. directionRandomizer?: number);
  83100. /**
  83101. * Called by the particle System when the direction is computed for the created particle.
  83102. * @param worldMatrix is the world matrix of the particle system
  83103. * @param directionToUpdate is the direction vector to update with the result
  83104. * @param particle is the particle we are computed the direction for
  83105. */
  83106. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  83107. /**
  83108. * Called by the particle System when the position is computed for the created particle.
  83109. * @param worldMatrix is the world matrix of the particle system
  83110. * @param positionToUpdate is the position vector to update with the result
  83111. * @param particle is the particle we are computed the position for
  83112. */
  83113. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  83114. /**
  83115. * Clones the current emitter and returns a copy of it
  83116. * @returns the new emitter
  83117. */
  83118. clone(): CylinderParticleEmitter;
  83119. /**
  83120. * Called by the GPUParticleSystem to setup the update shader
  83121. * @param effect defines the update shader
  83122. */
  83123. applyToShader(effect: Effect): void;
  83124. /**
  83125. * Returns a string to use to update the GPU particles update shader
  83126. * @returns a string containng the defines string
  83127. */
  83128. getEffectDefines(): string;
  83129. /**
  83130. * Returns the string "CylinderParticleEmitter"
  83131. * @returns a string containing the class name
  83132. */
  83133. getClassName(): string;
  83134. /**
  83135. * Serializes the particle system to a JSON object.
  83136. * @returns the JSON object
  83137. */
  83138. serialize(): any;
  83139. /**
  83140. * Parse properties from a JSON object
  83141. * @param serializationObject defines the JSON object
  83142. */
  83143. parse(serializationObject: any): void;
  83144. }
  83145. /**
  83146. * Particle emitter emitting particles from the inside of a cylinder.
  83147. * It emits the particles randomly between two vectors.
  83148. */
  83149. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  83150. /**
  83151. * The min limit of the emission direction.
  83152. */
  83153. direction1: Vector3;
  83154. /**
  83155. * The max limit of the emission direction.
  83156. */
  83157. direction2: Vector3;
  83158. /**
  83159. * Creates a new instance CylinderDirectedParticleEmitter
  83160. * @param radius the radius of the emission cylinder (1 by default)
  83161. * @param height the height of the emission cylinder (1 by default)
  83162. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  83163. * @param direction1 the min limit of the emission direction (up vector by default)
  83164. * @param direction2 the max limit of the emission direction (up vector by default)
  83165. */
  83166. constructor(radius?: number, height?: number, radiusRange?: number,
  83167. /**
  83168. * The min limit of the emission direction.
  83169. */
  83170. direction1?: Vector3,
  83171. /**
  83172. * The max limit of the emission direction.
  83173. */
  83174. direction2?: Vector3);
  83175. /**
  83176. * Called by the particle System when the direction is computed for the created particle.
  83177. * @param worldMatrix is the world matrix of the particle system
  83178. * @param directionToUpdate is the direction vector to update with the result
  83179. * @param particle is the particle we are computed the direction for
  83180. */
  83181. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  83182. /**
  83183. * Clones the current emitter and returns a copy of it
  83184. * @returns the new emitter
  83185. */
  83186. clone(): CylinderDirectedParticleEmitter;
  83187. /**
  83188. * Called by the GPUParticleSystem to setup the update shader
  83189. * @param effect defines the update shader
  83190. */
  83191. applyToShader(effect: Effect): void;
  83192. /**
  83193. * Returns a string to use to update the GPU particles update shader
  83194. * @returns a string containng the defines string
  83195. */
  83196. getEffectDefines(): string;
  83197. /**
  83198. * Returns the string "CylinderDirectedParticleEmitter"
  83199. * @returns a string containing the class name
  83200. */
  83201. getClassName(): string;
  83202. /**
  83203. * Serializes the particle system to a JSON object.
  83204. * @returns the JSON object
  83205. */
  83206. serialize(): any;
  83207. /**
  83208. * Parse properties from a JSON object
  83209. * @param serializationObject defines the JSON object
  83210. */
  83211. parse(serializationObject: any): void;
  83212. }
  83213. }
  83214. declare module BABYLON {
  83215. /**
  83216. * Particle emitter emitting particles from the inside of a hemisphere.
  83217. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  83218. */
  83219. export class HemisphericParticleEmitter implements IParticleEmitterType {
  83220. /**
  83221. * The radius of the emission hemisphere.
  83222. */
  83223. radius: number;
  83224. /**
  83225. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  83226. */
  83227. radiusRange: number;
  83228. /**
  83229. * How much to randomize the particle direction [0-1].
  83230. */
  83231. directionRandomizer: number;
  83232. /**
  83233. * Creates a new instance HemisphericParticleEmitter
  83234. * @param radius the radius of the emission hemisphere (1 by default)
  83235. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  83236. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  83237. */
  83238. constructor(
  83239. /**
  83240. * The radius of the emission hemisphere.
  83241. */
  83242. radius?: number,
  83243. /**
  83244. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  83245. */
  83246. radiusRange?: number,
  83247. /**
  83248. * How much to randomize the particle direction [0-1].
  83249. */
  83250. directionRandomizer?: number);
  83251. /**
  83252. * Called by the particle System when the direction is computed for the created particle.
  83253. * @param worldMatrix is the world matrix of the particle system
  83254. * @param directionToUpdate is the direction vector to update with the result
  83255. * @param particle is the particle we are computed the direction for
  83256. */
  83257. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  83258. /**
  83259. * Called by the particle System when the position is computed for the created particle.
  83260. * @param worldMatrix is the world matrix of the particle system
  83261. * @param positionToUpdate is the position vector to update with the result
  83262. * @param particle is the particle we are computed the position for
  83263. */
  83264. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  83265. /**
  83266. * Clones the current emitter and returns a copy of it
  83267. * @returns the new emitter
  83268. */
  83269. clone(): HemisphericParticleEmitter;
  83270. /**
  83271. * Called by the GPUParticleSystem to setup the update shader
  83272. * @param effect defines the update shader
  83273. */
  83274. applyToShader(effect: Effect): void;
  83275. /**
  83276. * Returns a string to use to update the GPU particles update shader
  83277. * @returns a string containng the defines string
  83278. */
  83279. getEffectDefines(): string;
  83280. /**
  83281. * Returns the string "HemisphericParticleEmitter"
  83282. * @returns a string containing the class name
  83283. */
  83284. getClassName(): string;
  83285. /**
  83286. * Serializes the particle system to a JSON object.
  83287. * @returns the JSON object
  83288. */
  83289. serialize(): any;
  83290. /**
  83291. * Parse properties from a JSON object
  83292. * @param serializationObject defines the JSON object
  83293. */
  83294. parse(serializationObject: any): void;
  83295. }
  83296. }
  83297. declare module BABYLON {
  83298. /**
  83299. * Particle emitter emitting particles from a point.
  83300. * It emits the particles randomly between 2 given directions.
  83301. */
  83302. export class PointParticleEmitter implements IParticleEmitterType {
  83303. /**
  83304. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  83305. */
  83306. direction1: Vector3;
  83307. /**
  83308. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  83309. */
  83310. direction2: Vector3;
  83311. /**
  83312. * Creates a new instance PointParticleEmitter
  83313. */
  83314. constructor();
  83315. /**
  83316. * Called by the particle System when the direction is computed for the created particle.
  83317. * @param worldMatrix is the world matrix of the particle system
  83318. * @param directionToUpdate is the direction vector to update with the result
  83319. * @param particle is the particle we are computed the direction for
  83320. */
  83321. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  83322. /**
  83323. * Called by the particle System when the position is computed for the created particle.
  83324. * @param worldMatrix is the world matrix of the particle system
  83325. * @param positionToUpdate is the position vector to update with the result
  83326. * @param particle is the particle we are computed the position for
  83327. */
  83328. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  83329. /**
  83330. * Clones the current emitter and returns a copy of it
  83331. * @returns the new emitter
  83332. */
  83333. clone(): PointParticleEmitter;
  83334. /**
  83335. * Called by the GPUParticleSystem to setup the update shader
  83336. * @param effect defines the update shader
  83337. */
  83338. applyToShader(effect: Effect): void;
  83339. /**
  83340. * Returns a string to use to update the GPU particles update shader
  83341. * @returns a string containng the defines string
  83342. */
  83343. getEffectDefines(): string;
  83344. /**
  83345. * Returns the string "PointParticleEmitter"
  83346. * @returns a string containing the class name
  83347. */
  83348. getClassName(): string;
  83349. /**
  83350. * Serializes the particle system to a JSON object.
  83351. * @returns the JSON object
  83352. */
  83353. serialize(): any;
  83354. /**
  83355. * Parse properties from a JSON object
  83356. * @param serializationObject defines the JSON object
  83357. */
  83358. parse(serializationObject: any): void;
  83359. }
  83360. }
  83361. declare module BABYLON {
  83362. /**
  83363. * Particle emitter emitting particles from the inside of a sphere.
  83364. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  83365. */
  83366. export class SphereParticleEmitter implements IParticleEmitterType {
  83367. /**
  83368. * The radius of the emission sphere.
  83369. */
  83370. radius: number;
  83371. /**
  83372. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  83373. */
  83374. radiusRange: number;
  83375. /**
  83376. * How much to randomize the particle direction [0-1].
  83377. */
  83378. directionRandomizer: number;
  83379. /**
  83380. * Creates a new instance SphereParticleEmitter
  83381. * @param radius the radius of the emission sphere (1 by default)
  83382. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  83383. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  83384. */
  83385. constructor(
  83386. /**
  83387. * The radius of the emission sphere.
  83388. */
  83389. radius?: number,
  83390. /**
  83391. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  83392. */
  83393. radiusRange?: number,
  83394. /**
  83395. * How much to randomize the particle direction [0-1].
  83396. */
  83397. directionRandomizer?: number);
  83398. /**
  83399. * Called by the particle System when the direction is computed for the created particle.
  83400. * @param worldMatrix is the world matrix of the particle system
  83401. * @param directionToUpdate is the direction vector to update with the result
  83402. * @param particle is the particle we are computed the direction for
  83403. */
  83404. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  83405. /**
  83406. * Called by the particle System when the position is computed for the created particle.
  83407. * @param worldMatrix is the world matrix of the particle system
  83408. * @param positionToUpdate is the position vector to update with the result
  83409. * @param particle is the particle we are computed the position for
  83410. */
  83411. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  83412. /**
  83413. * Clones the current emitter and returns a copy of it
  83414. * @returns the new emitter
  83415. */
  83416. clone(): SphereParticleEmitter;
  83417. /**
  83418. * Called by the GPUParticleSystem to setup the update shader
  83419. * @param effect defines the update shader
  83420. */
  83421. applyToShader(effect: Effect): void;
  83422. /**
  83423. * Returns a string to use to update the GPU particles update shader
  83424. * @returns a string containng the defines string
  83425. */
  83426. getEffectDefines(): string;
  83427. /**
  83428. * Returns the string "SphereParticleEmitter"
  83429. * @returns a string containing the class name
  83430. */
  83431. getClassName(): string;
  83432. /**
  83433. * Serializes the particle system to a JSON object.
  83434. * @returns the JSON object
  83435. */
  83436. serialize(): any;
  83437. /**
  83438. * Parse properties from a JSON object
  83439. * @param serializationObject defines the JSON object
  83440. */
  83441. parse(serializationObject: any): void;
  83442. }
  83443. /**
  83444. * Particle emitter emitting particles from the inside of a sphere.
  83445. * It emits the particles randomly between two vectors.
  83446. */
  83447. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  83448. /**
  83449. * The min limit of the emission direction.
  83450. */
  83451. direction1: Vector3;
  83452. /**
  83453. * The max limit of the emission direction.
  83454. */
  83455. direction2: Vector3;
  83456. /**
  83457. * Creates a new instance SphereDirectedParticleEmitter
  83458. * @param radius the radius of the emission sphere (1 by default)
  83459. * @param direction1 the min limit of the emission direction (up vector by default)
  83460. * @param direction2 the max limit of the emission direction (up vector by default)
  83461. */
  83462. constructor(radius?: number,
  83463. /**
  83464. * The min limit of the emission direction.
  83465. */
  83466. direction1?: Vector3,
  83467. /**
  83468. * The max limit of the emission direction.
  83469. */
  83470. direction2?: Vector3);
  83471. /**
  83472. * Called by the particle System when the direction is computed for the created particle.
  83473. * @param worldMatrix is the world matrix of the particle system
  83474. * @param directionToUpdate is the direction vector to update with the result
  83475. * @param particle is the particle we are computed the direction for
  83476. */
  83477. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  83478. /**
  83479. * Clones the current emitter and returns a copy of it
  83480. * @returns the new emitter
  83481. */
  83482. clone(): SphereDirectedParticleEmitter;
  83483. /**
  83484. * Called by the GPUParticleSystem to setup the update shader
  83485. * @param effect defines the update shader
  83486. */
  83487. applyToShader(effect: Effect): void;
  83488. /**
  83489. * Returns a string to use to update the GPU particles update shader
  83490. * @returns a string containng the defines string
  83491. */
  83492. getEffectDefines(): string;
  83493. /**
  83494. * Returns the string "SphereDirectedParticleEmitter"
  83495. * @returns a string containing the class name
  83496. */
  83497. getClassName(): string;
  83498. /**
  83499. * Serializes the particle system to a JSON object.
  83500. * @returns the JSON object
  83501. */
  83502. serialize(): any;
  83503. /**
  83504. * Parse properties from a JSON object
  83505. * @param serializationObject defines the JSON object
  83506. */
  83507. parse(serializationObject: any): void;
  83508. }
  83509. }
  83510. declare module BABYLON {
  83511. /**
  83512. * Interface representing a particle system in Babylon.js.
  83513. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  83514. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  83515. */
  83516. export interface IParticleSystem {
  83517. /**
  83518. * List of animations used by the particle system.
  83519. */
  83520. animations: Animation[];
  83521. /**
  83522. * The id of the Particle system.
  83523. */
  83524. id: string;
  83525. /**
  83526. * The name of the Particle system.
  83527. */
  83528. name: string;
  83529. /**
  83530. * The emitter represents the Mesh or position we are attaching the particle system to.
  83531. */
  83532. emitter: Nullable<AbstractMesh | Vector3>;
  83533. /**
  83534. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  83535. */
  83536. isBillboardBased: boolean;
  83537. /**
  83538. * The rendering group used by the Particle system to chose when to render.
  83539. */
  83540. renderingGroupId: number;
  83541. /**
  83542. * The layer mask we are rendering the particles through.
  83543. */
  83544. layerMask: number;
  83545. /**
  83546. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  83547. */
  83548. updateSpeed: number;
  83549. /**
  83550. * The amount of time the particle system is running (depends of the overall update speed).
  83551. */
  83552. targetStopDuration: number;
  83553. /**
  83554. * The texture used to render each particle. (this can be a spritesheet)
  83555. */
  83556. particleTexture: Nullable<Texture>;
  83557. /**
  83558. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  83559. */
  83560. blendMode: number;
  83561. /**
  83562. * Minimum life time of emitting particles.
  83563. */
  83564. minLifeTime: number;
  83565. /**
  83566. * Maximum life time of emitting particles.
  83567. */
  83568. maxLifeTime: number;
  83569. /**
  83570. * Minimum Size of emitting particles.
  83571. */
  83572. minSize: number;
  83573. /**
  83574. * Maximum Size of emitting particles.
  83575. */
  83576. maxSize: number;
  83577. /**
  83578. * Minimum scale of emitting particles on X axis.
  83579. */
  83580. minScaleX: number;
  83581. /**
  83582. * Maximum scale of emitting particles on X axis.
  83583. */
  83584. maxScaleX: number;
  83585. /**
  83586. * Minimum scale of emitting particles on Y axis.
  83587. */
  83588. minScaleY: number;
  83589. /**
  83590. * Maximum scale of emitting particles on Y axis.
  83591. */
  83592. maxScaleY: number;
  83593. /**
  83594. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  83595. */
  83596. color1: Color4;
  83597. /**
  83598. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  83599. */
  83600. color2: Color4;
  83601. /**
  83602. * Color the particle will have at the end of its lifetime.
  83603. */
  83604. colorDead: Color4;
  83605. /**
  83606. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  83607. */
  83608. emitRate: number;
  83609. /**
  83610. * You can use gravity if you want to give an orientation to your particles.
  83611. */
  83612. gravity: Vector3;
  83613. /**
  83614. * Minimum power of emitting particles.
  83615. */
  83616. minEmitPower: number;
  83617. /**
  83618. * Maximum power of emitting particles.
  83619. */
  83620. maxEmitPower: number;
  83621. /**
  83622. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  83623. */
  83624. minAngularSpeed: number;
  83625. /**
  83626. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  83627. */
  83628. maxAngularSpeed: number;
  83629. /**
  83630. * Gets or sets the minimal initial rotation in radians.
  83631. */
  83632. minInitialRotation: number;
  83633. /**
  83634. * Gets or sets the maximal initial rotation in radians.
  83635. */
  83636. maxInitialRotation: number;
  83637. /**
  83638. * The particle emitter type defines the emitter used by the particle system.
  83639. * It can be for example box, sphere, or cone...
  83640. */
  83641. particleEmitterType: Nullable<IParticleEmitterType>;
  83642. /**
  83643. * Defines the delay in milliseconds before starting the system (0 by default)
  83644. */
  83645. startDelay: number;
  83646. /**
  83647. * 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
  83648. */
  83649. preWarmCycles: number;
  83650. /**
  83651. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  83652. */
  83653. preWarmStepOffset: number;
  83654. /**
  83655. * 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)
  83656. */
  83657. spriteCellChangeSpeed: number;
  83658. /**
  83659. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  83660. */
  83661. startSpriteCellID: number;
  83662. /**
  83663. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  83664. */
  83665. endSpriteCellID: number;
  83666. /**
  83667. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  83668. */
  83669. spriteCellWidth: number;
  83670. /**
  83671. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  83672. */
  83673. spriteCellHeight: number;
  83674. /**
  83675. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  83676. */
  83677. spriteRandomStartCell: boolean;
  83678. /**
  83679. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  83680. */
  83681. isAnimationSheetEnabled: boolean;
  83682. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  83683. translationPivot: Vector2;
  83684. /**
  83685. * Gets or sets a texture used to add random noise to particle positions
  83686. */
  83687. noiseTexture: Nullable<BaseTexture>;
  83688. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  83689. noiseStrength: Vector3;
  83690. /**
  83691. * Gets or sets the billboard mode to use when isBillboardBased = true.
  83692. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  83693. */
  83694. billboardMode: number;
  83695. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  83696. limitVelocityDamping: number;
  83697. /**
  83698. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  83699. */
  83700. beginAnimationOnStart: boolean;
  83701. /**
  83702. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  83703. */
  83704. beginAnimationFrom: number;
  83705. /**
  83706. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  83707. */
  83708. beginAnimationTo: number;
  83709. /**
  83710. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  83711. */
  83712. beginAnimationLoop: boolean;
  83713. /**
  83714. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  83715. */
  83716. disposeOnStop: boolean;
  83717. /**
  83718. * Gets the maximum number of particles active at the same time.
  83719. * @returns The max number of active particles.
  83720. */
  83721. getCapacity(): number;
  83722. /**
  83723. * Gets if the system has been started. (Note: this will still be true after stop is called)
  83724. * @returns True if it has been started, otherwise false.
  83725. */
  83726. isStarted(): boolean;
  83727. /**
  83728. * Animates the particle system for this frame.
  83729. */
  83730. animate(): void;
  83731. /**
  83732. * Renders the particle system in its current state.
  83733. * @returns the current number of particles
  83734. */
  83735. render(): number;
  83736. /**
  83737. * Dispose the particle system and frees its associated resources.
  83738. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  83739. */
  83740. dispose(disposeTexture?: boolean): void;
  83741. /**
  83742. * Clones the particle system.
  83743. * @param name The name of the cloned object
  83744. * @param newEmitter The new emitter to use
  83745. * @returns the cloned particle system
  83746. */
  83747. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  83748. /**
  83749. * Serializes the particle system to a JSON object.
  83750. * @returns the JSON object
  83751. */
  83752. serialize(): any;
  83753. /**
  83754. * Rebuild the particle system
  83755. */
  83756. rebuild(): void;
  83757. /**
  83758. * Starts the particle system and begins to emit
  83759. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  83760. */
  83761. start(delay?: number): void;
  83762. /**
  83763. * Stops the particle system.
  83764. */
  83765. stop(): void;
  83766. /**
  83767. * Remove all active particles
  83768. */
  83769. reset(): void;
  83770. /**
  83771. * Is this system ready to be used/rendered
  83772. * @return true if the system is ready
  83773. */
  83774. isReady(): boolean;
  83775. /**
  83776. * Adds a new color gradient
  83777. * @param gradient defines the gradient to use (between 0 and 1)
  83778. * @param color1 defines the color to affect to the specified gradient
  83779. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  83780. * @returns the current particle system
  83781. */
  83782. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  83783. /**
  83784. * Remove a specific color gradient
  83785. * @param gradient defines the gradient to remove
  83786. * @returns the current particle system
  83787. */
  83788. removeColorGradient(gradient: number): IParticleSystem;
  83789. /**
  83790. * Adds a new size gradient
  83791. * @param gradient defines the gradient to use (between 0 and 1)
  83792. * @param factor defines the size factor to affect to the specified gradient
  83793. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  83794. * @returns the current particle system
  83795. */
  83796. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  83797. /**
  83798. * Remove a specific size gradient
  83799. * @param gradient defines the gradient to remove
  83800. * @returns the current particle system
  83801. */
  83802. removeSizeGradient(gradient: number): IParticleSystem;
  83803. /**
  83804. * Gets the current list of color gradients.
  83805. * You must use addColorGradient and removeColorGradient to udpate this list
  83806. * @returns the list of color gradients
  83807. */
  83808. getColorGradients(): Nullable<Array<ColorGradient>>;
  83809. /**
  83810. * Gets the current list of size gradients.
  83811. * You must use addSizeGradient and removeSizeGradient to udpate this list
  83812. * @returns the list of size gradients
  83813. */
  83814. getSizeGradients(): Nullable<Array<FactorGradient>>;
  83815. /**
  83816. * Gets the current list of angular speed gradients.
  83817. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  83818. * @returns the list of angular speed gradients
  83819. */
  83820. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  83821. /**
  83822. * Adds a new angular speed gradient
  83823. * @param gradient defines the gradient to use (between 0 and 1)
  83824. * @param factor defines the angular speed to affect to the specified gradient
  83825. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  83826. * @returns the current particle system
  83827. */
  83828. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  83829. /**
  83830. * Remove a specific angular speed gradient
  83831. * @param gradient defines the gradient to remove
  83832. * @returns the current particle system
  83833. */
  83834. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  83835. /**
  83836. * Gets the current list of velocity gradients.
  83837. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  83838. * @returns the list of velocity gradients
  83839. */
  83840. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  83841. /**
  83842. * Adds a new velocity gradient
  83843. * @param gradient defines the gradient to use (between 0 and 1)
  83844. * @param factor defines the velocity to affect to the specified gradient
  83845. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  83846. * @returns the current particle system
  83847. */
  83848. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  83849. /**
  83850. * Remove a specific velocity gradient
  83851. * @param gradient defines the gradient to remove
  83852. * @returns the current particle system
  83853. */
  83854. removeVelocityGradient(gradient: number): IParticleSystem;
  83855. /**
  83856. * Gets the current list of limit velocity gradients.
  83857. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  83858. * @returns the list of limit velocity gradients
  83859. */
  83860. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  83861. /**
  83862. * Adds a new limit velocity gradient
  83863. * @param gradient defines the gradient to use (between 0 and 1)
  83864. * @param factor defines the limit velocity to affect to the specified gradient
  83865. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  83866. * @returns the current particle system
  83867. */
  83868. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  83869. /**
  83870. * Remove a specific limit velocity gradient
  83871. * @param gradient defines the gradient to remove
  83872. * @returns the current particle system
  83873. */
  83874. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  83875. /**
  83876. * Adds a new drag gradient
  83877. * @param gradient defines the gradient to use (between 0 and 1)
  83878. * @param factor defines the drag to affect to the specified gradient
  83879. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  83880. * @returns the current particle system
  83881. */
  83882. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  83883. /**
  83884. * Remove a specific drag gradient
  83885. * @param gradient defines the gradient to remove
  83886. * @returns the current particle system
  83887. */
  83888. removeDragGradient(gradient: number): IParticleSystem;
  83889. /**
  83890. * Gets the current list of drag gradients.
  83891. * You must use addDragGradient and removeDragGradient to udpate this list
  83892. * @returns the list of drag gradients
  83893. */
  83894. getDragGradients(): Nullable<Array<FactorGradient>>;
  83895. /**
  83896. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  83897. * @param gradient defines the gradient to use (between 0 and 1)
  83898. * @param factor defines the emit rate to affect to the specified gradient
  83899. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  83900. * @returns the current particle system
  83901. */
  83902. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  83903. /**
  83904. * Remove a specific emit rate gradient
  83905. * @param gradient defines the gradient to remove
  83906. * @returns the current particle system
  83907. */
  83908. removeEmitRateGradient(gradient: number): IParticleSystem;
  83909. /**
  83910. * Gets the current list of emit rate gradients.
  83911. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  83912. * @returns the list of emit rate gradients
  83913. */
  83914. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  83915. /**
  83916. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  83917. * @param gradient defines the gradient to use (between 0 and 1)
  83918. * @param factor defines the start size to affect to the specified gradient
  83919. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  83920. * @returns the current particle system
  83921. */
  83922. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  83923. /**
  83924. * Remove a specific start size gradient
  83925. * @param gradient defines the gradient to remove
  83926. * @returns the current particle system
  83927. */
  83928. removeStartSizeGradient(gradient: number): IParticleSystem;
  83929. /**
  83930. * Gets the current list of start size gradients.
  83931. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  83932. * @returns the list of start size gradients
  83933. */
  83934. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  83935. /**
  83936. * Adds a new life time gradient
  83937. * @param gradient defines the gradient to use (between 0 and 1)
  83938. * @param factor defines the life time factor to affect to the specified gradient
  83939. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  83940. * @returns the current particle system
  83941. */
  83942. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  83943. /**
  83944. * Remove a specific life time gradient
  83945. * @param gradient defines the gradient to remove
  83946. * @returns the current particle system
  83947. */
  83948. removeLifeTimeGradient(gradient: number): IParticleSystem;
  83949. /**
  83950. * Gets the current list of life time gradients.
  83951. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  83952. * @returns the list of life time gradients
  83953. */
  83954. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  83955. /**
  83956. * Gets the current list of color gradients.
  83957. * You must use addColorGradient and removeColorGradient to udpate this list
  83958. * @returns the list of color gradients
  83959. */
  83960. getColorGradients(): Nullable<Array<ColorGradient>>;
  83961. /**
  83962. * Adds a new ramp gradient used to remap particle colors
  83963. * @param gradient defines the gradient to use (between 0 and 1)
  83964. * @param color defines the color to affect to the specified gradient
  83965. * @returns the current particle system
  83966. */
  83967. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  83968. /**
  83969. * Gets the current list of ramp gradients.
  83970. * You must use addRampGradient and removeRampGradient to udpate this list
  83971. * @returns the list of ramp gradients
  83972. */
  83973. getRampGradients(): Nullable<Array<Color3Gradient>>;
  83974. /** Gets or sets a boolean indicating that ramp gradients must be used
  83975. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  83976. */
  83977. useRampGradients: boolean;
  83978. /**
  83979. * Adds a new color remap gradient
  83980. * @param gradient defines the gradient to use (between 0 and 1)
  83981. * @param min defines the color remap minimal range
  83982. * @param max defines the color remap maximal range
  83983. * @returns the current particle system
  83984. */
  83985. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  83986. /**
  83987. * Gets the current list of color remap gradients.
  83988. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  83989. * @returns the list of color remap gradients
  83990. */
  83991. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  83992. /**
  83993. * Adds a new alpha remap gradient
  83994. * @param gradient defines the gradient to use (between 0 and 1)
  83995. * @param min defines the alpha remap minimal range
  83996. * @param max defines the alpha remap maximal range
  83997. * @returns the current particle system
  83998. */
  83999. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  84000. /**
  84001. * Gets the current list of alpha remap gradients.
  84002. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  84003. * @returns the list of alpha remap gradients
  84004. */
  84005. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  84006. /**
  84007. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  84008. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  84009. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  84010. * @returns the emitter
  84011. */
  84012. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  84013. /**
  84014. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  84015. * @param radius The radius of the hemisphere to emit from
  84016. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  84017. * @returns the emitter
  84018. */
  84019. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  84020. /**
  84021. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  84022. * @param radius The radius of the sphere to emit from
  84023. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  84024. * @returns the emitter
  84025. */
  84026. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  84027. /**
  84028. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  84029. * @param radius The radius of the sphere to emit from
  84030. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  84031. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  84032. * @returns the emitter
  84033. */
  84034. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  84035. /**
  84036. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  84037. * @param radius The radius of the emission cylinder
  84038. * @param height The height of the emission cylinder
  84039. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  84040. * @param directionRandomizer How much to randomize the particle direction [0-1]
  84041. * @returns the emitter
  84042. */
  84043. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  84044. /**
  84045. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  84046. * @param radius The radius of the cylinder to emit from
  84047. * @param height The height of the emission cylinder
  84048. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  84049. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  84050. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  84051. * @returns the emitter
  84052. */
  84053. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  84054. /**
  84055. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  84056. * @param radius The radius of the cone to emit from
  84057. * @param angle The base angle of the cone
  84058. * @returns the emitter
  84059. */
  84060. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  84061. /**
  84062. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  84063. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  84064. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  84065. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  84066. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  84067. * @returns the emitter
  84068. */
  84069. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  84070. /**
  84071. * Get hosting scene
  84072. * @returns the scene
  84073. */
  84074. getScene(): Scene;
  84075. }
  84076. }
  84077. declare module BABYLON {
  84078. /**
  84079. * Creates an instance based on a source mesh.
  84080. */
  84081. export class InstancedMesh extends AbstractMesh {
  84082. private _sourceMesh;
  84083. private _currentLOD;
  84084. /** @hidden */
  84085. _indexInSourceMeshInstanceArray: number;
  84086. constructor(name: string, source: Mesh);
  84087. /**
  84088. * Returns the string "InstancedMesh".
  84089. */
  84090. getClassName(): string;
  84091. /** Gets the list of lights affecting that mesh */
  84092. readonly lightSources: Light[];
  84093. _resyncLightSources(): void;
  84094. _resyncLighSource(light: Light): void;
  84095. _removeLightSource(light: Light, dispose: boolean): void;
  84096. /**
  84097. * If the source mesh receives shadows
  84098. */
  84099. readonly receiveShadows: boolean;
  84100. /**
  84101. * The material of the source mesh
  84102. */
  84103. readonly material: Nullable<Material>;
  84104. /**
  84105. * Visibility of the source mesh
  84106. */
  84107. readonly visibility: number;
  84108. /**
  84109. * Skeleton of the source mesh
  84110. */
  84111. readonly skeleton: Nullable<Skeleton>;
  84112. /**
  84113. * Rendering ground id of the source mesh
  84114. */
  84115. renderingGroupId: number;
  84116. /**
  84117. * Returns the total number of vertices (integer).
  84118. */
  84119. getTotalVertices(): number;
  84120. /**
  84121. * Returns a positive integer : the total number of indices in this mesh geometry.
  84122. * @returns the numner of indices or zero if the mesh has no geometry.
  84123. */
  84124. getTotalIndices(): number;
  84125. /**
  84126. * The source mesh of the instance
  84127. */
  84128. readonly sourceMesh: Mesh;
  84129. /**
  84130. * Is this node ready to be used/rendered
  84131. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  84132. * @return {boolean} is it ready
  84133. */
  84134. isReady(completeCheck?: boolean): boolean;
  84135. /**
  84136. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  84137. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  84138. * @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.
  84139. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  84140. */
  84141. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  84142. /**
  84143. * Sets the vertex data of the mesh geometry for the requested `kind`.
  84144. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  84145. * The `data` are either a numeric array either a Float32Array.
  84146. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  84147. * 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).
  84148. * Note that a new underlying VertexBuffer object is created each call.
  84149. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  84150. *
  84151. * Possible `kind` values :
  84152. * - VertexBuffer.PositionKind
  84153. * - VertexBuffer.UVKind
  84154. * - VertexBuffer.UV2Kind
  84155. * - VertexBuffer.UV3Kind
  84156. * - VertexBuffer.UV4Kind
  84157. * - VertexBuffer.UV5Kind
  84158. * - VertexBuffer.UV6Kind
  84159. * - VertexBuffer.ColorKind
  84160. * - VertexBuffer.MatricesIndicesKind
  84161. * - VertexBuffer.MatricesIndicesExtraKind
  84162. * - VertexBuffer.MatricesWeightsKind
  84163. * - VertexBuffer.MatricesWeightsExtraKind
  84164. *
  84165. * Returns the Mesh.
  84166. */
  84167. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  84168. /**
  84169. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  84170. * If the mesh has no geometry, it is simply returned as it is.
  84171. * The `data` are either a numeric array either a Float32Array.
  84172. * No new underlying VertexBuffer object is created.
  84173. * 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.
  84174. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  84175. *
  84176. * Possible `kind` values :
  84177. * - VertexBuffer.PositionKind
  84178. * - VertexBuffer.UVKind
  84179. * - VertexBuffer.UV2Kind
  84180. * - VertexBuffer.UV3Kind
  84181. * - VertexBuffer.UV4Kind
  84182. * - VertexBuffer.UV5Kind
  84183. * - VertexBuffer.UV6Kind
  84184. * - VertexBuffer.ColorKind
  84185. * - VertexBuffer.MatricesIndicesKind
  84186. * - VertexBuffer.MatricesIndicesExtraKind
  84187. * - VertexBuffer.MatricesWeightsKind
  84188. * - VertexBuffer.MatricesWeightsExtraKind
  84189. *
  84190. * Returns the Mesh.
  84191. */
  84192. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  84193. /**
  84194. * Sets the mesh indices.
  84195. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  84196. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  84197. * This method creates a new index buffer each call.
  84198. * Returns the Mesh.
  84199. */
  84200. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  84201. /**
  84202. * Boolean : True if the mesh owns the requested kind of data.
  84203. */
  84204. isVerticesDataPresent(kind: string): boolean;
  84205. /**
  84206. * Returns an array of indices (IndicesArray).
  84207. */
  84208. getIndices(): Nullable<IndicesArray>;
  84209. readonly _positions: Nullable<Vector3[]>;
  84210. /**
  84211. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  84212. * This means the mesh underlying bounding box and sphere are recomputed.
  84213. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  84214. * @returns the current mesh
  84215. */
  84216. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  84217. /** @hidden */
  84218. _preActivate(): InstancedMesh;
  84219. /** @hidden */
  84220. _activate(renderId: number, intermediateRendering: boolean): boolean;
  84221. /** @hidden */
  84222. _postActivate(): void;
  84223. getWorldMatrix(): Matrix;
  84224. readonly isAnInstance: boolean;
  84225. /**
  84226. * Returns the current associated LOD AbstractMesh.
  84227. */
  84228. getLOD(camera: Camera): AbstractMesh;
  84229. /** @hidden */
  84230. _syncSubMeshes(): InstancedMesh;
  84231. /** @hidden */
  84232. _generatePointsArray(): boolean;
  84233. /**
  84234. * Creates a new InstancedMesh from the current mesh.
  84235. * - name (string) : the cloned mesh name
  84236. * - newParent (optional Node) : the optional Node to parent the clone to.
  84237. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  84238. *
  84239. * Returns the clone.
  84240. */
  84241. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  84242. /**
  84243. * Disposes the InstancedMesh.
  84244. * Returns nothing.
  84245. */
  84246. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  84247. }
  84248. }
  84249. declare module BABYLON {
  84250. /**
  84251. * Defines the options associated with the creation of a shader material.
  84252. */
  84253. export interface IShaderMaterialOptions {
  84254. /**
  84255. * Does the material work in alpha blend mode
  84256. */
  84257. needAlphaBlending: boolean;
  84258. /**
  84259. * Does the material work in alpha test mode
  84260. */
  84261. needAlphaTesting: boolean;
  84262. /**
  84263. * The list of attribute names used in the shader
  84264. */
  84265. attributes: string[];
  84266. /**
  84267. * The list of unifrom names used in the shader
  84268. */
  84269. uniforms: string[];
  84270. /**
  84271. * The list of UBO names used in the shader
  84272. */
  84273. uniformBuffers: string[];
  84274. /**
  84275. * The list of sampler names used in the shader
  84276. */
  84277. samplers: string[];
  84278. /**
  84279. * The list of defines used in the shader
  84280. */
  84281. defines: string[];
  84282. }
  84283. /**
  84284. * 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.
  84285. *
  84286. * This returned material effects how the mesh will look based on the code in the shaders.
  84287. *
  84288. * @see http://doc.babylonjs.com/how_to/shader_material
  84289. */
  84290. export class ShaderMaterial extends Material {
  84291. private _shaderPath;
  84292. private _options;
  84293. private _textures;
  84294. private _textureArrays;
  84295. private _floats;
  84296. private _ints;
  84297. private _floatsArrays;
  84298. private _colors3;
  84299. private _colors3Arrays;
  84300. private _colors4;
  84301. private _colors4Arrays;
  84302. private _vectors2;
  84303. private _vectors3;
  84304. private _vectors4;
  84305. private _matrices;
  84306. private _matrices3x3;
  84307. private _matrices2x2;
  84308. private _vectors2Arrays;
  84309. private _vectors3Arrays;
  84310. private _vectors4Arrays;
  84311. private _cachedWorldViewMatrix;
  84312. private _cachedWorldViewProjectionMatrix;
  84313. private _renderId;
  84314. /**
  84315. * Instantiate a new shader material.
  84316. * 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.
  84317. * This returned material effects how the mesh will look based on the code in the shaders.
  84318. * @see http://doc.babylonjs.com/how_to/shader_material
  84319. * @param name Define the name of the material in the scene
  84320. * @param scene Define the scene the material belongs to
  84321. * @param shaderPath Defines the route to the shader code in one of three ways:
  84322. * * object: { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  84323. * * object: { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in script tags
  84324. * * object: { vertexSource: "vertex shader code string", fragmentSource: "fragment shader code string" } using with strings containing the shaders code
  84325. * * string: "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  84326. * @param options Define the options used to create the shader
  84327. */
  84328. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  84329. /**
  84330. * Gets the options used to compile the shader.
  84331. * They can be modified to trigger a new compilation
  84332. */
  84333. readonly options: IShaderMaterialOptions;
  84334. /**
  84335. * Gets the current class name of the material e.g. "ShaderMaterial"
  84336. * Mainly use in serialization.
  84337. * @returns the class name
  84338. */
  84339. getClassName(): string;
  84340. /**
  84341. * Specifies if the material will require alpha blending
  84342. * @returns a boolean specifying if alpha blending is needed
  84343. */
  84344. needAlphaBlending(): boolean;
  84345. /**
  84346. * Specifies if this material should be rendered in alpha test mode
  84347. * @returns a boolean specifying if an alpha test is needed.
  84348. */
  84349. needAlphaTesting(): boolean;
  84350. private _checkUniform;
  84351. /**
  84352. * Set a texture in the shader.
  84353. * @param name Define the name of the uniform samplers as defined in the shader
  84354. * @param texture Define the texture to bind to this sampler
  84355. * @return the material itself allowing "fluent" like uniform updates
  84356. */
  84357. setTexture(name: string, texture: Texture): ShaderMaterial;
  84358. /**
  84359. * Set a texture array in the shader.
  84360. * @param name Define the name of the uniform sampler array as defined in the shader
  84361. * @param textures Define the list of textures to bind to this sampler
  84362. * @return the material itself allowing "fluent" like uniform updates
  84363. */
  84364. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  84365. /**
  84366. * Set a float in the shader.
  84367. * @param name Define the name of the uniform as defined in the shader
  84368. * @param value Define the value to give to the uniform
  84369. * @return the material itself allowing "fluent" like uniform updates
  84370. */
  84371. setFloat(name: string, value: number): ShaderMaterial;
  84372. /**
  84373. * Set a int in the shader.
  84374. * @param name Define the name of the uniform as defined in the shader
  84375. * @param value Define the value to give to the uniform
  84376. * @return the material itself allowing "fluent" like uniform updates
  84377. */
  84378. setInt(name: string, value: number): ShaderMaterial;
  84379. /**
  84380. * Set an array of floats in the shader.
  84381. * @param name Define the name of the uniform as defined in the shader
  84382. * @param value Define the value to give to the uniform
  84383. * @return the material itself allowing "fluent" like uniform updates
  84384. */
  84385. setFloats(name: string, value: number[]): ShaderMaterial;
  84386. /**
  84387. * Set a vec3 in the shader from a Color3.
  84388. * @param name Define the name of the uniform as defined in the shader
  84389. * @param value Define the value to give to the uniform
  84390. * @return the material itself allowing "fluent" like uniform updates
  84391. */
  84392. setColor3(name: string, value: Color3): ShaderMaterial;
  84393. /**
  84394. * Set a vec3 array in the shader from a Color3 array.
  84395. * @param name Define the name of the uniform as defined in the shader
  84396. * @param value Define the value to give to the uniform
  84397. * @return the material itself allowing "fluent" like uniform updates
  84398. */
  84399. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  84400. /**
  84401. * Set a vec4 in the shader from a Color4.
  84402. * @param name Define the name of the uniform as defined in the shader
  84403. * @param value Define the value to give to the uniform
  84404. * @return the material itself allowing "fluent" like uniform updates
  84405. */
  84406. setColor4(name: string, value: Color4): ShaderMaterial;
  84407. /**
  84408. * Set a vec4 array in the shader from a Color4 array.
  84409. * @param name Define the name of the uniform as defined in the shader
  84410. * @param value Define the value to give to the uniform
  84411. * @return the material itself allowing "fluent" like uniform updates
  84412. */
  84413. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  84414. /**
  84415. * Set a vec2 in the shader from a Vector2.
  84416. * @param name Define the name of the uniform as defined in the shader
  84417. * @param value Define the value to give to the uniform
  84418. * @return the material itself allowing "fluent" like uniform updates
  84419. */
  84420. setVector2(name: string, value: Vector2): ShaderMaterial;
  84421. /**
  84422. * Set a vec3 in the shader from a Vector3.
  84423. * @param name Define the name of the uniform as defined in the shader
  84424. * @param value Define the value to give to the uniform
  84425. * @return the material itself allowing "fluent" like uniform updates
  84426. */
  84427. setVector3(name: string, value: Vector3): ShaderMaterial;
  84428. /**
  84429. * Set a vec4 in the shader from a Vector4.
  84430. * @param name Define the name of the uniform as defined in the shader
  84431. * @param value Define the value to give to the uniform
  84432. * @return the material itself allowing "fluent" like uniform updates
  84433. */
  84434. setVector4(name: string, value: Vector4): ShaderMaterial;
  84435. /**
  84436. * Set a mat4 in the shader from a Matrix.
  84437. * @param name Define the name of the uniform as defined in the shader
  84438. * @param value Define the value to give to the uniform
  84439. * @return the material itself allowing "fluent" like uniform updates
  84440. */
  84441. setMatrix(name: string, value: Matrix): ShaderMaterial;
  84442. /**
  84443. * Set a mat3 in the shader from a Float32Array.
  84444. * @param name Define the name of the uniform as defined in the shader
  84445. * @param value Define the value to give to the uniform
  84446. * @return the material itself allowing "fluent" like uniform updates
  84447. */
  84448. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  84449. /**
  84450. * Set a mat2 in the shader from a Float32Array.
  84451. * @param name Define the name of the uniform as defined in the shader
  84452. * @param value Define the value to give to the uniform
  84453. * @return the material itself allowing "fluent" like uniform updates
  84454. */
  84455. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  84456. /**
  84457. * Set a vec2 array in the shader from a number array.
  84458. * @param name Define the name of the uniform as defined in the shader
  84459. * @param value Define the value to give to the uniform
  84460. * @return the material itself allowing "fluent" like uniform updates
  84461. */
  84462. setArray2(name: string, value: number[]): ShaderMaterial;
  84463. /**
  84464. * Set a vec3 array in the shader from a number array.
  84465. * @param name Define the name of the uniform as defined in the shader
  84466. * @param value Define the value to give to the uniform
  84467. * @return the material itself allowing "fluent" like uniform updates
  84468. */
  84469. setArray3(name: string, value: number[]): ShaderMaterial;
  84470. /**
  84471. * Set a vec4 array in the shader from a number array.
  84472. * @param name Define the name of the uniform as defined in the shader
  84473. * @param value Define the value to give to the uniform
  84474. * @return the material itself allowing "fluent" like uniform updates
  84475. */
  84476. setArray4(name: string, value: number[]): ShaderMaterial;
  84477. private _checkCache;
  84478. /**
  84479. * Specifies that the submesh is ready to be used
  84480. * @param mesh defines the mesh to check
  84481. * @param subMesh defines which submesh to check
  84482. * @param useInstances specifies that instances should be used
  84483. * @returns a boolean indicating that the submesh is ready or not
  84484. */
  84485. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  84486. /**
  84487. * Checks if the material is ready to render the requested mesh
  84488. * @param mesh Define the mesh to render
  84489. * @param useInstances Define whether or not the material is used with instances
  84490. * @returns true if ready, otherwise false
  84491. */
  84492. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  84493. /**
  84494. * Binds the world matrix to the material
  84495. * @param world defines the world transformation matrix
  84496. */
  84497. bindOnlyWorldMatrix(world: Matrix): void;
  84498. /**
  84499. * Binds the material to the mesh
  84500. * @param world defines the world transformation matrix
  84501. * @param mesh defines the mesh to bind the material to
  84502. */
  84503. bind(world: Matrix, mesh?: Mesh): void;
  84504. /**
  84505. * Gets the active textures from the material
  84506. * @returns an array of textures
  84507. */
  84508. getActiveTextures(): BaseTexture[];
  84509. /**
  84510. * Specifies if the material uses a texture
  84511. * @param texture defines the texture to check against the material
  84512. * @returns a boolean specifying if the material uses the texture
  84513. */
  84514. hasTexture(texture: BaseTexture): boolean;
  84515. /**
  84516. * Makes a duplicate of the material, and gives it a new name
  84517. * @param name defines the new name for the duplicated material
  84518. * @returns the cloned material
  84519. */
  84520. clone(name: string): ShaderMaterial;
  84521. /**
  84522. * Disposes the material
  84523. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  84524. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  84525. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  84526. */
  84527. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  84528. /**
  84529. * Serializes this material in a JSON representation
  84530. * @returns the serialized material object
  84531. */
  84532. serialize(): any;
  84533. /**
  84534. * Creates a shader material from parsed shader material data
  84535. * @param source defines the JSON represnetation of the material
  84536. * @param scene defines the hosting scene
  84537. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  84538. * @returns a new material
  84539. */
  84540. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  84541. }
  84542. }
  84543. declare module BABYLON {
  84544. /** @hidden */
  84545. export var colorPixelShader: {
  84546. name: string;
  84547. shader: string;
  84548. };
  84549. }
  84550. declare module BABYLON {
  84551. /** @hidden */
  84552. export var colorVertexShader: {
  84553. name: string;
  84554. shader: string;
  84555. };
  84556. }
  84557. declare module BABYLON {
  84558. /**
  84559. * Line mesh
  84560. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  84561. */
  84562. export class LinesMesh extends Mesh {
  84563. /**
  84564. * If vertex color should be applied to the mesh
  84565. */
  84566. readonly useVertexColor?: boolean | undefined;
  84567. /**
  84568. * If vertex alpha should be applied to the mesh
  84569. */
  84570. readonly useVertexAlpha?: boolean | undefined;
  84571. /**
  84572. * Color of the line (Default: White)
  84573. */
  84574. color: Color3;
  84575. /**
  84576. * Alpha of the line (Default: 1)
  84577. */
  84578. alpha: number;
  84579. /**
  84580. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  84581. * This margin is expressed in world space coordinates, so its value may vary.
  84582. * Default value is 0.1
  84583. */
  84584. intersectionThreshold: number;
  84585. private _colorShader;
  84586. private color4;
  84587. /**
  84588. * Creates a new LinesMesh
  84589. * @param name defines the name
  84590. * @param scene defines the hosting scene
  84591. * @param parent defines the parent mesh if any
  84592. * @param source defines the optional source LinesMesh used to clone data from
  84593. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  84594. * When false, achieved by calling a clone(), also passing False.
  84595. * This will make creation of children, recursive.
  84596. * @param useVertexColor defines if this LinesMesh supports vertex color
  84597. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  84598. */
  84599. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<LinesMesh>, doNotCloneChildren?: boolean,
  84600. /**
  84601. * If vertex color should be applied to the mesh
  84602. */
  84603. useVertexColor?: boolean | undefined,
  84604. /**
  84605. * If vertex alpha should be applied to the mesh
  84606. */
  84607. useVertexAlpha?: boolean | undefined);
  84608. private _addClipPlaneDefine;
  84609. private _removeClipPlaneDefine;
  84610. isReady(): boolean;
  84611. /**
  84612. * Returns the string "LineMesh"
  84613. */
  84614. getClassName(): string;
  84615. /**
  84616. * @hidden
  84617. */
  84618. /**
  84619. * @hidden
  84620. */
  84621. material: Material;
  84622. /**
  84623. * @hidden
  84624. */
  84625. readonly checkCollisions: boolean;
  84626. /** @hidden */
  84627. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  84628. /** @hidden */
  84629. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  84630. /**
  84631. * Disposes of the line mesh
  84632. * @param doNotRecurse If children should be disposed
  84633. */
  84634. dispose(doNotRecurse?: boolean): void;
  84635. /**
  84636. * Returns a new LineMesh object cloned from the current one.
  84637. */
  84638. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  84639. /**
  84640. * Creates a new InstancedLinesMesh object from the mesh model.
  84641. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  84642. * @param name defines the name of the new instance
  84643. * @returns a new InstancedLinesMesh
  84644. */
  84645. createInstance(name: string): InstancedLinesMesh;
  84646. }
  84647. /**
  84648. * Creates an instance based on a source LinesMesh
  84649. */
  84650. export class InstancedLinesMesh extends InstancedMesh {
  84651. /**
  84652. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  84653. * This margin is expressed in world space coordinates, so its value may vary.
  84654. * Initilized with the intersectionThreshold value of the source LinesMesh
  84655. */
  84656. intersectionThreshold: number;
  84657. constructor(name: string, source: LinesMesh);
  84658. /**
  84659. * Returns the string "InstancedLinesMesh".
  84660. */
  84661. getClassName(): string;
  84662. }
  84663. }
  84664. declare module BABYLON {
  84665. /** @hidden */
  84666. export var linePixelShader: {
  84667. name: string;
  84668. shader: string;
  84669. };
  84670. }
  84671. declare module BABYLON {
  84672. /** @hidden */
  84673. export var lineVertexShader: {
  84674. name: string;
  84675. shader: string;
  84676. };
  84677. }
  84678. declare module BABYLON {
  84679. interface AbstractMesh {
  84680. /**
  84681. * Gets the edgesRenderer associated with the mesh
  84682. */
  84683. edgesRenderer: Nullable<EdgesRenderer>;
  84684. }
  84685. interface LinesMesh {
  84686. /**
  84687. * Enables the edge rendering mode on the mesh.
  84688. * This mode makes the mesh edges visible
  84689. * @param epsilon defines the maximal distance between two angles to detect a face
  84690. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  84691. * @returns the currentAbstractMesh
  84692. * @see https://www.babylonjs-playground.com/#19O9TU#0
  84693. */
  84694. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  84695. }
  84696. interface InstancedLinesMesh {
  84697. /**
  84698. * Enables the edge rendering mode on the mesh.
  84699. * This mode makes the mesh edges visible
  84700. * @param epsilon defines the maximal distance between two angles to detect a face
  84701. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  84702. * @returns the current InstancedLinesMesh
  84703. * @see https://www.babylonjs-playground.com/#19O9TU#0
  84704. */
  84705. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  84706. }
  84707. /**
  84708. * Defines the minimum contract an Edges renderer should follow.
  84709. */
  84710. export interface IEdgesRenderer extends IDisposable {
  84711. /**
  84712. * Gets or sets a boolean indicating if the edgesRenderer is active
  84713. */
  84714. isEnabled: boolean;
  84715. /**
  84716. * Renders the edges of the attached mesh,
  84717. */
  84718. render(): void;
  84719. /**
  84720. * Checks wether or not the edges renderer is ready to render.
  84721. * @return true if ready, otherwise false.
  84722. */
  84723. isReady(): boolean;
  84724. }
  84725. /**
  84726. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  84727. */
  84728. export class EdgesRenderer implements IEdgesRenderer {
  84729. /**
  84730. * Define the size of the edges with an orthographic camera
  84731. */
  84732. edgesWidthScalerForOrthographic: number;
  84733. /**
  84734. * Define the size of the edges with a perspective camera
  84735. */
  84736. edgesWidthScalerForPerspective: number;
  84737. protected _source: AbstractMesh;
  84738. protected _linesPositions: number[];
  84739. protected _linesNormals: number[];
  84740. protected _linesIndices: number[];
  84741. protected _epsilon: number;
  84742. protected _indicesCount: number;
  84743. protected _lineShader: ShaderMaterial;
  84744. protected _ib: DataBuffer;
  84745. protected _buffers: {
  84746. [key: string]: Nullable<VertexBuffer>;
  84747. };
  84748. protected _checkVerticesInsteadOfIndices: boolean;
  84749. private _meshRebuildObserver;
  84750. private _meshDisposeObserver;
  84751. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  84752. isEnabled: boolean;
  84753. /**
  84754. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  84755. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  84756. * @param source Mesh used to create edges
  84757. * @param epsilon sum of angles in adjacency to check for edge
  84758. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  84759. * @param generateEdgesLines - should generate Lines or only prepare resources.
  84760. */
  84761. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  84762. protected _prepareRessources(): void;
  84763. /** @hidden */
  84764. _rebuild(): void;
  84765. /**
  84766. * Releases the required resources for the edges renderer
  84767. */
  84768. dispose(): void;
  84769. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  84770. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  84771. /**
  84772. * Checks if the pair of p0 and p1 is en edge
  84773. * @param faceIndex
  84774. * @param edge
  84775. * @param faceNormals
  84776. * @param p0
  84777. * @param p1
  84778. * @private
  84779. */
  84780. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  84781. /**
  84782. * push line into the position, normal and index buffer
  84783. * @protected
  84784. */
  84785. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  84786. /**
  84787. * Generates lines edges from adjacencjes
  84788. * @private
  84789. */
  84790. _generateEdgesLines(): void;
  84791. /**
  84792. * Checks wether or not the edges renderer is ready to render.
  84793. * @return true if ready, otherwise false.
  84794. */
  84795. isReady(): boolean;
  84796. /**
  84797. * Renders the edges of the attached mesh,
  84798. */
  84799. render(): void;
  84800. }
  84801. /**
  84802. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  84803. */
  84804. export class LineEdgesRenderer extends EdgesRenderer {
  84805. /**
  84806. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  84807. * @param source LineMesh used to generate edges
  84808. * @param epsilon not important (specified angle for edge detection)
  84809. * @param checkVerticesInsteadOfIndices not important for LineMesh
  84810. */
  84811. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  84812. /**
  84813. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  84814. */
  84815. _generateEdgesLines(): void;
  84816. }
  84817. }
  84818. declare module BABYLON {
  84819. /**
  84820. * This represents the object necessary to create a rendering group.
  84821. * This is exclusively used and created by the rendering manager.
  84822. * To modify the behavior, you use the available helpers in your scene or meshes.
  84823. * @hidden
  84824. */
  84825. export class RenderingGroup {
  84826. index: number;
  84827. private static _zeroVector;
  84828. private _scene;
  84829. private _opaqueSubMeshes;
  84830. private _transparentSubMeshes;
  84831. private _alphaTestSubMeshes;
  84832. private _depthOnlySubMeshes;
  84833. private _particleSystems;
  84834. private _spriteManagers;
  84835. private _opaqueSortCompareFn;
  84836. private _alphaTestSortCompareFn;
  84837. private _transparentSortCompareFn;
  84838. private _renderOpaque;
  84839. private _renderAlphaTest;
  84840. private _renderTransparent;
  84841. /** @hidden */
  84842. _edgesRenderers: SmartArray<IEdgesRenderer>;
  84843. onBeforeTransparentRendering: () => void;
  84844. /**
  84845. * Set the opaque sort comparison function.
  84846. * If null the sub meshes will be render in the order they were created
  84847. */
  84848. opaqueSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  84849. /**
  84850. * Set the alpha test sort comparison function.
  84851. * If null the sub meshes will be render in the order they were created
  84852. */
  84853. alphaTestSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  84854. /**
  84855. * Set the transparent sort comparison function.
  84856. * If null the sub meshes will be render in the order they were created
  84857. */
  84858. transparentSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  84859. /**
  84860. * Creates a new rendering group.
  84861. * @param index The rendering group index
  84862. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  84863. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  84864. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  84865. */
  84866. 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>);
  84867. /**
  84868. * Render all the sub meshes contained in the group.
  84869. * @param customRenderFunction Used to override the default render behaviour of the group.
  84870. * @returns true if rendered some submeshes.
  84871. */
  84872. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  84873. /**
  84874. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  84875. * @param subMeshes The submeshes to render
  84876. */
  84877. private renderOpaqueSorted;
  84878. /**
  84879. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  84880. * @param subMeshes The submeshes to render
  84881. */
  84882. private renderAlphaTestSorted;
  84883. /**
  84884. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  84885. * @param subMeshes The submeshes to render
  84886. */
  84887. private renderTransparentSorted;
  84888. /**
  84889. * Renders the submeshes in a specified order.
  84890. * @param subMeshes The submeshes to sort before render
  84891. * @param sortCompareFn The comparison function use to sort
  84892. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  84893. * @param transparent Specifies to activate blending if true
  84894. */
  84895. private static renderSorted;
  84896. /**
  84897. * Renders the submeshes in the order they were dispatched (no sort applied).
  84898. * @param subMeshes The submeshes to render
  84899. */
  84900. private static renderUnsorted;
  84901. /**
  84902. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  84903. * are rendered back to front if in the same alpha index.
  84904. *
  84905. * @param a The first submesh
  84906. * @param b The second submesh
  84907. * @returns The result of the comparison
  84908. */
  84909. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  84910. /**
  84911. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  84912. * are rendered back to front.
  84913. *
  84914. * @param a The first submesh
  84915. * @param b The second submesh
  84916. * @returns The result of the comparison
  84917. */
  84918. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  84919. /**
  84920. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  84921. * are rendered front to back (prevent overdraw).
  84922. *
  84923. * @param a The first submesh
  84924. * @param b The second submesh
  84925. * @returns The result of the comparison
  84926. */
  84927. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  84928. /**
  84929. * Resets the different lists of submeshes to prepare a new frame.
  84930. */
  84931. prepare(): void;
  84932. dispose(): void;
  84933. /**
  84934. * Inserts the submesh in its correct queue depending on its material.
  84935. * @param subMesh The submesh to dispatch
  84936. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  84937. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  84938. */
  84939. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  84940. dispatchSprites(spriteManager: ISpriteManager): void;
  84941. dispatchParticles(particleSystem: IParticleSystem): void;
  84942. private _renderParticles;
  84943. private _renderSprites;
  84944. }
  84945. }
  84946. declare module BABYLON {
  84947. /**
  84948. * Interface describing the different options available in the rendering manager
  84949. * regarding Auto Clear between groups.
  84950. */
  84951. export interface IRenderingManagerAutoClearSetup {
  84952. /**
  84953. * Defines whether or not autoclear is enable.
  84954. */
  84955. autoClear: boolean;
  84956. /**
  84957. * Defines whether or not to autoclear the depth buffer.
  84958. */
  84959. depth: boolean;
  84960. /**
  84961. * Defines whether or not to autoclear the stencil buffer.
  84962. */
  84963. stencil: boolean;
  84964. }
  84965. /**
  84966. * This class is used by the onRenderingGroupObservable
  84967. */
  84968. export class RenderingGroupInfo {
  84969. /**
  84970. * The Scene that being rendered
  84971. */
  84972. scene: Scene;
  84973. /**
  84974. * The camera currently used for the rendering pass
  84975. */
  84976. camera: Nullable<Camera>;
  84977. /**
  84978. * The ID of the renderingGroup being processed
  84979. */
  84980. renderingGroupId: number;
  84981. }
  84982. /**
  84983. * This is the manager responsible of all the rendering for meshes sprites and particles.
  84984. * It is enable to manage the different groups as well as the different necessary sort functions.
  84985. * This should not be used directly aside of the few static configurations
  84986. */
  84987. export class RenderingManager {
  84988. /**
  84989. * The max id used for rendering groups (not included)
  84990. */
  84991. static MAX_RENDERINGGROUPS: number;
  84992. /**
  84993. * The min id used for rendering groups (included)
  84994. */
  84995. static MIN_RENDERINGGROUPS: number;
  84996. /**
  84997. * Used to globally prevent autoclearing scenes.
  84998. */
  84999. static AUTOCLEAR: boolean;
  85000. /**
  85001. * @hidden
  85002. */
  85003. _useSceneAutoClearSetup: boolean;
  85004. private _scene;
  85005. private _renderingGroups;
  85006. private _depthStencilBufferAlreadyCleaned;
  85007. private _autoClearDepthStencil;
  85008. private _customOpaqueSortCompareFn;
  85009. private _customAlphaTestSortCompareFn;
  85010. private _customTransparentSortCompareFn;
  85011. private _renderingGroupInfo;
  85012. /**
  85013. * Instantiates a new rendering group for a particular scene
  85014. * @param scene Defines the scene the groups belongs to
  85015. */
  85016. constructor(scene: Scene);
  85017. private _clearDepthStencilBuffer;
  85018. /**
  85019. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  85020. * @hidden
  85021. */
  85022. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  85023. /**
  85024. * Resets the different information of the group to prepare a new frame
  85025. * @hidden
  85026. */
  85027. reset(): void;
  85028. /**
  85029. * Dispose and release the group and its associated resources.
  85030. * @hidden
  85031. */
  85032. dispose(): void;
  85033. /**
  85034. * Clear the info related to rendering groups preventing retention points during dispose.
  85035. */
  85036. freeRenderingGroups(): void;
  85037. private _prepareRenderingGroup;
  85038. /**
  85039. * Add a sprite manager to the rendering manager in order to render it this frame.
  85040. * @param spriteManager Define the sprite manager to render
  85041. */
  85042. dispatchSprites(spriteManager: ISpriteManager): void;
  85043. /**
  85044. * Add a particle system to the rendering manager in order to render it this frame.
  85045. * @param particleSystem Define the particle system to render
  85046. */
  85047. dispatchParticles(particleSystem: IParticleSystem): void;
  85048. /**
  85049. * Add a submesh to the manager in order to render it this frame
  85050. * @param subMesh The submesh to dispatch
  85051. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  85052. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  85053. */
  85054. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  85055. /**
  85056. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  85057. * This allowed control for front to back rendering or reversly depending of the special needs.
  85058. *
  85059. * @param renderingGroupId The rendering group id corresponding to its index
  85060. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  85061. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  85062. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  85063. */
  85064. 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;
  85065. /**
  85066. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  85067. *
  85068. * @param renderingGroupId The rendering group id corresponding to its index
  85069. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  85070. * @param depth Automatically clears depth between groups if true and autoClear is true.
  85071. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  85072. */
  85073. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  85074. /**
  85075. * Gets the current auto clear configuration for one rendering group of the rendering
  85076. * manager.
  85077. * @param index the rendering group index to get the information for
  85078. * @returns The auto clear setup for the requested rendering group
  85079. */
  85080. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  85081. }
  85082. }
  85083. declare module BABYLON {
  85084. /**
  85085. * This Helps creating a texture that will be created from a camera in your scene.
  85086. * It is basically a dynamic texture that could be used to create special effects for instance.
  85087. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  85088. */
  85089. export class RenderTargetTexture extends Texture {
  85090. isCube: boolean;
  85091. /**
  85092. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  85093. */
  85094. static readonly REFRESHRATE_RENDER_ONCE: number;
  85095. /**
  85096. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  85097. */
  85098. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  85099. /**
  85100. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  85101. * the central point of your effect and can save a lot of performances.
  85102. */
  85103. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  85104. /**
  85105. * Use this predicate to dynamically define the list of mesh you want to render.
  85106. * If set, the renderList property will be overwritten.
  85107. */
  85108. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  85109. private _renderList;
  85110. /**
  85111. * Use this list to define the list of mesh you want to render.
  85112. */
  85113. renderList: Nullable<Array<AbstractMesh>>;
  85114. private _hookArray;
  85115. /**
  85116. * Define if particles should be rendered in your texture.
  85117. */
  85118. renderParticles: boolean;
  85119. /**
  85120. * Define if sprites should be rendered in your texture.
  85121. */
  85122. renderSprites: boolean;
  85123. /**
  85124. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  85125. */
  85126. coordinatesMode: number;
  85127. /**
  85128. * Define the camera used to render the texture.
  85129. */
  85130. activeCamera: Nullable<Camera>;
  85131. /**
  85132. * Override the render function of the texture with your own one.
  85133. */
  85134. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  85135. /**
  85136. * Define if camera post processes should be use while rendering the texture.
  85137. */
  85138. useCameraPostProcesses: boolean;
  85139. /**
  85140. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  85141. */
  85142. ignoreCameraViewport: boolean;
  85143. private _postProcessManager;
  85144. private _postProcesses;
  85145. private _resizeObserver;
  85146. /**
  85147. * An event triggered when the texture is unbind.
  85148. */
  85149. onBeforeBindObservable: Observable<RenderTargetTexture>;
  85150. /**
  85151. * An event triggered when the texture is unbind.
  85152. */
  85153. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  85154. private _onAfterUnbindObserver;
  85155. /**
  85156. * Set a after unbind callback in the texture.
  85157. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  85158. */
  85159. onAfterUnbind: () => void;
  85160. /**
  85161. * An event triggered before rendering the texture
  85162. */
  85163. onBeforeRenderObservable: Observable<number>;
  85164. private _onBeforeRenderObserver;
  85165. /**
  85166. * Set a before render callback in the texture.
  85167. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  85168. */
  85169. onBeforeRender: (faceIndex: number) => void;
  85170. /**
  85171. * An event triggered after rendering the texture
  85172. */
  85173. onAfterRenderObservable: Observable<number>;
  85174. private _onAfterRenderObserver;
  85175. /**
  85176. * Set a after render callback in the texture.
  85177. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  85178. */
  85179. onAfterRender: (faceIndex: number) => void;
  85180. /**
  85181. * An event triggered after the texture clear
  85182. */
  85183. onClearObservable: Observable<Engine>;
  85184. private _onClearObserver;
  85185. /**
  85186. * Set a clear callback in the texture.
  85187. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  85188. */
  85189. onClear: (Engine: Engine) => void;
  85190. /**
  85191. * An event triggered when the texture is resized.
  85192. */
  85193. onResizeObservable: Observable<RenderTargetTexture>;
  85194. /**
  85195. * Define the clear color of the Render Target if it should be different from the scene.
  85196. */
  85197. clearColor: Color4;
  85198. protected _size: number | {
  85199. width: number;
  85200. height: number;
  85201. };
  85202. protected _initialSizeParameter: number | {
  85203. width: number;
  85204. height: number;
  85205. } | {
  85206. ratio: number;
  85207. };
  85208. protected _sizeRatio: Nullable<number>;
  85209. /** @hidden */
  85210. _generateMipMaps: boolean;
  85211. protected _renderingManager: RenderingManager;
  85212. /** @hidden */
  85213. _waitingRenderList: string[];
  85214. protected _doNotChangeAspectRatio: boolean;
  85215. protected _currentRefreshId: number;
  85216. protected _refreshRate: number;
  85217. protected _textureMatrix: Matrix;
  85218. protected _samples: number;
  85219. protected _renderTargetOptions: RenderTargetCreationOptions;
  85220. /**
  85221. * Gets render target creation options that were used.
  85222. */
  85223. readonly renderTargetOptions: RenderTargetCreationOptions;
  85224. protected _engine: Engine;
  85225. protected _onRatioRescale(): void;
  85226. /**
  85227. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  85228. * It must define where the camera used to render the texture is set
  85229. */
  85230. boundingBoxPosition: Vector3;
  85231. private _boundingBoxSize;
  85232. /**
  85233. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  85234. * When defined, the cubemap will switch to local mode
  85235. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  85236. * @example https://www.babylonjs-playground.com/#RNASML
  85237. */
  85238. boundingBoxSize: Vector3;
  85239. /**
  85240. * In case the RTT has been created with a depth texture, get the associated
  85241. * depth texture.
  85242. * Otherwise, return null.
  85243. */
  85244. depthStencilTexture: Nullable<InternalTexture>;
  85245. /**
  85246. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  85247. * or used a shadow, depth texture...
  85248. * @param name The friendly name of the texture
  85249. * @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)
  85250. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  85251. * @param generateMipMaps True if mip maps need to be generated after render.
  85252. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  85253. * @param type The type of the buffer in the RTT (int, half float, float...)
  85254. * @param isCube True if a cube texture needs to be created
  85255. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  85256. * @param generateDepthBuffer True to generate a depth buffer
  85257. * @param generateStencilBuffer True to generate a stencil buffer
  85258. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  85259. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  85260. * @param delayAllocation if the texture allocation should be delayed (default: false)
  85261. */
  85262. constructor(name: string, size: number | {
  85263. width: number;
  85264. height: number;
  85265. } | {
  85266. ratio: number;
  85267. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  85268. /**
  85269. * Creates a depth stencil texture.
  85270. * This is only available in WebGL 2 or with the depth texture extension available.
  85271. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  85272. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  85273. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  85274. */
  85275. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  85276. private _processSizeParameter;
  85277. /**
  85278. * Define the number of samples to use in case of MSAA.
  85279. * It defaults to one meaning no MSAA has been enabled.
  85280. */
  85281. samples: number;
  85282. /**
  85283. * Resets the refresh counter of the texture and start bak from scratch.
  85284. * Could be useful to regenerate the texture if it is setup to render only once.
  85285. */
  85286. resetRefreshCounter(): void;
  85287. /**
  85288. * Define the refresh rate of the texture or the rendering frequency.
  85289. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  85290. */
  85291. refreshRate: number;
  85292. /**
  85293. * Adds a post process to the render target rendering passes.
  85294. * @param postProcess define the post process to add
  85295. */
  85296. addPostProcess(postProcess: PostProcess): void;
  85297. /**
  85298. * Clear all the post processes attached to the render target
  85299. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  85300. */
  85301. clearPostProcesses(dispose?: boolean): void;
  85302. /**
  85303. * Remove one of the post process from the list of attached post processes to the texture
  85304. * @param postProcess define the post process to remove from the list
  85305. */
  85306. removePostProcess(postProcess: PostProcess): void;
  85307. /** @hidden */
  85308. _shouldRender(): boolean;
  85309. /**
  85310. * Gets the actual render size of the texture.
  85311. * @returns the width of the render size
  85312. */
  85313. getRenderSize(): number;
  85314. /**
  85315. * Gets the actual render width of the texture.
  85316. * @returns the width of the render size
  85317. */
  85318. getRenderWidth(): number;
  85319. /**
  85320. * Gets the actual render height of the texture.
  85321. * @returns the height of the render size
  85322. */
  85323. getRenderHeight(): number;
  85324. /**
  85325. * Get if the texture can be rescaled or not.
  85326. */
  85327. readonly canRescale: boolean;
  85328. /**
  85329. * Resize the texture using a ratio.
  85330. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  85331. */
  85332. scale(ratio: number): void;
  85333. /**
  85334. * Get the texture reflection matrix used to rotate/transform the reflection.
  85335. * @returns the reflection matrix
  85336. */
  85337. getReflectionTextureMatrix(): Matrix;
  85338. /**
  85339. * Resize the texture to a new desired size.
  85340. * Be carrefull as it will recreate all the data in the new texture.
  85341. * @param size Define the new size. It can be:
  85342. * - a number for squared texture,
  85343. * - an object containing { width: number, height: number }
  85344. * - or an object containing a ratio { ratio: number }
  85345. */
  85346. resize(size: number | {
  85347. width: number;
  85348. height: number;
  85349. } | {
  85350. ratio: number;
  85351. }): void;
  85352. /**
  85353. * Renders all the objects from the render list into the texture.
  85354. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  85355. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  85356. */
  85357. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  85358. private _bestReflectionRenderTargetDimension;
  85359. /**
  85360. * @hidden
  85361. * @param faceIndex face index to bind to if this is a cubetexture
  85362. */
  85363. _bindFrameBuffer(faceIndex?: number): void;
  85364. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  85365. private renderToTarget;
  85366. /**
  85367. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  85368. * This allowed control for front to back rendering or reversly depending of the special needs.
  85369. *
  85370. * @param renderingGroupId The rendering group id corresponding to its index
  85371. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  85372. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  85373. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  85374. */
  85375. 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;
  85376. /**
  85377. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  85378. *
  85379. * @param renderingGroupId The rendering group id corresponding to its index
  85380. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  85381. */
  85382. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  85383. /**
  85384. * Clones the texture.
  85385. * @returns the cloned texture
  85386. */
  85387. clone(): RenderTargetTexture;
  85388. /**
  85389. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  85390. * @returns The JSON representation of the texture
  85391. */
  85392. serialize(): any;
  85393. /**
  85394. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  85395. */
  85396. disposeFramebufferObjects(): void;
  85397. /**
  85398. * Dispose the texture and release its associated resources.
  85399. */
  85400. dispose(): void;
  85401. /** @hidden */
  85402. _rebuild(): void;
  85403. /**
  85404. * Clear the info related to rendering groups preventing retention point in material dispose.
  85405. */
  85406. freeRenderingGroups(): void;
  85407. /**
  85408. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  85409. * @returns the view count
  85410. */
  85411. getViewCount(): number;
  85412. }
  85413. }
  85414. declare module BABYLON {
  85415. /**
  85416. * Base class for the main features of a material in Babylon.js
  85417. */
  85418. export class Material implements IAnimatable {
  85419. /**
  85420. * Returns the triangle fill mode
  85421. */
  85422. static readonly TriangleFillMode: number;
  85423. /**
  85424. * Returns the wireframe mode
  85425. */
  85426. static readonly WireFrameFillMode: number;
  85427. /**
  85428. * Returns the point fill mode
  85429. */
  85430. static readonly PointFillMode: number;
  85431. /**
  85432. * Returns the point list draw mode
  85433. */
  85434. static readonly PointListDrawMode: number;
  85435. /**
  85436. * Returns the line list draw mode
  85437. */
  85438. static readonly LineListDrawMode: number;
  85439. /**
  85440. * Returns the line loop draw mode
  85441. */
  85442. static readonly LineLoopDrawMode: number;
  85443. /**
  85444. * Returns the line strip draw mode
  85445. */
  85446. static readonly LineStripDrawMode: number;
  85447. /**
  85448. * Returns the triangle strip draw mode
  85449. */
  85450. static readonly TriangleStripDrawMode: number;
  85451. /**
  85452. * Returns the triangle fan draw mode
  85453. */
  85454. static readonly TriangleFanDrawMode: number;
  85455. /**
  85456. * Stores the clock-wise side orientation
  85457. */
  85458. static readonly ClockWiseSideOrientation: number;
  85459. /**
  85460. * Stores the counter clock-wise side orientation
  85461. */
  85462. static readonly CounterClockWiseSideOrientation: number;
  85463. /**
  85464. * The dirty texture flag value
  85465. */
  85466. static readonly TextureDirtyFlag: number;
  85467. /**
  85468. * The dirty light flag value
  85469. */
  85470. static readonly LightDirtyFlag: number;
  85471. /**
  85472. * The dirty fresnel flag value
  85473. */
  85474. static readonly FresnelDirtyFlag: number;
  85475. /**
  85476. * The dirty attribute flag value
  85477. */
  85478. static readonly AttributesDirtyFlag: number;
  85479. /**
  85480. * The dirty misc flag value
  85481. */
  85482. static readonly MiscDirtyFlag: number;
  85483. /**
  85484. * The all dirty flag value
  85485. */
  85486. static readonly AllDirtyFlag: number;
  85487. /**
  85488. * The ID of the material
  85489. */
  85490. id: string;
  85491. /**
  85492. * Gets or sets the unique id of the material
  85493. */
  85494. uniqueId: number;
  85495. /**
  85496. * The name of the material
  85497. */
  85498. name: string;
  85499. /**
  85500. * Gets or sets user defined metadata
  85501. */
  85502. metadata: any;
  85503. /**
  85504. * For internal use only. Please do not use.
  85505. */
  85506. reservedDataStore: any;
  85507. /**
  85508. * Specifies if the ready state should be checked on each call
  85509. */
  85510. checkReadyOnEveryCall: boolean;
  85511. /**
  85512. * Specifies if the ready state should be checked once
  85513. */
  85514. checkReadyOnlyOnce: boolean;
  85515. /**
  85516. * The state of the material
  85517. */
  85518. state: string;
  85519. /**
  85520. * The alpha value of the material
  85521. */
  85522. protected _alpha: number;
  85523. /**
  85524. * List of inspectable custom properties (used by the Inspector)
  85525. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  85526. */
  85527. inspectableCustomProperties: IInspectable[];
  85528. /**
  85529. * Sets the alpha value of the material
  85530. */
  85531. /**
  85532. * Gets the alpha value of the material
  85533. */
  85534. alpha: number;
  85535. /**
  85536. * Specifies if back face culling is enabled
  85537. */
  85538. protected _backFaceCulling: boolean;
  85539. /**
  85540. * Sets the back-face culling state
  85541. */
  85542. /**
  85543. * Gets the back-face culling state
  85544. */
  85545. backFaceCulling: boolean;
  85546. /**
  85547. * Stores the value for side orientation
  85548. */
  85549. sideOrientation: number;
  85550. /**
  85551. * Callback triggered when the material is compiled
  85552. */
  85553. onCompiled: Nullable<(effect: Effect) => void>;
  85554. /**
  85555. * Callback triggered when an error occurs
  85556. */
  85557. onError: Nullable<(effect: Effect, errors: string) => void>;
  85558. /**
  85559. * Callback triggered to get the render target textures
  85560. */
  85561. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  85562. /**
  85563. * Gets a boolean indicating that current material needs to register RTT
  85564. */
  85565. readonly hasRenderTargetTextures: boolean;
  85566. /**
  85567. * Specifies if the material should be serialized
  85568. */
  85569. doNotSerialize: boolean;
  85570. /**
  85571. * @hidden
  85572. */
  85573. _storeEffectOnSubMeshes: boolean;
  85574. /**
  85575. * Stores the animations for the material
  85576. */
  85577. animations: Nullable<Array<Animation>>;
  85578. /**
  85579. * An event triggered when the material is disposed
  85580. */
  85581. onDisposeObservable: Observable<Material>;
  85582. /**
  85583. * An observer which watches for dispose events
  85584. */
  85585. private _onDisposeObserver;
  85586. private _onUnBindObservable;
  85587. /**
  85588. * Called during a dispose event
  85589. */
  85590. onDispose: () => void;
  85591. private _onBindObservable;
  85592. /**
  85593. * An event triggered when the material is bound
  85594. */
  85595. readonly onBindObservable: Observable<AbstractMesh>;
  85596. /**
  85597. * An observer which watches for bind events
  85598. */
  85599. private _onBindObserver;
  85600. /**
  85601. * Called during a bind event
  85602. */
  85603. onBind: (Mesh: AbstractMesh) => void;
  85604. /**
  85605. * An event triggered when the material is unbound
  85606. */
  85607. readonly onUnBindObservable: Observable<Material>;
  85608. /**
  85609. * Stores the value of the alpha mode
  85610. */
  85611. private _alphaMode;
  85612. /**
  85613. * Sets the value of the alpha mode.
  85614. *
  85615. * | Value | Type | Description |
  85616. * | --- | --- | --- |
  85617. * | 0 | ALPHA_DISABLE | |
  85618. * | 1 | ALPHA_ADD | |
  85619. * | 2 | ALPHA_COMBINE | |
  85620. * | 3 | ALPHA_SUBTRACT | |
  85621. * | 4 | ALPHA_MULTIPLY | |
  85622. * | 5 | ALPHA_MAXIMIZED | |
  85623. * | 6 | ALPHA_ONEONE | |
  85624. * | 7 | ALPHA_PREMULTIPLIED | |
  85625. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  85626. * | 9 | ALPHA_INTERPOLATE | |
  85627. * | 10 | ALPHA_SCREENMODE | |
  85628. *
  85629. */
  85630. /**
  85631. * Gets the value of the alpha mode
  85632. */
  85633. alphaMode: number;
  85634. /**
  85635. * Stores the state of the need depth pre-pass value
  85636. */
  85637. private _needDepthPrePass;
  85638. /**
  85639. * Sets the need depth pre-pass value
  85640. */
  85641. /**
  85642. * Gets the depth pre-pass value
  85643. */
  85644. needDepthPrePass: boolean;
  85645. /**
  85646. * Specifies if depth writing should be disabled
  85647. */
  85648. disableDepthWrite: boolean;
  85649. /**
  85650. * Specifies if depth writing should be forced
  85651. */
  85652. forceDepthWrite: boolean;
  85653. /**
  85654. * Specifies if there should be a separate pass for culling
  85655. */
  85656. separateCullingPass: boolean;
  85657. /**
  85658. * Stores the state specifing if fog should be enabled
  85659. */
  85660. private _fogEnabled;
  85661. /**
  85662. * Sets the state for enabling fog
  85663. */
  85664. /**
  85665. * Gets the value of the fog enabled state
  85666. */
  85667. fogEnabled: boolean;
  85668. /**
  85669. * Stores the size of points
  85670. */
  85671. pointSize: number;
  85672. /**
  85673. * Stores the z offset value
  85674. */
  85675. zOffset: number;
  85676. /**
  85677. * Gets a value specifying if wireframe mode is enabled
  85678. */
  85679. /**
  85680. * Sets the state of wireframe mode
  85681. */
  85682. wireframe: boolean;
  85683. /**
  85684. * Gets the value specifying if point clouds are enabled
  85685. */
  85686. /**
  85687. * Sets the state of point cloud mode
  85688. */
  85689. pointsCloud: boolean;
  85690. /**
  85691. * Gets the material fill mode
  85692. */
  85693. /**
  85694. * Sets the material fill mode
  85695. */
  85696. fillMode: number;
  85697. /**
  85698. * @hidden
  85699. * Stores the effects for the material
  85700. */
  85701. _effect: Nullable<Effect>;
  85702. /**
  85703. * @hidden
  85704. * Specifies if the material was previously ready
  85705. */
  85706. _wasPreviouslyReady: boolean;
  85707. /**
  85708. * Specifies if uniform buffers should be used
  85709. */
  85710. private _useUBO;
  85711. /**
  85712. * Stores a reference to the scene
  85713. */
  85714. private _scene;
  85715. /**
  85716. * Stores the fill mode state
  85717. */
  85718. private _fillMode;
  85719. /**
  85720. * Specifies if the depth write state should be cached
  85721. */
  85722. private _cachedDepthWriteState;
  85723. /**
  85724. * Stores the uniform buffer
  85725. */
  85726. protected _uniformBuffer: UniformBuffer;
  85727. /** @hidden */
  85728. _indexInSceneMaterialArray: number;
  85729. /** @hidden */
  85730. meshMap: Nullable<{
  85731. [id: string]: AbstractMesh | undefined;
  85732. }>;
  85733. /**
  85734. * Creates a material instance
  85735. * @param name defines the name of the material
  85736. * @param scene defines the scene to reference
  85737. * @param doNotAdd specifies if the material should be added to the scene
  85738. */
  85739. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  85740. /**
  85741. * Returns a string representation of the current material
  85742. * @param fullDetails defines a boolean indicating which levels of logging is desired
  85743. * @returns a string with material information
  85744. */
  85745. toString(fullDetails?: boolean): string;
  85746. /**
  85747. * Gets the class name of the material
  85748. * @returns a string with the class name of the material
  85749. */
  85750. getClassName(): string;
  85751. /**
  85752. * Specifies if updates for the material been locked
  85753. */
  85754. readonly isFrozen: boolean;
  85755. /**
  85756. * Locks updates for the material
  85757. */
  85758. freeze(): void;
  85759. /**
  85760. * Unlocks updates for the material
  85761. */
  85762. unfreeze(): void;
  85763. /**
  85764. * Specifies if the material is ready to be used
  85765. * @param mesh defines the mesh to check
  85766. * @param useInstances specifies if instances should be used
  85767. * @returns a boolean indicating if the material is ready to be used
  85768. */
  85769. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  85770. /**
  85771. * Specifies that the submesh is ready to be used
  85772. * @param mesh defines the mesh to check
  85773. * @param subMesh defines which submesh to check
  85774. * @param useInstances specifies that instances should be used
  85775. * @returns a boolean indicating that the submesh is ready or not
  85776. */
  85777. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  85778. /**
  85779. * Returns the material effect
  85780. * @returns the effect associated with the material
  85781. */
  85782. getEffect(): Nullable<Effect>;
  85783. /**
  85784. * Returns the current scene
  85785. * @returns a Scene
  85786. */
  85787. getScene(): Scene;
  85788. /**
  85789. * Specifies if the material will require alpha blending
  85790. * @returns a boolean specifying if alpha blending is needed
  85791. */
  85792. needAlphaBlending(): boolean;
  85793. /**
  85794. * Specifies if the mesh will require alpha blending
  85795. * @param mesh defines the mesh to check
  85796. * @returns a boolean specifying if alpha blending is needed for the mesh
  85797. */
  85798. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  85799. /**
  85800. * Specifies if this material should be rendered in alpha test mode
  85801. * @returns a boolean specifying if an alpha test is needed.
  85802. */
  85803. needAlphaTesting(): boolean;
  85804. /**
  85805. * Gets the texture used for the alpha test
  85806. * @returns the texture to use for alpha testing
  85807. */
  85808. getAlphaTestTexture(): Nullable<BaseTexture>;
  85809. /**
  85810. * Marks the material to indicate that it needs to be re-calculated
  85811. */
  85812. markDirty(): void;
  85813. /** @hidden */
  85814. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  85815. /**
  85816. * Binds the material to the mesh
  85817. * @param world defines the world transformation matrix
  85818. * @param mesh defines the mesh to bind the material to
  85819. */
  85820. bind(world: Matrix, mesh?: Mesh): void;
  85821. /**
  85822. * Binds the submesh to the material
  85823. * @param world defines the world transformation matrix
  85824. * @param mesh defines the mesh containing the submesh
  85825. * @param subMesh defines the submesh to bind the material to
  85826. */
  85827. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  85828. /**
  85829. * Binds the world matrix to the material
  85830. * @param world defines the world transformation matrix
  85831. */
  85832. bindOnlyWorldMatrix(world: Matrix): void;
  85833. /**
  85834. * Binds the scene's uniform buffer to the effect.
  85835. * @param effect defines the effect to bind to the scene uniform buffer
  85836. * @param sceneUbo defines the uniform buffer storing scene data
  85837. */
  85838. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  85839. /**
  85840. * Binds the view matrix to the effect
  85841. * @param effect defines the effect to bind the view matrix to
  85842. */
  85843. bindView(effect: Effect): void;
  85844. /**
  85845. * Binds the view projection matrix to the effect
  85846. * @param effect defines the effect to bind the view projection matrix to
  85847. */
  85848. bindViewProjection(effect: Effect): void;
  85849. /**
  85850. * Specifies if material alpha testing should be turned on for the mesh
  85851. * @param mesh defines the mesh to check
  85852. */
  85853. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  85854. /**
  85855. * Processes to execute after binding the material to a mesh
  85856. * @param mesh defines the rendered mesh
  85857. */
  85858. protected _afterBind(mesh?: Mesh): void;
  85859. /**
  85860. * Unbinds the material from the mesh
  85861. */
  85862. unbind(): void;
  85863. /**
  85864. * Gets the active textures from the material
  85865. * @returns an array of textures
  85866. */
  85867. getActiveTextures(): BaseTexture[];
  85868. /**
  85869. * Specifies if the material uses a texture
  85870. * @param texture defines the texture to check against the material
  85871. * @returns a boolean specifying if the material uses the texture
  85872. */
  85873. hasTexture(texture: BaseTexture): boolean;
  85874. /**
  85875. * Makes a duplicate of the material, and gives it a new name
  85876. * @param name defines the new name for the duplicated material
  85877. * @returns the cloned material
  85878. */
  85879. clone(name: string): Nullable<Material>;
  85880. /**
  85881. * Gets the meshes bound to the material
  85882. * @returns an array of meshes bound to the material
  85883. */
  85884. getBindedMeshes(): AbstractMesh[];
  85885. /**
  85886. * Force shader compilation
  85887. * @param mesh defines the mesh associated with this material
  85888. * @param onCompiled defines a function to execute once the material is compiled
  85889. * @param options defines the options to configure the compilation
  85890. */
  85891. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  85892. clipPlane: boolean;
  85893. }>): void;
  85894. /**
  85895. * Force shader compilation
  85896. * @param mesh defines the mesh that will use this material
  85897. * @param options defines additional options for compiling the shaders
  85898. * @returns a promise that resolves when the compilation completes
  85899. */
  85900. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<{
  85901. clipPlane: boolean;
  85902. }>): Promise<void>;
  85903. private static readonly _AllDirtyCallBack;
  85904. private static readonly _ImageProcessingDirtyCallBack;
  85905. private static readonly _TextureDirtyCallBack;
  85906. private static readonly _FresnelDirtyCallBack;
  85907. private static readonly _MiscDirtyCallBack;
  85908. private static readonly _LightsDirtyCallBack;
  85909. private static readonly _AttributeDirtyCallBack;
  85910. private static _FresnelAndMiscDirtyCallBack;
  85911. private static _TextureAndMiscDirtyCallBack;
  85912. private static readonly _DirtyCallbackArray;
  85913. private static readonly _RunDirtyCallBacks;
  85914. /**
  85915. * Marks a define in the material to indicate that it needs to be re-computed
  85916. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  85917. */
  85918. markAsDirty(flag: number): void;
  85919. /**
  85920. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  85921. * @param func defines a function which checks material defines against the submeshes
  85922. */
  85923. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  85924. /**
  85925. * Indicates that we need to re-calculated for all submeshes
  85926. */
  85927. protected _markAllSubMeshesAsAllDirty(): void;
  85928. /**
  85929. * Indicates that image processing needs to be re-calculated for all submeshes
  85930. */
  85931. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  85932. /**
  85933. * Indicates that textures need to be re-calculated for all submeshes
  85934. */
  85935. protected _markAllSubMeshesAsTexturesDirty(): void;
  85936. /**
  85937. * Indicates that fresnel needs to be re-calculated for all submeshes
  85938. */
  85939. protected _markAllSubMeshesAsFresnelDirty(): void;
  85940. /**
  85941. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  85942. */
  85943. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  85944. /**
  85945. * Indicates that lights need to be re-calculated for all submeshes
  85946. */
  85947. protected _markAllSubMeshesAsLightsDirty(): void;
  85948. /**
  85949. * Indicates that attributes need to be re-calculated for all submeshes
  85950. */
  85951. protected _markAllSubMeshesAsAttributesDirty(): void;
  85952. /**
  85953. * Indicates that misc needs to be re-calculated for all submeshes
  85954. */
  85955. protected _markAllSubMeshesAsMiscDirty(): void;
  85956. /**
  85957. * Indicates that textures and misc need to be re-calculated for all submeshes
  85958. */
  85959. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  85960. /**
  85961. * Disposes the material
  85962. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  85963. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  85964. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  85965. */
  85966. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  85967. /** @hidden */
  85968. private releaseVertexArrayObject;
  85969. /**
  85970. * Serializes this material
  85971. * @returns the serialized material object
  85972. */
  85973. serialize(): any;
  85974. /**
  85975. * Creates a material from parsed material data
  85976. * @param parsedMaterial defines parsed material data
  85977. * @param scene defines the hosting scene
  85978. * @param rootUrl defines the root URL to use to load textures
  85979. * @returns a new material
  85980. */
  85981. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  85982. }
  85983. }
  85984. declare module BABYLON {
  85985. /**
  85986. * A multi-material is used to apply different materials to different parts of the same object without the need of
  85987. * separate meshes. This can be use to improve performances.
  85988. * @see http://doc.babylonjs.com/how_to/multi_materials
  85989. */
  85990. export class MultiMaterial extends Material {
  85991. private _subMaterials;
  85992. /**
  85993. * Gets or Sets the list of Materials used within the multi material.
  85994. * They need to be ordered according to the submeshes order in the associated mesh
  85995. */
  85996. subMaterials: Nullable<Material>[];
  85997. /**
  85998. * Function used to align with Node.getChildren()
  85999. * @returns the list of Materials used within the multi material
  86000. */
  86001. getChildren(): Nullable<Material>[];
  86002. /**
  86003. * Instantiates a new Multi Material
  86004. * A multi-material is used to apply different materials to different parts of the same object without the need of
  86005. * separate meshes. This can be use to improve performances.
  86006. * @see http://doc.babylonjs.com/how_to/multi_materials
  86007. * @param name Define the name in the scene
  86008. * @param scene Define the scene the material belongs to
  86009. */
  86010. constructor(name: string, scene: Scene);
  86011. private _hookArray;
  86012. /**
  86013. * Get one of the submaterial by its index in the submaterials array
  86014. * @param index The index to look the sub material at
  86015. * @returns The Material if the index has been defined
  86016. */
  86017. getSubMaterial(index: number): Nullable<Material>;
  86018. /**
  86019. * Get the list of active textures for the whole sub materials list.
  86020. * @returns All the textures that will be used during the rendering
  86021. */
  86022. getActiveTextures(): BaseTexture[];
  86023. /**
  86024. * Gets the current class name of the material e.g. "MultiMaterial"
  86025. * Mainly use in serialization.
  86026. * @returns the class name
  86027. */
  86028. getClassName(): string;
  86029. /**
  86030. * Checks if the material is ready to render the requested sub mesh
  86031. * @param mesh Define the mesh the submesh belongs to
  86032. * @param subMesh Define the sub mesh to look readyness for
  86033. * @param useInstances Define whether or not the material is used with instances
  86034. * @returns true if ready, otherwise false
  86035. */
  86036. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  86037. /**
  86038. * Clones the current material and its related sub materials
  86039. * @param name Define the name of the newly cloned material
  86040. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  86041. * @returns the cloned material
  86042. */
  86043. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  86044. /**
  86045. * Serializes the materials into a JSON representation.
  86046. * @returns the JSON representation
  86047. */
  86048. serialize(): any;
  86049. /**
  86050. * Dispose the material and release its associated resources
  86051. * @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)
  86052. * @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)
  86053. * @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)
  86054. */
  86055. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  86056. /**
  86057. * Creates a MultiMaterial from parsed MultiMaterial data.
  86058. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  86059. * @param scene defines the hosting scene
  86060. * @returns a new MultiMaterial
  86061. */
  86062. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  86063. }
  86064. }
  86065. declare module BABYLON {
  86066. /**
  86067. * Base class for submeshes
  86068. */
  86069. export class BaseSubMesh {
  86070. /** @hidden */
  86071. _materialDefines: Nullable<MaterialDefines>;
  86072. /** @hidden */
  86073. _materialEffect: Nullable<Effect>;
  86074. /**
  86075. * Gets associated effect
  86076. */
  86077. readonly effect: Nullable<Effect>;
  86078. /**
  86079. * Sets associated effect (effect used to render this submesh)
  86080. * @param effect defines the effect to associate with
  86081. * @param defines defines the set of defines used to compile this effect
  86082. */
  86083. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  86084. }
  86085. /**
  86086. * Defines a subdivision inside a mesh
  86087. */
  86088. export class SubMesh extends BaseSubMesh implements ICullable {
  86089. /** the material index to use */
  86090. materialIndex: number;
  86091. /** vertex index start */
  86092. verticesStart: number;
  86093. /** vertices count */
  86094. verticesCount: number;
  86095. /** index start */
  86096. indexStart: number;
  86097. /** indices count */
  86098. indexCount: number;
  86099. /** @hidden */
  86100. _linesIndexCount: number;
  86101. private _mesh;
  86102. private _renderingMesh;
  86103. private _boundingInfo;
  86104. private _linesIndexBuffer;
  86105. /** @hidden */
  86106. _lastColliderWorldVertices: Nullable<Vector3[]>;
  86107. /** @hidden */
  86108. _trianglePlanes: Plane[];
  86109. /** @hidden */
  86110. _lastColliderTransformMatrix: Nullable<Matrix>;
  86111. /** @hidden */
  86112. _renderId: number;
  86113. /** @hidden */
  86114. _alphaIndex: number;
  86115. /** @hidden */
  86116. _distanceToCamera: number;
  86117. /** @hidden */
  86118. _id: number;
  86119. private _currentMaterial;
  86120. /**
  86121. * Add a new submesh to a mesh
  86122. * @param materialIndex defines the material index to use
  86123. * @param verticesStart defines vertex index start
  86124. * @param verticesCount defines vertices count
  86125. * @param indexStart defines index start
  86126. * @param indexCount defines indices count
  86127. * @param mesh defines the parent mesh
  86128. * @param renderingMesh defines an optional rendering mesh
  86129. * @param createBoundingBox defines if bounding box should be created for this submesh
  86130. * @returns the new submesh
  86131. */
  86132. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  86133. /**
  86134. * Creates a new submesh
  86135. * @param materialIndex defines the material index to use
  86136. * @param verticesStart defines vertex index start
  86137. * @param verticesCount defines vertices count
  86138. * @param indexStart defines index start
  86139. * @param indexCount defines indices count
  86140. * @param mesh defines the parent mesh
  86141. * @param renderingMesh defines an optional rendering mesh
  86142. * @param createBoundingBox defines if bounding box should be created for this submesh
  86143. */
  86144. constructor(
  86145. /** the material index to use */
  86146. materialIndex: number,
  86147. /** vertex index start */
  86148. verticesStart: number,
  86149. /** vertices count */
  86150. verticesCount: number,
  86151. /** index start */
  86152. indexStart: number,
  86153. /** indices count */
  86154. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  86155. /**
  86156. * Returns true if this submesh covers the entire parent mesh
  86157. * @ignorenaming
  86158. */
  86159. readonly IsGlobal: boolean;
  86160. /**
  86161. * Returns the submesh BoudingInfo object
  86162. * @returns current bounding info (or mesh's one if the submesh is global)
  86163. */
  86164. getBoundingInfo(): BoundingInfo;
  86165. /**
  86166. * Sets the submesh BoundingInfo
  86167. * @param boundingInfo defines the new bounding info to use
  86168. * @returns the SubMesh
  86169. */
  86170. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  86171. /**
  86172. * Returns the mesh of the current submesh
  86173. * @return the parent mesh
  86174. */
  86175. getMesh(): AbstractMesh;
  86176. /**
  86177. * Returns the rendering mesh of the submesh
  86178. * @returns the rendering mesh (could be different from parent mesh)
  86179. */
  86180. getRenderingMesh(): Mesh;
  86181. /**
  86182. * Returns the submesh material
  86183. * @returns null or the current material
  86184. */
  86185. getMaterial(): Nullable<Material>;
  86186. /**
  86187. * Sets a new updated BoundingInfo object to the submesh
  86188. * @param data defines an optional position array to use to determine the bounding info
  86189. * @returns the SubMesh
  86190. */
  86191. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  86192. /** @hidden */
  86193. _checkCollision(collider: Collider): boolean;
  86194. /**
  86195. * Updates the submesh BoundingInfo
  86196. * @param world defines the world matrix to use to update the bounding info
  86197. * @returns the submesh
  86198. */
  86199. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  86200. /**
  86201. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  86202. * @param frustumPlanes defines the frustum planes
  86203. * @returns true if the submesh is intersecting with the frustum
  86204. */
  86205. isInFrustum(frustumPlanes: Plane[]): boolean;
  86206. /**
  86207. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  86208. * @param frustumPlanes defines the frustum planes
  86209. * @returns true if the submesh is inside the frustum
  86210. */
  86211. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  86212. /**
  86213. * Renders the submesh
  86214. * @param enableAlphaMode defines if alpha needs to be used
  86215. * @returns the submesh
  86216. */
  86217. render(enableAlphaMode: boolean): SubMesh;
  86218. /**
  86219. * @hidden
  86220. */
  86221. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  86222. /**
  86223. * Checks if the submesh intersects with a ray
  86224. * @param ray defines the ray to test
  86225. * @returns true is the passed ray intersects the submesh bounding box
  86226. */
  86227. canIntersects(ray: Ray): boolean;
  86228. /**
  86229. * Intersects current submesh with a ray
  86230. * @param ray defines the ray to test
  86231. * @param positions defines mesh's positions array
  86232. * @param indices defines mesh's indices array
  86233. * @param fastCheck defines if only bounding info should be used
  86234. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  86235. * @returns intersection info or null if no intersection
  86236. */
  86237. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  86238. /** @hidden */
  86239. private _intersectLines;
  86240. /** @hidden */
  86241. private _intersectUnIndexedLines;
  86242. /** @hidden */
  86243. private _intersectTriangles;
  86244. /** @hidden */
  86245. private _intersectUnIndexedTriangles;
  86246. /** @hidden */
  86247. _rebuild(): void;
  86248. /**
  86249. * Creates a new submesh from the passed mesh
  86250. * @param newMesh defines the new hosting mesh
  86251. * @param newRenderingMesh defines an optional rendering mesh
  86252. * @returns the new submesh
  86253. */
  86254. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  86255. /**
  86256. * Release associated resources
  86257. */
  86258. dispose(): void;
  86259. /**
  86260. * Gets the class name
  86261. * @returns the string "SubMesh".
  86262. */
  86263. getClassName(): string;
  86264. /**
  86265. * Creates a new submesh from indices data
  86266. * @param materialIndex the index of the main mesh material
  86267. * @param startIndex the index where to start the copy in the mesh indices array
  86268. * @param indexCount the number of indices to copy then from the startIndex
  86269. * @param mesh the main mesh to create the submesh from
  86270. * @param renderingMesh the optional rendering mesh
  86271. * @returns a new submesh
  86272. */
  86273. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  86274. }
  86275. }
  86276. declare module BABYLON {
  86277. /**
  86278. * Class used to represent data loading progression
  86279. */
  86280. export class SceneLoaderFlags {
  86281. private static _ForceFullSceneLoadingForIncremental;
  86282. private static _ShowLoadingScreen;
  86283. private static _CleanBoneMatrixWeights;
  86284. private static _loggingLevel;
  86285. /**
  86286. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  86287. */
  86288. static ForceFullSceneLoadingForIncremental: boolean;
  86289. /**
  86290. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  86291. */
  86292. static ShowLoadingScreen: boolean;
  86293. /**
  86294. * Defines the current logging level (while loading the scene)
  86295. * @ignorenaming
  86296. */
  86297. static loggingLevel: number;
  86298. /**
  86299. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  86300. */
  86301. static CleanBoneMatrixWeights: boolean;
  86302. }
  86303. }
  86304. declare module BABYLON {
  86305. /**
  86306. * Class used to store geometry data (vertex buffers + index buffer)
  86307. */
  86308. export class Geometry implements IGetSetVerticesData {
  86309. /**
  86310. * Gets or sets the ID of the geometry
  86311. */
  86312. id: string;
  86313. /**
  86314. * Gets or sets the unique ID of the geometry
  86315. */
  86316. uniqueId: number;
  86317. /**
  86318. * Gets the delay loading state of the geometry (none by default which means not delayed)
  86319. */
  86320. delayLoadState: number;
  86321. /**
  86322. * Gets the file containing the data to load when running in delay load state
  86323. */
  86324. delayLoadingFile: Nullable<string>;
  86325. /**
  86326. * Callback called when the geometry is updated
  86327. */
  86328. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  86329. private _scene;
  86330. private _engine;
  86331. private _meshes;
  86332. private _totalVertices;
  86333. /** @hidden */
  86334. _indices: IndicesArray;
  86335. /** @hidden */
  86336. _vertexBuffers: {
  86337. [key: string]: VertexBuffer;
  86338. };
  86339. private _isDisposed;
  86340. private _extend;
  86341. private _boundingBias;
  86342. /** @hidden */
  86343. _delayInfo: Array<string>;
  86344. private _indexBuffer;
  86345. private _indexBufferIsUpdatable;
  86346. /** @hidden */
  86347. _boundingInfo: Nullable<BoundingInfo>;
  86348. /** @hidden */
  86349. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  86350. /** @hidden */
  86351. _softwareSkinningFrameId: number;
  86352. private _vertexArrayObjects;
  86353. private _updatable;
  86354. /** @hidden */
  86355. _positions: Nullable<Vector3[]>;
  86356. /**
  86357. * 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
  86358. */
  86359. /**
  86360. * 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
  86361. */
  86362. boundingBias: Vector2;
  86363. /**
  86364. * Static function used to attach a new empty geometry to a mesh
  86365. * @param mesh defines the mesh to attach the geometry to
  86366. * @returns the new Geometry
  86367. */
  86368. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  86369. /**
  86370. * Creates a new geometry
  86371. * @param id defines the unique ID
  86372. * @param scene defines the hosting scene
  86373. * @param vertexData defines the VertexData used to get geometry data
  86374. * @param updatable defines if geometry must be updatable (false by default)
  86375. * @param mesh defines the mesh that will be associated with the geometry
  86376. */
  86377. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  86378. /**
  86379. * Gets the current extend of the geometry
  86380. */
  86381. readonly extend: {
  86382. minimum: Vector3;
  86383. maximum: Vector3;
  86384. };
  86385. /**
  86386. * Gets the hosting scene
  86387. * @returns the hosting Scene
  86388. */
  86389. getScene(): Scene;
  86390. /**
  86391. * Gets the hosting engine
  86392. * @returns the hosting Engine
  86393. */
  86394. getEngine(): Engine;
  86395. /**
  86396. * Defines if the geometry is ready to use
  86397. * @returns true if the geometry is ready to be used
  86398. */
  86399. isReady(): boolean;
  86400. /**
  86401. * Gets a value indicating that the geometry should not be serialized
  86402. */
  86403. readonly doNotSerialize: boolean;
  86404. /** @hidden */
  86405. _rebuild(): void;
  86406. /**
  86407. * Affects all geometry data in one call
  86408. * @param vertexData defines the geometry data
  86409. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  86410. */
  86411. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  86412. /**
  86413. * Set specific vertex data
  86414. * @param kind defines the data kind (Position, normal, etc...)
  86415. * @param data defines the vertex data to use
  86416. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  86417. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  86418. */
  86419. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  86420. /**
  86421. * Removes a specific vertex data
  86422. * @param kind defines the data kind (Position, normal, etc...)
  86423. */
  86424. removeVerticesData(kind: string): void;
  86425. /**
  86426. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  86427. * @param buffer defines the vertex buffer to use
  86428. * @param totalVertices defines the total number of vertices for position kind (could be null)
  86429. */
  86430. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  86431. /**
  86432. * Update a specific vertex buffer
  86433. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  86434. * It will do nothing if the buffer is not updatable
  86435. * @param kind defines the data kind (Position, normal, etc...)
  86436. * @param data defines the data to use
  86437. * @param offset defines the offset in the target buffer where to store the data
  86438. * @param useBytes set to true if the offset is in bytes
  86439. */
  86440. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  86441. /**
  86442. * Update a specific vertex buffer
  86443. * This function will create a new buffer if the current one is not updatable
  86444. * @param kind defines the data kind (Position, normal, etc...)
  86445. * @param data defines the data to use
  86446. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  86447. */
  86448. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  86449. private _updateBoundingInfo;
  86450. /** @hidden */
  86451. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  86452. /**
  86453. * Gets total number of vertices
  86454. * @returns the total number of vertices
  86455. */
  86456. getTotalVertices(): number;
  86457. /**
  86458. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  86459. * @param kind defines the data kind (Position, normal, etc...)
  86460. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  86461. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  86462. * @returns a float array containing vertex data
  86463. */
  86464. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  86465. /**
  86466. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  86467. * @param kind defines the data kind (Position, normal, etc...)
  86468. * @returns true if the vertex buffer with the specified kind is updatable
  86469. */
  86470. isVertexBufferUpdatable(kind: string): boolean;
  86471. /**
  86472. * Gets a specific vertex buffer
  86473. * @param kind defines the data kind (Position, normal, etc...)
  86474. * @returns a VertexBuffer
  86475. */
  86476. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  86477. /**
  86478. * Returns all vertex buffers
  86479. * @return an object holding all vertex buffers indexed by kind
  86480. */
  86481. getVertexBuffers(): Nullable<{
  86482. [key: string]: VertexBuffer;
  86483. }>;
  86484. /**
  86485. * Gets a boolean indicating if specific vertex buffer is present
  86486. * @param kind defines the data kind (Position, normal, etc...)
  86487. * @returns true if data is present
  86488. */
  86489. isVerticesDataPresent(kind: string): boolean;
  86490. /**
  86491. * Gets a list of all attached data kinds (Position, normal, etc...)
  86492. * @returns a list of string containing all kinds
  86493. */
  86494. getVerticesDataKinds(): string[];
  86495. /**
  86496. * Update index buffer
  86497. * @param indices defines the indices to store in the index buffer
  86498. * @param offset defines the offset in the target buffer where to store the data
  86499. * @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)
  86500. */
  86501. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  86502. /**
  86503. * Creates a new index buffer
  86504. * @param indices defines the indices to store in the index buffer
  86505. * @param totalVertices defines the total number of vertices (could be null)
  86506. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  86507. */
  86508. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  86509. /**
  86510. * Return the total number of indices
  86511. * @returns the total number of indices
  86512. */
  86513. getTotalIndices(): number;
  86514. /**
  86515. * Gets the index buffer array
  86516. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  86517. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  86518. * @returns the index buffer array
  86519. */
  86520. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  86521. /**
  86522. * Gets the index buffer
  86523. * @return the index buffer
  86524. */
  86525. getIndexBuffer(): Nullable<DataBuffer>;
  86526. /** @hidden */
  86527. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  86528. /**
  86529. * Release the associated resources for a specific mesh
  86530. * @param mesh defines the source mesh
  86531. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  86532. */
  86533. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  86534. /**
  86535. * Apply current geometry to a given mesh
  86536. * @param mesh defines the mesh to apply geometry to
  86537. */
  86538. applyToMesh(mesh: Mesh): void;
  86539. private _updateExtend;
  86540. private _applyToMesh;
  86541. private notifyUpdate;
  86542. /**
  86543. * Load the geometry if it was flagged as delay loaded
  86544. * @param scene defines the hosting scene
  86545. * @param onLoaded defines a callback called when the geometry is loaded
  86546. */
  86547. load(scene: Scene, onLoaded?: () => void): void;
  86548. private _queueLoad;
  86549. /**
  86550. * Invert the geometry to move from a right handed system to a left handed one.
  86551. */
  86552. toLeftHanded(): void;
  86553. /** @hidden */
  86554. _resetPointsArrayCache(): void;
  86555. /** @hidden */
  86556. _generatePointsArray(): boolean;
  86557. /**
  86558. * Gets a value indicating if the geometry is disposed
  86559. * @returns true if the geometry was disposed
  86560. */
  86561. isDisposed(): boolean;
  86562. private _disposeVertexArrayObjects;
  86563. /**
  86564. * Free all associated resources
  86565. */
  86566. dispose(): void;
  86567. /**
  86568. * Clone the current geometry into a new geometry
  86569. * @param id defines the unique ID of the new geometry
  86570. * @returns a new geometry object
  86571. */
  86572. copy(id: string): Geometry;
  86573. /**
  86574. * Serialize the current geometry info (and not the vertices data) into a JSON object
  86575. * @return a JSON representation of the current geometry data (without the vertices data)
  86576. */
  86577. serialize(): any;
  86578. private toNumberArray;
  86579. /**
  86580. * Serialize all vertices data into a JSON oject
  86581. * @returns a JSON representation of the current geometry data
  86582. */
  86583. serializeVerticeData(): any;
  86584. /**
  86585. * Extracts a clone of a mesh geometry
  86586. * @param mesh defines the source mesh
  86587. * @param id defines the unique ID of the new geometry object
  86588. * @returns the new geometry object
  86589. */
  86590. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  86591. /**
  86592. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  86593. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  86594. * Be aware Math.random() could cause collisions, but:
  86595. * "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"
  86596. * @returns a string containing a new GUID
  86597. */
  86598. static RandomId(): string;
  86599. /** @hidden */
  86600. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  86601. private static _CleanMatricesWeights;
  86602. /**
  86603. * Create a new geometry from persisted data (Using .babylon file format)
  86604. * @param parsedVertexData defines the persisted data
  86605. * @param scene defines the hosting scene
  86606. * @param rootUrl defines the root url to use to load assets (like delayed data)
  86607. * @returns the new geometry object
  86608. */
  86609. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  86610. }
  86611. }
  86612. declare module BABYLON {
  86613. /**
  86614. * Define an interface for all classes that will get and set the data on vertices
  86615. */
  86616. export interface IGetSetVerticesData {
  86617. /**
  86618. * Gets a boolean indicating if specific vertex data is present
  86619. * @param kind defines the vertex data kind to use
  86620. * @returns true is data kind is present
  86621. */
  86622. isVerticesDataPresent(kind: string): boolean;
  86623. /**
  86624. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  86625. * @param kind defines the data kind (Position, normal, etc...)
  86626. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  86627. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  86628. * @returns a float array containing vertex data
  86629. */
  86630. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  86631. /**
  86632. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  86633. * @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.
  86634. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  86635. * @returns the indices array or an empty array if the mesh has no geometry
  86636. */
  86637. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  86638. /**
  86639. * Set specific vertex data
  86640. * @param kind defines the data kind (Position, normal, etc...)
  86641. * @param data defines the vertex data to use
  86642. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  86643. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  86644. */
  86645. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  86646. /**
  86647. * Update a specific associated vertex buffer
  86648. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  86649. * - VertexBuffer.PositionKind
  86650. * - VertexBuffer.UVKind
  86651. * - VertexBuffer.UV2Kind
  86652. * - VertexBuffer.UV3Kind
  86653. * - VertexBuffer.UV4Kind
  86654. * - VertexBuffer.UV5Kind
  86655. * - VertexBuffer.UV6Kind
  86656. * - VertexBuffer.ColorKind
  86657. * - VertexBuffer.MatricesIndicesKind
  86658. * - VertexBuffer.MatricesIndicesExtraKind
  86659. * - VertexBuffer.MatricesWeightsKind
  86660. * - VertexBuffer.MatricesWeightsExtraKind
  86661. * @param data defines the data source
  86662. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  86663. * @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)
  86664. */
  86665. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  86666. /**
  86667. * Creates a new index buffer
  86668. * @param indices defines the indices to store in the index buffer
  86669. * @param totalVertices defines the total number of vertices (could be null)
  86670. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  86671. */
  86672. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  86673. }
  86674. /**
  86675. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  86676. */
  86677. export class VertexData {
  86678. /**
  86679. * Mesh side orientation : usually the external or front surface
  86680. */
  86681. static readonly FRONTSIDE: number;
  86682. /**
  86683. * Mesh side orientation : usually the internal or back surface
  86684. */
  86685. static readonly BACKSIDE: number;
  86686. /**
  86687. * Mesh side orientation : both internal and external or front and back surfaces
  86688. */
  86689. static readonly DOUBLESIDE: number;
  86690. /**
  86691. * Mesh side orientation : by default, `FRONTSIDE`
  86692. */
  86693. static readonly DEFAULTSIDE: number;
  86694. /**
  86695. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  86696. */
  86697. positions: Nullable<FloatArray>;
  86698. /**
  86699. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  86700. */
  86701. normals: Nullable<FloatArray>;
  86702. /**
  86703. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  86704. */
  86705. tangents: Nullable<FloatArray>;
  86706. /**
  86707. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  86708. */
  86709. uvs: Nullable<FloatArray>;
  86710. /**
  86711. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  86712. */
  86713. uvs2: Nullable<FloatArray>;
  86714. /**
  86715. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  86716. */
  86717. uvs3: Nullable<FloatArray>;
  86718. /**
  86719. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  86720. */
  86721. uvs4: Nullable<FloatArray>;
  86722. /**
  86723. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  86724. */
  86725. uvs5: Nullable<FloatArray>;
  86726. /**
  86727. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  86728. */
  86729. uvs6: Nullable<FloatArray>;
  86730. /**
  86731. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  86732. */
  86733. colors: Nullable<FloatArray>;
  86734. /**
  86735. * 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).
  86736. */
  86737. matricesIndices: Nullable<FloatArray>;
  86738. /**
  86739. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  86740. */
  86741. matricesWeights: Nullable<FloatArray>;
  86742. /**
  86743. * An array extending the number of possible indices
  86744. */
  86745. matricesIndicesExtra: Nullable<FloatArray>;
  86746. /**
  86747. * An array extending the number of possible weights when the number of indices is extended
  86748. */
  86749. matricesWeightsExtra: Nullable<FloatArray>;
  86750. /**
  86751. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  86752. */
  86753. indices: Nullable<IndicesArray>;
  86754. /**
  86755. * Uses the passed data array to set the set the values for the specified kind of data
  86756. * @param data a linear array of floating numbers
  86757. * @param kind the type of data that is being set, eg positions, colors etc
  86758. */
  86759. set(data: FloatArray, kind: string): void;
  86760. /**
  86761. * Associates the vertexData to the passed Mesh.
  86762. * Sets it as updatable or not (default `false`)
  86763. * @param mesh the mesh the vertexData is applied to
  86764. * @param updatable when used and having the value true allows new data to update the vertexData
  86765. * @returns the VertexData
  86766. */
  86767. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  86768. /**
  86769. * Associates the vertexData to the passed Geometry.
  86770. * Sets it as updatable or not (default `false`)
  86771. * @param geometry the geometry the vertexData is applied to
  86772. * @param updatable when used and having the value true allows new data to update the vertexData
  86773. * @returns VertexData
  86774. */
  86775. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  86776. /**
  86777. * Updates the associated mesh
  86778. * @param mesh the mesh to be updated
  86779. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  86780. * @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
  86781. * @returns VertexData
  86782. */
  86783. updateMesh(mesh: Mesh): VertexData;
  86784. /**
  86785. * Updates the associated geometry
  86786. * @param geometry the geometry to be updated
  86787. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  86788. * @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
  86789. * @returns VertexData.
  86790. */
  86791. updateGeometry(geometry: Geometry): VertexData;
  86792. private _applyTo;
  86793. private _update;
  86794. /**
  86795. * Transforms each position and each normal of the vertexData according to the passed Matrix
  86796. * @param matrix the transforming matrix
  86797. * @returns the VertexData
  86798. */
  86799. transform(matrix: Matrix): VertexData;
  86800. /**
  86801. * Merges the passed VertexData into the current one
  86802. * @param other the VertexData to be merged into the current one
  86803. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  86804. * @returns the modified VertexData
  86805. */
  86806. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  86807. private _mergeElement;
  86808. private _validate;
  86809. /**
  86810. * Serializes the VertexData
  86811. * @returns a serialized object
  86812. */
  86813. serialize(): any;
  86814. /**
  86815. * Extracts the vertexData from a mesh
  86816. * @param mesh the mesh from which to extract the VertexData
  86817. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  86818. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  86819. * @returns the object VertexData associated to the passed mesh
  86820. */
  86821. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  86822. /**
  86823. * Extracts the vertexData from the geometry
  86824. * @param geometry the geometry from which to extract the VertexData
  86825. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  86826. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  86827. * @returns the object VertexData associated to the passed mesh
  86828. */
  86829. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  86830. private static _ExtractFrom;
  86831. /**
  86832. * Creates the VertexData for a Ribbon
  86833. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  86834. * * pathArray array of paths, each of which an array of successive Vector3
  86835. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  86836. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  86837. * * 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
  86838. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  86839. * * 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)
  86840. * * 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)
  86841. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  86842. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  86843. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  86844. * @returns the VertexData of the ribbon
  86845. */
  86846. static CreateRibbon(options: {
  86847. pathArray: Vector3[][];
  86848. closeArray?: boolean;
  86849. closePath?: boolean;
  86850. offset?: number;
  86851. sideOrientation?: number;
  86852. frontUVs?: Vector4;
  86853. backUVs?: Vector4;
  86854. invertUV?: boolean;
  86855. uvs?: Vector2[];
  86856. colors?: Color4[];
  86857. }): VertexData;
  86858. /**
  86859. * Creates the VertexData for a box
  86860. * @param options an object used to set the following optional parameters for the box, required but can be empty
  86861. * * size sets the width, height and depth of the box to the value of size, optional default 1
  86862. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  86863. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  86864. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  86865. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  86866. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  86867. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  86868. * * 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)
  86869. * * 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)
  86870. * @returns the VertexData of the box
  86871. */
  86872. static CreateBox(options: {
  86873. size?: number;
  86874. width?: number;
  86875. height?: number;
  86876. depth?: number;
  86877. faceUV?: Vector4[];
  86878. faceColors?: Color4[];
  86879. sideOrientation?: number;
  86880. frontUVs?: Vector4;
  86881. backUVs?: Vector4;
  86882. }): VertexData;
  86883. /**
  86884. * Creates the VertexData for a tiled box
  86885. * @param options an object used to set the following optional parameters for the box, required but can be empty
  86886. * * faceTiles sets the pattern, tile size and number of tiles for a face
  86887. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  86888. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  86889. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  86890. * @returns the VertexData of the box
  86891. */
  86892. static CreateTiledBox(options: {
  86893. pattern?: number;
  86894. width?: number;
  86895. height?: number;
  86896. depth?: number;
  86897. tileSize?: number;
  86898. tileWidth?: number;
  86899. tileHeight?: number;
  86900. alignHorizontal?: number;
  86901. alignVertical?: number;
  86902. faceUV?: Vector4[];
  86903. faceColors?: Color4[];
  86904. sideOrientation?: number;
  86905. }): VertexData;
  86906. /**
  86907. * Creates the VertexData for a tiled plane
  86908. * @param options an object used to set the following optional parameters for the box, required but can be empty
  86909. * * pattern a limited pattern arrangement depending on the number
  86910. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  86911. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  86912. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  86913. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  86914. * * 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)
  86915. * * 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)
  86916. * @returns the VertexData of the tiled plane
  86917. */
  86918. static CreateTiledPlane(options: {
  86919. pattern?: number;
  86920. tileSize?: number;
  86921. tileWidth?: number;
  86922. tileHeight?: number;
  86923. size?: number;
  86924. width?: number;
  86925. height?: number;
  86926. alignHorizontal?: number;
  86927. alignVertical?: number;
  86928. sideOrientation?: number;
  86929. frontUVs?: Vector4;
  86930. backUVs?: Vector4;
  86931. }): VertexData;
  86932. /**
  86933. * Creates the VertexData for an ellipsoid, defaults to a sphere
  86934. * @param options an object used to set the following optional parameters for the box, required but can be empty
  86935. * * segments sets the number of horizontal strips optional, default 32
  86936. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  86937. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  86938. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  86939. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  86940. * * 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
  86941. * * 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
  86942. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  86943. * * 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)
  86944. * * 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)
  86945. * @returns the VertexData of the ellipsoid
  86946. */
  86947. static CreateSphere(options: {
  86948. segments?: number;
  86949. diameter?: number;
  86950. diameterX?: number;
  86951. diameterY?: number;
  86952. diameterZ?: number;
  86953. arc?: number;
  86954. slice?: number;
  86955. sideOrientation?: number;
  86956. frontUVs?: Vector4;
  86957. backUVs?: Vector4;
  86958. }): VertexData;
  86959. /**
  86960. * Creates the VertexData for a cylinder, cone or prism
  86961. * @param options an object used to set the following optional parameters for the box, required but can be empty
  86962. * * height sets the height (y direction) of the cylinder, optional, default 2
  86963. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  86964. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  86965. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  86966. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  86967. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  86968. * * 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
  86969. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  86970. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  86971. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  86972. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  86973. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  86974. * * 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)
  86975. * * 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)
  86976. * @returns the VertexData of the cylinder, cone or prism
  86977. */
  86978. static CreateCylinder(options: {
  86979. height?: number;
  86980. diameterTop?: number;
  86981. diameterBottom?: number;
  86982. diameter?: number;
  86983. tessellation?: number;
  86984. subdivisions?: number;
  86985. arc?: number;
  86986. faceColors?: Color4[];
  86987. faceUV?: Vector4[];
  86988. hasRings?: boolean;
  86989. enclose?: boolean;
  86990. sideOrientation?: number;
  86991. frontUVs?: Vector4;
  86992. backUVs?: Vector4;
  86993. }): VertexData;
  86994. /**
  86995. * Creates the VertexData for a torus
  86996. * @param options an object used to set the following optional parameters for the box, required but can be empty
  86997. * * diameter the diameter of the torus, optional default 1
  86998. * * thickness the diameter of the tube forming the torus, optional default 0.5
  86999. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  87000. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  87001. * * 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)
  87002. * * 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)
  87003. * @returns the VertexData of the torus
  87004. */
  87005. static CreateTorus(options: {
  87006. diameter?: number;
  87007. thickness?: number;
  87008. tessellation?: number;
  87009. sideOrientation?: number;
  87010. frontUVs?: Vector4;
  87011. backUVs?: Vector4;
  87012. }): VertexData;
  87013. /**
  87014. * Creates the VertexData of the LineSystem
  87015. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  87016. * - lines an array of lines, each line being an array of successive Vector3
  87017. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  87018. * @returns the VertexData of the LineSystem
  87019. */
  87020. static CreateLineSystem(options: {
  87021. lines: Vector3[][];
  87022. colors?: Nullable<Color4[][]>;
  87023. }): VertexData;
  87024. /**
  87025. * Create the VertexData for a DashedLines
  87026. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  87027. * - points an array successive Vector3
  87028. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  87029. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  87030. * - dashNb the intended total number of dashes, optional, default 200
  87031. * @returns the VertexData for the DashedLines
  87032. */
  87033. static CreateDashedLines(options: {
  87034. points: Vector3[];
  87035. dashSize?: number;
  87036. gapSize?: number;
  87037. dashNb?: number;
  87038. }): VertexData;
  87039. /**
  87040. * Creates the VertexData for a Ground
  87041. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  87042. * - width the width (x direction) of the ground, optional, default 1
  87043. * - height the height (z direction) of the ground, optional, default 1
  87044. * - subdivisions the number of subdivisions per side, optional, default 1
  87045. * @returns the VertexData of the Ground
  87046. */
  87047. static CreateGround(options: {
  87048. width?: number;
  87049. height?: number;
  87050. subdivisions?: number;
  87051. subdivisionsX?: number;
  87052. subdivisionsY?: number;
  87053. }): VertexData;
  87054. /**
  87055. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  87056. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  87057. * * xmin the ground minimum X coordinate, optional, default -1
  87058. * * zmin the ground minimum Z coordinate, optional, default -1
  87059. * * xmax the ground maximum X coordinate, optional, default 1
  87060. * * zmax the ground maximum Z coordinate, optional, default 1
  87061. * * 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}
  87062. * * 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}
  87063. * @returns the VertexData of the TiledGround
  87064. */
  87065. static CreateTiledGround(options: {
  87066. xmin: number;
  87067. zmin: number;
  87068. xmax: number;
  87069. zmax: number;
  87070. subdivisions?: {
  87071. w: number;
  87072. h: number;
  87073. };
  87074. precision?: {
  87075. w: number;
  87076. h: number;
  87077. };
  87078. }): VertexData;
  87079. /**
  87080. * Creates the VertexData of the Ground designed from a heightmap
  87081. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  87082. * * width the width (x direction) of the ground
  87083. * * height the height (z direction) of the ground
  87084. * * subdivisions the number of subdivisions per side
  87085. * * minHeight the minimum altitude on the ground, optional, default 0
  87086. * * maxHeight the maximum altitude on the ground, optional default 1
  87087. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  87088. * * buffer the array holding the image color data
  87089. * * bufferWidth the width of image
  87090. * * bufferHeight the height of image
  87091. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  87092. * @returns the VertexData of the Ground designed from a heightmap
  87093. */
  87094. static CreateGroundFromHeightMap(options: {
  87095. width: number;
  87096. height: number;
  87097. subdivisions: number;
  87098. minHeight: number;
  87099. maxHeight: number;
  87100. colorFilter: Color3;
  87101. buffer: Uint8Array;
  87102. bufferWidth: number;
  87103. bufferHeight: number;
  87104. alphaFilter: number;
  87105. }): VertexData;
  87106. /**
  87107. * Creates the VertexData for a Plane
  87108. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  87109. * * size sets the width and height of the plane to the value of size, optional default 1
  87110. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  87111. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  87112. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  87113. * * 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)
  87114. * * 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)
  87115. * @returns the VertexData of the box
  87116. */
  87117. static CreatePlane(options: {
  87118. size?: number;
  87119. width?: number;
  87120. height?: number;
  87121. sideOrientation?: number;
  87122. frontUVs?: Vector4;
  87123. backUVs?: Vector4;
  87124. }): VertexData;
  87125. /**
  87126. * Creates the VertexData of the Disc or regular Polygon
  87127. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  87128. * * radius the radius of the disc, optional default 0.5
  87129. * * tessellation the number of polygon sides, optional, default 64
  87130. * * 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
  87131. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  87132. * * 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)
  87133. * * 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)
  87134. * @returns the VertexData of the box
  87135. */
  87136. static CreateDisc(options: {
  87137. radius?: number;
  87138. tessellation?: number;
  87139. arc?: number;
  87140. sideOrientation?: number;
  87141. frontUVs?: Vector4;
  87142. backUVs?: Vector4;
  87143. }): VertexData;
  87144. /**
  87145. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  87146. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  87147. * @param polygon a mesh built from polygonTriangulation.build()
  87148. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  87149. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  87150. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  87151. * @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)
  87152. * @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)
  87153. * @returns the VertexData of the Polygon
  87154. */
  87155. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  87156. /**
  87157. * Creates the VertexData of the IcoSphere
  87158. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  87159. * * radius the radius of the IcoSphere, optional default 1
  87160. * * radiusX allows stretching in the x direction, optional, default radius
  87161. * * radiusY allows stretching in the y direction, optional, default radius
  87162. * * radiusZ allows stretching in the z direction, optional, default radius
  87163. * * flat when true creates a flat shaded mesh, optional, default true
  87164. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  87165. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  87166. * * 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)
  87167. * * 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)
  87168. * @returns the VertexData of the IcoSphere
  87169. */
  87170. static CreateIcoSphere(options: {
  87171. radius?: number;
  87172. radiusX?: number;
  87173. radiusY?: number;
  87174. radiusZ?: number;
  87175. flat?: boolean;
  87176. subdivisions?: number;
  87177. sideOrientation?: number;
  87178. frontUVs?: Vector4;
  87179. backUVs?: Vector4;
  87180. }): VertexData;
  87181. /**
  87182. * Creates the VertexData for a Polyhedron
  87183. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  87184. * * type provided types are:
  87185. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  87186. * * 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)
  87187. * * size the size of the IcoSphere, optional default 1
  87188. * * sizeX allows stretching in the x direction, optional, default size
  87189. * * sizeY allows stretching in the y direction, optional, default size
  87190. * * sizeZ allows stretching in the z direction, optional, default size
  87191. * * 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
  87192. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  87193. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  87194. * * flat when true creates a flat shaded mesh, optional, default true
  87195. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  87196. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  87197. * * 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)
  87198. * * 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)
  87199. * @returns the VertexData of the Polyhedron
  87200. */
  87201. static CreatePolyhedron(options: {
  87202. type?: number;
  87203. size?: number;
  87204. sizeX?: number;
  87205. sizeY?: number;
  87206. sizeZ?: number;
  87207. custom?: any;
  87208. faceUV?: Vector4[];
  87209. faceColors?: Color4[];
  87210. flat?: boolean;
  87211. sideOrientation?: number;
  87212. frontUVs?: Vector4;
  87213. backUVs?: Vector4;
  87214. }): VertexData;
  87215. /**
  87216. * Creates the VertexData for a TorusKnot
  87217. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  87218. * * radius the radius of the torus knot, optional, default 2
  87219. * * tube the thickness of the tube, optional, default 0.5
  87220. * * radialSegments the number of sides on each tube segments, optional, default 32
  87221. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  87222. * * p the number of windings around the z axis, optional, default 2
  87223. * * q the number of windings around the x axis, optional, default 3
  87224. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  87225. * * 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)
  87226. * * 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)
  87227. * @returns the VertexData of the Torus Knot
  87228. */
  87229. static CreateTorusKnot(options: {
  87230. radius?: number;
  87231. tube?: number;
  87232. radialSegments?: number;
  87233. tubularSegments?: number;
  87234. p?: number;
  87235. q?: number;
  87236. sideOrientation?: number;
  87237. frontUVs?: Vector4;
  87238. backUVs?: Vector4;
  87239. }): VertexData;
  87240. /**
  87241. * Compute normals for given positions and indices
  87242. * @param positions an array of vertex positions, [...., x, y, z, ......]
  87243. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  87244. * @param normals an array of vertex normals, [...., x, y, z, ......]
  87245. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  87246. * * facetNormals : optional array of facet normals (vector3)
  87247. * * facetPositions : optional array of facet positions (vector3)
  87248. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  87249. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  87250. * * bInfo : optional bounding info, required for facetPartitioning computation
  87251. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  87252. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  87253. * * useRightHandedSystem: optional boolean to for right handed system computation
  87254. * * depthSort : optional boolean to enable the facet depth sort computation
  87255. * * distanceTo : optional Vector3 to compute the facet depth from this location
  87256. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  87257. */
  87258. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  87259. facetNormals?: any;
  87260. facetPositions?: any;
  87261. facetPartitioning?: any;
  87262. ratio?: number;
  87263. bInfo?: any;
  87264. bbSize?: Vector3;
  87265. subDiv?: any;
  87266. useRightHandedSystem?: boolean;
  87267. depthSort?: boolean;
  87268. distanceTo?: Vector3;
  87269. depthSortedFacets?: any;
  87270. }): void;
  87271. /** @hidden */
  87272. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  87273. /**
  87274. * Applies VertexData created from the imported parameters to the geometry
  87275. * @param parsedVertexData the parsed data from an imported file
  87276. * @param geometry the geometry to apply the VertexData to
  87277. */
  87278. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  87279. }
  87280. }
  87281. declare module BABYLON {
  87282. /**
  87283. * Defines a target to use with MorphTargetManager
  87284. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  87285. */
  87286. export class MorphTarget implements IAnimatable {
  87287. /** defines the name of the target */
  87288. name: string;
  87289. /**
  87290. * Gets or sets the list of animations
  87291. */
  87292. animations: Animation[];
  87293. private _scene;
  87294. private _positions;
  87295. private _normals;
  87296. private _tangents;
  87297. private _uvs;
  87298. private _influence;
  87299. /**
  87300. * Observable raised when the influence changes
  87301. */
  87302. onInfluenceChanged: Observable<boolean>;
  87303. /** @hidden */
  87304. _onDataLayoutChanged: Observable<void>;
  87305. /**
  87306. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  87307. */
  87308. influence: number;
  87309. /**
  87310. * Gets or sets the id of the morph Target
  87311. */
  87312. id: string;
  87313. private _animationPropertiesOverride;
  87314. /**
  87315. * Gets or sets the animation properties override
  87316. */
  87317. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  87318. /**
  87319. * Creates a new MorphTarget
  87320. * @param name defines the name of the target
  87321. * @param influence defines the influence to use
  87322. * @param scene defines the scene the morphtarget belongs to
  87323. */
  87324. constructor(
  87325. /** defines the name of the target */
  87326. name: string, influence?: number, scene?: Nullable<Scene>);
  87327. /**
  87328. * Gets a boolean defining if the target contains position data
  87329. */
  87330. readonly hasPositions: boolean;
  87331. /**
  87332. * Gets a boolean defining if the target contains normal data
  87333. */
  87334. readonly hasNormals: boolean;
  87335. /**
  87336. * Gets a boolean defining if the target contains tangent data
  87337. */
  87338. readonly hasTangents: boolean;
  87339. /**
  87340. * Gets a boolean defining if the target contains texture coordinates data
  87341. */
  87342. readonly hasUVs: boolean;
  87343. /**
  87344. * Affects position data to this target
  87345. * @param data defines the position data to use
  87346. */
  87347. setPositions(data: Nullable<FloatArray>): void;
  87348. /**
  87349. * Gets the position data stored in this target
  87350. * @returns a FloatArray containing the position data (or null if not present)
  87351. */
  87352. getPositions(): Nullable<FloatArray>;
  87353. /**
  87354. * Affects normal data to this target
  87355. * @param data defines the normal data to use
  87356. */
  87357. setNormals(data: Nullable<FloatArray>): void;
  87358. /**
  87359. * Gets the normal data stored in this target
  87360. * @returns a FloatArray containing the normal data (or null if not present)
  87361. */
  87362. getNormals(): Nullable<FloatArray>;
  87363. /**
  87364. * Affects tangent data to this target
  87365. * @param data defines the tangent data to use
  87366. */
  87367. setTangents(data: Nullable<FloatArray>): void;
  87368. /**
  87369. * Gets the tangent data stored in this target
  87370. * @returns a FloatArray containing the tangent data (or null if not present)
  87371. */
  87372. getTangents(): Nullable<FloatArray>;
  87373. /**
  87374. * Affects texture coordinates data to this target
  87375. * @param data defines the texture coordinates data to use
  87376. */
  87377. setUVs(data: Nullable<FloatArray>): void;
  87378. /**
  87379. * Gets the texture coordinates data stored in this target
  87380. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  87381. */
  87382. getUVs(): Nullable<FloatArray>;
  87383. /**
  87384. * Serializes the current target into a Serialization object
  87385. * @returns the serialized object
  87386. */
  87387. serialize(): any;
  87388. /**
  87389. * Returns the string "MorphTarget"
  87390. * @returns "MorphTarget"
  87391. */
  87392. getClassName(): string;
  87393. /**
  87394. * Creates a new target from serialized data
  87395. * @param serializationObject defines the serialized data to use
  87396. * @returns a new MorphTarget
  87397. */
  87398. static Parse(serializationObject: any): MorphTarget;
  87399. /**
  87400. * Creates a MorphTarget from mesh data
  87401. * @param mesh defines the source mesh
  87402. * @param name defines the name to use for the new target
  87403. * @param influence defines the influence to attach to the target
  87404. * @returns a new MorphTarget
  87405. */
  87406. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  87407. }
  87408. }
  87409. declare module BABYLON {
  87410. /**
  87411. * This class is used to deform meshes using morphing between different targets
  87412. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  87413. */
  87414. export class MorphTargetManager {
  87415. private _targets;
  87416. private _targetInfluenceChangedObservers;
  87417. private _targetDataLayoutChangedObservers;
  87418. private _activeTargets;
  87419. private _scene;
  87420. private _influences;
  87421. private _supportsNormals;
  87422. private _supportsTangents;
  87423. private _supportsUVs;
  87424. private _vertexCount;
  87425. private _uniqueId;
  87426. private _tempInfluences;
  87427. /**
  87428. * Gets or sets a boolean indicating if normals must be morphed
  87429. */
  87430. enableNormalMorphing: boolean;
  87431. /**
  87432. * Gets or sets a boolean indicating if tangents must be morphed
  87433. */
  87434. enableTangentMorphing: boolean;
  87435. /**
  87436. * Gets or sets a boolean indicating if UV must be morphed
  87437. */
  87438. enableUVMorphing: boolean;
  87439. /**
  87440. * Creates a new MorphTargetManager
  87441. * @param scene defines the current scene
  87442. */
  87443. constructor(scene?: Nullable<Scene>);
  87444. /**
  87445. * Gets the unique ID of this manager
  87446. */
  87447. readonly uniqueId: number;
  87448. /**
  87449. * Gets the number of vertices handled by this manager
  87450. */
  87451. readonly vertexCount: number;
  87452. /**
  87453. * Gets a boolean indicating if this manager supports morphing of normals
  87454. */
  87455. readonly supportsNormals: boolean;
  87456. /**
  87457. * Gets a boolean indicating if this manager supports morphing of tangents
  87458. */
  87459. readonly supportsTangents: boolean;
  87460. /**
  87461. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  87462. */
  87463. readonly supportsUVs: boolean;
  87464. /**
  87465. * Gets the number of targets stored in this manager
  87466. */
  87467. readonly numTargets: number;
  87468. /**
  87469. * Gets the number of influencers (ie. the number of targets with influences > 0)
  87470. */
  87471. readonly numInfluencers: number;
  87472. /**
  87473. * Gets the list of influences (one per target)
  87474. */
  87475. readonly influences: Float32Array;
  87476. /**
  87477. * Gets the active target at specified index. An active target is a target with an influence > 0
  87478. * @param index defines the index to check
  87479. * @returns the requested target
  87480. */
  87481. getActiveTarget(index: number): MorphTarget;
  87482. /**
  87483. * Gets the target at specified index
  87484. * @param index defines the index to check
  87485. * @returns the requested target
  87486. */
  87487. getTarget(index: number): MorphTarget;
  87488. /**
  87489. * Add a new target to this manager
  87490. * @param target defines the target to add
  87491. */
  87492. addTarget(target: MorphTarget): void;
  87493. /**
  87494. * Removes a target from the manager
  87495. * @param target defines the target to remove
  87496. */
  87497. removeTarget(target: MorphTarget): void;
  87498. /**
  87499. * Serializes the current manager into a Serialization object
  87500. * @returns the serialized object
  87501. */
  87502. serialize(): any;
  87503. private _syncActiveTargets;
  87504. /**
  87505. * Syncrhonize the targets with all the meshes using this morph target manager
  87506. */
  87507. synchronize(): void;
  87508. /**
  87509. * Creates a new MorphTargetManager from serialized data
  87510. * @param serializationObject defines the serialized data
  87511. * @param scene defines the hosting scene
  87512. * @returns the new MorphTargetManager
  87513. */
  87514. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  87515. }
  87516. }
  87517. declare module BABYLON {
  87518. /**
  87519. * Class used to represent a specific level of detail of a mesh
  87520. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  87521. */
  87522. export class MeshLODLevel {
  87523. /** Defines the distance where this level should star being displayed */
  87524. distance: number;
  87525. /** Defines the mesh to use to render this level */
  87526. mesh: Nullable<Mesh>;
  87527. /**
  87528. * Creates a new LOD level
  87529. * @param distance defines the distance where this level should star being displayed
  87530. * @param mesh defines the mesh to use to render this level
  87531. */
  87532. constructor(
  87533. /** Defines the distance where this level should star being displayed */
  87534. distance: number,
  87535. /** Defines the mesh to use to render this level */
  87536. mesh: Nullable<Mesh>);
  87537. }
  87538. }
  87539. declare module BABYLON {
  87540. /**
  87541. * Mesh representing the gorund
  87542. */
  87543. export class GroundMesh extends Mesh {
  87544. /** If octree should be generated */
  87545. generateOctree: boolean;
  87546. private _heightQuads;
  87547. /** @hidden */
  87548. _subdivisionsX: number;
  87549. /** @hidden */
  87550. _subdivisionsY: number;
  87551. /** @hidden */
  87552. _width: number;
  87553. /** @hidden */
  87554. _height: number;
  87555. /** @hidden */
  87556. _minX: number;
  87557. /** @hidden */
  87558. _maxX: number;
  87559. /** @hidden */
  87560. _minZ: number;
  87561. /** @hidden */
  87562. _maxZ: number;
  87563. constructor(name: string, scene: Scene);
  87564. /**
  87565. * "GroundMesh"
  87566. * @returns "GroundMesh"
  87567. */
  87568. getClassName(): string;
  87569. /**
  87570. * The minimum of x and y subdivisions
  87571. */
  87572. readonly subdivisions: number;
  87573. /**
  87574. * X subdivisions
  87575. */
  87576. readonly subdivisionsX: number;
  87577. /**
  87578. * Y subdivisions
  87579. */
  87580. readonly subdivisionsY: number;
  87581. /**
  87582. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  87583. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  87584. * @param chunksCount the number of subdivisions for x and y
  87585. * @param octreeBlocksSize (Default: 32)
  87586. */
  87587. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  87588. /**
  87589. * Returns a height (y) value in the Worl system :
  87590. * the ground altitude at the coordinates (x, z) expressed in the World system.
  87591. * @param x x coordinate
  87592. * @param z z coordinate
  87593. * @returns the ground y position if (x, z) are outside the ground surface.
  87594. */
  87595. getHeightAtCoordinates(x: number, z: number): number;
  87596. /**
  87597. * Returns a normalized vector (Vector3) orthogonal to the ground
  87598. * at the ground coordinates (x, z) expressed in the World system.
  87599. * @param x x coordinate
  87600. * @param z z coordinate
  87601. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  87602. */
  87603. getNormalAtCoordinates(x: number, z: number): Vector3;
  87604. /**
  87605. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  87606. * at the ground coordinates (x, z) expressed in the World system.
  87607. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  87608. * @param x x coordinate
  87609. * @param z z coordinate
  87610. * @param ref vector to store the result
  87611. * @returns the GroundMesh.
  87612. */
  87613. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  87614. /**
  87615. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  87616. * if the ground has been updated.
  87617. * This can be used in the render loop.
  87618. * @returns the GroundMesh.
  87619. */
  87620. updateCoordinateHeights(): GroundMesh;
  87621. private _getFacetAt;
  87622. private _initHeightQuads;
  87623. private _computeHeightQuads;
  87624. /**
  87625. * Serializes this ground mesh
  87626. * @param serializationObject object to write serialization to
  87627. */
  87628. serialize(serializationObject: any): void;
  87629. /**
  87630. * Parses a serialized ground mesh
  87631. * @param parsedMesh the serialized mesh
  87632. * @param scene the scene to create the ground mesh in
  87633. * @returns the created ground mesh
  87634. */
  87635. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  87636. }
  87637. }
  87638. declare module BABYLON {
  87639. /**
  87640. * Interface for Physics-Joint data
  87641. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  87642. */
  87643. export interface PhysicsJointData {
  87644. /**
  87645. * The main pivot of the joint
  87646. */
  87647. mainPivot?: Vector3;
  87648. /**
  87649. * The connected pivot of the joint
  87650. */
  87651. connectedPivot?: Vector3;
  87652. /**
  87653. * The main axis of the joint
  87654. */
  87655. mainAxis?: Vector3;
  87656. /**
  87657. * The connected axis of the joint
  87658. */
  87659. connectedAxis?: Vector3;
  87660. /**
  87661. * The collision of the joint
  87662. */
  87663. collision?: boolean;
  87664. /**
  87665. * Native Oimo/Cannon/Energy data
  87666. */
  87667. nativeParams?: any;
  87668. }
  87669. /**
  87670. * This is a holder class for the physics joint created by the physics plugin
  87671. * It holds a set of functions to control the underlying joint
  87672. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  87673. */
  87674. export class PhysicsJoint {
  87675. /**
  87676. * The type of the physics joint
  87677. */
  87678. type: number;
  87679. /**
  87680. * The data for the physics joint
  87681. */
  87682. jointData: PhysicsJointData;
  87683. private _physicsJoint;
  87684. protected _physicsPlugin: IPhysicsEnginePlugin;
  87685. /**
  87686. * Initializes the physics joint
  87687. * @param type The type of the physics joint
  87688. * @param jointData The data for the physics joint
  87689. */
  87690. constructor(
  87691. /**
  87692. * The type of the physics joint
  87693. */
  87694. type: number,
  87695. /**
  87696. * The data for the physics joint
  87697. */
  87698. jointData: PhysicsJointData);
  87699. /**
  87700. * Gets the physics joint
  87701. */
  87702. /**
  87703. * Sets the physics joint
  87704. */
  87705. physicsJoint: any;
  87706. /**
  87707. * Sets the physics plugin
  87708. */
  87709. physicsPlugin: IPhysicsEnginePlugin;
  87710. /**
  87711. * Execute a function that is physics-plugin specific.
  87712. * @param {Function} func the function that will be executed.
  87713. * It accepts two parameters: the physics world and the physics joint
  87714. */
  87715. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  87716. /**
  87717. * Distance-Joint type
  87718. */
  87719. static DistanceJoint: number;
  87720. /**
  87721. * Hinge-Joint type
  87722. */
  87723. static HingeJoint: number;
  87724. /**
  87725. * Ball-and-Socket joint type
  87726. */
  87727. static BallAndSocketJoint: number;
  87728. /**
  87729. * Wheel-Joint type
  87730. */
  87731. static WheelJoint: number;
  87732. /**
  87733. * Slider-Joint type
  87734. */
  87735. static SliderJoint: number;
  87736. /**
  87737. * Prismatic-Joint type
  87738. */
  87739. static PrismaticJoint: number;
  87740. /**
  87741. * Universal-Joint type
  87742. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  87743. */
  87744. static UniversalJoint: number;
  87745. /**
  87746. * Hinge-Joint 2 type
  87747. */
  87748. static Hinge2Joint: number;
  87749. /**
  87750. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  87751. */
  87752. static PointToPointJoint: number;
  87753. /**
  87754. * Spring-Joint type
  87755. */
  87756. static SpringJoint: number;
  87757. /**
  87758. * Lock-Joint type
  87759. */
  87760. static LockJoint: number;
  87761. }
  87762. /**
  87763. * A class representing a physics distance joint
  87764. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  87765. */
  87766. export class DistanceJoint extends PhysicsJoint {
  87767. /**
  87768. *
  87769. * @param jointData The data for the Distance-Joint
  87770. */
  87771. constructor(jointData: DistanceJointData);
  87772. /**
  87773. * Update the predefined distance.
  87774. * @param maxDistance The maximum preferred distance
  87775. * @param minDistance The minimum preferred distance
  87776. */
  87777. updateDistance(maxDistance: number, minDistance?: number): void;
  87778. }
  87779. /**
  87780. * Represents a Motor-Enabled Joint
  87781. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  87782. */
  87783. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  87784. /**
  87785. * Initializes the Motor-Enabled Joint
  87786. * @param type The type of the joint
  87787. * @param jointData The physica joint data for the joint
  87788. */
  87789. constructor(type: number, jointData: PhysicsJointData);
  87790. /**
  87791. * Set the motor values.
  87792. * Attention, this function is plugin specific. Engines won't react 100% the same.
  87793. * @param force the force to apply
  87794. * @param maxForce max force for this motor.
  87795. */
  87796. setMotor(force?: number, maxForce?: number): void;
  87797. /**
  87798. * Set the motor's limits.
  87799. * Attention, this function is plugin specific. Engines won't react 100% the same.
  87800. * @param upperLimit The upper limit of the motor
  87801. * @param lowerLimit The lower limit of the motor
  87802. */
  87803. setLimit(upperLimit: number, lowerLimit?: number): void;
  87804. }
  87805. /**
  87806. * This class represents a single physics Hinge-Joint
  87807. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  87808. */
  87809. export class HingeJoint extends MotorEnabledJoint {
  87810. /**
  87811. * Initializes the Hinge-Joint
  87812. * @param jointData The joint data for the Hinge-Joint
  87813. */
  87814. constructor(jointData: PhysicsJointData);
  87815. /**
  87816. * Set the motor values.
  87817. * Attention, this function is plugin specific. Engines won't react 100% the same.
  87818. * @param {number} force the force to apply
  87819. * @param {number} maxForce max force for this motor.
  87820. */
  87821. setMotor(force?: number, maxForce?: number): void;
  87822. /**
  87823. * Set the motor's limits.
  87824. * Attention, this function is plugin specific. Engines won't react 100% the same.
  87825. * @param upperLimit The upper limit of the motor
  87826. * @param lowerLimit The lower limit of the motor
  87827. */
  87828. setLimit(upperLimit: number, lowerLimit?: number): void;
  87829. }
  87830. /**
  87831. * This class represents a dual hinge physics joint (same as wheel joint)
  87832. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  87833. */
  87834. export class Hinge2Joint extends MotorEnabledJoint {
  87835. /**
  87836. * Initializes the Hinge2-Joint
  87837. * @param jointData The joint data for the Hinge2-Joint
  87838. */
  87839. constructor(jointData: PhysicsJointData);
  87840. /**
  87841. * Set the motor values.
  87842. * Attention, this function is plugin specific. Engines won't react 100% the same.
  87843. * @param {number} targetSpeed the speed the motor is to reach
  87844. * @param {number} maxForce max force for this motor.
  87845. * @param {motorIndex} the motor's index, 0 or 1.
  87846. */
  87847. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  87848. /**
  87849. * Set the motor limits.
  87850. * Attention, this function is plugin specific. Engines won't react 100% the same.
  87851. * @param {number} upperLimit the upper limit
  87852. * @param {number} lowerLimit lower limit
  87853. * @param {motorIndex} the motor's index, 0 or 1.
  87854. */
  87855. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  87856. }
  87857. /**
  87858. * Interface for a motor enabled joint
  87859. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  87860. */
  87861. export interface IMotorEnabledJoint {
  87862. /**
  87863. * Physics joint
  87864. */
  87865. physicsJoint: any;
  87866. /**
  87867. * Sets the motor of the motor-enabled joint
  87868. * @param force The force of the motor
  87869. * @param maxForce The maximum force of the motor
  87870. * @param motorIndex The index of the motor
  87871. */
  87872. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  87873. /**
  87874. * Sets the limit of the motor
  87875. * @param upperLimit The upper limit of the motor
  87876. * @param lowerLimit The lower limit of the motor
  87877. * @param motorIndex The index of the motor
  87878. */
  87879. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  87880. }
  87881. /**
  87882. * Joint data for a Distance-Joint
  87883. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  87884. */
  87885. export interface DistanceJointData extends PhysicsJointData {
  87886. /**
  87887. * Max distance the 2 joint objects can be apart
  87888. */
  87889. maxDistance: number;
  87890. }
  87891. /**
  87892. * Joint data from a spring joint
  87893. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  87894. */
  87895. export interface SpringJointData extends PhysicsJointData {
  87896. /**
  87897. * Length of the spring
  87898. */
  87899. length: number;
  87900. /**
  87901. * Stiffness of the spring
  87902. */
  87903. stiffness: number;
  87904. /**
  87905. * Damping of the spring
  87906. */
  87907. damping: number;
  87908. /** this callback will be called when applying the force to the impostors. */
  87909. forceApplicationCallback: () => void;
  87910. }
  87911. }
  87912. declare module BABYLON {
  87913. /**
  87914. * Holds the data for the raycast result
  87915. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  87916. */
  87917. export class PhysicsRaycastResult {
  87918. private _hasHit;
  87919. private _hitDistance;
  87920. private _hitNormalWorld;
  87921. private _hitPointWorld;
  87922. private _rayFromWorld;
  87923. private _rayToWorld;
  87924. /**
  87925. * Gets if there was a hit
  87926. */
  87927. readonly hasHit: boolean;
  87928. /**
  87929. * Gets the distance from the hit
  87930. */
  87931. readonly hitDistance: number;
  87932. /**
  87933. * Gets the hit normal/direction in the world
  87934. */
  87935. readonly hitNormalWorld: Vector3;
  87936. /**
  87937. * Gets the hit point in the world
  87938. */
  87939. readonly hitPointWorld: Vector3;
  87940. /**
  87941. * Gets the ray "start point" of the ray in the world
  87942. */
  87943. readonly rayFromWorld: Vector3;
  87944. /**
  87945. * Gets the ray "end point" of the ray in the world
  87946. */
  87947. readonly rayToWorld: Vector3;
  87948. /**
  87949. * Sets the hit data (normal & point in world space)
  87950. * @param hitNormalWorld defines the normal in world space
  87951. * @param hitPointWorld defines the point in world space
  87952. */
  87953. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  87954. /**
  87955. * Sets the distance from the start point to the hit point
  87956. * @param distance
  87957. */
  87958. setHitDistance(distance: number): void;
  87959. /**
  87960. * Calculates the distance manually
  87961. */
  87962. calculateHitDistance(): void;
  87963. /**
  87964. * Resets all the values to default
  87965. * @param from The from point on world space
  87966. * @param to The to point on world space
  87967. */
  87968. reset(from?: Vector3, to?: Vector3): void;
  87969. }
  87970. /**
  87971. * Interface for the size containing width and height
  87972. */
  87973. interface IXYZ {
  87974. /**
  87975. * X
  87976. */
  87977. x: number;
  87978. /**
  87979. * Y
  87980. */
  87981. y: number;
  87982. /**
  87983. * Z
  87984. */
  87985. z: number;
  87986. }
  87987. }
  87988. declare module BABYLON {
  87989. /**
  87990. * Interface used to describe a physics joint
  87991. */
  87992. export interface PhysicsImpostorJoint {
  87993. /** Defines the main impostor to which the joint is linked */
  87994. mainImpostor: PhysicsImpostor;
  87995. /** Defines the impostor that is connected to the main impostor using this joint */
  87996. connectedImpostor: PhysicsImpostor;
  87997. /** Defines the joint itself */
  87998. joint: PhysicsJoint;
  87999. }
  88000. /** @hidden */
  88001. export interface IPhysicsEnginePlugin {
  88002. world: any;
  88003. name: string;
  88004. setGravity(gravity: Vector3): void;
  88005. setTimeStep(timeStep: number): void;
  88006. getTimeStep(): number;
  88007. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  88008. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  88009. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  88010. generatePhysicsBody(impostor: PhysicsImpostor): void;
  88011. removePhysicsBody(impostor: PhysicsImpostor): void;
  88012. generateJoint(joint: PhysicsImpostorJoint): void;
  88013. removeJoint(joint: PhysicsImpostorJoint): void;
  88014. isSupported(): boolean;
  88015. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  88016. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  88017. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  88018. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  88019. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  88020. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  88021. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  88022. getBodyMass(impostor: PhysicsImpostor): number;
  88023. getBodyFriction(impostor: PhysicsImpostor): number;
  88024. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  88025. getBodyRestitution(impostor: PhysicsImpostor): number;
  88026. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  88027. getBodyPressure?(impostor: PhysicsImpostor): number;
  88028. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  88029. getBodyStiffness?(impostor: PhysicsImpostor): number;
  88030. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  88031. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  88032. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  88033. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  88034. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  88035. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  88036. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  88037. sleepBody(impostor: PhysicsImpostor): void;
  88038. wakeUpBody(impostor: PhysicsImpostor): void;
  88039. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  88040. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  88041. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  88042. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  88043. getRadius(impostor: PhysicsImpostor): number;
  88044. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  88045. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  88046. dispose(): void;
  88047. }
  88048. /**
  88049. * Interface used to define a physics engine
  88050. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  88051. */
  88052. export interface IPhysicsEngine {
  88053. /**
  88054. * Gets the gravity vector used by the simulation
  88055. */
  88056. gravity: Vector3;
  88057. /**
  88058. * Sets the gravity vector used by the simulation
  88059. * @param gravity defines the gravity vector to use
  88060. */
  88061. setGravity(gravity: Vector3): void;
  88062. /**
  88063. * Set the time step of the physics engine.
  88064. * Default is 1/60.
  88065. * To slow it down, enter 1/600 for example.
  88066. * To speed it up, 1/30
  88067. * @param newTimeStep the new timestep to apply to this world.
  88068. */
  88069. setTimeStep(newTimeStep: number): void;
  88070. /**
  88071. * Get the time step of the physics engine.
  88072. * @returns the current time step
  88073. */
  88074. getTimeStep(): number;
  88075. /**
  88076. * Release all resources
  88077. */
  88078. dispose(): void;
  88079. /**
  88080. * Gets the name of the current physics plugin
  88081. * @returns the name of the plugin
  88082. */
  88083. getPhysicsPluginName(): string;
  88084. /**
  88085. * Adding a new impostor for the impostor tracking.
  88086. * This will be done by the impostor itself.
  88087. * @param impostor the impostor to add
  88088. */
  88089. addImpostor(impostor: PhysicsImpostor): void;
  88090. /**
  88091. * Remove an impostor from the engine.
  88092. * This impostor and its mesh will not longer be updated by the physics engine.
  88093. * @param impostor the impostor to remove
  88094. */
  88095. removeImpostor(impostor: PhysicsImpostor): void;
  88096. /**
  88097. * Add a joint to the physics engine
  88098. * @param mainImpostor defines the main impostor to which the joint is added.
  88099. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  88100. * @param joint defines the joint that will connect both impostors.
  88101. */
  88102. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  88103. /**
  88104. * Removes a joint from the simulation
  88105. * @param mainImpostor defines the impostor used with the joint
  88106. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  88107. * @param joint defines the joint to remove
  88108. */
  88109. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  88110. /**
  88111. * Gets the current plugin used to run the simulation
  88112. * @returns current plugin
  88113. */
  88114. getPhysicsPlugin(): IPhysicsEnginePlugin;
  88115. /**
  88116. * Gets the list of physic impostors
  88117. * @returns an array of PhysicsImpostor
  88118. */
  88119. getImpostors(): Array<PhysicsImpostor>;
  88120. /**
  88121. * Gets the impostor for a physics enabled object
  88122. * @param object defines the object impersonated by the impostor
  88123. * @returns the PhysicsImpostor or null if not found
  88124. */
  88125. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  88126. /**
  88127. * Gets the impostor for a physics body object
  88128. * @param body defines physics body used by the impostor
  88129. * @returns the PhysicsImpostor or null if not found
  88130. */
  88131. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  88132. /**
  88133. * Does a raycast in the physics world
  88134. * @param from when should the ray start?
  88135. * @param to when should the ray end?
  88136. * @returns PhysicsRaycastResult
  88137. */
  88138. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  88139. /**
  88140. * Called by the scene. No need to call it.
  88141. * @param delta defines the timespam between frames
  88142. */
  88143. _step(delta: number): void;
  88144. }
  88145. }
  88146. declare module BABYLON {
  88147. /**
  88148. * The interface for the physics imposter parameters
  88149. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  88150. */
  88151. export interface PhysicsImpostorParameters {
  88152. /**
  88153. * The mass of the physics imposter
  88154. */
  88155. mass: number;
  88156. /**
  88157. * The friction of the physics imposter
  88158. */
  88159. friction?: number;
  88160. /**
  88161. * The coefficient of restitution of the physics imposter
  88162. */
  88163. restitution?: number;
  88164. /**
  88165. * The native options of the physics imposter
  88166. */
  88167. nativeOptions?: any;
  88168. /**
  88169. * Specifies if the parent should be ignored
  88170. */
  88171. ignoreParent?: boolean;
  88172. /**
  88173. * Specifies if bi-directional transformations should be disabled
  88174. */
  88175. disableBidirectionalTransformation?: boolean;
  88176. /**
  88177. * The pressure inside the physics imposter, soft object only
  88178. */
  88179. pressure?: number;
  88180. /**
  88181. * The stiffness the physics imposter, soft object only
  88182. */
  88183. stiffness?: number;
  88184. /**
  88185. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  88186. */
  88187. velocityIterations?: number;
  88188. /**
  88189. * The number of iterations used in maintaining consistent vertex positions, soft object only
  88190. */
  88191. positionIterations?: number;
  88192. /**
  88193. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  88194. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  88195. * Add to fix multiple points
  88196. */
  88197. fixedPoints?: number;
  88198. /**
  88199. * The collision margin around a soft object
  88200. */
  88201. margin?: number;
  88202. /**
  88203. * The collision margin around a soft object
  88204. */
  88205. damping?: number;
  88206. /**
  88207. * The path for a rope based on an extrusion
  88208. */
  88209. path?: any;
  88210. /**
  88211. * The shape of an extrusion used for a rope based on an extrusion
  88212. */
  88213. shape?: any;
  88214. }
  88215. /**
  88216. * Interface for a physics-enabled object
  88217. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  88218. */
  88219. export interface IPhysicsEnabledObject {
  88220. /**
  88221. * The position of the physics-enabled object
  88222. */
  88223. position: Vector3;
  88224. /**
  88225. * The rotation of the physics-enabled object
  88226. */
  88227. rotationQuaternion: Nullable<Quaternion>;
  88228. /**
  88229. * The scale of the physics-enabled object
  88230. */
  88231. scaling: Vector3;
  88232. /**
  88233. * The rotation of the physics-enabled object
  88234. */
  88235. rotation?: Vector3;
  88236. /**
  88237. * The parent of the physics-enabled object
  88238. */
  88239. parent?: any;
  88240. /**
  88241. * The bounding info of the physics-enabled object
  88242. * @returns The bounding info of the physics-enabled object
  88243. */
  88244. getBoundingInfo(): BoundingInfo;
  88245. /**
  88246. * Computes the world matrix
  88247. * @param force Specifies if the world matrix should be computed by force
  88248. * @returns A world matrix
  88249. */
  88250. computeWorldMatrix(force: boolean): Matrix;
  88251. /**
  88252. * Gets the world matrix
  88253. * @returns A world matrix
  88254. */
  88255. getWorldMatrix?(): Matrix;
  88256. /**
  88257. * Gets the child meshes
  88258. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  88259. * @returns An array of abstract meshes
  88260. */
  88261. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  88262. /**
  88263. * Gets the vertex data
  88264. * @param kind The type of vertex data
  88265. * @returns A nullable array of numbers, or a float32 array
  88266. */
  88267. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  88268. /**
  88269. * Gets the indices from the mesh
  88270. * @returns A nullable array of index arrays
  88271. */
  88272. getIndices?(): Nullable<IndicesArray>;
  88273. /**
  88274. * Gets the scene from the mesh
  88275. * @returns the indices array or null
  88276. */
  88277. getScene?(): Scene;
  88278. /**
  88279. * Gets the absolute position from the mesh
  88280. * @returns the absolute position
  88281. */
  88282. getAbsolutePosition(): Vector3;
  88283. /**
  88284. * Gets the absolute pivot point from the mesh
  88285. * @returns the absolute pivot point
  88286. */
  88287. getAbsolutePivotPoint(): Vector3;
  88288. /**
  88289. * Rotates the mesh
  88290. * @param axis The axis of rotation
  88291. * @param amount The amount of rotation
  88292. * @param space The space of the rotation
  88293. * @returns The rotation transform node
  88294. */
  88295. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  88296. /**
  88297. * Translates the mesh
  88298. * @param axis The axis of translation
  88299. * @param distance The distance of translation
  88300. * @param space The space of the translation
  88301. * @returns The transform node
  88302. */
  88303. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  88304. /**
  88305. * Sets the absolute position of the mesh
  88306. * @param absolutePosition The absolute position of the mesh
  88307. * @returns The transform node
  88308. */
  88309. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  88310. /**
  88311. * Gets the class name of the mesh
  88312. * @returns The class name
  88313. */
  88314. getClassName(): string;
  88315. }
  88316. /**
  88317. * Represents a physics imposter
  88318. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  88319. */
  88320. export class PhysicsImpostor {
  88321. /**
  88322. * The physics-enabled object used as the physics imposter
  88323. */
  88324. object: IPhysicsEnabledObject;
  88325. /**
  88326. * The type of the physics imposter
  88327. */
  88328. type: number;
  88329. private _options;
  88330. private _scene?;
  88331. /**
  88332. * The default object size of the imposter
  88333. */
  88334. static DEFAULT_OBJECT_SIZE: Vector3;
  88335. /**
  88336. * The identity quaternion of the imposter
  88337. */
  88338. static IDENTITY_QUATERNION: Quaternion;
  88339. /** @hidden */
  88340. _pluginData: any;
  88341. private _physicsEngine;
  88342. private _physicsBody;
  88343. private _bodyUpdateRequired;
  88344. private _onBeforePhysicsStepCallbacks;
  88345. private _onAfterPhysicsStepCallbacks;
  88346. /** @hidden */
  88347. _onPhysicsCollideCallbacks: Array<{
  88348. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  88349. otherImpostors: Array<PhysicsImpostor>;
  88350. }>;
  88351. private _deltaPosition;
  88352. private _deltaRotation;
  88353. private _deltaRotationConjugated;
  88354. /** @hidden */
  88355. _isFromLine: boolean;
  88356. private _parent;
  88357. private _isDisposed;
  88358. private static _tmpVecs;
  88359. private static _tmpQuat;
  88360. /**
  88361. * Specifies if the physics imposter is disposed
  88362. */
  88363. readonly isDisposed: boolean;
  88364. /**
  88365. * Gets the mass of the physics imposter
  88366. */
  88367. mass: number;
  88368. /**
  88369. * Gets the coefficient of friction
  88370. */
  88371. /**
  88372. * Sets the coefficient of friction
  88373. */
  88374. friction: number;
  88375. /**
  88376. * Gets the coefficient of restitution
  88377. */
  88378. /**
  88379. * Sets the coefficient of restitution
  88380. */
  88381. restitution: number;
  88382. /**
  88383. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  88384. */
  88385. /**
  88386. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  88387. */
  88388. pressure: number;
  88389. /**
  88390. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  88391. */
  88392. /**
  88393. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  88394. */
  88395. stiffness: number;
  88396. /**
  88397. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  88398. */
  88399. /**
  88400. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  88401. */
  88402. velocityIterations: number;
  88403. /**
  88404. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  88405. */
  88406. /**
  88407. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  88408. */
  88409. positionIterations: number;
  88410. /**
  88411. * The unique id of the physics imposter
  88412. * set by the physics engine when adding this impostor to the array
  88413. */
  88414. uniqueId: number;
  88415. /**
  88416. * @hidden
  88417. */
  88418. soft: boolean;
  88419. /**
  88420. * @hidden
  88421. */
  88422. segments: number;
  88423. private _joints;
  88424. /**
  88425. * Initializes the physics imposter
  88426. * @param object The physics-enabled object used as the physics imposter
  88427. * @param type The type of the physics imposter
  88428. * @param _options The options for the physics imposter
  88429. * @param _scene The Babylon scene
  88430. */
  88431. constructor(
  88432. /**
  88433. * The physics-enabled object used as the physics imposter
  88434. */
  88435. object: IPhysicsEnabledObject,
  88436. /**
  88437. * The type of the physics imposter
  88438. */
  88439. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  88440. /**
  88441. * This function will completly initialize this impostor.
  88442. * It will create a new body - but only if this mesh has no parent.
  88443. * If it has, this impostor will not be used other than to define the impostor
  88444. * of the child mesh.
  88445. * @hidden
  88446. */
  88447. _init(): void;
  88448. private _getPhysicsParent;
  88449. /**
  88450. * Should a new body be generated.
  88451. * @returns boolean specifying if body initialization is required
  88452. */
  88453. isBodyInitRequired(): boolean;
  88454. /**
  88455. * Sets the updated scaling
  88456. * @param updated Specifies if the scaling is updated
  88457. */
  88458. setScalingUpdated(): void;
  88459. /**
  88460. * Force a regeneration of this or the parent's impostor's body.
  88461. * Use under cautious - This will remove all joints already implemented.
  88462. */
  88463. forceUpdate(): void;
  88464. /**
  88465. * Gets the body that holds this impostor. Either its own, or its parent.
  88466. */
  88467. /**
  88468. * Set the physics body. Used mainly by the physics engine/plugin
  88469. */
  88470. physicsBody: any;
  88471. /**
  88472. * Get the parent of the physics imposter
  88473. * @returns Physics imposter or null
  88474. */
  88475. /**
  88476. * Sets the parent of the physics imposter
  88477. */
  88478. parent: Nullable<PhysicsImpostor>;
  88479. /**
  88480. * Resets the update flags
  88481. */
  88482. resetUpdateFlags(): void;
  88483. /**
  88484. * Gets the object extend size
  88485. * @returns the object extend size
  88486. */
  88487. getObjectExtendSize(): Vector3;
  88488. /**
  88489. * Gets the object center
  88490. * @returns The object center
  88491. */
  88492. getObjectCenter(): Vector3;
  88493. /**
  88494. * Get a specific parametes from the options parameter
  88495. * @param paramName The object parameter name
  88496. * @returns The object parameter
  88497. */
  88498. getParam(paramName: string): any;
  88499. /**
  88500. * Sets a specific parameter in the options given to the physics plugin
  88501. * @param paramName The parameter name
  88502. * @param value The value of the parameter
  88503. */
  88504. setParam(paramName: string, value: number): void;
  88505. /**
  88506. * Specifically change the body's mass option. Won't recreate the physics body object
  88507. * @param mass The mass of the physics imposter
  88508. */
  88509. setMass(mass: number): void;
  88510. /**
  88511. * Gets the linear velocity
  88512. * @returns linear velocity or null
  88513. */
  88514. getLinearVelocity(): Nullable<Vector3>;
  88515. /**
  88516. * Sets the linear velocity
  88517. * @param velocity linear velocity or null
  88518. */
  88519. setLinearVelocity(velocity: Nullable<Vector3>): void;
  88520. /**
  88521. * Gets the angular velocity
  88522. * @returns angular velocity or null
  88523. */
  88524. getAngularVelocity(): Nullable<Vector3>;
  88525. /**
  88526. * Sets the angular velocity
  88527. * @param velocity The velocity or null
  88528. */
  88529. setAngularVelocity(velocity: Nullable<Vector3>): void;
  88530. /**
  88531. * Execute a function with the physics plugin native code
  88532. * Provide a function the will have two variables - the world object and the physics body object
  88533. * @param func The function to execute with the physics plugin native code
  88534. */
  88535. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  88536. /**
  88537. * Register a function that will be executed before the physics world is stepping forward
  88538. * @param func The function to execute before the physics world is stepped forward
  88539. */
  88540. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  88541. /**
  88542. * Unregister a function that will be executed before the physics world is stepping forward
  88543. * @param func The function to execute before the physics world is stepped forward
  88544. */
  88545. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  88546. /**
  88547. * Register a function that will be executed after the physics step
  88548. * @param func The function to execute after physics step
  88549. */
  88550. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  88551. /**
  88552. * Unregisters a function that will be executed after the physics step
  88553. * @param func The function to execute after physics step
  88554. */
  88555. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  88556. /**
  88557. * register a function that will be executed when this impostor collides against a different body
  88558. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  88559. * @param func Callback that is executed on collision
  88560. */
  88561. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  88562. /**
  88563. * Unregisters the physics imposter on contact
  88564. * @param collideAgainst The physics object to collide against
  88565. * @param func Callback to execute on collision
  88566. */
  88567. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  88568. private _tmpQuat;
  88569. private _tmpQuat2;
  88570. /**
  88571. * Get the parent rotation
  88572. * @returns The parent rotation
  88573. */
  88574. getParentsRotation(): Quaternion;
  88575. /**
  88576. * this function is executed by the physics engine.
  88577. */
  88578. beforeStep: () => void;
  88579. /**
  88580. * this function is executed by the physics engine
  88581. */
  88582. afterStep: () => void;
  88583. /**
  88584. * Legacy collision detection event support
  88585. */
  88586. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  88587. /**
  88588. * event and body object due to cannon's event-based architecture.
  88589. */
  88590. onCollide: (e: {
  88591. body: any;
  88592. }) => void;
  88593. /**
  88594. * Apply a force
  88595. * @param force The force to apply
  88596. * @param contactPoint The contact point for the force
  88597. * @returns The physics imposter
  88598. */
  88599. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  88600. /**
  88601. * Apply an impulse
  88602. * @param force The impulse force
  88603. * @param contactPoint The contact point for the impulse force
  88604. * @returns The physics imposter
  88605. */
  88606. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  88607. /**
  88608. * A help function to create a joint
  88609. * @param otherImpostor A physics imposter used to create a joint
  88610. * @param jointType The type of joint
  88611. * @param jointData The data for the joint
  88612. * @returns The physics imposter
  88613. */
  88614. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  88615. /**
  88616. * Add a joint to this impostor with a different impostor
  88617. * @param otherImpostor A physics imposter used to add a joint
  88618. * @param joint The joint to add
  88619. * @returns The physics imposter
  88620. */
  88621. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  88622. /**
  88623. * Add an anchor to a cloth impostor
  88624. * @param otherImpostor rigid impostor to anchor to
  88625. * @param width ratio across width from 0 to 1
  88626. * @param height ratio up height from 0 to 1
  88627. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  88628. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  88629. * @returns impostor the soft imposter
  88630. */
  88631. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  88632. /**
  88633. * Add a hook to a rope impostor
  88634. * @param otherImpostor rigid impostor to anchor to
  88635. * @param length ratio across rope from 0 to 1
  88636. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  88637. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  88638. * @returns impostor the rope imposter
  88639. */
  88640. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  88641. /**
  88642. * Will keep this body still, in a sleep mode.
  88643. * @returns the physics imposter
  88644. */
  88645. sleep(): PhysicsImpostor;
  88646. /**
  88647. * Wake the body up.
  88648. * @returns The physics imposter
  88649. */
  88650. wakeUp(): PhysicsImpostor;
  88651. /**
  88652. * Clones the physics imposter
  88653. * @param newObject The physics imposter clones to this physics-enabled object
  88654. * @returns A nullable physics imposter
  88655. */
  88656. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  88657. /**
  88658. * Disposes the physics imposter
  88659. */
  88660. dispose(): void;
  88661. /**
  88662. * Sets the delta position
  88663. * @param position The delta position amount
  88664. */
  88665. setDeltaPosition(position: Vector3): void;
  88666. /**
  88667. * Sets the delta rotation
  88668. * @param rotation The delta rotation amount
  88669. */
  88670. setDeltaRotation(rotation: Quaternion): void;
  88671. /**
  88672. * Gets the box size of the physics imposter and stores the result in the input parameter
  88673. * @param result Stores the box size
  88674. * @returns The physics imposter
  88675. */
  88676. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  88677. /**
  88678. * Gets the radius of the physics imposter
  88679. * @returns Radius of the physics imposter
  88680. */
  88681. getRadius(): number;
  88682. /**
  88683. * Sync a bone with this impostor
  88684. * @param bone The bone to sync to the impostor.
  88685. * @param boneMesh The mesh that the bone is influencing.
  88686. * @param jointPivot The pivot of the joint / bone in local space.
  88687. * @param distToJoint Optional distance from the impostor to the joint.
  88688. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  88689. */
  88690. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  88691. /**
  88692. * Sync impostor to a bone
  88693. * @param bone The bone that the impostor will be synced to.
  88694. * @param boneMesh The mesh that the bone is influencing.
  88695. * @param jointPivot The pivot of the joint / bone in local space.
  88696. * @param distToJoint Optional distance from the impostor to the joint.
  88697. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  88698. * @param boneAxis Optional vector3 axis the bone is aligned with
  88699. */
  88700. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  88701. /**
  88702. * No-Imposter type
  88703. */
  88704. static NoImpostor: number;
  88705. /**
  88706. * Sphere-Imposter type
  88707. */
  88708. static SphereImpostor: number;
  88709. /**
  88710. * Box-Imposter type
  88711. */
  88712. static BoxImpostor: number;
  88713. /**
  88714. * Plane-Imposter type
  88715. */
  88716. static PlaneImpostor: number;
  88717. /**
  88718. * Mesh-imposter type
  88719. */
  88720. static MeshImpostor: number;
  88721. /**
  88722. * Capsule-Impostor type (Ammo.js plugin only)
  88723. */
  88724. static CapsuleImpostor: number;
  88725. /**
  88726. * Cylinder-Imposter type
  88727. */
  88728. static CylinderImpostor: number;
  88729. /**
  88730. * Particle-Imposter type
  88731. */
  88732. static ParticleImpostor: number;
  88733. /**
  88734. * Heightmap-Imposter type
  88735. */
  88736. static HeightmapImpostor: number;
  88737. /**
  88738. * ConvexHull-Impostor type (Ammo.js plugin only)
  88739. */
  88740. static ConvexHullImpostor: number;
  88741. /**
  88742. * Rope-Imposter type
  88743. */
  88744. static RopeImpostor: number;
  88745. /**
  88746. * Cloth-Imposter type
  88747. */
  88748. static ClothImpostor: number;
  88749. /**
  88750. * Softbody-Imposter type
  88751. */
  88752. static SoftbodyImpostor: number;
  88753. }
  88754. }
  88755. declare module BABYLON {
  88756. /**
  88757. * @hidden
  88758. **/
  88759. export class _CreationDataStorage {
  88760. closePath?: boolean;
  88761. closeArray?: boolean;
  88762. idx: number[];
  88763. dashSize: number;
  88764. gapSize: number;
  88765. path3D: Path3D;
  88766. pathArray: Vector3[][];
  88767. arc: number;
  88768. radius: number;
  88769. cap: number;
  88770. tessellation: number;
  88771. }
  88772. /**
  88773. * @hidden
  88774. **/
  88775. class _InstanceDataStorage {
  88776. visibleInstances: any;
  88777. batchCache: _InstancesBatch;
  88778. instancesBufferSize: number;
  88779. instancesBuffer: Nullable<Buffer>;
  88780. instancesData: Float32Array;
  88781. overridenInstanceCount: number;
  88782. isFrozen: boolean;
  88783. previousBatch: Nullable<_InstancesBatch>;
  88784. hardwareInstancedRendering: boolean;
  88785. sideOrientation: number;
  88786. }
  88787. /**
  88788. * @hidden
  88789. **/
  88790. export class _InstancesBatch {
  88791. mustReturn: boolean;
  88792. visibleInstances: Nullable<InstancedMesh[]>[];
  88793. renderSelf: boolean[];
  88794. hardwareInstancedRendering: boolean[];
  88795. }
  88796. /**
  88797. * Class used to represent renderable models
  88798. */
  88799. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  88800. /**
  88801. * Mesh side orientation : usually the external or front surface
  88802. */
  88803. static readonly FRONTSIDE: number;
  88804. /**
  88805. * Mesh side orientation : usually the internal or back surface
  88806. */
  88807. static readonly BACKSIDE: number;
  88808. /**
  88809. * Mesh side orientation : both internal and external or front and back surfaces
  88810. */
  88811. static readonly DOUBLESIDE: number;
  88812. /**
  88813. * Mesh side orientation : by default, `FRONTSIDE`
  88814. */
  88815. static readonly DEFAULTSIDE: number;
  88816. /**
  88817. * Mesh cap setting : no cap
  88818. */
  88819. static readonly NO_CAP: number;
  88820. /**
  88821. * Mesh cap setting : one cap at the beginning of the mesh
  88822. */
  88823. static readonly CAP_START: number;
  88824. /**
  88825. * Mesh cap setting : one cap at the end of the mesh
  88826. */
  88827. static readonly CAP_END: number;
  88828. /**
  88829. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  88830. */
  88831. static readonly CAP_ALL: number;
  88832. /**
  88833. * Mesh pattern setting : no flip or rotate
  88834. */
  88835. static readonly NO_FLIP: number;
  88836. /**
  88837. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  88838. */
  88839. static readonly FLIP_TILE: number;
  88840. /**
  88841. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  88842. */
  88843. static readonly ROTATE_TILE: number;
  88844. /**
  88845. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  88846. */
  88847. static readonly FLIP_ROW: number;
  88848. /**
  88849. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  88850. */
  88851. static readonly ROTATE_ROW: number;
  88852. /**
  88853. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  88854. */
  88855. static readonly FLIP_N_ROTATE_TILE: number;
  88856. /**
  88857. * Mesh pattern setting : rotate pattern and rotate
  88858. */
  88859. static readonly FLIP_N_ROTATE_ROW: number;
  88860. /**
  88861. * Mesh tile positioning : part tiles same on left/right or top/bottom
  88862. */
  88863. static readonly CENTER: number;
  88864. /**
  88865. * Mesh tile positioning : part tiles on left
  88866. */
  88867. static readonly LEFT: number;
  88868. /**
  88869. * Mesh tile positioning : part tiles on right
  88870. */
  88871. static readonly RIGHT: number;
  88872. /**
  88873. * Mesh tile positioning : part tiles on top
  88874. */
  88875. static readonly TOP: number;
  88876. /**
  88877. * Mesh tile positioning : part tiles on bottom
  88878. */
  88879. static readonly BOTTOM: number;
  88880. /**
  88881. * Gets the default side orientation.
  88882. * @param orientation the orientation to value to attempt to get
  88883. * @returns the default orientation
  88884. * @hidden
  88885. */
  88886. static _GetDefaultSideOrientation(orientation?: number): number;
  88887. private _internalMeshDataInfo;
  88888. /**
  88889. * An event triggered before rendering the mesh
  88890. */
  88891. readonly onBeforeRenderObservable: Observable<Mesh>;
  88892. /**
  88893. * An event triggered before binding the mesh
  88894. */
  88895. readonly onBeforeBindObservable: Observable<Mesh>;
  88896. /**
  88897. * An event triggered after rendering the mesh
  88898. */
  88899. readonly onAfterRenderObservable: Observable<Mesh>;
  88900. /**
  88901. * An event triggered before drawing the mesh
  88902. */
  88903. readonly onBeforeDrawObservable: Observable<Mesh>;
  88904. private _onBeforeDrawObserver;
  88905. /**
  88906. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  88907. */
  88908. onBeforeDraw: () => void;
  88909. readonly hasInstances: boolean;
  88910. /**
  88911. * Gets the delay loading state of the mesh (when delay loading is turned on)
  88912. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  88913. */
  88914. delayLoadState: number;
  88915. /**
  88916. * Gets the list of instances created from this mesh
  88917. * it is not supposed to be modified manually.
  88918. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  88919. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  88920. */
  88921. instances: InstancedMesh[];
  88922. /**
  88923. * Gets the file containing delay loading data for this mesh
  88924. */
  88925. delayLoadingFile: string;
  88926. /** @hidden */
  88927. _binaryInfo: any;
  88928. /**
  88929. * User defined function used to change how LOD level selection is done
  88930. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  88931. */
  88932. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  88933. /**
  88934. * Gets or sets the morph target manager
  88935. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  88936. */
  88937. morphTargetManager: Nullable<MorphTargetManager>;
  88938. /** @hidden */
  88939. _creationDataStorage: Nullable<_CreationDataStorage>;
  88940. /** @hidden */
  88941. _geometry: Nullable<Geometry>;
  88942. /** @hidden */
  88943. _delayInfo: Array<string>;
  88944. /** @hidden */
  88945. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  88946. /** @hidden */
  88947. _instanceDataStorage: _InstanceDataStorage;
  88948. private _effectiveMaterial;
  88949. /** @hidden */
  88950. _shouldGenerateFlatShading: boolean;
  88951. /** @hidden */
  88952. _originalBuilderSideOrientation: number;
  88953. /**
  88954. * Use this property to change the original side orientation defined at construction time
  88955. */
  88956. overrideMaterialSideOrientation: Nullable<number>;
  88957. /**
  88958. * Gets the source mesh (the one used to clone this one from)
  88959. */
  88960. readonly source: Nullable<Mesh>;
  88961. /**
  88962. * Gets or sets a boolean indicating that this mesh does not use index buffer
  88963. */
  88964. isUnIndexed: boolean;
  88965. /**
  88966. * @constructor
  88967. * @param name The value used by scene.getMeshByName() to do a lookup.
  88968. * @param scene The scene to add this mesh to.
  88969. * @param parent The parent of this mesh, if it has one
  88970. * @param source An optional Mesh from which geometry is shared, cloned.
  88971. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  88972. * When false, achieved by calling a clone(), also passing False.
  88973. * This will make creation of children, recursive.
  88974. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  88975. */
  88976. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  88977. instantiateHierarychy(newParent?: Nullable<TransformNode>): Nullable<TransformNode>;
  88978. /**
  88979. * Gets the class name
  88980. * @returns the string "Mesh".
  88981. */
  88982. getClassName(): string;
  88983. /** @hidden */
  88984. readonly _isMesh: boolean;
  88985. /**
  88986. * Returns a description of this mesh
  88987. * @param fullDetails define if full details about this mesh must be used
  88988. * @returns a descriptive string representing this mesh
  88989. */
  88990. toString(fullDetails?: boolean): string;
  88991. /** @hidden */
  88992. _unBindEffect(): void;
  88993. /**
  88994. * Gets a boolean indicating if this mesh has LOD
  88995. */
  88996. readonly hasLODLevels: boolean;
  88997. /**
  88998. * Gets the list of MeshLODLevel associated with the current mesh
  88999. * @returns an array of MeshLODLevel
  89000. */
  89001. getLODLevels(): MeshLODLevel[];
  89002. private _sortLODLevels;
  89003. /**
  89004. * Add a mesh as LOD level triggered at the given distance.
  89005. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  89006. * @param distance The distance from the center of the object to show this level
  89007. * @param mesh The mesh to be added as LOD level (can be null)
  89008. * @return This mesh (for chaining)
  89009. */
  89010. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  89011. /**
  89012. * Returns the LOD level mesh at the passed distance or null if not found.
  89013. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  89014. * @param distance The distance from the center of the object to show this level
  89015. * @returns a Mesh or `null`
  89016. */
  89017. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  89018. /**
  89019. * Remove a mesh from the LOD array
  89020. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  89021. * @param mesh defines the mesh to be removed
  89022. * @return This mesh (for chaining)
  89023. */
  89024. removeLODLevel(mesh: Mesh): Mesh;
  89025. /**
  89026. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  89027. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  89028. * @param camera defines the camera to use to compute distance
  89029. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  89030. * @return This mesh (for chaining)
  89031. */
  89032. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  89033. /**
  89034. * Gets the mesh internal Geometry object
  89035. */
  89036. readonly geometry: Nullable<Geometry>;
  89037. /**
  89038. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  89039. * @returns the total number of vertices
  89040. */
  89041. getTotalVertices(): number;
  89042. /**
  89043. * Returns the content of an associated vertex buffer
  89044. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  89045. * - VertexBuffer.PositionKind
  89046. * - VertexBuffer.UVKind
  89047. * - VertexBuffer.UV2Kind
  89048. * - VertexBuffer.UV3Kind
  89049. * - VertexBuffer.UV4Kind
  89050. * - VertexBuffer.UV5Kind
  89051. * - VertexBuffer.UV6Kind
  89052. * - VertexBuffer.ColorKind
  89053. * - VertexBuffer.MatricesIndicesKind
  89054. * - VertexBuffer.MatricesIndicesExtraKind
  89055. * - VertexBuffer.MatricesWeightsKind
  89056. * - VertexBuffer.MatricesWeightsExtraKind
  89057. * @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
  89058. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  89059. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  89060. */
  89061. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  89062. /**
  89063. * Returns the mesh VertexBuffer object from the requested `kind`
  89064. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  89065. * - VertexBuffer.PositionKind
  89066. * - VertexBuffer.NormalKind
  89067. * - VertexBuffer.UVKind
  89068. * - VertexBuffer.UV2Kind
  89069. * - VertexBuffer.UV3Kind
  89070. * - VertexBuffer.UV4Kind
  89071. * - VertexBuffer.UV5Kind
  89072. * - VertexBuffer.UV6Kind
  89073. * - VertexBuffer.ColorKind
  89074. * - VertexBuffer.MatricesIndicesKind
  89075. * - VertexBuffer.MatricesIndicesExtraKind
  89076. * - VertexBuffer.MatricesWeightsKind
  89077. * - VertexBuffer.MatricesWeightsExtraKind
  89078. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  89079. */
  89080. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  89081. /**
  89082. * Tests if a specific vertex buffer is associated with this mesh
  89083. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  89084. * - VertexBuffer.PositionKind
  89085. * - VertexBuffer.NormalKind
  89086. * - VertexBuffer.UVKind
  89087. * - VertexBuffer.UV2Kind
  89088. * - VertexBuffer.UV3Kind
  89089. * - VertexBuffer.UV4Kind
  89090. * - VertexBuffer.UV5Kind
  89091. * - VertexBuffer.UV6Kind
  89092. * - VertexBuffer.ColorKind
  89093. * - VertexBuffer.MatricesIndicesKind
  89094. * - VertexBuffer.MatricesIndicesExtraKind
  89095. * - VertexBuffer.MatricesWeightsKind
  89096. * - VertexBuffer.MatricesWeightsExtraKind
  89097. * @returns a boolean
  89098. */
  89099. isVerticesDataPresent(kind: string): boolean;
  89100. /**
  89101. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  89102. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  89103. * - VertexBuffer.PositionKind
  89104. * - VertexBuffer.UVKind
  89105. * - VertexBuffer.UV2Kind
  89106. * - VertexBuffer.UV3Kind
  89107. * - VertexBuffer.UV4Kind
  89108. * - VertexBuffer.UV5Kind
  89109. * - VertexBuffer.UV6Kind
  89110. * - VertexBuffer.ColorKind
  89111. * - VertexBuffer.MatricesIndicesKind
  89112. * - VertexBuffer.MatricesIndicesExtraKind
  89113. * - VertexBuffer.MatricesWeightsKind
  89114. * - VertexBuffer.MatricesWeightsExtraKind
  89115. * @returns a boolean
  89116. */
  89117. isVertexBufferUpdatable(kind: string): boolean;
  89118. /**
  89119. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  89120. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  89121. * - VertexBuffer.PositionKind
  89122. * - VertexBuffer.NormalKind
  89123. * - VertexBuffer.UVKind
  89124. * - VertexBuffer.UV2Kind
  89125. * - VertexBuffer.UV3Kind
  89126. * - VertexBuffer.UV4Kind
  89127. * - VertexBuffer.UV5Kind
  89128. * - VertexBuffer.UV6Kind
  89129. * - VertexBuffer.ColorKind
  89130. * - VertexBuffer.MatricesIndicesKind
  89131. * - VertexBuffer.MatricesIndicesExtraKind
  89132. * - VertexBuffer.MatricesWeightsKind
  89133. * - VertexBuffer.MatricesWeightsExtraKind
  89134. * @returns an array of strings
  89135. */
  89136. getVerticesDataKinds(): string[];
  89137. /**
  89138. * Returns a positive integer : the total number of indices in this mesh geometry.
  89139. * @returns the numner of indices or zero if the mesh has no geometry.
  89140. */
  89141. getTotalIndices(): number;
  89142. /**
  89143. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  89144. * @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.
  89145. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  89146. * @returns the indices array or an empty array if the mesh has no geometry
  89147. */
  89148. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  89149. readonly isBlocked: boolean;
  89150. /**
  89151. * Determine if the current mesh is ready to be rendered
  89152. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  89153. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  89154. * @returns true if all associated assets are ready (material, textures, shaders)
  89155. */
  89156. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  89157. /**
  89158. * 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.
  89159. */
  89160. readonly areNormalsFrozen: boolean;
  89161. /**
  89162. * 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.
  89163. * @returns the current mesh
  89164. */
  89165. freezeNormals(): Mesh;
  89166. /**
  89167. * 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
  89168. * @returns the current mesh
  89169. */
  89170. unfreezeNormals(): Mesh;
  89171. /**
  89172. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  89173. */
  89174. overridenInstanceCount: number;
  89175. /** @hidden */
  89176. _preActivate(): Mesh;
  89177. /** @hidden */
  89178. _preActivateForIntermediateRendering(renderId: number): Mesh;
  89179. /** @hidden */
  89180. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  89181. /**
  89182. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  89183. * This means the mesh underlying bounding box and sphere are recomputed.
  89184. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  89185. * @returns the current mesh
  89186. */
  89187. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  89188. /** @hidden */
  89189. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  89190. /**
  89191. * This function will subdivide the mesh into multiple submeshes
  89192. * @param count defines the expected number of submeshes
  89193. */
  89194. subdivide(count: number): void;
  89195. /**
  89196. * Copy a FloatArray into a specific associated vertex buffer
  89197. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  89198. * - VertexBuffer.PositionKind
  89199. * - VertexBuffer.UVKind
  89200. * - VertexBuffer.UV2Kind
  89201. * - VertexBuffer.UV3Kind
  89202. * - VertexBuffer.UV4Kind
  89203. * - VertexBuffer.UV5Kind
  89204. * - VertexBuffer.UV6Kind
  89205. * - VertexBuffer.ColorKind
  89206. * - VertexBuffer.MatricesIndicesKind
  89207. * - VertexBuffer.MatricesIndicesExtraKind
  89208. * - VertexBuffer.MatricesWeightsKind
  89209. * - VertexBuffer.MatricesWeightsExtraKind
  89210. * @param data defines the data source
  89211. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  89212. * @param stride defines the data stride size (can be null)
  89213. * @returns the current mesh
  89214. */
  89215. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  89216. /**
  89217. * Flags an associated vertex buffer as updatable
  89218. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  89219. * - VertexBuffer.PositionKind
  89220. * - VertexBuffer.UVKind
  89221. * - VertexBuffer.UV2Kind
  89222. * - VertexBuffer.UV3Kind
  89223. * - VertexBuffer.UV4Kind
  89224. * - VertexBuffer.UV5Kind
  89225. * - VertexBuffer.UV6Kind
  89226. * - VertexBuffer.ColorKind
  89227. * - VertexBuffer.MatricesIndicesKind
  89228. * - VertexBuffer.MatricesIndicesExtraKind
  89229. * - VertexBuffer.MatricesWeightsKind
  89230. * - VertexBuffer.MatricesWeightsExtraKind
  89231. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  89232. */
  89233. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  89234. /**
  89235. * Sets the mesh global Vertex Buffer
  89236. * @param buffer defines the buffer to use
  89237. * @returns the current mesh
  89238. */
  89239. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  89240. /**
  89241. * Update a specific associated vertex buffer
  89242. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  89243. * - VertexBuffer.PositionKind
  89244. * - VertexBuffer.UVKind
  89245. * - VertexBuffer.UV2Kind
  89246. * - VertexBuffer.UV3Kind
  89247. * - VertexBuffer.UV4Kind
  89248. * - VertexBuffer.UV5Kind
  89249. * - VertexBuffer.UV6Kind
  89250. * - VertexBuffer.ColorKind
  89251. * - VertexBuffer.MatricesIndicesKind
  89252. * - VertexBuffer.MatricesIndicesExtraKind
  89253. * - VertexBuffer.MatricesWeightsKind
  89254. * - VertexBuffer.MatricesWeightsExtraKind
  89255. * @param data defines the data source
  89256. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  89257. * @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)
  89258. * @returns the current mesh
  89259. */
  89260. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  89261. /**
  89262. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  89263. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  89264. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  89265. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  89266. * @returns the current mesh
  89267. */
  89268. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  89269. /**
  89270. * Creates a un-shared specific occurence of the geometry for the mesh.
  89271. * @returns the current mesh
  89272. */
  89273. makeGeometryUnique(): Mesh;
  89274. /**
  89275. * Set the index buffer of this mesh
  89276. * @param indices defines the source data
  89277. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  89278. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  89279. * @returns the current mesh
  89280. */
  89281. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  89282. /**
  89283. * Update the current index buffer
  89284. * @param indices defines the source data
  89285. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  89286. * @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)
  89287. * @returns the current mesh
  89288. */
  89289. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  89290. /**
  89291. * Invert the geometry to move from a right handed system to a left handed one.
  89292. * @returns the current mesh
  89293. */
  89294. toLeftHanded(): Mesh;
  89295. /** @hidden */
  89296. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  89297. /** @hidden */
  89298. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  89299. /**
  89300. * Registers for this mesh a javascript function called just before the rendering process
  89301. * @param func defines the function to call before rendering this mesh
  89302. * @returns the current mesh
  89303. */
  89304. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  89305. /**
  89306. * Disposes a previously registered javascript function called before the rendering
  89307. * @param func defines the function to remove
  89308. * @returns the current mesh
  89309. */
  89310. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  89311. /**
  89312. * Registers for this mesh a javascript function called just after the rendering is complete
  89313. * @param func defines the function to call after rendering this mesh
  89314. * @returns the current mesh
  89315. */
  89316. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  89317. /**
  89318. * Disposes a previously registered javascript function called after the rendering.
  89319. * @param func defines the function to remove
  89320. * @returns the current mesh
  89321. */
  89322. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  89323. /** @hidden */
  89324. _getInstancesRenderList(subMeshId: number): _InstancesBatch;
  89325. /** @hidden */
  89326. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  89327. /** @hidden */
  89328. _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  89329. /** @hidden */
  89330. _rebuild(): void;
  89331. /** @hidden */
  89332. _freeze(): void;
  89333. /** @hidden */
  89334. _unFreeze(): void;
  89335. /**
  89336. * 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
  89337. * @param subMesh defines the subMesh to render
  89338. * @param enableAlphaMode defines if alpha mode can be changed
  89339. * @returns the current mesh
  89340. */
  89341. render(subMesh: SubMesh, enableAlphaMode: boolean): Mesh;
  89342. private _onBeforeDraw;
  89343. /**
  89344. * Renormalize the mesh and patch it up if there are no weights
  89345. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  89346. * However in the case of zero weights then we set just a single influence to 1.
  89347. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  89348. */
  89349. cleanMatrixWeights(): void;
  89350. private normalizeSkinFourWeights;
  89351. private normalizeSkinWeightsAndExtra;
  89352. /**
  89353. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  89354. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  89355. * the user know there was an issue with importing the mesh
  89356. * @returns a validation object with skinned, valid and report string
  89357. */
  89358. validateSkinning(): {
  89359. skinned: boolean;
  89360. valid: boolean;
  89361. report: string;
  89362. };
  89363. /** @hidden */
  89364. _checkDelayState(): Mesh;
  89365. private _queueLoad;
  89366. /**
  89367. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  89368. * A mesh is in the frustum if its bounding box intersects the frustum
  89369. * @param frustumPlanes defines the frustum to test
  89370. * @returns true if the mesh is in the frustum planes
  89371. */
  89372. isInFrustum(frustumPlanes: Plane[]): boolean;
  89373. /**
  89374. * Sets the mesh material by the material or multiMaterial `id` property
  89375. * @param id is a string identifying the material or the multiMaterial
  89376. * @returns the current mesh
  89377. */
  89378. setMaterialByID(id: string): Mesh;
  89379. /**
  89380. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  89381. * @returns an array of IAnimatable
  89382. */
  89383. getAnimatables(): IAnimatable[];
  89384. /**
  89385. * Modifies the mesh geometry according to the passed transformation matrix.
  89386. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  89387. * The mesh normals are modified using the same transformation.
  89388. * Note that, under the hood, this method sets a new VertexBuffer each call.
  89389. * @param transform defines the transform matrix to use
  89390. * @see http://doc.babylonjs.com/resources/baking_transformations
  89391. * @returns the current mesh
  89392. */
  89393. bakeTransformIntoVertices(transform: Matrix): Mesh;
  89394. /**
  89395. * Modifies the mesh geometry according to its own current World Matrix.
  89396. * The mesh World Matrix is then reset.
  89397. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  89398. * Note that, under the hood, this method sets a new VertexBuffer each call.
  89399. * @see http://doc.babylonjs.com/resources/baking_transformations
  89400. * @returns the current mesh
  89401. */
  89402. bakeCurrentTransformIntoVertices(): Mesh;
  89403. /** @hidden */
  89404. readonly _positions: Nullable<Vector3[]>;
  89405. /** @hidden */
  89406. _resetPointsArrayCache(): Mesh;
  89407. /** @hidden */
  89408. _generatePointsArray(): boolean;
  89409. /**
  89410. * Returns a new Mesh object generated from the current mesh properties.
  89411. * This method must not get confused with createInstance()
  89412. * @param name is a string, the name given to the new mesh
  89413. * @param newParent can be any Node object (default `null`)
  89414. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  89415. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  89416. * @returns a new mesh
  89417. */
  89418. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Nullable<AbstractMesh>;
  89419. /**
  89420. * Releases resources associated with this mesh.
  89421. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  89422. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  89423. */
  89424. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  89425. /**
  89426. * Modifies the mesh geometry according to a displacement map.
  89427. * 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.
  89428. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  89429. * @param url is a string, the URL from the image file is to be downloaded.
  89430. * @param minHeight is the lower limit of the displacement.
  89431. * @param maxHeight is the upper limit of the displacement.
  89432. * @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.
  89433. * @param uvOffset is an optional vector2 used to offset UV.
  89434. * @param uvScale is an optional vector2 used to scale UV.
  89435. * @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.
  89436. * @returns the Mesh.
  89437. */
  89438. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  89439. /**
  89440. * Modifies the mesh geometry according to a displacementMap buffer.
  89441. * 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.
  89442. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  89443. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  89444. * @param heightMapWidth is the width of the buffer image.
  89445. * @param heightMapHeight is the height of the buffer image.
  89446. * @param minHeight is the lower limit of the displacement.
  89447. * @param maxHeight is the upper limit of the displacement.
  89448. * @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.
  89449. * @param uvOffset is an optional vector2 used to offset UV.
  89450. * @param uvScale is an optional vector2 used to scale UV.
  89451. * @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.
  89452. * @returns the Mesh.
  89453. */
  89454. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  89455. /**
  89456. * Modify the mesh to get a flat shading rendering.
  89457. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  89458. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  89459. * @returns current mesh
  89460. */
  89461. convertToFlatShadedMesh(): Mesh;
  89462. /**
  89463. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  89464. * In other words, more vertices, no more indices and a single bigger VBO.
  89465. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  89466. * @returns current mesh
  89467. */
  89468. convertToUnIndexedMesh(): Mesh;
  89469. /**
  89470. * Inverses facet orientations.
  89471. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  89472. * @param flipNormals will also inverts the normals
  89473. * @returns current mesh
  89474. */
  89475. flipFaces(flipNormals?: boolean): Mesh;
  89476. /**
  89477. * Increase the number of facets and hence vertices in a mesh
  89478. * Vertex normals are interpolated from existing vertex normals
  89479. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  89480. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  89481. */
  89482. increaseVertices(numberPerEdge: number): void;
  89483. /**
  89484. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  89485. * This will undo any application of covertToFlatShadedMesh
  89486. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  89487. */
  89488. forceSharedVertices(): void;
  89489. /** @hidden */
  89490. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  89491. /** @hidden */
  89492. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  89493. /**
  89494. * Creates a new InstancedMesh object from the mesh model.
  89495. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  89496. * @param name defines the name of the new instance
  89497. * @returns a new InstancedMesh
  89498. */
  89499. createInstance(name: string): InstancedMesh;
  89500. /**
  89501. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  89502. * After this call, all the mesh instances have the same submeshes than the current mesh.
  89503. * @returns the current mesh
  89504. */
  89505. synchronizeInstances(): Mesh;
  89506. /**
  89507. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  89508. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  89509. * This should be used together with the simplification to avoid disappearing triangles.
  89510. * @param successCallback an optional success callback to be called after the optimization finished.
  89511. * @returns the current mesh
  89512. */
  89513. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  89514. /**
  89515. * Serialize current mesh
  89516. * @param serializationObject defines the object which will receive the serialization data
  89517. */
  89518. serialize(serializationObject: any): void;
  89519. /** @hidden */
  89520. _syncGeometryWithMorphTargetManager(): void;
  89521. /** @hidden */
  89522. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  89523. /**
  89524. * Returns a new Mesh object parsed from the source provided.
  89525. * @param parsedMesh is the source
  89526. * @param scene defines the hosting scene
  89527. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  89528. * @returns a new Mesh
  89529. */
  89530. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  89531. /**
  89532. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  89533. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  89534. * @param name defines the name of the mesh to create
  89535. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  89536. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  89537. * @param closePath creates a seam between the first and the last points of each path of the path array
  89538. * @param offset is taken in account only if the `pathArray` is containing a single path
  89539. * @param scene defines the hosting scene
  89540. * @param updatable defines if the mesh must be flagged as updatable
  89541. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  89542. * @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)
  89543. * @returns a new Mesh
  89544. */
  89545. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  89546. /**
  89547. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  89548. * @param name defines the name of the mesh to create
  89549. * @param radius sets the radius size (float) of the polygon (default 0.5)
  89550. * @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
  89551. * @param scene defines the hosting scene
  89552. * @param updatable defines if the mesh must be flagged as updatable
  89553. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  89554. * @returns a new Mesh
  89555. */
  89556. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  89557. /**
  89558. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  89559. * @param name defines the name of the mesh to create
  89560. * @param size sets the size (float) of each box side (default 1)
  89561. * @param scene defines the hosting scene
  89562. * @param updatable defines if the mesh must be flagged as updatable
  89563. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  89564. * @returns a new Mesh
  89565. */
  89566. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  89567. /**
  89568. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  89569. * @param name defines the name of the mesh to create
  89570. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  89571. * @param diameter sets the diameter size (float) of the sphere (default 1)
  89572. * @param scene defines the hosting scene
  89573. * @param updatable defines if the mesh must be flagged as updatable
  89574. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  89575. * @returns a new Mesh
  89576. */
  89577. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  89578. /**
  89579. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  89580. * @param name defines the name of the mesh to create
  89581. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  89582. * @param diameter sets the diameter size (float) of the sphere (default 1)
  89583. * @param scene defines the hosting scene
  89584. * @returns a new Mesh
  89585. */
  89586. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  89587. /**
  89588. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  89589. * @param name defines the name of the mesh to create
  89590. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  89591. * @param diameterTop set the top cap diameter (floats, default 1)
  89592. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  89593. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  89594. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  89595. * @param scene defines the hosting scene
  89596. * @param updatable defines if the mesh must be flagged as updatable
  89597. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  89598. * @returns a new Mesh
  89599. */
  89600. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  89601. /**
  89602. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  89603. * @param name defines the name of the mesh to create
  89604. * @param diameter sets the diameter size (float) of the torus (default 1)
  89605. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  89606. * @param tessellation sets the number of torus sides (postive integer, default 16)
  89607. * @param scene defines the hosting scene
  89608. * @param updatable defines if the mesh must be flagged as updatable
  89609. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  89610. * @returns a new Mesh
  89611. */
  89612. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  89613. /**
  89614. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  89615. * @param name defines the name of the mesh to create
  89616. * @param radius sets the global radius size (float) of the torus knot (default 2)
  89617. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  89618. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  89619. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  89620. * @param p the number of windings on X axis (positive integers, default 2)
  89621. * @param q the number of windings on Y axis (positive integers, default 3)
  89622. * @param scene defines the hosting scene
  89623. * @param updatable defines if the mesh must be flagged as updatable
  89624. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  89625. * @returns a new Mesh
  89626. */
  89627. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  89628. /**
  89629. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  89630. * @param name defines the name of the mesh to create
  89631. * @param points is an array successive Vector3
  89632. * @param scene defines the hosting scene
  89633. * @param updatable defines if the mesh must be flagged as updatable
  89634. * @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).
  89635. * @returns a new Mesh
  89636. */
  89637. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  89638. /**
  89639. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  89640. * @param name defines the name of the mesh to create
  89641. * @param points is an array successive Vector3
  89642. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  89643. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  89644. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  89645. * @param scene defines the hosting scene
  89646. * @param updatable defines if the mesh must be flagged as updatable
  89647. * @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)
  89648. * @returns a new Mesh
  89649. */
  89650. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  89651. /**
  89652. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  89653. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  89654. * 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.
  89655. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  89656. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  89657. * Remember you can only change the shape positions, not their number when updating a polygon.
  89658. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  89659. * @param name defines the name of the mesh to create
  89660. * @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
  89661. * @param scene defines the hosting scene
  89662. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  89663. * @param updatable defines if the mesh must be flagged as updatable
  89664. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  89665. * @param earcutInjection can be used to inject your own earcut reference
  89666. * @returns a new Mesh
  89667. */
  89668. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  89669. /**
  89670. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  89671. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  89672. * @param name defines the name of the mesh to create
  89673. * @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
  89674. * @param depth defines the height of extrusion
  89675. * @param scene defines the hosting scene
  89676. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  89677. * @param updatable defines if the mesh must be flagged as updatable
  89678. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  89679. * @param earcutInjection can be used to inject your own earcut reference
  89680. * @returns a new Mesh
  89681. */
  89682. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  89683. /**
  89684. * Creates an extruded shape mesh.
  89685. * 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
  89686. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  89687. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  89688. * @param name defines the name of the mesh to create
  89689. * @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
  89690. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  89691. * @param scale is the value to scale the shape
  89692. * @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
  89693. * @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
  89694. * @param scene defines the hosting scene
  89695. * @param updatable defines if the mesh must be flagged as updatable
  89696. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  89697. * @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)
  89698. * @returns a new Mesh
  89699. */
  89700. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  89701. /**
  89702. * Creates an custom extruded shape mesh.
  89703. * The custom extrusion is a parametric shape.
  89704. * It has no predefined shape. Its final shape will depend on the input parameters.
  89705. * Please consider using the same method from the MeshBuilder class instead
  89706. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  89707. * @param name defines the name of the mesh to create
  89708. * @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
  89709. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  89710. * @param scaleFunction is a custom Javascript function called on each path point
  89711. * @param rotationFunction is a custom Javascript function called on each path point
  89712. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  89713. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  89714. * @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
  89715. * @param scene defines the hosting scene
  89716. * @param updatable defines if the mesh must be flagged as updatable
  89717. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  89718. * @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)
  89719. * @returns a new Mesh
  89720. */
  89721. 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;
  89722. /**
  89723. * Creates lathe mesh.
  89724. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  89725. * Please consider using the same method from the MeshBuilder class instead
  89726. * @param name defines the name of the mesh to create
  89727. * @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
  89728. * @param radius is the radius value of the lathe
  89729. * @param tessellation is the side number of the lathe.
  89730. * @param scene defines the hosting scene
  89731. * @param updatable defines if the mesh must be flagged as updatable
  89732. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  89733. * @returns a new Mesh
  89734. */
  89735. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  89736. /**
  89737. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  89738. * @param name defines the name of the mesh to create
  89739. * @param size sets the size (float) of both sides of the plane at once (default 1)
  89740. * @param scene defines the hosting scene
  89741. * @param updatable defines if the mesh must be flagged as updatable
  89742. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  89743. * @returns a new Mesh
  89744. */
  89745. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  89746. /**
  89747. * Creates a ground mesh.
  89748. * Please consider using the same method from the MeshBuilder class instead
  89749. * @param name defines the name of the mesh to create
  89750. * @param width set the width of the ground
  89751. * @param height set the height of the ground
  89752. * @param subdivisions sets the number of subdivisions per side
  89753. * @param scene defines the hosting scene
  89754. * @param updatable defines if the mesh must be flagged as updatable
  89755. * @returns a new Mesh
  89756. */
  89757. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  89758. /**
  89759. * Creates a tiled ground mesh.
  89760. * Please consider using the same method from the MeshBuilder class instead
  89761. * @param name defines the name of the mesh to create
  89762. * @param xmin set the ground minimum X coordinate
  89763. * @param zmin set the ground minimum Y coordinate
  89764. * @param xmax set the ground maximum X coordinate
  89765. * @param zmax set the ground maximum Z coordinate
  89766. * @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
  89767. * @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
  89768. * @param scene defines the hosting scene
  89769. * @param updatable defines if the mesh must be flagged as updatable
  89770. * @returns a new Mesh
  89771. */
  89772. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  89773. w: number;
  89774. h: number;
  89775. }, precision: {
  89776. w: number;
  89777. h: number;
  89778. }, scene: Scene, updatable?: boolean): Mesh;
  89779. /**
  89780. * Creates a ground mesh from a height map.
  89781. * Please consider using the same method from the MeshBuilder class instead
  89782. * @see http://doc.babylonjs.com/babylon101/height_map
  89783. * @param name defines the name of the mesh to create
  89784. * @param url sets the URL of the height map image resource
  89785. * @param width set the ground width size
  89786. * @param height set the ground height size
  89787. * @param subdivisions sets the number of subdivision per side
  89788. * @param minHeight is the minimum altitude on the ground
  89789. * @param maxHeight is the maximum altitude on the ground
  89790. * @param scene defines the hosting scene
  89791. * @param updatable defines if the mesh must be flagged as updatable
  89792. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  89793. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  89794. * @returns a new Mesh
  89795. */
  89796. 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;
  89797. /**
  89798. * Creates a tube mesh.
  89799. * The tube is a parametric shape.
  89800. * It has no predefined shape. Its final shape will depend on the input parameters.
  89801. * Please consider using the same method from the MeshBuilder class instead
  89802. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  89803. * @param name defines the name of the mesh to create
  89804. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  89805. * @param radius sets the tube radius size
  89806. * @param tessellation is the number of sides on the tubular surface
  89807. * @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
  89808. * @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
  89809. * @param scene defines the hosting scene
  89810. * @param updatable defines if the mesh must be flagged as updatable
  89811. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  89812. * @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)
  89813. * @returns a new Mesh
  89814. */
  89815. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  89816. (i: number, distance: number): number;
  89817. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  89818. /**
  89819. * Creates a polyhedron mesh.
  89820. * Please consider using the same method from the MeshBuilder class instead.
  89821. * * 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
  89822. * * The parameter `size` (positive float, default 1) sets the polygon size
  89823. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  89824. * * 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`
  89825. * * 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
  89826. * * 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)`)
  89827. * * 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
  89828. * * 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
  89829. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  89830. * * If you create a double-sided mesh, you can choose what parts of 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
  89831. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  89832. * @param name defines the name of the mesh to create
  89833. * @param options defines the options used to create the mesh
  89834. * @param scene defines the hosting scene
  89835. * @returns a new Mesh
  89836. */
  89837. static CreatePolyhedron(name: string, options: {
  89838. type?: number;
  89839. size?: number;
  89840. sizeX?: number;
  89841. sizeY?: number;
  89842. sizeZ?: number;
  89843. custom?: any;
  89844. faceUV?: Vector4[];
  89845. faceColors?: Color4[];
  89846. updatable?: boolean;
  89847. sideOrientation?: number;
  89848. }, scene: Scene): Mesh;
  89849. /**
  89850. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  89851. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  89852. * * 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`)
  89853. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  89854. * * 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
  89855. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  89856. * * If you create a double-sided mesh, you can choose what parts of 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
  89857. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  89858. * @param name defines the name of the mesh
  89859. * @param options defines the options used to create the mesh
  89860. * @param scene defines the hosting scene
  89861. * @returns a new Mesh
  89862. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  89863. */
  89864. static CreateIcoSphere(name: string, options: {
  89865. radius?: number;
  89866. flat?: boolean;
  89867. subdivisions?: number;
  89868. sideOrientation?: number;
  89869. updatable?: boolean;
  89870. }, scene: Scene): Mesh;
  89871. /**
  89872. * Creates a decal mesh.
  89873. * Please consider using the same method from the MeshBuilder class instead.
  89874. * A decal is a mesh usually applied as a model onto the surface of another mesh
  89875. * @param name defines the name of the mesh
  89876. * @param sourceMesh defines the mesh receiving the decal
  89877. * @param position sets the position of the decal in world coordinates
  89878. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  89879. * @param size sets the decal scaling
  89880. * @param angle sets the angle to rotate the decal
  89881. * @returns a new Mesh
  89882. */
  89883. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  89884. /**
  89885. * Prepare internal position array for software CPU skinning
  89886. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  89887. */
  89888. setPositionsForCPUSkinning(): Float32Array;
  89889. /**
  89890. * Prepare internal normal array for software CPU skinning
  89891. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  89892. */
  89893. setNormalsForCPUSkinning(): Float32Array;
  89894. /**
  89895. * Updates the vertex buffer by applying transformation from the bones
  89896. * @param skeleton defines the skeleton to apply to current mesh
  89897. * @returns the current mesh
  89898. */
  89899. applySkeleton(skeleton: Skeleton): Mesh;
  89900. /**
  89901. * 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
  89902. * @param meshes defines the list of meshes to scan
  89903. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  89904. */
  89905. static MinMax(meshes: AbstractMesh[]): {
  89906. min: Vector3;
  89907. max: Vector3;
  89908. };
  89909. /**
  89910. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  89911. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  89912. * @returns a vector3
  89913. */
  89914. static Center(meshesOrMinMaxVector: {
  89915. min: Vector3;
  89916. max: Vector3;
  89917. } | AbstractMesh[]): Vector3;
  89918. /**
  89919. * Merge the array of meshes into a single mesh for performance reasons.
  89920. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  89921. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  89922. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  89923. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  89924. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  89925. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  89926. * @returns a new mesh
  89927. */
  89928. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  89929. /** @hidden */
  89930. addInstance(instance: InstancedMesh): void;
  89931. /** @hidden */
  89932. removeInstance(instance: InstancedMesh): void;
  89933. }
  89934. }
  89935. declare module BABYLON {
  89936. /**
  89937. * This is the base class of all the camera used in the application.
  89938. * @see http://doc.babylonjs.com/features/cameras
  89939. */
  89940. export class Camera extends Node {
  89941. /** @hidden */
  89942. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  89943. /**
  89944. * This is the default projection mode used by the cameras.
  89945. * It helps recreating a feeling of perspective and better appreciate depth.
  89946. * This is the best way to simulate real life cameras.
  89947. */
  89948. static readonly PERSPECTIVE_CAMERA: number;
  89949. /**
  89950. * This helps creating camera with an orthographic mode.
  89951. * 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.
  89952. */
  89953. static readonly ORTHOGRAPHIC_CAMERA: number;
  89954. /**
  89955. * This is the default FOV mode for perspective cameras.
  89956. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  89957. */
  89958. static readonly FOVMODE_VERTICAL_FIXED: number;
  89959. /**
  89960. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  89961. */
  89962. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  89963. /**
  89964. * This specifies ther is no need for a camera rig.
  89965. * Basically only one eye is rendered corresponding to the camera.
  89966. */
  89967. static readonly RIG_MODE_NONE: number;
  89968. /**
  89969. * Simulates a camera Rig with one blue eye and one red eye.
  89970. * This can be use with 3d blue and red glasses.
  89971. */
  89972. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  89973. /**
  89974. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  89975. */
  89976. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  89977. /**
  89978. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  89979. */
  89980. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  89981. /**
  89982. * Defines that both eyes of the camera will be rendered over under each other.
  89983. */
  89984. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  89985. /**
  89986. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  89987. */
  89988. static readonly RIG_MODE_VR: number;
  89989. /**
  89990. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  89991. */
  89992. static readonly RIG_MODE_WEBVR: number;
  89993. /**
  89994. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  89995. */
  89996. static readonly RIG_MODE_CUSTOM: number;
  89997. /**
  89998. * Defines if by default attaching controls should prevent the default javascript event to continue.
  89999. */
  90000. static ForceAttachControlToAlwaysPreventDefault: boolean;
  90001. /**
  90002. * Define the input manager associated with the camera.
  90003. */
  90004. inputs: CameraInputsManager<Camera>;
  90005. /** @hidden */
  90006. _position: Vector3;
  90007. /**
  90008. * Define the current local position of the camera in the scene
  90009. */
  90010. position: Vector3;
  90011. /**
  90012. * The vector the camera should consider as up.
  90013. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  90014. */
  90015. upVector: Vector3;
  90016. /**
  90017. * Define the current limit on the left side for an orthographic camera
  90018. * In scene unit
  90019. */
  90020. orthoLeft: Nullable<number>;
  90021. /**
  90022. * Define the current limit on the right side for an orthographic camera
  90023. * In scene unit
  90024. */
  90025. orthoRight: Nullable<number>;
  90026. /**
  90027. * Define the current limit on the bottom side for an orthographic camera
  90028. * In scene unit
  90029. */
  90030. orthoBottom: Nullable<number>;
  90031. /**
  90032. * Define the current limit on the top side for an orthographic camera
  90033. * In scene unit
  90034. */
  90035. orthoTop: Nullable<number>;
  90036. /**
  90037. * Field Of View is set in Radians. (default is 0.8)
  90038. */
  90039. fov: number;
  90040. /**
  90041. * Define the minimum distance the camera can see from.
  90042. * This is important to note that the depth buffer are not infinite and the closer it starts
  90043. * the more your scene might encounter depth fighting issue.
  90044. */
  90045. minZ: number;
  90046. /**
  90047. * Define the maximum distance the camera can see to.
  90048. * This is important to note that the depth buffer are not infinite and the further it end
  90049. * the more your scene might encounter depth fighting issue.
  90050. */
  90051. maxZ: number;
  90052. /**
  90053. * Define the default inertia of the camera.
  90054. * This helps giving a smooth feeling to the camera movement.
  90055. */
  90056. inertia: number;
  90057. /**
  90058. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  90059. */
  90060. mode: number;
  90061. /**
  90062. * Define wether the camera is intermediate.
  90063. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  90064. */
  90065. isIntermediate: boolean;
  90066. /**
  90067. * Define the viewport of the camera.
  90068. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  90069. */
  90070. viewport: Viewport;
  90071. /**
  90072. * Restricts the camera to viewing objects with the same layerMask.
  90073. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  90074. */
  90075. layerMask: number;
  90076. /**
  90077. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  90078. */
  90079. fovMode: number;
  90080. /**
  90081. * Rig mode of the camera.
  90082. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  90083. * This is normally controlled byt the camera themselves as internal use.
  90084. */
  90085. cameraRigMode: number;
  90086. /**
  90087. * Defines the distance between both "eyes" in case of a RIG
  90088. */
  90089. interaxialDistance: number;
  90090. /**
  90091. * Defines if stereoscopic rendering is done side by side or over under.
  90092. */
  90093. isStereoscopicSideBySide: boolean;
  90094. /**
  90095. * 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
  90096. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  90097. * else in the scene. (Eg. security camera)
  90098. *
  90099. * 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)
  90100. */
  90101. customRenderTargets: RenderTargetTexture[];
  90102. /**
  90103. * When set, the camera will render to this render target instead of the default canvas
  90104. *
  90105. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  90106. */
  90107. outputRenderTarget: Nullable<RenderTargetTexture>;
  90108. /**
  90109. * Observable triggered when the camera view matrix has changed.
  90110. */
  90111. onViewMatrixChangedObservable: Observable<Camera>;
  90112. /**
  90113. * Observable triggered when the camera Projection matrix has changed.
  90114. */
  90115. onProjectionMatrixChangedObservable: Observable<Camera>;
  90116. /**
  90117. * Observable triggered when the inputs have been processed.
  90118. */
  90119. onAfterCheckInputsObservable: Observable<Camera>;
  90120. /**
  90121. * Observable triggered when reset has been called and applied to the camera.
  90122. */
  90123. onRestoreStateObservable: Observable<Camera>;
  90124. /** @hidden */
  90125. _cameraRigParams: any;
  90126. /** @hidden */
  90127. _rigCameras: Camera[];
  90128. /** @hidden */
  90129. _rigPostProcess: Nullable<PostProcess>;
  90130. protected _webvrViewMatrix: Matrix;
  90131. /** @hidden */
  90132. _skipRendering: boolean;
  90133. /** @hidden */
  90134. _projectionMatrix: Matrix;
  90135. /** @hidden */
  90136. _postProcesses: Nullable<PostProcess>[];
  90137. /** @hidden */
  90138. _activeMeshes: SmartArray<AbstractMesh>;
  90139. protected _globalPosition: Vector3;
  90140. /** @hidden */
  90141. _computedViewMatrix: Matrix;
  90142. private _doNotComputeProjectionMatrix;
  90143. private _transformMatrix;
  90144. private _frustumPlanes;
  90145. private _refreshFrustumPlanes;
  90146. private _storedFov;
  90147. private _stateStored;
  90148. /**
  90149. * Instantiates a new camera object.
  90150. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  90151. * @see http://doc.babylonjs.com/features/cameras
  90152. * @param name Defines the name of the camera in the scene
  90153. * @param position Defines the position of the camera
  90154. * @param scene Defines the scene the camera belongs too
  90155. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  90156. */
  90157. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  90158. /**
  90159. * Store current camera state (fov, position, etc..)
  90160. * @returns the camera
  90161. */
  90162. storeState(): Camera;
  90163. /**
  90164. * Restores the camera state values if it has been stored. You must call storeState() first
  90165. */
  90166. protected _restoreStateValues(): boolean;
  90167. /**
  90168. * Restored camera state. You must call storeState() first.
  90169. * @returns true if restored and false otherwise
  90170. */
  90171. restoreState(): boolean;
  90172. /**
  90173. * Gets the class name of the camera.
  90174. * @returns the class name
  90175. */
  90176. getClassName(): string;
  90177. /** @hidden */
  90178. readonly _isCamera: boolean;
  90179. /**
  90180. * Gets a string representation of the camera useful for debug purpose.
  90181. * @param fullDetails Defines that a more verboe level of logging is required
  90182. * @returns the string representation
  90183. */
  90184. toString(fullDetails?: boolean): string;
  90185. /**
  90186. * Gets the current world space position of the camera.
  90187. */
  90188. readonly globalPosition: Vector3;
  90189. /**
  90190. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  90191. * @returns the active meshe list
  90192. */
  90193. getActiveMeshes(): SmartArray<AbstractMesh>;
  90194. /**
  90195. * Check wether a mesh is part of the current active mesh list of the camera
  90196. * @param mesh Defines the mesh to check
  90197. * @returns true if active, false otherwise
  90198. */
  90199. isActiveMesh(mesh: Mesh): boolean;
  90200. /**
  90201. * Is this camera ready to be used/rendered
  90202. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  90203. * @return true if the camera is ready
  90204. */
  90205. isReady(completeCheck?: boolean): boolean;
  90206. /** @hidden */
  90207. _initCache(): void;
  90208. /** @hidden */
  90209. _updateCache(ignoreParentClass?: boolean): void;
  90210. /** @hidden */
  90211. _isSynchronized(): boolean;
  90212. /** @hidden */
  90213. _isSynchronizedViewMatrix(): boolean;
  90214. /** @hidden */
  90215. _isSynchronizedProjectionMatrix(): boolean;
  90216. /**
  90217. * Attach the input controls to a specific dom element to get the input from.
  90218. * @param element Defines the element the controls should be listened from
  90219. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  90220. */
  90221. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  90222. /**
  90223. * Detach the current controls from the specified dom element.
  90224. * @param element Defines the element to stop listening the inputs from
  90225. */
  90226. detachControl(element: HTMLElement): void;
  90227. /**
  90228. * Update the camera state according to the different inputs gathered during the frame.
  90229. */
  90230. update(): void;
  90231. /** @hidden */
  90232. _checkInputs(): void;
  90233. /** @hidden */
  90234. readonly rigCameras: Camera[];
  90235. /**
  90236. * Gets the post process used by the rig cameras
  90237. */
  90238. readonly rigPostProcess: Nullable<PostProcess>;
  90239. /**
  90240. * Internal, gets the first post proces.
  90241. * @returns the first post process to be run on this camera.
  90242. */
  90243. _getFirstPostProcess(): Nullable<PostProcess>;
  90244. private _cascadePostProcessesToRigCams;
  90245. /**
  90246. * Attach a post process to the camera.
  90247. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  90248. * @param postProcess The post process to attach to the camera
  90249. * @param insertAt The position of the post process in case several of them are in use in the scene
  90250. * @returns the position the post process has been inserted at
  90251. */
  90252. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  90253. /**
  90254. * Detach a post process to the camera.
  90255. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  90256. * @param postProcess The post process to detach from the camera
  90257. */
  90258. detachPostProcess(postProcess: PostProcess): void;
  90259. /**
  90260. * Gets the current world matrix of the camera
  90261. */
  90262. getWorldMatrix(): Matrix;
  90263. /** @hidden */
  90264. _getViewMatrix(): Matrix;
  90265. /**
  90266. * Gets the current view matrix of the camera.
  90267. * @param force forces the camera to recompute the matrix without looking at the cached state
  90268. * @returns the view matrix
  90269. */
  90270. getViewMatrix(force?: boolean): Matrix;
  90271. /**
  90272. * Freeze the projection matrix.
  90273. * It will prevent the cache check of the camera projection compute and can speed up perf
  90274. * if no parameter of the camera are meant to change
  90275. * @param projection Defines manually a projection if necessary
  90276. */
  90277. freezeProjectionMatrix(projection?: Matrix): void;
  90278. /**
  90279. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  90280. */
  90281. unfreezeProjectionMatrix(): void;
  90282. /**
  90283. * Gets the current projection matrix of the camera.
  90284. * @param force forces the camera to recompute the matrix without looking at the cached state
  90285. * @returns the projection matrix
  90286. */
  90287. getProjectionMatrix(force?: boolean): Matrix;
  90288. /**
  90289. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  90290. * @returns a Matrix
  90291. */
  90292. getTransformationMatrix(): Matrix;
  90293. private _updateFrustumPlanes;
  90294. /**
  90295. * Checks if a cullable object (mesh...) is in the camera frustum
  90296. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  90297. * @param target The object to check
  90298. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  90299. * @returns true if the object is in frustum otherwise false
  90300. */
  90301. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  90302. /**
  90303. * Checks if a cullable object (mesh...) is in the camera frustum
  90304. * Unlike isInFrustum this cheks the full bounding box
  90305. * @param target The object to check
  90306. * @returns true if the object is in frustum otherwise false
  90307. */
  90308. isCompletelyInFrustum(target: ICullable): boolean;
  90309. /**
  90310. * Gets a ray in the forward direction from the camera.
  90311. * @param length Defines the length of the ray to create
  90312. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  90313. * @param origin Defines the start point of the ray which defaults to the camera position
  90314. * @returns the forward ray
  90315. */
  90316. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  90317. /**
  90318. * Releases resources associated with this node.
  90319. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  90320. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  90321. */
  90322. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  90323. /** @hidden */
  90324. _isLeftCamera: boolean;
  90325. /**
  90326. * Gets the left camera of a rig setup in case of Rigged Camera
  90327. */
  90328. readonly isLeftCamera: boolean;
  90329. /** @hidden */
  90330. _isRightCamera: boolean;
  90331. /**
  90332. * Gets the right camera of a rig setup in case of Rigged Camera
  90333. */
  90334. readonly isRightCamera: boolean;
  90335. /**
  90336. * Gets the left camera of a rig setup in case of Rigged Camera
  90337. */
  90338. readonly leftCamera: Nullable<FreeCamera>;
  90339. /**
  90340. * Gets the right camera of a rig setup in case of Rigged Camera
  90341. */
  90342. readonly rightCamera: Nullable<FreeCamera>;
  90343. /**
  90344. * Gets the left camera target of a rig setup in case of Rigged Camera
  90345. * @returns the target position
  90346. */
  90347. getLeftTarget(): Nullable<Vector3>;
  90348. /**
  90349. * Gets the right camera target of a rig setup in case of Rigged Camera
  90350. * @returns the target position
  90351. */
  90352. getRightTarget(): Nullable<Vector3>;
  90353. /**
  90354. * @hidden
  90355. */
  90356. setCameraRigMode(mode: number, rigParams: any): void;
  90357. /** @hidden */
  90358. static _setStereoscopicRigMode(camera: Camera): void;
  90359. /** @hidden */
  90360. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  90361. /** @hidden */
  90362. static _setVRRigMode(camera: Camera, rigParams: any): void;
  90363. /** @hidden */
  90364. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  90365. /** @hidden */
  90366. _getVRProjectionMatrix(): Matrix;
  90367. protected _updateCameraRotationMatrix(): void;
  90368. protected _updateWebVRCameraRotationMatrix(): void;
  90369. /**
  90370. * This function MUST be overwritten by the different WebVR cameras available.
  90371. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  90372. * @hidden
  90373. */
  90374. _getWebVRProjectionMatrix(): Matrix;
  90375. /**
  90376. * This function MUST be overwritten by the different WebVR cameras available.
  90377. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  90378. * @hidden
  90379. */
  90380. _getWebVRViewMatrix(): Matrix;
  90381. /** @hidden */
  90382. setCameraRigParameter(name: string, value: any): void;
  90383. /**
  90384. * needs to be overridden by children so sub has required properties to be copied
  90385. * @hidden
  90386. */
  90387. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  90388. /**
  90389. * May need to be overridden by children
  90390. * @hidden
  90391. */
  90392. _updateRigCameras(): void;
  90393. /** @hidden */
  90394. _setupInputs(): void;
  90395. /**
  90396. * Serialiaze the camera setup to a json represention
  90397. * @returns the JSON representation
  90398. */
  90399. serialize(): any;
  90400. /**
  90401. * Clones the current camera.
  90402. * @param name The cloned camera name
  90403. * @returns the cloned camera
  90404. */
  90405. clone(name: string): Camera;
  90406. /**
  90407. * Gets the direction of the camera relative to a given local axis.
  90408. * @param localAxis Defines the reference axis to provide a relative direction.
  90409. * @return the direction
  90410. */
  90411. getDirection(localAxis: Vector3): Vector3;
  90412. /**
  90413. * Gets the direction of the camera relative to a given local axis into a passed vector.
  90414. * @param localAxis Defines the reference axis to provide a relative direction.
  90415. * @param result Defines the vector to store the result in
  90416. */
  90417. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  90418. /**
  90419. * Gets a camera constructor for a given camera type
  90420. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  90421. * @param name The name of the camera the result will be able to instantiate
  90422. * @param scene The scene the result will construct the camera in
  90423. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  90424. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  90425. * @returns a factory method to construc the camera
  90426. */
  90427. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  90428. /**
  90429. * Compute the world matrix of the camera.
  90430. * @returns the camera workd matrix
  90431. */
  90432. computeWorldMatrix(): Matrix;
  90433. /**
  90434. * Parse a JSON and creates the camera from the parsed information
  90435. * @param parsedCamera The JSON to parse
  90436. * @param scene The scene to instantiate the camera in
  90437. * @returns the newly constructed camera
  90438. */
  90439. static Parse(parsedCamera: any, scene: Scene): Camera;
  90440. }
  90441. }
  90442. declare module BABYLON {
  90443. /**
  90444. * Class containing static functions to help procedurally build meshes
  90445. */
  90446. export class DiscBuilder {
  90447. /**
  90448. * Creates a plane polygonal mesh. By default, this is a disc
  90449. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  90450. * * 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
  90451. * * 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
  90452. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  90453. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  90454. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  90455. * @param name defines the name of the mesh
  90456. * @param options defines the options used to create the mesh
  90457. * @param scene defines the hosting scene
  90458. * @returns the plane polygonal mesh
  90459. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  90460. */
  90461. static CreateDisc(name: string, options: {
  90462. radius?: number;
  90463. tessellation?: number;
  90464. arc?: number;
  90465. updatable?: boolean;
  90466. sideOrientation?: number;
  90467. frontUVs?: Vector4;
  90468. backUVs?: Vector4;
  90469. }, scene?: Nullable<Scene>): Mesh;
  90470. }
  90471. }
  90472. declare module BABYLON {
  90473. /**
  90474. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  90475. *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.
  90476. * The SPS is also a particle system. It provides some methods to manage the particles.
  90477. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  90478. *
  90479. * Full documentation here : http://doc.babylonjs.com/how_to/Solid_Particle_System
  90480. */
  90481. export class SolidParticleSystem implements IDisposable {
  90482. /**
  90483. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  90484. * Example : var p = SPS.particles[i];
  90485. */
  90486. particles: SolidParticle[];
  90487. /**
  90488. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  90489. */
  90490. nbParticles: number;
  90491. /**
  90492. * If the particles must ever face the camera (default false). Useful for planar particles.
  90493. */
  90494. billboard: boolean;
  90495. /**
  90496. * Recompute normals when adding a shape
  90497. */
  90498. recomputeNormals: boolean;
  90499. /**
  90500. * This a counter ofr your own usage. It's not set by any SPS functions.
  90501. */
  90502. counter: number;
  90503. /**
  90504. * The SPS name. This name is also given to the underlying mesh.
  90505. */
  90506. name: string;
  90507. /**
  90508. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  90509. */
  90510. mesh: Mesh;
  90511. /**
  90512. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  90513. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  90514. */
  90515. vars: any;
  90516. /**
  90517. * This array is populated when the SPS is set as 'pickable'.
  90518. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  90519. * Each element of this array is an object `{idx: int, faceId: int}`.
  90520. * `idx` is the picked particle index in the `SPS.particles` array
  90521. * `faceId` is the picked face index counted within this particle.
  90522. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  90523. */
  90524. pickedParticles: {
  90525. idx: number;
  90526. faceId: number;
  90527. }[];
  90528. /**
  90529. * This array is populated when `enableDepthSort` is set to true.
  90530. * Each element of this array is an instance of the class DepthSortedParticle.
  90531. */
  90532. depthSortedParticles: DepthSortedParticle[];
  90533. /**
  90534. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  90535. * @hidden
  90536. */
  90537. _bSphereOnly: boolean;
  90538. /**
  90539. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  90540. * @hidden
  90541. */
  90542. _bSphereRadiusFactor: number;
  90543. private _scene;
  90544. private _positions;
  90545. private _indices;
  90546. private _normals;
  90547. private _colors;
  90548. private _uvs;
  90549. private _indices32;
  90550. private _positions32;
  90551. private _normals32;
  90552. private _fixedNormal32;
  90553. private _colors32;
  90554. private _uvs32;
  90555. private _index;
  90556. private _updatable;
  90557. private _pickable;
  90558. private _isVisibilityBoxLocked;
  90559. private _alwaysVisible;
  90560. private _depthSort;
  90561. private _shapeCounter;
  90562. private _copy;
  90563. private _color;
  90564. private _computeParticleColor;
  90565. private _computeParticleTexture;
  90566. private _computeParticleRotation;
  90567. private _computeParticleVertex;
  90568. private _computeBoundingBox;
  90569. private _depthSortParticles;
  90570. private _camera;
  90571. private _mustUnrotateFixedNormals;
  90572. private _particlesIntersect;
  90573. private _needs32Bits;
  90574. /**
  90575. * Creates a SPS (Solid Particle System) object.
  90576. * @param name (String) is the SPS name, this will be the underlying mesh name.
  90577. * @param scene (Scene) is the scene in which the SPS is added.
  90578. * @param options defines the options of the sps e.g.
  90579. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  90580. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  90581. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  90582. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  90583. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  90584. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  90585. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  90586. */
  90587. constructor(name: string, scene: Scene, options?: {
  90588. updatable?: boolean;
  90589. isPickable?: boolean;
  90590. enableDepthSort?: boolean;
  90591. particleIntersection?: boolean;
  90592. boundingSphereOnly?: boolean;
  90593. bSphereRadiusFactor?: number;
  90594. });
  90595. /**
  90596. * Builds the SPS underlying mesh. Returns a standard Mesh.
  90597. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  90598. * @returns the created mesh
  90599. */
  90600. buildMesh(): Mesh;
  90601. /**
  90602. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  90603. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  90604. * Thus the particles generated from `digest()` have their property `position` set yet.
  90605. * @param mesh ( Mesh ) is the mesh to be digested
  90606. * @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
  90607. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  90608. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  90609. * @returns the current SPS
  90610. */
  90611. digest(mesh: Mesh, options?: {
  90612. facetNb?: number;
  90613. number?: number;
  90614. delta?: number;
  90615. }): SolidParticleSystem;
  90616. private _unrotateFixedNormals;
  90617. private _resetCopy;
  90618. private _meshBuilder;
  90619. private _posToShape;
  90620. private _uvsToShapeUV;
  90621. private _addParticle;
  90622. /**
  90623. * Adds some particles to the SPS from the model shape. Returns the shape id.
  90624. * Please read the doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  90625. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  90626. * @param nb (positive integer) the number of particles to be created from this model
  90627. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  90628. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  90629. * @returns the number of shapes in the system
  90630. */
  90631. addShape(mesh: Mesh, nb: number, options?: {
  90632. positionFunction?: any;
  90633. vertexFunction?: any;
  90634. }): number;
  90635. private _rebuildParticle;
  90636. /**
  90637. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  90638. * @returns the SPS.
  90639. */
  90640. rebuildMesh(): SolidParticleSystem;
  90641. /**
  90642. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  90643. * This method calls `updateParticle()` for each particle of the SPS.
  90644. * For an animated SPS, it is usually called within the render loop.
  90645. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  90646. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  90647. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  90648. * @returns the SPS.
  90649. */
  90650. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  90651. /**
  90652. * Disposes the SPS.
  90653. */
  90654. dispose(): void;
  90655. /**
  90656. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  90657. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  90658. * @returns the SPS.
  90659. */
  90660. refreshVisibleSize(): SolidParticleSystem;
  90661. /**
  90662. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  90663. * @param size the size (float) of the visibility box
  90664. * note : this doesn't lock the SPS mesh bounding box.
  90665. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  90666. */
  90667. setVisibilityBox(size: number): void;
  90668. /**
  90669. * Gets whether the SPS as always visible or not
  90670. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  90671. */
  90672. /**
  90673. * Sets the SPS as always visible or not
  90674. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  90675. */
  90676. isAlwaysVisible: boolean;
  90677. /**
  90678. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  90679. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  90680. */
  90681. /**
  90682. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  90683. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  90684. */
  90685. isVisibilityBoxLocked: boolean;
  90686. /**
  90687. * Tells to `setParticles()` to compute the particle rotations or not.
  90688. * Default value : true. The SPS is faster when it's set to false.
  90689. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  90690. */
  90691. /**
  90692. * Gets if `setParticles()` computes the particle rotations or not.
  90693. * Default value : true. The SPS is faster when it's set to false.
  90694. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  90695. */
  90696. computeParticleRotation: boolean;
  90697. /**
  90698. * Tells to `setParticles()` to compute the particle colors or not.
  90699. * Default value : true. The SPS is faster when it's set to false.
  90700. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  90701. */
  90702. /**
  90703. * Gets if `setParticles()` computes the particle colors or not.
  90704. * Default value : true. The SPS is faster when it's set to false.
  90705. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  90706. */
  90707. computeParticleColor: boolean;
  90708. /**
  90709. * Gets if `setParticles()` computes the particle textures or not.
  90710. * Default value : true. The SPS is faster when it's set to false.
  90711. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  90712. */
  90713. computeParticleTexture: boolean;
  90714. /**
  90715. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  90716. * Default value : false. The SPS is faster when it's set to false.
  90717. * Note : the particle custom vertex positions aren't stored values.
  90718. */
  90719. /**
  90720. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  90721. * Default value : false. The SPS is faster when it's set to false.
  90722. * Note : the particle custom vertex positions aren't stored values.
  90723. */
  90724. computeParticleVertex: boolean;
  90725. /**
  90726. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  90727. */
  90728. /**
  90729. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  90730. */
  90731. computeBoundingBox: boolean;
  90732. /**
  90733. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  90734. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  90735. * Default : `true`
  90736. */
  90737. /**
  90738. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  90739. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  90740. * Default : `true`
  90741. */
  90742. depthSortParticles: boolean;
  90743. /**
  90744. * This function does nothing. It may be overwritten to set all the particle first values.
  90745. * The SPS doesn't call this function, you may have to call it by your own.
  90746. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  90747. */
  90748. initParticles(): void;
  90749. /**
  90750. * This function does nothing. It may be overwritten to recycle a particle.
  90751. * The SPS doesn't call this function, you may have to call it by your own.
  90752. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  90753. * @param particle The particle to recycle
  90754. * @returns the recycled particle
  90755. */
  90756. recycleParticle(particle: SolidParticle): SolidParticle;
  90757. /**
  90758. * Updates a particle : this function should be overwritten by the user.
  90759. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  90760. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  90761. * @example : just set a particle position or velocity and recycle conditions
  90762. * @param particle The particle to update
  90763. * @returns the updated particle
  90764. */
  90765. updateParticle(particle: SolidParticle): SolidParticle;
  90766. /**
  90767. * Updates a vertex of a particle : it can be overwritten by the user.
  90768. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  90769. * @param particle the current particle
  90770. * @param vertex the current index of the current particle
  90771. * @param pt the index of the current vertex in the particle shape
  90772. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  90773. * @example : just set a vertex particle position
  90774. * @returns the updated vertex
  90775. */
  90776. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  90777. /**
  90778. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  90779. * This does nothing and may be overwritten by the user.
  90780. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  90781. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  90782. * @param update the boolean update value actually passed to setParticles()
  90783. */
  90784. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  90785. /**
  90786. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  90787. * This will be passed three parameters.
  90788. * This does nothing and may be overwritten by the user.
  90789. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  90790. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  90791. * @param update the boolean update value actually passed to setParticles()
  90792. */
  90793. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  90794. }
  90795. }
  90796. declare module BABYLON {
  90797. /**
  90798. * Represents one particle of a solid particle system.
  90799. */
  90800. export class SolidParticle {
  90801. /**
  90802. * particle global index
  90803. */
  90804. idx: number;
  90805. /**
  90806. * The color of the particle
  90807. */
  90808. color: Nullable<Color4>;
  90809. /**
  90810. * The world space position of the particle.
  90811. */
  90812. position: Vector3;
  90813. /**
  90814. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  90815. */
  90816. rotation: Vector3;
  90817. /**
  90818. * The world space rotation quaternion of the particle.
  90819. */
  90820. rotationQuaternion: Nullable<Quaternion>;
  90821. /**
  90822. * The scaling of the particle.
  90823. */
  90824. scaling: Vector3;
  90825. /**
  90826. * The uvs of the particle.
  90827. */
  90828. uvs: Vector4;
  90829. /**
  90830. * The current speed of the particle.
  90831. */
  90832. velocity: Vector3;
  90833. /**
  90834. * The pivot point in the particle local space.
  90835. */
  90836. pivot: Vector3;
  90837. /**
  90838. * Must the particle be translated from its pivot point in its local space ?
  90839. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  90840. * Default : false
  90841. */
  90842. translateFromPivot: boolean;
  90843. /**
  90844. * Is the particle active or not ?
  90845. */
  90846. alive: boolean;
  90847. /**
  90848. * Is the particle visible or not ?
  90849. */
  90850. isVisible: boolean;
  90851. /**
  90852. * Index of this particle in the global "positions" array (Internal use)
  90853. * @hidden
  90854. */
  90855. _pos: number;
  90856. /**
  90857. * @hidden Index of this particle in the global "indices" array (Internal use)
  90858. */
  90859. _ind: number;
  90860. /**
  90861. * @hidden ModelShape of this particle (Internal use)
  90862. */
  90863. _model: ModelShape;
  90864. /**
  90865. * ModelShape id of this particle
  90866. */
  90867. shapeId: number;
  90868. /**
  90869. * Index of the particle in its shape id
  90870. */
  90871. idxInShape: number;
  90872. /**
  90873. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  90874. */
  90875. _modelBoundingInfo: BoundingInfo;
  90876. /**
  90877. * @hidden Particle BoundingInfo object (Internal use)
  90878. */
  90879. _boundingInfo: BoundingInfo;
  90880. /**
  90881. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  90882. */
  90883. _sps: SolidParticleSystem;
  90884. /**
  90885. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  90886. */
  90887. _stillInvisible: boolean;
  90888. /**
  90889. * @hidden Last computed particle rotation matrix
  90890. */
  90891. _rotationMatrix: number[];
  90892. /**
  90893. * Parent particle Id, if any.
  90894. * Default null.
  90895. */
  90896. parentId: Nullable<number>;
  90897. /**
  90898. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  90899. * The possible values are :
  90900. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  90901. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  90902. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  90903. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  90904. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  90905. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  90906. * */
  90907. cullingStrategy: number;
  90908. /**
  90909. * @hidden Internal global position in the SPS.
  90910. */
  90911. _globalPosition: Vector3;
  90912. /**
  90913. * Creates a Solid Particle object.
  90914. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  90915. * @param particleIndex (integer) is the particle index in the Solid Particle System pool. It's also the particle identifier.
  90916. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  90917. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  90918. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  90919. * @param shapeId (integer) is the model shape identifier in the SPS.
  90920. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  90921. * @param sps defines the sps it is associated to
  90922. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  90923. */
  90924. constructor(particleIndex: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>);
  90925. /**
  90926. * Legacy support, changed scale to scaling
  90927. */
  90928. /**
  90929. * Legacy support, changed scale to scaling
  90930. */
  90931. scale: Vector3;
  90932. /**
  90933. * Legacy support, changed quaternion to rotationQuaternion
  90934. */
  90935. /**
  90936. * Legacy support, changed quaternion to rotationQuaternion
  90937. */
  90938. quaternion: Nullable<Quaternion>;
  90939. /**
  90940. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  90941. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  90942. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  90943. * @returns true if it intersects
  90944. */
  90945. intersectsMesh(target: Mesh | SolidParticle): boolean;
  90946. /**
  90947. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  90948. * A particle is in the frustum if its bounding box intersects the frustum
  90949. * @param frustumPlanes defines the frustum to test
  90950. * @returns true if the particle is in the frustum planes
  90951. */
  90952. isInFrustum(frustumPlanes: Plane[]): boolean;
  90953. /**
  90954. * get the rotation matrix of the particle
  90955. * @hidden
  90956. */
  90957. getRotationMatrix(m: Matrix): void;
  90958. }
  90959. /**
  90960. * Represents the shape of the model used by one particle of a solid particle system.
  90961. * SPS internal tool, don't use it manually.
  90962. */
  90963. export class ModelShape {
  90964. /**
  90965. * The shape id
  90966. * @hidden
  90967. */
  90968. shapeID: number;
  90969. /**
  90970. * flat array of model positions (internal use)
  90971. * @hidden
  90972. */
  90973. _shape: Vector3[];
  90974. /**
  90975. * flat array of model UVs (internal use)
  90976. * @hidden
  90977. */
  90978. _shapeUV: number[];
  90979. /**
  90980. * length of the shape in the model indices array (internal use)
  90981. * @hidden
  90982. */
  90983. _indicesLength: number;
  90984. /**
  90985. * Custom position function (internal use)
  90986. * @hidden
  90987. */
  90988. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  90989. /**
  90990. * Custom vertex function (internal use)
  90991. * @hidden
  90992. */
  90993. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  90994. /**
  90995. * 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.
  90996. * SPS internal tool, don't use it manually.
  90997. * @hidden
  90998. */
  90999. constructor(id: number, shape: Vector3[], indicesLength: number, shapeUV: number[], posFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>, vtxFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>);
  91000. }
  91001. /**
  91002. * Represents a Depth Sorted Particle in the solid particle system.
  91003. */
  91004. export class DepthSortedParticle {
  91005. /**
  91006. * Index of the particle in the "indices" array
  91007. */
  91008. ind: number;
  91009. /**
  91010. * Length of the particle shape in the "indices" array
  91011. */
  91012. indicesLength: number;
  91013. /**
  91014. * Squared distance from the particle to the camera
  91015. */
  91016. sqDistance: number;
  91017. }
  91018. }
  91019. declare module BABYLON {
  91020. /**
  91021. * @hidden
  91022. */
  91023. export class _MeshCollisionData {
  91024. _checkCollisions: boolean;
  91025. _collisionMask: number;
  91026. _collisionGroup: number;
  91027. _collider: Nullable<Collider>;
  91028. _oldPositionForCollisions: Vector3;
  91029. _diffPositionForCollisions: Vector3;
  91030. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  91031. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  91032. }
  91033. }
  91034. declare module BABYLON {
  91035. /** @hidden */
  91036. class _FacetDataStorage {
  91037. facetPositions: Vector3[];
  91038. facetNormals: Vector3[];
  91039. facetPartitioning: number[][];
  91040. facetNb: number;
  91041. partitioningSubdivisions: number;
  91042. partitioningBBoxRatio: number;
  91043. facetDataEnabled: boolean;
  91044. facetParameters: any;
  91045. bbSize: Vector3;
  91046. subDiv: {
  91047. max: number;
  91048. X: number;
  91049. Y: number;
  91050. Z: number;
  91051. };
  91052. facetDepthSort: boolean;
  91053. facetDepthSortEnabled: boolean;
  91054. depthSortedIndices: IndicesArray;
  91055. depthSortedFacets: {
  91056. ind: number;
  91057. sqDistance: number;
  91058. }[];
  91059. facetDepthSortFunction: (f1: {
  91060. ind: number;
  91061. sqDistance: number;
  91062. }, f2: {
  91063. ind: number;
  91064. sqDistance: number;
  91065. }) => number;
  91066. facetDepthSortFrom: Vector3;
  91067. facetDepthSortOrigin: Vector3;
  91068. invertedMatrix: Matrix;
  91069. }
  91070. /**
  91071. * @hidden
  91072. **/
  91073. class _InternalAbstractMeshDataInfo {
  91074. _hasVertexAlpha: boolean;
  91075. _useVertexColors: boolean;
  91076. _numBoneInfluencers: number;
  91077. _applyFog: boolean;
  91078. _receiveShadows: boolean;
  91079. _facetData: _FacetDataStorage;
  91080. _visibility: number;
  91081. _skeleton: Nullable<Skeleton>;
  91082. _layerMask: number;
  91083. _computeBonesUsingShaders: boolean;
  91084. _isActive: boolean;
  91085. _onlyForInstances: boolean;
  91086. _isActiveIntermediate: boolean;
  91087. _onlyForInstancesIntermediate: boolean;
  91088. }
  91089. /**
  91090. * Class used to store all common mesh properties
  91091. */
  91092. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  91093. /** No occlusion */
  91094. static OCCLUSION_TYPE_NONE: number;
  91095. /** Occlusion set to optimisitic */
  91096. static OCCLUSION_TYPE_OPTIMISTIC: number;
  91097. /** Occlusion set to strict */
  91098. static OCCLUSION_TYPE_STRICT: number;
  91099. /** Use an accurante occlusion algorithm */
  91100. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  91101. /** Use a conservative occlusion algorithm */
  91102. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  91103. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  91104. * Test order :
  91105. * Is the bounding sphere outside the frustum ?
  91106. * If not, are the bounding box vertices outside the frustum ?
  91107. * It not, then the cullable object is in the frustum.
  91108. */
  91109. static readonly CULLINGSTRATEGY_STANDARD: number;
  91110. /** Culling strategy : Bounding Sphere Only.
  91111. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  91112. * It's also less accurate than the standard because some not visible objects can still be selected.
  91113. * Test : is the bounding sphere outside the frustum ?
  91114. * If not, then the cullable object is in the frustum.
  91115. */
  91116. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  91117. /** Culling strategy : Optimistic Inclusion.
  91118. * This in an inclusion test first, then the standard exclusion test.
  91119. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  91120. * 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.
  91121. * Anyway, it's as accurate as the standard strategy.
  91122. * Test :
  91123. * Is the cullable object bounding sphere center in the frustum ?
  91124. * If not, apply the default culling strategy.
  91125. */
  91126. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  91127. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  91128. * This in an inclusion test first, then the bounding sphere only exclusion test.
  91129. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  91130. * 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.
  91131. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  91132. * Test :
  91133. * Is the cullable object bounding sphere center in the frustum ?
  91134. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  91135. */
  91136. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  91137. /**
  91138. * No billboard
  91139. */
  91140. static readonly BILLBOARDMODE_NONE: number;
  91141. /** Billboard on X axis */
  91142. static readonly BILLBOARDMODE_X: number;
  91143. /** Billboard on Y axis */
  91144. static readonly BILLBOARDMODE_Y: number;
  91145. /** Billboard on Z axis */
  91146. static readonly BILLBOARDMODE_Z: number;
  91147. /** Billboard on all axes */
  91148. static readonly BILLBOARDMODE_ALL: number;
  91149. /** Billboard on using position instead of orientation */
  91150. static readonly BILLBOARDMODE_USE_POSITION: number;
  91151. /** @hidden */
  91152. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  91153. /**
  91154. * The culling strategy to use to check whether the mesh must be rendered or not.
  91155. * This value can be changed at any time and will be used on the next render mesh selection.
  91156. * The possible values are :
  91157. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  91158. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  91159. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  91160. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  91161. * Please read each static variable documentation to get details about the culling process.
  91162. * */
  91163. cullingStrategy: number;
  91164. /**
  91165. * Gets the number of facets in the mesh
  91166. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  91167. */
  91168. readonly facetNb: number;
  91169. /**
  91170. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  91171. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  91172. */
  91173. partitioningSubdivisions: number;
  91174. /**
  91175. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  91176. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  91177. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  91178. */
  91179. partitioningBBoxRatio: number;
  91180. /**
  91181. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  91182. * Works only for updatable meshes.
  91183. * Doesn't work with multi-materials
  91184. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  91185. */
  91186. mustDepthSortFacets: boolean;
  91187. /**
  91188. * The location (Vector3) where the facet depth sort must be computed from.
  91189. * By default, the active camera position.
  91190. * Used only when facet depth sort is enabled
  91191. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  91192. */
  91193. facetDepthSortFrom: Vector3;
  91194. /**
  91195. * gets a boolean indicating if facetData is enabled
  91196. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  91197. */
  91198. readonly isFacetDataEnabled: boolean;
  91199. /** @hidden */
  91200. _updateNonUniformScalingState(value: boolean): boolean;
  91201. /**
  91202. * An event triggered when this mesh collides with another one
  91203. */
  91204. onCollideObservable: Observable<AbstractMesh>;
  91205. /** Set a function to call when this mesh collides with another one */
  91206. onCollide: () => void;
  91207. /**
  91208. * An event triggered when the collision's position changes
  91209. */
  91210. onCollisionPositionChangeObservable: Observable<Vector3>;
  91211. /** Set a function to call when the collision's position changes */
  91212. onCollisionPositionChange: () => void;
  91213. /**
  91214. * An event triggered when material is changed
  91215. */
  91216. onMaterialChangedObservable: Observable<AbstractMesh>;
  91217. /**
  91218. * Gets or sets the orientation for POV movement & rotation
  91219. */
  91220. definedFacingForward: boolean;
  91221. /** @hidden */
  91222. _occlusionQuery: Nullable<WebGLQuery>;
  91223. /** @hidden */
  91224. _renderingGroup: Nullable<RenderingGroup>;
  91225. /**
  91226. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  91227. */
  91228. /**
  91229. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  91230. */
  91231. visibility: number;
  91232. /** Gets or sets the alpha index used to sort transparent meshes
  91233. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  91234. */
  91235. alphaIndex: number;
  91236. /**
  91237. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  91238. */
  91239. isVisible: boolean;
  91240. /**
  91241. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  91242. */
  91243. isPickable: boolean;
  91244. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  91245. showSubMeshesBoundingBox: boolean;
  91246. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  91247. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  91248. */
  91249. isBlocker: boolean;
  91250. /**
  91251. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  91252. */
  91253. enablePointerMoveEvents: boolean;
  91254. /**
  91255. * Specifies the rendering group id for this mesh (0 by default)
  91256. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  91257. */
  91258. renderingGroupId: number;
  91259. private _material;
  91260. /** Gets or sets current material */
  91261. material: Nullable<Material>;
  91262. /**
  91263. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  91264. * @see http://doc.babylonjs.com/babylon101/shadows
  91265. */
  91266. receiveShadows: boolean;
  91267. /** Defines color to use when rendering outline */
  91268. outlineColor: Color3;
  91269. /** Define width to use when rendering outline */
  91270. outlineWidth: number;
  91271. /** Defines color to use when rendering overlay */
  91272. overlayColor: Color3;
  91273. /** Defines alpha to use when rendering overlay */
  91274. overlayAlpha: number;
  91275. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  91276. hasVertexAlpha: boolean;
  91277. /** 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) */
  91278. useVertexColors: boolean;
  91279. /**
  91280. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  91281. */
  91282. computeBonesUsingShaders: boolean;
  91283. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  91284. numBoneInfluencers: number;
  91285. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  91286. applyFog: boolean;
  91287. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  91288. useOctreeForRenderingSelection: boolean;
  91289. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  91290. useOctreeForPicking: boolean;
  91291. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  91292. useOctreeForCollisions: boolean;
  91293. /**
  91294. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  91295. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  91296. */
  91297. layerMask: number;
  91298. /**
  91299. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  91300. */
  91301. alwaysSelectAsActiveMesh: boolean;
  91302. /**
  91303. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  91304. */
  91305. doNotSyncBoundingInfo: boolean;
  91306. /**
  91307. * Gets or sets the current action manager
  91308. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  91309. */
  91310. actionManager: Nullable<AbstractActionManager>;
  91311. private _meshCollisionData;
  91312. /**
  91313. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  91314. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  91315. */
  91316. ellipsoid: Vector3;
  91317. /**
  91318. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  91319. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  91320. */
  91321. ellipsoidOffset: Vector3;
  91322. /**
  91323. * Gets or sets a collision mask used to mask collisions (default is -1).
  91324. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  91325. */
  91326. collisionMask: number;
  91327. /**
  91328. * Gets or sets the current collision group mask (-1 by default).
  91329. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  91330. */
  91331. collisionGroup: number;
  91332. /**
  91333. * Defines edge width used when edgesRenderer is enabled
  91334. * @see https://www.babylonjs-playground.com/#10OJSG#13
  91335. */
  91336. edgesWidth: number;
  91337. /**
  91338. * Defines edge color used when edgesRenderer is enabled
  91339. * @see https://www.babylonjs-playground.com/#10OJSG#13
  91340. */
  91341. edgesColor: Color4;
  91342. /** @hidden */
  91343. _edgesRenderer: Nullable<IEdgesRenderer>;
  91344. /** @hidden */
  91345. _masterMesh: Nullable<AbstractMesh>;
  91346. /** @hidden */
  91347. _boundingInfo: Nullable<BoundingInfo>;
  91348. /** @hidden */
  91349. _renderId: number;
  91350. /**
  91351. * Gets or sets the list of subMeshes
  91352. * @see http://doc.babylonjs.com/how_to/multi_materials
  91353. */
  91354. subMeshes: SubMesh[];
  91355. /** @hidden */
  91356. _intersectionsInProgress: AbstractMesh[];
  91357. /** @hidden */
  91358. _unIndexed: boolean;
  91359. /** @hidden */
  91360. _lightSources: Light[];
  91361. /** Gets the list of lights affecting that mesh */
  91362. readonly lightSources: Light[];
  91363. /** @hidden */
  91364. readonly _positions: Nullable<Vector3[]>;
  91365. /** @hidden */
  91366. _waitingData: {
  91367. lods: Nullable<any>;
  91368. actions: Nullable<any>;
  91369. freezeWorldMatrix: Nullable<boolean>;
  91370. };
  91371. /** @hidden */
  91372. _bonesTransformMatrices: Nullable<Float32Array>;
  91373. /** @hidden */
  91374. _transformMatrixTexture: Nullable<RawTexture>;
  91375. /**
  91376. * Gets or sets a skeleton to apply skining transformations
  91377. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  91378. */
  91379. skeleton: Nullable<Skeleton>;
  91380. /**
  91381. * An event triggered when the mesh is rebuilt.
  91382. */
  91383. onRebuildObservable: Observable<AbstractMesh>;
  91384. /**
  91385. * Creates a new AbstractMesh
  91386. * @param name defines the name of the mesh
  91387. * @param scene defines the hosting scene
  91388. */
  91389. constructor(name: string, scene?: Nullable<Scene>);
  91390. /**
  91391. * Returns the string "AbstractMesh"
  91392. * @returns "AbstractMesh"
  91393. */
  91394. getClassName(): string;
  91395. /**
  91396. * Gets a string representation of the current mesh
  91397. * @param fullDetails defines a boolean indicating if full details must be included
  91398. * @returns a string representation of the current mesh
  91399. */
  91400. toString(fullDetails?: boolean): string;
  91401. /**
  91402. * @hidden
  91403. */
  91404. protected _getEffectiveParent(): Nullable<Node>;
  91405. /** @hidden */
  91406. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  91407. /** @hidden */
  91408. _rebuild(): void;
  91409. /** @hidden */
  91410. _resyncLightSources(): void;
  91411. /** @hidden */
  91412. _resyncLighSource(light: Light): void;
  91413. /** @hidden */
  91414. _unBindEffect(): void;
  91415. /** @hidden */
  91416. _removeLightSource(light: Light, dispose: boolean): void;
  91417. private _markSubMeshesAsDirty;
  91418. /** @hidden */
  91419. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  91420. /** @hidden */
  91421. _markSubMeshesAsAttributesDirty(): void;
  91422. /** @hidden */
  91423. _markSubMeshesAsMiscDirty(): void;
  91424. /**
  91425. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  91426. */
  91427. scaling: Vector3;
  91428. /**
  91429. * Returns true if the mesh is blocked. Implemented by child classes
  91430. */
  91431. readonly isBlocked: boolean;
  91432. /**
  91433. * Returns the mesh itself by default. Implemented by child classes
  91434. * @param camera defines the camera to use to pick the right LOD level
  91435. * @returns the currentAbstractMesh
  91436. */
  91437. getLOD(camera: Camera): Nullable<AbstractMesh>;
  91438. /**
  91439. * Returns 0 by default. Implemented by child classes
  91440. * @returns an integer
  91441. */
  91442. getTotalVertices(): number;
  91443. /**
  91444. * Returns a positive integer : the total number of indices in this mesh geometry.
  91445. * @returns the numner of indices or zero if the mesh has no geometry.
  91446. */
  91447. getTotalIndices(): number;
  91448. /**
  91449. * Returns null by default. Implemented by child classes
  91450. * @returns null
  91451. */
  91452. getIndices(): Nullable<IndicesArray>;
  91453. /**
  91454. * Returns the array of the requested vertex data kind. Implemented by child classes
  91455. * @param kind defines the vertex data kind to use
  91456. * @returns null
  91457. */
  91458. getVerticesData(kind: string): Nullable<FloatArray>;
  91459. /**
  91460. * Sets the vertex data of the mesh geometry for the requested `kind`.
  91461. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  91462. * Note that a new underlying VertexBuffer object is created each call.
  91463. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  91464. * @param kind defines vertex data kind:
  91465. * * VertexBuffer.PositionKind
  91466. * * VertexBuffer.UVKind
  91467. * * VertexBuffer.UV2Kind
  91468. * * VertexBuffer.UV3Kind
  91469. * * VertexBuffer.UV4Kind
  91470. * * VertexBuffer.UV5Kind
  91471. * * VertexBuffer.UV6Kind
  91472. * * VertexBuffer.ColorKind
  91473. * * VertexBuffer.MatricesIndicesKind
  91474. * * VertexBuffer.MatricesIndicesExtraKind
  91475. * * VertexBuffer.MatricesWeightsKind
  91476. * * VertexBuffer.MatricesWeightsExtraKind
  91477. * @param data defines the data source
  91478. * @param updatable defines if the data must be flagged as updatable (or static)
  91479. * @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
  91480. * @returns the current mesh
  91481. */
  91482. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  91483. /**
  91484. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  91485. * If the mesh has no geometry, it is simply returned as it is.
  91486. * @param kind defines vertex data kind:
  91487. * * VertexBuffer.PositionKind
  91488. * * VertexBuffer.UVKind
  91489. * * VertexBuffer.UV2Kind
  91490. * * VertexBuffer.UV3Kind
  91491. * * VertexBuffer.UV4Kind
  91492. * * VertexBuffer.UV5Kind
  91493. * * VertexBuffer.UV6Kind
  91494. * * VertexBuffer.ColorKind
  91495. * * VertexBuffer.MatricesIndicesKind
  91496. * * VertexBuffer.MatricesIndicesExtraKind
  91497. * * VertexBuffer.MatricesWeightsKind
  91498. * * VertexBuffer.MatricesWeightsExtraKind
  91499. * @param data defines the data source
  91500. * @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
  91501. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  91502. * @returns the current mesh
  91503. */
  91504. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  91505. /**
  91506. * Sets the mesh indices,
  91507. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  91508. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  91509. * @param totalVertices Defines the total number of vertices
  91510. * @returns the current mesh
  91511. */
  91512. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  91513. /**
  91514. * Gets a boolean indicating if specific vertex data is present
  91515. * @param kind defines the vertex data kind to use
  91516. * @returns true is data kind is present
  91517. */
  91518. isVerticesDataPresent(kind: string): boolean;
  91519. /**
  91520. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  91521. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  91522. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  91523. * @returns a BoundingInfo
  91524. */
  91525. getBoundingInfo(): BoundingInfo;
  91526. /**
  91527. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  91528. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  91529. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  91530. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  91531. * @returns the current mesh
  91532. */
  91533. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  91534. /**
  91535. * Overwrite the current bounding info
  91536. * @param boundingInfo defines the new bounding info
  91537. * @returns the current mesh
  91538. */
  91539. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  91540. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  91541. readonly useBones: boolean;
  91542. /** @hidden */
  91543. _preActivate(): void;
  91544. /** @hidden */
  91545. _preActivateForIntermediateRendering(renderId: number): void;
  91546. /** @hidden */
  91547. _activate(renderId: number, intermediateRendering: boolean): boolean;
  91548. /** @hidden */
  91549. _postActivate(): void;
  91550. /** @hidden */
  91551. _freeze(): void;
  91552. /** @hidden */
  91553. _unFreeze(): void;
  91554. /**
  91555. * Gets the current world matrix
  91556. * @returns a Matrix
  91557. */
  91558. getWorldMatrix(): Matrix;
  91559. /** @hidden */
  91560. _getWorldMatrixDeterminant(): number;
  91561. /**
  91562. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  91563. */
  91564. readonly isAnInstance: boolean;
  91565. /**
  91566. * Gets a boolean indicating if this mesh has instances
  91567. */
  91568. readonly hasInstances: boolean;
  91569. /**
  91570. * Perform relative position change from the point of view of behind the front of the mesh.
  91571. * This is performed taking into account the meshes current rotation, so you do not have to care.
  91572. * Supports definition of mesh facing forward or backward
  91573. * @param amountRight defines the distance on the right axis
  91574. * @param amountUp defines the distance on the up axis
  91575. * @param amountForward defines the distance on the forward axis
  91576. * @returns the current mesh
  91577. */
  91578. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  91579. /**
  91580. * Calculate relative position change from the point of view of behind the front of the mesh.
  91581. * This is performed taking into account the meshes current rotation, so you do not have to care.
  91582. * Supports definition of mesh facing forward or backward
  91583. * @param amountRight defines the distance on the right axis
  91584. * @param amountUp defines the distance on the up axis
  91585. * @param amountForward defines the distance on the forward axis
  91586. * @returns the new displacement vector
  91587. */
  91588. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  91589. /**
  91590. * Perform relative rotation change from the point of view of behind the front of the mesh.
  91591. * Supports definition of mesh facing forward or backward
  91592. * @param flipBack defines the flip
  91593. * @param twirlClockwise defines the twirl
  91594. * @param tiltRight defines the tilt
  91595. * @returns the current mesh
  91596. */
  91597. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  91598. /**
  91599. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  91600. * Supports definition of mesh facing forward or backward.
  91601. * @param flipBack defines the flip
  91602. * @param twirlClockwise defines the twirl
  91603. * @param tiltRight defines the tilt
  91604. * @returns the new rotation vector
  91605. */
  91606. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  91607. /**
  91608. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  91609. * This means the mesh underlying bounding box and sphere are recomputed.
  91610. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  91611. * @returns the current mesh
  91612. */
  91613. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  91614. /** @hidden */
  91615. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  91616. /** @hidden */
  91617. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  91618. /** @hidden */
  91619. _updateBoundingInfo(): AbstractMesh;
  91620. /** @hidden */
  91621. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  91622. /** @hidden */
  91623. protected _afterComputeWorldMatrix(): void;
  91624. /** @hidden */
  91625. readonly _effectiveMesh: AbstractMesh;
  91626. /**
  91627. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  91628. * A mesh is in the frustum if its bounding box intersects the frustum
  91629. * @param frustumPlanes defines the frustum to test
  91630. * @returns true if the mesh is in the frustum planes
  91631. */
  91632. isInFrustum(frustumPlanes: Plane[]): boolean;
  91633. /**
  91634. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  91635. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  91636. * @param frustumPlanes defines the frustum to test
  91637. * @returns true if the mesh is completely in the frustum planes
  91638. */
  91639. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  91640. /**
  91641. * True if the mesh intersects another mesh or a SolidParticle object
  91642. * @param mesh defines a target mesh or SolidParticle to test
  91643. * @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)
  91644. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  91645. * @returns true if there is an intersection
  91646. */
  91647. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  91648. /**
  91649. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  91650. * @param point defines the point to test
  91651. * @returns true if there is an intersection
  91652. */
  91653. intersectsPoint(point: Vector3): boolean;
  91654. /**
  91655. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  91656. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  91657. */
  91658. checkCollisions: boolean;
  91659. /**
  91660. * Gets Collider object used to compute collisions (not physics)
  91661. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  91662. */
  91663. readonly collider: Nullable<Collider>;
  91664. /**
  91665. * Move the mesh using collision engine
  91666. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  91667. * @param displacement defines the requested displacement vector
  91668. * @returns the current mesh
  91669. */
  91670. moveWithCollisions(displacement: Vector3): AbstractMesh;
  91671. private _onCollisionPositionChange;
  91672. /** @hidden */
  91673. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  91674. /** @hidden */
  91675. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  91676. /** @hidden */
  91677. _checkCollision(collider: Collider): AbstractMesh;
  91678. /** @hidden */
  91679. _generatePointsArray(): boolean;
  91680. /**
  91681. * Checks if the passed Ray intersects with the mesh
  91682. * @param ray defines the ray to use
  91683. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  91684. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  91685. * @returns the picking info
  91686. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  91687. */
  91688. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): PickingInfo;
  91689. /**
  91690. * Clones the current mesh
  91691. * @param name defines the mesh name
  91692. * @param newParent defines the new mesh parent
  91693. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  91694. * @returns the new mesh
  91695. */
  91696. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  91697. /**
  91698. * Disposes all the submeshes of the current meshnp
  91699. * @returns the current mesh
  91700. */
  91701. releaseSubMeshes(): AbstractMesh;
  91702. /**
  91703. * Releases resources associated with this abstract mesh.
  91704. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  91705. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  91706. */
  91707. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  91708. /**
  91709. * Adds the passed mesh as a child to the current mesh
  91710. * @param mesh defines the child mesh
  91711. * @returns the current mesh
  91712. */
  91713. addChild(mesh: AbstractMesh): AbstractMesh;
  91714. /**
  91715. * Removes the passed mesh from the current mesh children list
  91716. * @param mesh defines the child mesh
  91717. * @returns the current mesh
  91718. */
  91719. removeChild(mesh: AbstractMesh): AbstractMesh;
  91720. /** @hidden */
  91721. private _initFacetData;
  91722. /**
  91723. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  91724. * This method can be called within the render loop.
  91725. * 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
  91726. * @returns the current mesh
  91727. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  91728. */
  91729. updateFacetData(): AbstractMesh;
  91730. /**
  91731. * Returns the facetLocalNormals array.
  91732. * The normals are expressed in the mesh local spac
  91733. * @returns an array of Vector3
  91734. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  91735. */
  91736. getFacetLocalNormals(): Vector3[];
  91737. /**
  91738. * Returns the facetLocalPositions array.
  91739. * The facet positions are expressed in the mesh local space
  91740. * @returns an array of Vector3
  91741. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  91742. */
  91743. getFacetLocalPositions(): Vector3[];
  91744. /**
  91745. * Returns the facetLocalPartioning array
  91746. * @returns an array of array of numbers
  91747. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  91748. */
  91749. getFacetLocalPartitioning(): number[][];
  91750. /**
  91751. * Returns the i-th facet position in the world system.
  91752. * This method allocates a new Vector3 per call
  91753. * @param i defines the facet index
  91754. * @returns a new Vector3
  91755. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  91756. */
  91757. getFacetPosition(i: number): Vector3;
  91758. /**
  91759. * Sets the reference Vector3 with the i-th facet position in the world system
  91760. * @param i defines the facet index
  91761. * @param ref defines the target vector
  91762. * @returns the current mesh
  91763. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  91764. */
  91765. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  91766. /**
  91767. * Returns the i-th facet normal in the world system.
  91768. * This method allocates a new Vector3 per call
  91769. * @param i defines the facet index
  91770. * @returns a new Vector3
  91771. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  91772. */
  91773. getFacetNormal(i: number): Vector3;
  91774. /**
  91775. * Sets the reference Vector3 with the i-th facet normal in the world system
  91776. * @param i defines the facet index
  91777. * @param ref defines the target vector
  91778. * @returns the current mesh
  91779. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  91780. */
  91781. getFacetNormalToRef(i: number, ref: Vector3): this;
  91782. /**
  91783. * 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)
  91784. * @param x defines x coordinate
  91785. * @param y defines y coordinate
  91786. * @param z defines z coordinate
  91787. * @returns the array of facet indexes
  91788. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  91789. */
  91790. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  91791. /**
  91792. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  91793. * @param projected sets as the (x,y,z) world projection on the facet
  91794. * @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
  91795. * @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
  91796. * @param x defines x coordinate
  91797. * @param y defines y coordinate
  91798. * @param z defines z coordinate
  91799. * @returns the face index if found (or null instead)
  91800. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  91801. */
  91802. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  91803. /**
  91804. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  91805. * @param projected sets as the (x,y,z) local projection on the facet
  91806. * @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
  91807. * @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
  91808. * @param x defines x coordinate
  91809. * @param y defines y coordinate
  91810. * @param z defines z coordinate
  91811. * @returns the face index if found (or null instead)
  91812. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  91813. */
  91814. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  91815. /**
  91816. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  91817. * @returns the parameters
  91818. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  91819. */
  91820. getFacetDataParameters(): any;
  91821. /**
  91822. * Disables the feature FacetData and frees the related memory
  91823. * @returns the current mesh
  91824. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  91825. */
  91826. disableFacetData(): AbstractMesh;
  91827. /**
  91828. * Updates the AbstractMesh indices array
  91829. * @param indices defines the data source
  91830. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  91831. * @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)
  91832. * @returns the current mesh
  91833. */
  91834. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  91835. /**
  91836. * Creates new normals data for the mesh
  91837. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  91838. * @returns the current mesh
  91839. */
  91840. createNormals(updatable: boolean): AbstractMesh;
  91841. /**
  91842. * Align the mesh with a normal
  91843. * @param normal defines the normal to use
  91844. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  91845. * @returns the current mesh
  91846. */
  91847. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  91848. /** @hidden */
  91849. _checkOcclusionQuery(): boolean;
  91850. /**
  91851. * Disables the mesh edge rendering mode
  91852. * @returns the currentAbstractMesh
  91853. */
  91854. disableEdgesRendering(): AbstractMesh;
  91855. /**
  91856. * Enables the edge rendering mode on the mesh.
  91857. * This mode makes the mesh edges visible
  91858. * @param epsilon defines the maximal distance between two angles to detect a face
  91859. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  91860. * @returns the currentAbstractMesh
  91861. * @see https://www.babylonjs-playground.com/#19O9TU#0
  91862. */
  91863. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  91864. }
  91865. }
  91866. declare module BABYLON {
  91867. /**
  91868. * Interface used to define ActionEvent
  91869. */
  91870. export interface IActionEvent {
  91871. /** The mesh or sprite that triggered the action */
  91872. source: any;
  91873. /** The X mouse cursor position at the time of the event */
  91874. pointerX: number;
  91875. /** The Y mouse cursor position at the time of the event */
  91876. pointerY: number;
  91877. /** The mesh that is currently pointed at (can be null) */
  91878. meshUnderPointer: Nullable<AbstractMesh>;
  91879. /** the original (browser) event that triggered the ActionEvent */
  91880. sourceEvent?: any;
  91881. /** additional data for the event */
  91882. additionalData?: any;
  91883. }
  91884. /**
  91885. * ActionEvent is the event being sent when an action is triggered.
  91886. */
  91887. export class ActionEvent implements IActionEvent {
  91888. /** The mesh or sprite that triggered the action */
  91889. source: any;
  91890. /** The X mouse cursor position at the time of the event */
  91891. pointerX: number;
  91892. /** The Y mouse cursor position at the time of the event */
  91893. pointerY: number;
  91894. /** The mesh that is currently pointed at (can be null) */
  91895. meshUnderPointer: Nullable<AbstractMesh>;
  91896. /** the original (browser) event that triggered the ActionEvent */
  91897. sourceEvent?: any;
  91898. /** additional data for the event */
  91899. additionalData?: any;
  91900. /**
  91901. * Creates a new ActionEvent
  91902. * @param source The mesh or sprite that triggered the action
  91903. * @param pointerX The X mouse cursor position at the time of the event
  91904. * @param pointerY The Y mouse cursor position at the time of the event
  91905. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  91906. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  91907. * @param additionalData additional data for the event
  91908. */
  91909. constructor(
  91910. /** The mesh or sprite that triggered the action */
  91911. source: any,
  91912. /** The X mouse cursor position at the time of the event */
  91913. pointerX: number,
  91914. /** The Y mouse cursor position at the time of the event */
  91915. pointerY: number,
  91916. /** The mesh that is currently pointed at (can be null) */
  91917. meshUnderPointer: Nullable<AbstractMesh>,
  91918. /** the original (browser) event that triggered the ActionEvent */
  91919. sourceEvent?: any,
  91920. /** additional data for the event */
  91921. additionalData?: any);
  91922. /**
  91923. * Helper function to auto-create an ActionEvent from a source mesh.
  91924. * @param source The source mesh that triggered the event
  91925. * @param evt The original (browser) event
  91926. * @param additionalData additional data for the event
  91927. * @returns the new ActionEvent
  91928. */
  91929. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  91930. /**
  91931. * Helper function to auto-create an ActionEvent from a source sprite
  91932. * @param source The source sprite that triggered the event
  91933. * @param scene Scene associated with the sprite
  91934. * @param evt The original (browser) event
  91935. * @param additionalData additional data for the event
  91936. * @returns the new ActionEvent
  91937. */
  91938. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  91939. /**
  91940. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  91941. * @param scene the scene where the event occurred
  91942. * @param evt The original (browser) event
  91943. * @returns the new ActionEvent
  91944. */
  91945. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  91946. /**
  91947. * Helper function to auto-create an ActionEvent from a primitive
  91948. * @param prim defines the target primitive
  91949. * @param pointerPos defines the pointer position
  91950. * @param evt The original (browser) event
  91951. * @param additionalData additional data for the event
  91952. * @returns the new ActionEvent
  91953. */
  91954. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  91955. }
  91956. }
  91957. declare module BABYLON {
  91958. /**
  91959. * Abstract class used to decouple action Manager from scene and meshes.
  91960. * Do not instantiate.
  91961. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  91962. */
  91963. export abstract class AbstractActionManager implements IDisposable {
  91964. /** Gets the list of active triggers */
  91965. static Triggers: {
  91966. [key: string]: number;
  91967. };
  91968. /** Gets the cursor to use when hovering items */
  91969. hoverCursor: string;
  91970. /** Gets the list of actions */
  91971. actions: IAction[];
  91972. /**
  91973. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  91974. */
  91975. isRecursive: boolean;
  91976. /**
  91977. * Releases all associated resources
  91978. */
  91979. abstract dispose(): void;
  91980. /**
  91981. * Does this action manager has pointer triggers
  91982. */
  91983. abstract readonly hasPointerTriggers: boolean;
  91984. /**
  91985. * Does this action manager has pick triggers
  91986. */
  91987. abstract readonly hasPickTriggers: boolean;
  91988. /**
  91989. * Process a specific trigger
  91990. * @param trigger defines the trigger to process
  91991. * @param evt defines the event details to be processed
  91992. */
  91993. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  91994. /**
  91995. * Does this action manager handles actions of any of the given triggers
  91996. * @param triggers defines the triggers to be tested
  91997. * @return a boolean indicating whether one (or more) of the triggers is handled
  91998. */
  91999. abstract hasSpecificTriggers(triggers: number[]): boolean;
  92000. /**
  92001. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  92002. * speed.
  92003. * @param triggerA defines the trigger to be tested
  92004. * @param triggerB defines the trigger to be tested
  92005. * @return a boolean indicating whether one (or more) of the triggers is handled
  92006. */
  92007. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  92008. /**
  92009. * Does this action manager handles actions of a given trigger
  92010. * @param trigger defines the trigger to be tested
  92011. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  92012. * @return whether the trigger is handled
  92013. */
  92014. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  92015. /**
  92016. * Serialize this manager to a JSON object
  92017. * @param name defines the property name to store this manager
  92018. * @returns a JSON representation of this manager
  92019. */
  92020. abstract serialize(name: string): any;
  92021. /**
  92022. * Registers an action to this action manager
  92023. * @param action defines the action to be registered
  92024. * @return the action amended (prepared) after registration
  92025. */
  92026. abstract registerAction(action: IAction): Nullable<IAction>;
  92027. /**
  92028. * Unregisters an action to this action manager
  92029. * @param action defines the action to be unregistered
  92030. * @return a boolean indicating whether the action has been unregistered
  92031. */
  92032. abstract unregisterAction(action: IAction): Boolean;
  92033. /**
  92034. * Does exist one action manager with at least one trigger
  92035. **/
  92036. static readonly HasTriggers: boolean;
  92037. /**
  92038. * Does exist one action manager with at least one pick trigger
  92039. **/
  92040. static readonly HasPickTriggers: boolean;
  92041. /**
  92042. * Does exist one action manager that handles actions of a given trigger
  92043. * @param trigger defines the trigger to be tested
  92044. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  92045. **/
  92046. static HasSpecificTrigger(trigger: number): boolean;
  92047. }
  92048. }
  92049. declare module BABYLON {
  92050. /**
  92051. * Defines how a node can be built from a string name.
  92052. */
  92053. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  92054. /**
  92055. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  92056. */
  92057. export class Node implements IBehaviorAware<Node> {
  92058. /** @hidden */
  92059. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  92060. private static _NodeConstructors;
  92061. /**
  92062. * Add a new node constructor
  92063. * @param type defines the type name of the node to construct
  92064. * @param constructorFunc defines the constructor function
  92065. */
  92066. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  92067. /**
  92068. * Returns a node constructor based on type name
  92069. * @param type defines the type name
  92070. * @param name defines the new node name
  92071. * @param scene defines the hosting scene
  92072. * @param options defines optional options to transmit to constructors
  92073. * @returns the new constructor or null
  92074. */
  92075. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  92076. /**
  92077. * Gets or sets the name of the node
  92078. */
  92079. name: string;
  92080. /**
  92081. * Gets or sets the id of the node
  92082. */
  92083. id: string;
  92084. /**
  92085. * Gets or sets the unique id of the node
  92086. */
  92087. uniqueId: number;
  92088. /**
  92089. * Gets or sets a string used to store user defined state for the node
  92090. */
  92091. state: string;
  92092. /**
  92093. * Gets or sets an object used to store user defined information for the node
  92094. */
  92095. metadata: any;
  92096. /**
  92097. * For internal use only. Please do not use.
  92098. */
  92099. reservedDataStore: any;
  92100. /**
  92101. * List of inspectable custom properties (used by the Inspector)
  92102. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  92103. */
  92104. inspectableCustomProperties: IInspectable[];
  92105. /**
  92106. * Gets or sets a boolean used to define if the node must be serialized
  92107. */
  92108. doNotSerialize: boolean;
  92109. /** @hidden */
  92110. _isDisposed: boolean;
  92111. /**
  92112. * Gets a list of Animations associated with the node
  92113. */
  92114. animations: Animation[];
  92115. protected _ranges: {
  92116. [name: string]: Nullable<AnimationRange>;
  92117. };
  92118. /**
  92119. * Callback raised when the node is ready to be used
  92120. */
  92121. onReady: Nullable<(node: Node) => void>;
  92122. private _isEnabled;
  92123. private _isParentEnabled;
  92124. private _isReady;
  92125. /** @hidden */
  92126. _currentRenderId: number;
  92127. private _parentUpdateId;
  92128. /** @hidden */
  92129. _childUpdateId: number;
  92130. /** @hidden */
  92131. _waitingParentId: Nullable<string>;
  92132. /** @hidden */
  92133. _scene: Scene;
  92134. /** @hidden */
  92135. _cache: any;
  92136. private _parentNode;
  92137. private _children;
  92138. /** @hidden */
  92139. _worldMatrix: Matrix;
  92140. /** @hidden */
  92141. _worldMatrixDeterminant: number;
  92142. /** @hidden */
  92143. _worldMatrixDeterminantIsDirty: boolean;
  92144. /** @hidden */
  92145. private _sceneRootNodesIndex;
  92146. /**
  92147. * Gets a boolean indicating if the node has been disposed
  92148. * @returns true if the node was disposed
  92149. */
  92150. isDisposed(): boolean;
  92151. /**
  92152. * Gets or sets the parent of the node (without keeping the current position in the scene)
  92153. * @see https://doc.babylonjs.com/how_to/parenting
  92154. */
  92155. parent: Nullable<Node>;
  92156. private addToSceneRootNodes;
  92157. private removeFromSceneRootNodes;
  92158. private _animationPropertiesOverride;
  92159. /**
  92160. * Gets or sets the animation properties override
  92161. */
  92162. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  92163. /**
  92164. * Gets a string idenfifying the name of the class
  92165. * @returns "Node" string
  92166. */
  92167. getClassName(): string;
  92168. /** @hidden */
  92169. readonly _isNode: boolean;
  92170. /**
  92171. * An event triggered when the mesh is disposed
  92172. */
  92173. onDisposeObservable: Observable<Node>;
  92174. private _onDisposeObserver;
  92175. /**
  92176. * Sets a callback that will be raised when the node will be disposed
  92177. */
  92178. onDispose: () => void;
  92179. /**
  92180. * Creates a new Node
  92181. * @param name the name and id to be given to this node
  92182. * @param scene the scene this node will be added to
  92183. * @param addToRootNodes the node will be added to scene.rootNodes
  92184. */
  92185. constructor(name: string, scene?: Nullable<Scene>, addToRootNodes?: boolean);
  92186. /**
  92187. * Gets the scene of the node
  92188. * @returns a scene
  92189. */
  92190. getScene(): Scene;
  92191. /**
  92192. * Gets the engine of the node
  92193. * @returns a Engine
  92194. */
  92195. getEngine(): Engine;
  92196. private _behaviors;
  92197. /**
  92198. * Attach a behavior to the node
  92199. * @see http://doc.babylonjs.com/features/behaviour
  92200. * @param behavior defines the behavior to attach
  92201. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  92202. * @returns the current Node
  92203. */
  92204. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  92205. /**
  92206. * Remove an attached behavior
  92207. * @see http://doc.babylonjs.com/features/behaviour
  92208. * @param behavior defines the behavior to attach
  92209. * @returns the current Node
  92210. */
  92211. removeBehavior(behavior: Behavior<Node>): Node;
  92212. /**
  92213. * Gets the list of attached behaviors
  92214. * @see http://doc.babylonjs.com/features/behaviour
  92215. */
  92216. readonly behaviors: Behavior<Node>[];
  92217. /**
  92218. * Gets an attached behavior by name
  92219. * @param name defines the name of the behavior to look for
  92220. * @see http://doc.babylonjs.com/features/behaviour
  92221. * @returns null if behavior was not found else the requested behavior
  92222. */
  92223. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  92224. /**
  92225. * Returns the latest update of the World matrix
  92226. * @returns a Matrix
  92227. */
  92228. getWorldMatrix(): Matrix;
  92229. /** @hidden */
  92230. _getWorldMatrixDeterminant(): number;
  92231. /**
  92232. * Returns directly the latest state of the mesh World matrix.
  92233. * A Matrix is returned.
  92234. */
  92235. readonly worldMatrixFromCache: Matrix;
  92236. /** @hidden */
  92237. _initCache(): void;
  92238. /** @hidden */
  92239. updateCache(force?: boolean): void;
  92240. /** @hidden */
  92241. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  92242. /** @hidden */
  92243. _updateCache(ignoreParentClass?: boolean): void;
  92244. /** @hidden */
  92245. _isSynchronized(): boolean;
  92246. /** @hidden */
  92247. _markSyncedWithParent(): void;
  92248. /** @hidden */
  92249. isSynchronizedWithParent(): boolean;
  92250. /** @hidden */
  92251. isSynchronized(): boolean;
  92252. /**
  92253. * Is this node ready to be used/rendered
  92254. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  92255. * @return true if the node is ready
  92256. */
  92257. isReady(completeCheck?: boolean): boolean;
  92258. /**
  92259. * Is this node enabled?
  92260. * 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
  92261. * @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
  92262. * @return whether this node (and its parent) is enabled
  92263. */
  92264. isEnabled(checkAncestors?: boolean): boolean;
  92265. /** @hidden */
  92266. protected _syncParentEnabledState(): void;
  92267. /**
  92268. * Set the enabled state of this node
  92269. * @param value defines the new enabled state
  92270. */
  92271. setEnabled(value: boolean): void;
  92272. /**
  92273. * Is this node a descendant of the given node?
  92274. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  92275. * @param ancestor defines the parent node to inspect
  92276. * @returns a boolean indicating if this node is a descendant of the given node
  92277. */
  92278. isDescendantOf(ancestor: Node): boolean;
  92279. /** @hidden */
  92280. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  92281. /**
  92282. * Will return all nodes that have this node as ascendant
  92283. * @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
  92284. * @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
  92285. * @return all children nodes of all types
  92286. */
  92287. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  92288. /**
  92289. * Get all child-meshes of this node
  92290. * @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)
  92291. * @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
  92292. * @returns an array of AbstractMesh
  92293. */
  92294. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  92295. /**
  92296. * Get all direct children of this node
  92297. * @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
  92298. * @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)
  92299. * @returns an array of Node
  92300. */
  92301. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  92302. /** @hidden */
  92303. _setReady(state: boolean): void;
  92304. /**
  92305. * Get an animation by name
  92306. * @param name defines the name of the animation to look for
  92307. * @returns null if not found else the requested animation
  92308. */
  92309. getAnimationByName(name: string): Nullable<Animation>;
  92310. /**
  92311. * Creates an animation range for this node
  92312. * @param name defines the name of the range
  92313. * @param from defines the starting key
  92314. * @param to defines the end key
  92315. */
  92316. createAnimationRange(name: string, from: number, to: number): void;
  92317. /**
  92318. * Delete a specific animation range
  92319. * @param name defines the name of the range to delete
  92320. * @param deleteFrames defines if animation frames from the range must be deleted as well
  92321. */
  92322. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  92323. /**
  92324. * Get an animation range by name
  92325. * @param name defines the name of the animation range to look for
  92326. * @returns null if not found else the requested animation range
  92327. */
  92328. getAnimationRange(name: string): Nullable<AnimationRange>;
  92329. /**
  92330. * Gets the list of all animation ranges defined on this node
  92331. * @returns an array
  92332. */
  92333. getAnimationRanges(): Nullable<AnimationRange>[];
  92334. /**
  92335. * Will start the animation sequence
  92336. * @param name defines the range frames for animation sequence
  92337. * @param loop defines if the animation should loop (false by default)
  92338. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  92339. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  92340. * @returns the object created for this animation. If range does not exist, it will return null
  92341. */
  92342. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  92343. /**
  92344. * Serialize animation ranges into a JSON compatible object
  92345. * @returns serialization object
  92346. */
  92347. serializeAnimationRanges(): any;
  92348. /**
  92349. * Computes the world matrix of the node
  92350. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  92351. * @returns the world matrix
  92352. */
  92353. computeWorldMatrix(force?: boolean): Matrix;
  92354. /**
  92355. * Releases resources associated with this node.
  92356. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  92357. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  92358. */
  92359. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  92360. /**
  92361. * Parse animation range data from a serialization object and store them into a given node
  92362. * @param node defines where to store the animation ranges
  92363. * @param parsedNode defines the serialization object to read data from
  92364. * @param scene defines the hosting scene
  92365. */
  92366. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  92367. /**
  92368. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  92369. * @param includeDescendants Include bounding info from descendants as well (true by default)
  92370. * @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
  92371. * @returns the new bounding vectors
  92372. */
  92373. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  92374. min: Vector3;
  92375. max: Vector3;
  92376. };
  92377. }
  92378. }
  92379. declare module BABYLON {
  92380. /**
  92381. * @hidden
  92382. */
  92383. export class _IAnimationState {
  92384. key: number;
  92385. repeatCount: number;
  92386. workValue?: any;
  92387. loopMode?: number;
  92388. offsetValue?: any;
  92389. highLimitValue?: any;
  92390. }
  92391. /**
  92392. * Class used to store any kind of animation
  92393. */
  92394. export class Animation {
  92395. /**Name of the animation */
  92396. name: string;
  92397. /**Property to animate */
  92398. targetProperty: string;
  92399. /**The frames per second of the animation */
  92400. framePerSecond: number;
  92401. /**The data type of the animation */
  92402. dataType: number;
  92403. /**The loop mode of the animation */
  92404. loopMode?: number | undefined;
  92405. /**Specifies if blending should be enabled */
  92406. enableBlending?: boolean | undefined;
  92407. /**
  92408. * Use matrix interpolation instead of using direct key value when animating matrices
  92409. */
  92410. static AllowMatricesInterpolation: boolean;
  92411. /**
  92412. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  92413. */
  92414. static AllowMatrixDecomposeForInterpolation: boolean;
  92415. /**
  92416. * Stores the key frames of the animation
  92417. */
  92418. private _keys;
  92419. /**
  92420. * Stores the easing function of the animation
  92421. */
  92422. private _easingFunction;
  92423. /**
  92424. * @hidden Internal use only
  92425. */
  92426. _runtimeAnimations: RuntimeAnimation[];
  92427. /**
  92428. * The set of event that will be linked to this animation
  92429. */
  92430. private _events;
  92431. /**
  92432. * Stores an array of target property paths
  92433. */
  92434. targetPropertyPath: string[];
  92435. /**
  92436. * Stores the blending speed of the animation
  92437. */
  92438. blendingSpeed: number;
  92439. /**
  92440. * Stores the animation ranges for the animation
  92441. */
  92442. private _ranges;
  92443. /**
  92444. * @hidden Internal use
  92445. */
  92446. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  92447. /**
  92448. * Sets up an animation
  92449. * @param property The property to animate
  92450. * @param animationType The animation type to apply
  92451. * @param framePerSecond The frames per second of the animation
  92452. * @param easingFunction The easing function used in the animation
  92453. * @returns The created animation
  92454. */
  92455. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  92456. /**
  92457. * Create and start an animation on a node
  92458. * @param name defines the name of the global animation that will be run on all nodes
  92459. * @param node defines the root node where the animation will take place
  92460. * @param targetProperty defines property to animate
  92461. * @param framePerSecond defines the number of frame per second yo use
  92462. * @param totalFrame defines the number of frames in total
  92463. * @param from defines the initial value
  92464. * @param to defines the final value
  92465. * @param loopMode defines which loop mode you want to use (off by default)
  92466. * @param easingFunction defines the easing function to use (linear by default)
  92467. * @param onAnimationEnd defines the callback to call when animation end
  92468. * @returns the animatable created for this animation
  92469. */
  92470. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  92471. /**
  92472. * Create and start an animation on a node and its descendants
  92473. * @param name defines the name of the global animation that will be run on all nodes
  92474. * @param node defines the root node where the animation will take place
  92475. * @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
  92476. * @param targetProperty defines property to animate
  92477. * @param framePerSecond defines the number of frame per second to use
  92478. * @param totalFrame defines the number of frames in total
  92479. * @param from defines the initial value
  92480. * @param to defines the final value
  92481. * @param loopMode defines which loop mode you want to use (off by default)
  92482. * @param easingFunction defines the easing function to use (linear by default)
  92483. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  92484. * @returns the list of animatables created for all nodes
  92485. * @example https://www.babylonjs-playground.com/#MH0VLI
  92486. */
  92487. 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[]>;
  92488. /**
  92489. * Creates a new animation, merges it with the existing animations and starts it
  92490. * @param name Name of the animation
  92491. * @param node Node which contains the scene that begins the animations
  92492. * @param targetProperty Specifies which property to animate
  92493. * @param framePerSecond The frames per second of the animation
  92494. * @param totalFrame The total number of frames
  92495. * @param from The frame at the beginning of the animation
  92496. * @param to The frame at the end of the animation
  92497. * @param loopMode Specifies the loop mode of the animation
  92498. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  92499. * @param onAnimationEnd Callback to run once the animation is complete
  92500. * @returns Nullable animation
  92501. */
  92502. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  92503. /**
  92504. * Transition property of an host to the target Value
  92505. * @param property The property to transition
  92506. * @param targetValue The target Value of the property
  92507. * @param host The object where the property to animate belongs
  92508. * @param scene Scene used to run the animation
  92509. * @param frameRate Framerate (in frame/s) to use
  92510. * @param transition The transition type we want to use
  92511. * @param duration The duration of the animation, in milliseconds
  92512. * @param onAnimationEnd Callback trigger at the end of the animation
  92513. * @returns Nullable animation
  92514. */
  92515. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  92516. /**
  92517. * Return the array of runtime animations currently using this animation
  92518. */
  92519. readonly runtimeAnimations: RuntimeAnimation[];
  92520. /**
  92521. * Specifies if any of the runtime animations are currently running
  92522. */
  92523. readonly hasRunningRuntimeAnimations: boolean;
  92524. /**
  92525. * Initializes the animation
  92526. * @param name Name of the animation
  92527. * @param targetProperty Property to animate
  92528. * @param framePerSecond The frames per second of the animation
  92529. * @param dataType The data type of the animation
  92530. * @param loopMode The loop mode of the animation
  92531. * @param enableBlending Specifies if blending should be enabled
  92532. */
  92533. constructor(
  92534. /**Name of the animation */
  92535. name: string,
  92536. /**Property to animate */
  92537. targetProperty: string,
  92538. /**The frames per second of the animation */
  92539. framePerSecond: number,
  92540. /**The data type of the animation */
  92541. dataType: number,
  92542. /**The loop mode of the animation */
  92543. loopMode?: number | undefined,
  92544. /**Specifies if blending should be enabled */
  92545. enableBlending?: boolean | undefined);
  92546. /**
  92547. * Converts the animation to a string
  92548. * @param fullDetails support for multiple levels of logging within scene loading
  92549. * @returns String form of the animation
  92550. */
  92551. toString(fullDetails?: boolean): string;
  92552. /**
  92553. * Add an event to this animation
  92554. * @param event Event to add
  92555. */
  92556. addEvent(event: AnimationEvent): void;
  92557. /**
  92558. * Remove all events found at the given frame
  92559. * @param frame The frame to remove events from
  92560. */
  92561. removeEvents(frame: number): void;
  92562. /**
  92563. * Retrieves all the events from the animation
  92564. * @returns Events from the animation
  92565. */
  92566. getEvents(): AnimationEvent[];
  92567. /**
  92568. * Creates an animation range
  92569. * @param name Name of the animation range
  92570. * @param from Starting frame of the animation range
  92571. * @param to Ending frame of the animation
  92572. */
  92573. createRange(name: string, from: number, to: number): void;
  92574. /**
  92575. * Deletes an animation range by name
  92576. * @param name Name of the animation range to delete
  92577. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  92578. */
  92579. deleteRange(name: string, deleteFrames?: boolean): void;
  92580. /**
  92581. * Gets the animation range by name, or null if not defined
  92582. * @param name Name of the animation range
  92583. * @returns Nullable animation range
  92584. */
  92585. getRange(name: string): Nullable<AnimationRange>;
  92586. /**
  92587. * Gets the key frames from the animation
  92588. * @returns The key frames of the animation
  92589. */
  92590. getKeys(): Array<IAnimationKey>;
  92591. /**
  92592. * Gets the highest frame rate of the animation
  92593. * @returns Highest frame rate of the animation
  92594. */
  92595. getHighestFrame(): number;
  92596. /**
  92597. * Gets the easing function of the animation
  92598. * @returns Easing function of the animation
  92599. */
  92600. getEasingFunction(): IEasingFunction;
  92601. /**
  92602. * Sets the easing function of the animation
  92603. * @param easingFunction A custom mathematical formula for animation
  92604. */
  92605. setEasingFunction(easingFunction: EasingFunction): void;
  92606. /**
  92607. * Interpolates a scalar linearly
  92608. * @param startValue Start value of the animation curve
  92609. * @param endValue End value of the animation curve
  92610. * @param gradient Scalar amount to interpolate
  92611. * @returns Interpolated scalar value
  92612. */
  92613. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  92614. /**
  92615. * Interpolates a scalar cubically
  92616. * @param startValue Start value of the animation curve
  92617. * @param outTangent End tangent of the animation
  92618. * @param endValue End value of the animation curve
  92619. * @param inTangent Start tangent of the animation curve
  92620. * @param gradient Scalar amount to interpolate
  92621. * @returns Interpolated scalar value
  92622. */
  92623. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  92624. /**
  92625. * Interpolates a quaternion using a spherical linear interpolation
  92626. * @param startValue Start value of the animation curve
  92627. * @param endValue End value of the animation curve
  92628. * @param gradient Scalar amount to interpolate
  92629. * @returns Interpolated quaternion value
  92630. */
  92631. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  92632. /**
  92633. * Interpolates a quaternion cubically
  92634. * @param startValue Start value of the animation curve
  92635. * @param outTangent End tangent of the animation curve
  92636. * @param endValue End value of the animation curve
  92637. * @param inTangent Start tangent of the animation curve
  92638. * @param gradient Scalar amount to interpolate
  92639. * @returns Interpolated quaternion value
  92640. */
  92641. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  92642. /**
  92643. * Interpolates a Vector3 linearl
  92644. * @param startValue Start value of the animation curve
  92645. * @param endValue End value of the animation curve
  92646. * @param gradient Scalar amount to interpolate
  92647. * @returns Interpolated scalar value
  92648. */
  92649. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  92650. /**
  92651. * Interpolates a Vector3 cubically
  92652. * @param startValue Start value of the animation curve
  92653. * @param outTangent End tangent of the animation
  92654. * @param endValue End value of the animation curve
  92655. * @param inTangent Start tangent of the animation curve
  92656. * @param gradient Scalar amount to interpolate
  92657. * @returns InterpolatedVector3 value
  92658. */
  92659. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  92660. /**
  92661. * Interpolates a Vector2 linearly
  92662. * @param startValue Start value of the animation curve
  92663. * @param endValue End value of the animation curve
  92664. * @param gradient Scalar amount to interpolate
  92665. * @returns Interpolated Vector2 value
  92666. */
  92667. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  92668. /**
  92669. * Interpolates a Vector2 cubically
  92670. * @param startValue Start value of the animation curve
  92671. * @param outTangent End tangent of the animation
  92672. * @param endValue End value of the animation curve
  92673. * @param inTangent Start tangent of the animation curve
  92674. * @param gradient Scalar amount to interpolate
  92675. * @returns Interpolated Vector2 value
  92676. */
  92677. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  92678. /**
  92679. * Interpolates a size linearly
  92680. * @param startValue Start value of the animation curve
  92681. * @param endValue End value of the animation curve
  92682. * @param gradient Scalar amount to interpolate
  92683. * @returns Interpolated Size value
  92684. */
  92685. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  92686. /**
  92687. * Interpolates a Color3 linearly
  92688. * @param startValue Start value of the animation curve
  92689. * @param endValue End value of the animation curve
  92690. * @param gradient Scalar amount to interpolate
  92691. * @returns Interpolated Color3 value
  92692. */
  92693. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  92694. /**
  92695. * @hidden Internal use only
  92696. */
  92697. _getKeyValue(value: any): any;
  92698. /**
  92699. * @hidden Internal use only
  92700. */
  92701. _interpolate(currentFrame: number, state: _IAnimationState): any;
  92702. /**
  92703. * Defines the function to use to interpolate matrices
  92704. * @param startValue defines the start matrix
  92705. * @param endValue defines the end matrix
  92706. * @param gradient defines the gradient between both matrices
  92707. * @param result defines an optional target matrix where to store the interpolation
  92708. * @returns the interpolated matrix
  92709. */
  92710. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  92711. /**
  92712. * Makes a copy of the animation
  92713. * @returns Cloned animation
  92714. */
  92715. clone(): Animation;
  92716. /**
  92717. * Sets the key frames of the animation
  92718. * @param values The animation key frames to set
  92719. */
  92720. setKeys(values: Array<IAnimationKey>): void;
  92721. /**
  92722. * Serializes the animation to an object
  92723. * @returns Serialized object
  92724. */
  92725. serialize(): any;
  92726. /**
  92727. * Float animation type
  92728. */
  92729. private static _ANIMATIONTYPE_FLOAT;
  92730. /**
  92731. * Vector3 animation type
  92732. */
  92733. private static _ANIMATIONTYPE_VECTOR3;
  92734. /**
  92735. * Quaternion animation type
  92736. */
  92737. private static _ANIMATIONTYPE_QUATERNION;
  92738. /**
  92739. * Matrix animation type
  92740. */
  92741. private static _ANIMATIONTYPE_MATRIX;
  92742. /**
  92743. * Color3 animation type
  92744. */
  92745. private static _ANIMATIONTYPE_COLOR3;
  92746. /**
  92747. * Vector2 animation type
  92748. */
  92749. private static _ANIMATIONTYPE_VECTOR2;
  92750. /**
  92751. * Size animation type
  92752. */
  92753. private static _ANIMATIONTYPE_SIZE;
  92754. /**
  92755. * Relative Loop Mode
  92756. */
  92757. private static _ANIMATIONLOOPMODE_RELATIVE;
  92758. /**
  92759. * Cycle Loop Mode
  92760. */
  92761. private static _ANIMATIONLOOPMODE_CYCLE;
  92762. /**
  92763. * Constant Loop Mode
  92764. */
  92765. private static _ANIMATIONLOOPMODE_CONSTANT;
  92766. /**
  92767. * Get the float animation type
  92768. */
  92769. static readonly ANIMATIONTYPE_FLOAT: number;
  92770. /**
  92771. * Get the Vector3 animation type
  92772. */
  92773. static readonly ANIMATIONTYPE_VECTOR3: number;
  92774. /**
  92775. * Get the Vector2 animation type
  92776. */
  92777. static readonly ANIMATIONTYPE_VECTOR2: number;
  92778. /**
  92779. * Get the Size animation type
  92780. */
  92781. static readonly ANIMATIONTYPE_SIZE: number;
  92782. /**
  92783. * Get the Quaternion animation type
  92784. */
  92785. static readonly ANIMATIONTYPE_QUATERNION: number;
  92786. /**
  92787. * Get the Matrix animation type
  92788. */
  92789. static readonly ANIMATIONTYPE_MATRIX: number;
  92790. /**
  92791. * Get the Color3 animation type
  92792. */
  92793. static readonly ANIMATIONTYPE_COLOR3: number;
  92794. /**
  92795. * Get the Relative Loop Mode
  92796. */
  92797. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  92798. /**
  92799. * Get the Cycle Loop Mode
  92800. */
  92801. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  92802. /**
  92803. * Get the Constant Loop Mode
  92804. */
  92805. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  92806. /** @hidden */
  92807. static _UniversalLerp(left: any, right: any, amount: number): any;
  92808. /**
  92809. * Parses an animation object and creates an animation
  92810. * @param parsedAnimation Parsed animation object
  92811. * @returns Animation object
  92812. */
  92813. static Parse(parsedAnimation: any): Animation;
  92814. /**
  92815. * Appends the serialized animations from the source animations
  92816. * @param source Source containing the animations
  92817. * @param destination Target to store the animations
  92818. */
  92819. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  92820. }
  92821. }
  92822. declare module BABYLON {
  92823. /**
  92824. * Interface containing an array of animations
  92825. */
  92826. export interface IAnimatable {
  92827. /**
  92828. * Array of animations
  92829. */
  92830. animations: Nullable<Array<Animation>>;
  92831. }
  92832. }
  92833. declare module BABYLON {
  92834. /**
  92835. * This represents all the required information to add a fresnel effect on a material:
  92836. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  92837. */
  92838. export class FresnelParameters {
  92839. private _isEnabled;
  92840. /**
  92841. * Define if the fresnel effect is enable or not.
  92842. */
  92843. isEnabled: boolean;
  92844. /**
  92845. * Define the color used on edges (grazing angle)
  92846. */
  92847. leftColor: Color3;
  92848. /**
  92849. * Define the color used on center
  92850. */
  92851. rightColor: Color3;
  92852. /**
  92853. * Define bias applied to computed fresnel term
  92854. */
  92855. bias: number;
  92856. /**
  92857. * Defined the power exponent applied to fresnel term
  92858. */
  92859. power: number;
  92860. /**
  92861. * Clones the current fresnel and its valuues
  92862. * @returns a clone fresnel configuration
  92863. */
  92864. clone(): FresnelParameters;
  92865. /**
  92866. * Serializes the current fresnel parameters to a JSON representation.
  92867. * @return the JSON serialization
  92868. */
  92869. serialize(): any;
  92870. /**
  92871. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  92872. * @param parsedFresnelParameters Define the JSON representation
  92873. * @returns the parsed parameters
  92874. */
  92875. static Parse(parsedFresnelParameters: any): FresnelParameters;
  92876. }
  92877. }
  92878. declare module BABYLON {
  92879. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  92880. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  92881. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  92882. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  92883. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  92884. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  92885. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  92886. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  92887. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  92888. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  92889. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  92890. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  92891. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  92892. /**
  92893. * Decorator used to define property that can be serialized as reference to a camera
  92894. * @param sourceName defines the name of the property to decorate
  92895. */
  92896. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  92897. /**
  92898. * Class used to help serialization objects
  92899. */
  92900. export class SerializationHelper {
  92901. /** @hidden */
  92902. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  92903. /** @hidden */
  92904. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  92905. /** @hidden */
  92906. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  92907. /** @hidden */
  92908. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  92909. /**
  92910. * Appends the serialized animations from the source animations
  92911. * @param source Source containing the animations
  92912. * @param destination Target to store the animations
  92913. */
  92914. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  92915. /**
  92916. * Static function used to serialized a specific entity
  92917. * @param entity defines the entity to serialize
  92918. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  92919. * @returns a JSON compatible object representing the serialization of the entity
  92920. */
  92921. static Serialize<T>(entity: T, serializationObject?: any): any;
  92922. /**
  92923. * Creates a new entity from a serialization data object
  92924. * @param creationFunction defines a function used to instanciated the new entity
  92925. * @param source defines the source serialization data
  92926. * @param scene defines the hosting scene
  92927. * @param rootUrl defines the root url for resources
  92928. * @returns a new entity
  92929. */
  92930. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  92931. /**
  92932. * Clones an object
  92933. * @param creationFunction defines the function used to instanciate the new object
  92934. * @param source defines the source object
  92935. * @returns the cloned object
  92936. */
  92937. static Clone<T>(creationFunction: () => T, source: T): T;
  92938. /**
  92939. * Instanciates a new object based on a source one (some data will be shared between both object)
  92940. * @param creationFunction defines the function used to instanciate the new object
  92941. * @param source defines the source object
  92942. * @returns the new object
  92943. */
  92944. static Instanciate<T>(creationFunction: () => T, source: T): T;
  92945. }
  92946. }
  92947. declare module BABYLON {
  92948. /**
  92949. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  92950. */
  92951. export interface CubeMapInfo {
  92952. /**
  92953. * The pixel array for the front face.
  92954. * This is stored in format, left to right, up to down format.
  92955. */
  92956. front: Nullable<ArrayBufferView>;
  92957. /**
  92958. * The pixel array for the back face.
  92959. * This is stored in format, left to right, up to down format.
  92960. */
  92961. back: Nullable<ArrayBufferView>;
  92962. /**
  92963. * The pixel array for the left face.
  92964. * This is stored in format, left to right, up to down format.
  92965. */
  92966. left: Nullable<ArrayBufferView>;
  92967. /**
  92968. * The pixel array for the right face.
  92969. * This is stored in format, left to right, up to down format.
  92970. */
  92971. right: Nullable<ArrayBufferView>;
  92972. /**
  92973. * The pixel array for the up face.
  92974. * This is stored in format, left to right, up to down format.
  92975. */
  92976. up: Nullable<ArrayBufferView>;
  92977. /**
  92978. * The pixel array for the down face.
  92979. * This is stored in format, left to right, up to down format.
  92980. */
  92981. down: Nullable<ArrayBufferView>;
  92982. /**
  92983. * The size of the cubemap stored.
  92984. *
  92985. * Each faces will be size * size pixels.
  92986. */
  92987. size: number;
  92988. /**
  92989. * The format of the texture.
  92990. *
  92991. * RGBA, RGB.
  92992. */
  92993. format: number;
  92994. /**
  92995. * The type of the texture data.
  92996. *
  92997. * UNSIGNED_INT, FLOAT.
  92998. */
  92999. type: number;
  93000. /**
  93001. * Specifies whether the texture is in gamma space.
  93002. */
  93003. gammaSpace: boolean;
  93004. }
  93005. /**
  93006. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  93007. */
  93008. export class PanoramaToCubeMapTools {
  93009. private static FACE_FRONT;
  93010. private static FACE_BACK;
  93011. private static FACE_RIGHT;
  93012. private static FACE_LEFT;
  93013. private static FACE_DOWN;
  93014. private static FACE_UP;
  93015. /**
  93016. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  93017. *
  93018. * @param float32Array The source data.
  93019. * @param inputWidth The width of the input panorama.
  93020. * @param inputHeight The height of the input panorama.
  93021. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  93022. * @return The cubemap data
  93023. */
  93024. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  93025. private static CreateCubemapTexture;
  93026. private static CalcProjectionSpherical;
  93027. }
  93028. }
  93029. declare module BABYLON {
  93030. /**
  93031. * Helper class dealing with the extraction of spherical polynomial dataArray
  93032. * from a cube map.
  93033. */
  93034. export class CubeMapToSphericalPolynomialTools {
  93035. private static FileFaces;
  93036. /**
  93037. * Converts a texture to the according Spherical Polynomial data.
  93038. * This extracts the first 3 orders only as they are the only one used in the lighting.
  93039. *
  93040. * @param texture The texture to extract the information from.
  93041. * @return The Spherical Polynomial data.
  93042. */
  93043. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  93044. /**
  93045. * Converts a cubemap to the according Spherical Polynomial data.
  93046. * This extracts the first 3 orders only as they are the only one used in the lighting.
  93047. *
  93048. * @param cubeInfo The Cube map to extract the information from.
  93049. * @return The Spherical Polynomial data.
  93050. */
  93051. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  93052. }
  93053. }
  93054. declare module BABYLON {
  93055. /**
  93056. * Class used to manipulate GUIDs
  93057. */
  93058. export class GUID {
  93059. /**
  93060. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  93061. * Be aware Math.random() could cause collisions, but:
  93062. * "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"
  93063. * @returns a pseudo random id
  93064. */
  93065. static RandomId(): string;
  93066. }
  93067. }
  93068. declare module BABYLON {
  93069. /**
  93070. * Base class of all the textures in babylon.
  93071. * It groups all the common properties the materials, post process, lights... might need
  93072. * in order to make a correct use of the texture.
  93073. */
  93074. export class BaseTexture implements IAnimatable {
  93075. /**
  93076. * Default anisotropic filtering level for the application.
  93077. * It is set to 4 as a good tradeoff between perf and quality.
  93078. */
  93079. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  93080. /**
  93081. * Gets or sets the unique id of the texture
  93082. */
  93083. uniqueId: number;
  93084. /**
  93085. * Define the name of the texture.
  93086. */
  93087. name: string;
  93088. /**
  93089. * Gets or sets an object used to store user defined information.
  93090. */
  93091. metadata: any;
  93092. /**
  93093. * For internal use only. Please do not use.
  93094. */
  93095. reservedDataStore: any;
  93096. private _hasAlpha;
  93097. /**
  93098. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  93099. */
  93100. hasAlpha: boolean;
  93101. /**
  93102. * Defines if the alpha value should be determined via the rgb values.
  93103. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  93104. */
  93105. getAlphaFromRGB: boolean;
  93106. /**
  93107. * Intensity or strength of the texture.
  93108. * It is commonly used by materials to fine tune the intensity of the texture
  93109. */
  93110. level: number;
  93111. /**
  93112. * Define the UV chanel to use starting from 0 and defaulting to 0.
  93113. * This is part of the texture as textures usually maps to one uv set.
  93114. */
  93115. coordinatesIndex: number;
  93116. private _coordinatesMode;
  93117. /**
  93118. * How a texture is mapped.
  93119. *
  93120. * | Value | Type | Description |
  93121. * | ----- | ----------------------------------- | ----------- |
  93122. * | 0 | EXPLICIT_MODE | |
  93123. * | 1 | SPHERICAL_MODE | |
  93124. * | 2 | PLANAR_MODE | |
  93125. * | 3 | CUBIC_MODE | |
  93126. * | 4 | PROJECTION_MODE | |
  93127. * | 5 | SKYBOX_MODE | |
  93128. * | 6 | INVCUBIC_MODE | |
  93129. * | 7 | EQUIRECTANGULAR_MODE | |
  93130. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  93131. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  93132. */
  93133. coordinatesMode: number;
  93134. /**
  93135. * | Value | Type | Description |
  93136. * | ----- | ------------------ | ----------- |
  93137. * | 0 | CLAMP_ADDRESSMODE | |
  93138. * | 1 | WRAP_ADDRESSMODE | |
  93139. * | 2 | MIRROR_ADDRESSMODE | |
  93140. */
  93141. wrapU: number;
  93142. /**
  93143. * | Value | Type | Description |
  93144. * | ----- | ------------------ | ----------- |
  93145. * | 0 | CLAMP_ADDRESSMODE | |
  93146. * | 1 | WRAP_ADDRESSMODE | |
  93147. * | 2 | MIRROR_ADDRESSMODE | |
  93148. */
  93149. wrapV: number;
  93150. /**
  93151. * | Value | Type | Description |
  93152. * | ----- | ------------------ | ----------- |
  93153. * | 0 | CLAMP_ADDRESSMODE | |
  93154. * | 1 | WRAP_ADDRESSMODE | |
  93155. * | 2 | MIRROR_ADDRESSMODE | |
  93156. */
  93157. wrapR: number;
  93158. /**
  93159. * With compliant hardware and browser (supporting anisotropic filtering)
  93160. * this defines the level of anisotropic filtering in the texture.
  93161. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  93162. */
  93163. anisotropicFilteringLevel: number;
  93164. /**
  93165. * Define if the texture is a cube texture or if false a 2d texture.
  93166. */
  93167. isCube: boolean;
  93168. /**
  93169. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  93170. */
  93171. is3D: boolean;
  93172. /**
  93173. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  93174. * HDR texture are usually stored in linear space.
  93175. * This only impacts the PBR and Background materials
  93176. */
  93177. gammaSpace: boolean;
  93178. /**
  93179. * Gets whether or not the texture contains RGBD data.
  93180. */
  93181. readonly isRGBD: boolean;
  93182. /**
  93183. * Is Z inverted in the texture (useful in a cube texture).
  93184. */
  93185. invertZ: boolean;
  93186. /**
  93187. * Are mip maps generated for this texture or not.
  93188. */
  93189. readonly noMipmap: boolean;
  93190. /**
  93191. * @hidden
  93192. */
  93193. lodLevelInAlpha: boolean;
  93194. /**
  93195. * With prefiltered texture, defined the offset used during the prefiltering steps.
  93196. */
  93197. lodGenerationOffset: number;
  93198. /**
  93199. * With prefiltered texture, defined the scale used during the prefiltering steps.
  93200. */
  93201. lodGenerationScale: number;
  93202. /**
  93203. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  93204. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  93205. * average roughness values.
  93206. */
  93207. linearSpecularLOD: boolean;
  93208. /**
  93209. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  93210. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  93211. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  93212. */
  93213. irradianceTexture: Nullable<BaseTexture>;
  93214. /**
  93215. * Define if the texture is a render target.
  93216. */
  93217. isRenderTarget: boolean;
  93218. /**
  93219. * Define the unique id of the texture in the scene.
  93220. */
  93221. readonly uid: string;
  93222. /**
  93223. * Return a string representation of the texture.
  93224. * @returns the texture as a string
  93225. */
  93226. toString(): string;
  93227. /**
  93228. * Get the class name of the texture.
  93229. * @returns "BaseTexture"
  93230. */
  93231. getClassName(): string;
  93232. /**
  93233. * Define the list of animation attached to the texture.
  93234. */
  93235. animations: Animation[];
  93236. /**
  93237. * An event triggered when the texture is disposed.
  93238. */
  93239. onDisposeObservable: Observable<BaseTexture>;
  93240. private _onDisposeObserver;
  93241. /**
  93242. * Callback triggered when the texture has been disposed.
  93243. * Kept for back compatibility, you can use the onDisposeObservable instead.
  93244. */
  93245. onDispose: () => void;
  93246. /**
  93247. * Define the current state of the loading sequence when in delayed load mode.
  93248. */
  93249. delayLoadState: number;
  93250. private _scene;
  93251. /** @hidden */
  93252. _texture: Nullable<InternalTexture>;
  93253. private _uid;
  93254. /**
  93255. * Define if the texture is preventinga material to render or not.
  93256. * If not and the texture is not ready, the engine will use a default black texture instead.
  93257. */
  93258. readonly isBlocking: boolean;
  93259. /**
  93260. * Instantiates a new BaseTexture.
  93261. * Base class of all the textures in babylon.
  93262. * It groups all the common properties the materials, post process, lights... might need
  93263. * in order to make a correct use of the texture.
  93264. * @param scene Define the scene the texture blongs to
  93265. */
  93266. constructor(scene: Nullable<Scene>);
  93267. /**
  93268. * Get the scene the texture belongs to.
  93269. * @returns the scene or null if undefined
  93270. */
  93271. getScene(): Nullable<Scene>;
  93272. /**
  93273. * Get the texture transform matrix used to offset tile the texture for istance.
  93274. * @returns the transformation matrix
  93275. */
  93276. getTextureMatrix(): Matrix;
  93277. /**
  93278. * Get the texture reflection matrix used to rotate/transform the reflection.
  93279. * @returns the reflection matrix
  93280. */
  93281. getReflectionTextureMatrix(): Matrix;
  93282. /**
  93283. * Get the underlying lower level texture from Babylon.
  93284. * @returns the insternal texture
  93285. */
  93286. getInternalTexture(): Nullable<InternalTexture>;
  93287. /**
  93288. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  93289. * @returns true if ready or not blocking
  93290. */
  93291. isReadyOrNotBlocking(): boolean;
  93292. /**
  93293. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  93294. * @returns true if fully ready
  93295. */
  93296. isReady(): boolean;
  93297. private _cachedSize;
  93298. /**
  93299. * Get the size of the texture.
  93300. * @returns the texture size.
  93301. */
  93302. getSize(): ISize;
  93303. /**
  93304. * Get the base size of the texture.
  93305. * It can be different from the size if the texture has been resized for POT for instance
  93306. * @returns the base size
  93307. */
  93308. getBaseSize(): ISize;
  93309. /**
  93310. * Update the sampling mode of the texture.
  93311. * Default is Trilinear mode.
  93312. *
  93313. * | Value | Type | Description |
  93314. * | ----- | ------------------ | ----------- |
  93315. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  93316. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  93317. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  93318. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  93319. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  93320. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  93321. * | 7 | NEAREST_LINEAR | |
  93322. * | 8 | NEAREST_NEAREST | |
  93323. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  93324. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  93325. * | 11 | LINEAR_LINEAR | |
  93326. * | 12 | LINEAR_NEAREST | |
  93327. *
  93328. * > _mag_: magnification filter (close to the viewer)
  93329. * > _min_: minification filter (far from the viewer)
  93330. * > _mip_: filter used between mip map levels
  93331. *@param samplingMode Define the new sampling mode of the texture
  93332. */
  93333. updateSamplingMode(samplingMode: number): void;
  93334. /**
  93335. * Scales the texture if is `canRescale()`
  93336. * @param ratio the resize factor we want to use to rescale
  93337. */
  93338. scale(ratio: number): void;
  93339. /**
  93340. * Get if the texture can rescale.
  93341. */
  93342. readonly canRescale: boolean;
  93343. /** @hidden */
  93344. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  93345. /** @hidden */
  93346. _rebuild(): void;
  93347. /**
  93348. * Triggers the load sequence in delayed load mode.
  93349. */
  93350. delayLoad(): void;
  93351. /**
  93352. * Clones the texture.
  93353. * @returns the cloned texture
  93354. */
  93355. clone(): Nullable<BaseTexture>;
  93356. /**
  93357. * Get the texture underlying type (INT, FLOAT...)
  93358. */
  93359. readonly textureType: number;
  93360. /**
  93361. * Get the texture underlying format (RGB, RGBA...)
  93362. */
  93363. readonly textureFormat: number;
  93364. /**
  93365. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  93366. * This will returns an RGBA array buffer containing either in values (0-255) or
  93367. * float values (0-1) depending of the underlying buffer type.
  93368. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  93369. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  93370. * @param buffer defines a user defined buffer to fill with data (can be null)
  93371. * @returns The Array buffer containing the pixels data.
  93372. */
  93373. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  93374. /**
  93375. * Release and destroy the underlying lower level texture aka internalTexture.
  93376. */
  93377. releaseInternalTexture(): void;
  93378. /**
  93379. * Get the polynomial representation of the texture data.
  93380. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  93381. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  93382. */
  93383. sphericalPolynomial: Nullable<SphericalPolynomial>;
  93384. /** @hidden */
  93385. readonly _lodTextureHigh: Nullable<BaseTexture>;
  93386. /** @hidden */
  93387. readonly _lodTextureMid: Nullable<BaseTexture>;
  93388. /** @hidden */
  93389. readonly _lodTextureLow: Nullable<BaseTexture>;
  93390. /**
  93391. * Dispose the texture and release its associated resources.
  93392. */
  93393. dispose(): void;
  93394. /**
  93395. * Serialize the texture into a JSON representation that can be parsed later on.
  93396. * @returns the JSON representation of the texture
  93397. */
  93398. serialize(): any;
  93399. /**
  93400. * Helper function to be called back once a list of texture contains only ready textures.
  93401. * @param textures Define the list of textures to wait for
  93402. * @param callback Define the callback triggered once the entire list will be ready
  93403. */
  93404. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  93405. }
  93406. }
  93407. declare module BABYLON {
  93408. /**
  93409. * Class used to store data associated with WebGL texture data for the engine
  93410. * This class should not be used directly
  93411. */
  93412. export class InternalTexture {
  93413. /** @hidden */
  93414. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  93415. /**
  93416. * The source of the texture data is unknown
  93417. */
  93418. static DATASOURCE_UNKNOWN: number;
  93419. /**
  93420. * Texture data comes from an URL
  93421. */
  93422. static DATASOURCE_URL: number;
  93423. /**
  93424. * Texture data is only used for temporary storage
  93425. */
  93426. static DATASOURCE_TEMP: number;
  93427. /**
  93428. * Texture data comes from raw data (ArrayBuffer)
  93429. */
  93430. static DATASOURCE_RAW: number;
  93431. /**
  93432. * Texture content is dynamic (video or dynamic texture)
  93433. */
  93434. static DATASOURCE_DYNAMIC: number;
  93435. /**
  93436. * Texture content is generated by rendering to it
  93437. */
  93438. static DATASOURCE_RENDERTARGET: number;
  93439. /**
  93440. * Texture content is part of a multi render target process
  93441. */
  93442. static DATASOURCE_MULTIRENDERTARGET: number;
  93443. /**
  93444. * Texture data comes from a cube data file
  93445. */
  93446. static DATASOURCE_CUBE: number;
  93447. /**
  93448. * Texture data comes from a raw cube data
  93449. */
  93450. static DATASOURCE_CUBERAW: number;
  93451. /**
  93452. * Texture data come from a prefiltered cube data file
  93453. */
  93454. static DATASOURCE_CUBEPREFILTERED: number;
  93455. /**
  93456. * Texture content is raw 3D data
  93457. */
  93458. static DATASOURCE_RAW3D: number;
  93459. /**
  93460. * Texture content is a depth texture
  93461. */
  93462. static DATASOURCE_DEPTHTEXTURE: number;
  93463. /**
  93464. * Texture data comes from a raw cube data encoded with RGBD
  93465. */
  93466. static DATASOURCE_CUBERAW_RGBD: number;
  93467. /**
  93468. * Defines if the texture is ready
  93469. */
  93470. isReady: boolean;
  93471. /**
  93472. * Defines if the texture is a cube texture
  93473. */
  93474. isCube: boolean;
  93475. /**
  93476. * Defines if the texture contains 3D data
  93477. */
  93478. is3D: boolean;
  93479. /**
  93480. * Defines if the texture contains multiview data
  93481. */
  93482. isMultiview: boolean;
  93483. /**
  93484. * Gets the URL used to load this texture
  93485. */
  93486. url: string;
  93487. /**
  93488. * Gets the sampling mode of the texture
  93489. */
  93490. samplingMode: number;
  93491. /**
  93492. * Gets a boolean indicating if the texture needs mipmaps generation
  93493. */
  93494. generateMipMaps: boolean;
  93495. /**
  93496. * Gets the number of samples used by the texture (WebGL2+ only)
  93497. */
  93498. samples: number;
  93499. /**
  93500. * Gets the type of the texture (int, float...)
  93501. */
  93502. type: number;
  93503. /**
  93504. * Gets the format of the texture (RGB, RGBA...)
  93505. */
  93506. format: number;
  93507. /**
  93508. * Observable called when the texture is loaded
  93509. */
  93510. onLoadedObservable: Observable<InternalTexture>;
  93511. /**
  93512. * Gets the width of the texture
  93513. */
  93514. width: number;
  93515. /**
  93516. * Gets the height of the texture
  93517. */
  93518. height: number;
  93519. /**
  93520. * Gets the depth of the texture
  93521. */
  93522. depth: number;
  93523. /**
  93524. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  93525. */
  93526. baseWidth: number;
  93527. /**
  93528. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  93529. */
  93530. baseHeight: number;
  93531. /**
  93532. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  93533. */
  93534. baseDepth: number;
  93535. /**
  93536. * Gets a boolean indicating if the texture is inverted on Y axis
  93537. */
  93538. invertY: boolean;
  93539. /** @hidden */
  93540. _invertVScale: boolean;
  93541. /** @hidden */
  93542. _associatedChannel: number;
  93543. /** @hidden */
  93544. _dataSource: number;
  93545. /** @hidden */
  93546. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>;
  93547. /** @hidden */
  93548. _bufferView: Nullable<ArrayBufferView>;
  93549. /** @hidden */
  93550. _bufferViewArray: Nullable<ArrayBufferView[]>;
  93551. /** @hidden */
  93552. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  93553. /** @hidden */
  93554. _size: number;
  93555. /** @hidden */
  93556. _extension: string;
  93557. /** @hidden */
  93558. _files: Nullable<string[]>;
  93559. /** @hidden */
  93560. _workingCanvas: Nullable<HTMLCanvasElement>;
  93561. /** @hidden */
  93562. _workingContext: Nullable<CanvasRenderingContext2D>;
  93563. /** @hidden */
  93564. _framebuffer: Nullable<WebGLFramebuffer>;
  93565. /** @hidden */
  93566. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  93567. /** @hidden */
  93568. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  93569. /** @hidden */
  93570. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  93571. /** @hidden */
  93572. _attachments: Nullable<number[]>;
  93573. /** @hidden */
  93574. _cachedCoordinatesMode: Nullable<number>;
  93575. /** @hidden */
  93576. _cachedWrapU: Nullable<number>;
  93577. /** @hidden */
  93578. _cachedWrapV: Nullable<number>;
  93579. /** @hidden */
  93580. _cachedWrapR: Nullable<number>;
  93581. /** @hidden */
  93582. _cachedAnisotropicFilteringLevel: Nullable<number>;
  93583. /** @hidden */
  93584. _isDisabled: boolean;
  93585. /** @hidden */
  93586. _compression: Nullable<string>;
  93587. /** @hidden */
  93588. _generateStencilBuffer: boolean;
  93589. /** @hidden */
  93590. _generateDepthBuffer: boolean;
  93591. /** @hidden */
  93592. _comparisonFunction: number;
  93593. /** @hidden */
  93594. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  93595. /** @hidden */
  93596. _lodGenerationScale: number;
  93597. /** @hidden */
  93598. _lodGenerationOffset: number;
  93599. /** @hidden */
  93600. _colorTextureArray: Nullable<WebGLTexture>;
  93601. /** @hidden */
  93602. _depthStencilTextureArray: Nullable<WebGLTexture>;
  93603. /** @hidden */
  93604. _lodTextureHigh: Nullable<BaseTexture>;
  93605. /** @hidden */
  93606. _lodTextureMid: Nullable<BaseTexture>;
  93607. /** @hidden */
  93608. _lodTextureLow: Nullable<BaseTexture>;
  93609. /** @hidden */
  93610. _isRGBD: boolean;
  93611. /** @hidden */
  93612. _linearSpecularLOD: boolean;
  93613. /** @hidden */
  93614. _irradianceTexture: Nullable<BaseTexture>;
  93615. /** @hidden */
  93616. _webGLTexture: Nullable<WebGLTexture>;
  93617. /** @hidden */
  93618. _references: number;
  93619. private _engine;
  93620. /**
  93621. * Gets the Engine the texture belongs to.
  93622. * @returns The babylon engine
  93623. */
  93624. getEngine(): Engine;
  93625. /**
  93626. * Gets the data source type of the texture (can be one of the InternalTexture.DATASOURCE_XXXX)
  93627. */
  93628. readonly dataSource: number;
  93629. /**
  93630. * Creates a new InternalTexture
  93631. * @param engine defines the engine to use
  93632. * @param dataSource defines the type of data that will be used
  93633. * @param delayAllocation if the texture allocation should be delayed (default: false)
  93634. */
  93635. constructor(engine: Engine, dataSource: number, delayAllocation?: boolean);
  93636. /**
  93637. * Increments the number of references (ie. the number of Texture that point to it)
  93638. */
  93639. incrementReferences(): void;
  93640. /**
  93641. * Change the size of the texture (not the size of the content)
  93642. * @param width defines the new width
  93643. * @param height defines the new height
  93644. * @param depth defines the new depth (1 by default)
  93645. */
  93646. updateSize(width: int, height: int, depth?: int): void;
  93647. /** @hidden */
  93648. _rebuild(): void;
  93649. /** @hidden */
  93650. _swapAndDie(target: InternalTexture): void;
  93651. /**
  93652. * Dispose the current allocated resources
  93653. */
  93654. dispose(): void;
  93655. }
  93656. }
  93657. declare module BABYLON {
  93658. /**
  93659. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  93660. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  93661. */
  93662. export class EffectFallbacks {
  93663. private _defines;
  93664. private _currentRank;
  93665. private _maxRank;
  93666. private _mesh;
  93667. /**
  93668. * Removes the fallback from the bound mesh.
  93669. */
  93670. unBindMesh(): void;
  93671. /**
  93672. * Adds a fallback on the specified property.
  93673. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  93674. * @param define The name of the define in the shader
  93675. */
  93676. addFallback(rank: number, define: string): void;
  93677. /**
  93678. * Sets the mesh to use CPU skinning when needing to fallback.
  93679. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  93680. * @param mesh The mesh to use the fallbacks.
  93681. */
  93682. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  93683. /**
  93684. * Checks to see if more fallbacks are still availible.
  93685. */
  93686. readonly hasMoreFallbacks: boolean;
  93687. /**
  93688. * Removes the defines that should be removed when falling back.
  93689. * @param currentDefines defines the current define statements for the shader.
  93690. * @param effect defines the current effect we try to compile
  93691. * @returns The resulting defines with defines of the current rank removed.
  93692. */
  93693. reduce(currentDefines: string, effect: Effect): string;
  93694. }
  93695. /**
  93696. * Options to be used when creating an effect.
  93697. */
  93698. export class EffectCreationOptions {
  93699. /**
  93700. * Atrributes that will be used in the shader.
  93701. */
  93702. attributes: string[];
  93703. /**
  93704. * Uniform varible names that will be set in the shader.
  93705. */
  93706. uniformsNames: string[];
  93707. /**
  93708. * Uniform buffer varible names that will be set in the shader.
  93709. */
  93710. uniformBuffersNames: string[];
  93711. /**
  93712. * Sampler texture variable names that will be set in the shader.
  93713. */
  93714. samplers: string[];
  93715. /**
  93716. * Define statements that will be set in the shader.
  93717. */
  93718. defines: any;
  93719. /**
  93720. * Possible fallbacks for this effect to improve performance when needed.
  93721. */
  93722. fallbacks: Nullable<EffectFallbacks>;
  93723. /**
  93724. * Callback that will be called when the shader is compiled.
  93725. */
  93726. onCompiled: Nullable<(effect: Effect) => void>;
  93727. /**
  93728. * Callback that will be called if an error occurs during shader compilation.
  93729. */
  93730. onError: Nullable<(effect: Effect, errors: string) => void>;
  93731. /**
  93732. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  93733. */
  93734. indexParameters: any;
  93735. /**
  93736. * Max number of lights that can be used in the shader.
  93737. */
  93738. maxSimultaneousLights: number;
  93739. /**
  93740. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  93741. */
  93742. transformFeedbackVaryings: Nullable<string[]>;
  93743. }
  93744. /**
  93745. * Effect containing vertex and fragment shader that can be executed on an object.
  93746. */
  93747. export class Effect implements IDisposable {
  93748. /**
  93749. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  93750. */
  93751. static ShadersRepository: string;
  93752. /**
  93753. * Name of the effect.
  93754. */
  93755. name: any;
  93756. /**
  93757. * String container all the define statements that should be set on the shader.
  93758. */
  93759. defines: string;
  93760. /**
  93761. * Callback that will be called when the shader is compiled.
  93762. */
  93763. onCompiled: Nullable<(effect: Effect) => void>;
  93764. /**
  93765. * Callback that will be called if an error occurs during shader compilation.
  93766. */
  93767. onError: Nullable<(effect: Effect, errors: string) => void>;
  93768. /**
  93769. * Callback that will be called when effect is bound.
  93770. */
  93771. onBind: Nullable<(effect: Effect) => void>;
  93772. /**
  93773. * Unique ID of the effect.
  93774. */
  93775. uniqueId: number;
  93776. /**
  93777. * Observable that will be called when the shader is compiled.
  93778. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  93779. */
  93780. onCompileObservable: Observable<Effect>;
  93781. /**
  93782. * Observable that will be called if an error occurs during shader compilation.
  93783. */
  93784. onErrorObservable: Observable<Effect>;
  93785. /** @hidden */
  93786. _onBindObservable: Nullable<Observable<Effect>>;
  93787. /**
  93788. * Observable that will be called when effect is bound.
  93789. */
  93790. readonly onBindObservable: Observable<Effect>;
  93791. /** @hidden */
  93792. _bonesComputationForcedToCPU: boolean;
  93793. private static _uniqueIdSeed;
  93794. private _engine;
  93795. private _uniformBuffersNames;
  93796. private _uniformsNames;
  93797. private _samplerList;
  93798. private _samplers;
  93799. private _isReady;
  93800. private _compilationError;
  93801. private _attributesNames;
  93802. private _attributes;
  93803. private _uniforms;
  93804. /**
  93805. * Key for the effect.
  93806. * @hidden
  93807. */
  93808. _key: string;
  93809. private _indexParameters;
  93810. private _fallbacks;
  93811. private _vertexSourceCode;
  93812. private _fragmentSourceCode;
  93813. private _vertexSourceCodeOverride;
  93814. private _fragmentSourceCodeOverride;
  93815. private _transformFeedbackVaryings;
  93816. /**
  93817. * Compiled shader to webGL program.
  93818. * @hidden
  93819. */
  93820. _pipelineContext: Nullable<IPipelineContext>;
  93821. private _valueCache;
  93822. private static _baseCache;
  93823. /**
  93824. * Instantiates an effect.
  93825. * An effect can be used to create/manage/execute vertex and fragment shaders.
  93826. * @param baseName Name of the effect.
  93827. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  93828. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  93829. * @param samplers List of sampler variables that will be passed to the shader.
  93830. * @param engine Engine to be used to render the effect
  93831. * @param defines Define statements to be added to the shader.
  93832. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  93833. * @param onCompiled Callback that will be called when the shader is compiled.
  93834. * @param onError Callback that will be called if an error occurs during shader compilation.
  93835. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  93836. */
  93837. constructor(baseName: any, attributesNamesOrOptions: string[] | EffectCreationOptions, uniformsNamesOrEngine: string[] | Engine, samplers?: Nullable<string[]>, engine?: Engine, defines?: Nullable<string>, fallbacks?: Nullable<EffectFallbacks>, onCompiled?: Nullable<(effect: Effect) => void>, onError?: Nullable<(effect: Effect, errors: string) => void>, indexParameters?: any);
  93838. private _useFinalCode;
  93839. /**
  93840. * Unique key for this effect
  93841. */
  93842. readonly key: string;
  93843. /**
  93844. * If the effect has been compiled and prepared.
  93845. * @returns if the effect is compiled and prepared.
  93846. */
  93847. isReady(): boolean;
  93848. private _isReadyInternal;
  93849. /**
  93850. * The engine the effect was initialized with.
  93851. * @returns the engine.
  93852. */
  93853. getEngine(): Engine;
  93854. /**
  93855. * The pipeline context for this effect
  93856. * @returns the associated pipeline context
  93857. */
  93858. getPipelineContext(): Nullable<IPipelineContext>;
  93859. /**
  93860. * The set of names of attribute variables for the shader.
  93861. * @returns An array of attribute names.
  93862. */
  93863. getAttributesNames(): string[];
  93864. /**
  93865. * Returns the attribute at the given index.
  93866. * @param index The index of the attribute.
  93867. * @returns The location of the attribute.
  93868. */
  93869. getAttributeLocation(index: number): number;
  93870. /**
  93871. * Returns the attribute based on the name of the variable.
  93872. * @param name of the attribute to look up.
  93873. * @returns the attribute location.
  93874. */
  93875. getAttributeLocationByName(name: string): number;
  93876. /**
  93877. * The number of attributes.
  93878. * @returns the numnber of attributes.
  93879. */
  93880. getAttributesCount(): number;
  93881. /**
  93882. * Gets the index of a uniform variable.
  93883. * @param uniformName of the uniform to look up.
  93884. * @returns the index.
  93885. */
  93886. getUniformIndex(uniformName: string): number;
  93887. /**
  93888. * Returns the attribute based on the name of the variable.
  93889. * @param uniformName of the uniform to look up.
  93890. * @returns the location of the uniform.
  93891. */
  93892. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  93893. /**
  93894. * Returns an array of sampler variable names
  93895. * @returns The array of sampler variable neames.
  93896. */
  93897. getSamplers(): string[];
  93898. /**
  93899. * The error from the last compilation.
  93900. * @returns the error string.
  93901. */
  93902. getCompilationError(): string;
  93903. /**
  93904. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  93905. * @param func The callback to be used.
  93906. */
  93907. executeWhenCompiled(func: (effect: Effect) => void): void;
  93908. private _checkIsReady;
  93909. /** @hidden */
  93910. _loadVertexShader(vertex: any, callback: (data: any) => void): void;
  93911. /** @hidden */
  93912. _loadFragmentShader(fragment: any, callback: (data: any) => void): void;
  93913. /** @hidden */
  93914. _dumpShadersSource(vertexCode: string, fragmentCode: string, defines: string): void;
  93915. /**
  93916. * Recompiles the webGL program
  93917. * @param vertexSourceCode The source code for the vertex shader.
  93918. * @param fragmentSourceCode The source code for the fragment shader.
  93919. * @param onCompiled Callback called when completed.
  93920. * @param onError Callback called on error.
  93921. * @hidden
  93922. */
  93923. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  93924. /**
  93925. * Prepares the effect
  93926. * @hidden
  93927. */
  93928. _prepareEffect(): void;
  93929. private _processCompilationErrors;
  93930. /**
  93931. * Checks if the effect is supported. (Must be called after compilation)
  93932. */
  93933. readonly isSupported: boolean;
  93934. /**
  93935. * Binds a texture to the engine to be used as output of the shader.
  93936. * @param channel Name of the output variable.
  93937. * @param texture Texture to bind.
  93938. * @hidden
  93939. */
  93940. _bindTexture(channel: string, texture: InternalTexture): void;
  93941. /**
  93942. * Sets a texture on the engine to be used in the shader.
  93943. * @param channel Name of the sampler variable.
  93944. * @param texture Texture to set.
  93945. */
  93946. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  93947. /**
  93948. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  93949. * @param channel Name of the sampler variable.
  93950. * @param texture Texture to set.
  93951. */
  93952. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  93953. /**
  93954. * Sets an array of textures on the engine to be used in the shader.
  93955. * @param channel Name of the variable.
  93956. * @param textures Textures to set.
  93957. */
  93958. setTextureArray(channel: string, textures: BaseTexture[]): void;
  93959. /**
  93960. * 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)
  93961. * @param channel Name of the sampler variable.
  93962. * @param postProcess Post process to get the input texture from.
  93963. */
  93964. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  93965. /**
  93966. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  93967. * 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)
  93968. * @param channel Name of the sampler variable.
  93969. * @param postProcess Post process to get the output texture from.
  93970. */
  93971. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  93972. /** @hidden */
  93973. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  93974. /** @hidden */
  93975. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  93976. /** @hidden */
  93977. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  93978. /** @hidden */
  93979. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  93980. /**
  93981. * Binds a buffer to a uniform.
  93982. * @param buffer Buffer to bind.
  93983. * @param name Name of the uniform variable to bind to.
  93984. */
  93985. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  93986. /**
  93987. * Binds block to a uniform.
  93988. * @param blockName Name of the block to bind.
  93989. * @param index Index to bind.
  93990. */
  93991. bindUniformBlock(blockName: string, index: number): void;
  93992. /**
  93993. * Sets an interger value on a uniform variable.
  93994. * @param uniformName Name of the variable.
  93995. * @param value Value to be set.
  93996. * @returns this effect.
  93997. */
  93998. setInt(uniformName: string, value: number): Effect;
  93999. /**
  94000. * Sets an int array on a uniform variable.
  94001. * @param uniformName Name of the variable.
  94002. * @param array array to be set.
  94003. * @returns this effect.
  94004. */
  94005. setIntArray(uniformName: string, array: Int32Array): Effect;
  94006. /**
  94007. * 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)
  94008. * @param uniformName Name of the variable.
  94009. * @param array array to be set.
  94010. * @returns this effect.
  94011. */
  94012. setIntArray2(uniformName: string, array: Int32Array): Effect;
  94013. /**
  94014. * 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)
  94015. * @param uniformName Name of the variable.
  94016. * @param array array to be set.
  94017. * @returns this effect.
  94018. */
  94019. setIntArray3(uniformName: string, array: Int32Array): Effect;
  94020. /**
  94021. * 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)
  94022. * @param uniformName Name of the variable.
  94023. * @param array array to be set.
  94024. * @returns this effect.
  94025. */
  94026. setIntArray4(uniformName: string, array: Int32Array): Effect;
  94027. /**
  94028. * Sets an float array on a uniform variable.
  94029. * @param uniformName Name of the variable.
  94030. * @param array array to be set.
  94031. * @returns this effect.
  94032. */
  94033. setFloatArray(uniformName: string, array: Float32Array): Effect;
  94034. /**
  94035. * 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)
  94036. * @param uniformName Name of the variable.
  94037. * @param array array to be set.
  94038. * @returns this effect.
  94039. */
  94040. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  94041. /**
  94042. * 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)
  94043. * @param uniformName Name of the variable.
  94044. * @param array array to be set.
  94045. * @returns this effect.
  94046. */
  94047. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  94048. /**
  94049. * 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)
  94050. * @param uniformName Name of the variable.
  94051. * @param array array to be set.
  94052. * @returns this effect.
  94053. */
  94054. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  94055. /**
  94056. * Sets an array on a uniform variable.
  94057. * @param uniformName Name of the variable.
  94058. * @param array array to be set.
  94059. * @returns this effect.
  94060. */
  94061. setArray(uniformName: string, array: number[]): Effect;
  94062. /**
  94063. * 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)
  94064. * @param uniformName Name of the variable.
  94065. * @param array array to be set.
  94066. * @returns this effect.
  94067. */
  94068. setArray2(uniformName: string, array: number[]): Effect;
  94069. /**
  94070. * 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)
  94071. * @param uniformName Name of the variable.
  94072. * @param array array to be set.
  94073. * @returns this effect.
  94074. */
  94075. setArray3(uniformName: string, array: number[]): Effect;
  94076. /**
  94077. * 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)
  94078. * @param uniformName Name of the variable.
  94079. * @param array array to be set.
  94080. * @returns this effect.
  94081. */
  94082. setArray4(uniformName: string, array: number[]): Effect;
  94083. /**
  94084. * Sets matrices on a uniform variable.
  94085. * @param uniformName Name of the variable.
  94086. * @param matrices matrices to be set.
  94087. * @returns this effect.
  94088. */
  94089. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  94090. /**
  94091. * Sets matrix on a uniform variable.
  94092. * @param uniformName Name of the variable.
  94093. * @param matrix matrix to be set.
  94094. * @returns this effect.
  94095. */
  94096. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  94097. /**
  94098. * 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)
  94099. * @param uniformName Name of the variable.
  94100. * @param matrix matrix to be set.
  94101. * @returns this effect.
  94102. */
  94103. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  94104. /**
  94105. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  94106. * @param uniformName Name of the variable.
  94107. * @param matrix matrix to be set.
  94108. * @returns this effect.
  94109. */
  94110. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  94111. /**
  94112. * Sets a float on a uniform variable.
  94113. * @param uniformName Name of the variable.
  94114. * @param value value to be set.
  94115. * @returns this effect.
  94116. */
  94117. setFloat(uniformName: string, value: number): Effect;
  94118. /**
  94119. * Sets a boolean on a uniform variable.
  94120. * @param uniformName Name of the variable.
  94121. * @param bool value to be set.
  94122. * @returns this effect.
  94123. */
  94124. setBool(uniformName: string, bool: boolean): Effect;
  94125. /**
  94126. * Sets a Vector2 on a uniform variable.
  94127. * @param uniformName Name of the variable.
  94128. * @param vector2 vector2 to be set.
  94129. * @returns this effect.
  94130. */
  94131. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  94132. /**
  94133. * Sets a float2 on a uniform variable.
  94134. * @param uniformName Name of the variable.
  94135. * @param x First float in float2.
  94136. * @param y Second float in float2.
  94137. * @returns this effect.
  94138. */
  94139. setFloat2(uniformName: string, x: number, y: number): Effect;
  94140. /**
  94141. * Sets a Vector3 on a uniform variable.
  94142. * @param uniformName Name of the variable.
  94143. * @param vector3 Value to be set.
  94144. * @returns this effect.
  94145. */
  94146. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  94147. /**
  94148. * Sets a float3 on a uniform variable.
  94149. * @param uniformName Name of the variable.
  94150. * @param x First float in float3.
  94151. * @param y Second float in float3.
  94152. * @param z Third float in float3.
  94153. * @returns this effect.
  94154. */
  94155. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  94156. /**
  94157. * Sets a Vector4 on a uniform variable.
  94158. * @param uniformName Name of the variable.
  94159. * @param vector4 Value to be set.
  94160. * @returns this effect.
  94161. */
  94162. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  94163. /**
  94164. * Sets a float4 on a uniform variable.
  94165. * @param uniformName Name of the variable.
  94166. * @param x First float in float4.
  94167. * @param y Second float in float4.
  94168. * @param z Third float in float4.
  94169. * @param w Fourth float in float4.
  94170. * @returns this effect.
  94171. */
  94172. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  94173. /**
  94174. * Sets a Color3 on a uniform variable.
  94175. * @param uniformName Name of the variable.
  94176. * @param color3 Value to be set.
  94177. * @returns this effect.
  94178. */
  94179. setColor3(uniformName: string, color3: IColor3Like): Effect;
  94180. /**
  94181. * Sets a Color4 on a uniform variable.
  94182. * @param uniformName Name of the variable.
  94183. * @param color3 Value to be set.
  94184. * @param alpha Alpha value to be set.
  94185. * @returns this effect.
  94186. */
  94187. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  94188. /**
  94189. * Sets a Color4 on a uniform variable
  94190. * @param uniformName defines the name of the variable
  94191. * @param color4 defines the value to be set
  94192. * @returns this effect.
  94193. */
  94194. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  94195. /** Release all associated resources */
  94196. dispose(): void;
  94197. /**
  94198. * This function will add a new shader to the shader store
  94199. * @param name the name of the shader
  94200. * @param pixelShader optional pixel shader content
  94201. * @param vertexShader optional vertex shader content
  94202. */
  94203. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  94204. /**
  94205. * Store of each shader (The can be looked up using effect.key)
  94206. */
  94207. static ShadersStore: {
  94208. [key: string]: string;
  94209. };
  94210. /**
  94211. * Store of each included file for a shader (The can be looked up using effect.key)
  94212. */
  94213. static IncludesShadersStore: {
  94214. [key: string]: string;
  94215. };
  94216. /**
  94217. * Resets the cache of effects.
  94218. */
  94219. static ResetCache(): void;
  94220. }
  94221. }
  94222. declare module BABYLON {
  94223. /**
  94224. * Uniform buffer objects.
  94225. *
  94226. * Handles blocks of uniform on the GPU.
  94227. *
  94228. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  94229. *
  94230. * For more information, please refer to :
  94231. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  94232. */
  94233. export class UniformBuffer {
  94234. private _engine;
  94235. private _buffer;
  94236. private _data;
  94237. private _bufferData;
  94238. private _dynamic?;
  94239. private _uniformLocations;
  94240. private _uniformSizes;
  94241. private _uniformLocationPointer;
  94242. private _needSync;
  94243. private _noUBO;
  94244. private _currentEffect;
  94245. private static _MAX_UNIFORM_SIZE;
  94246. private static _tempBuffer;
  94247. /**
  94248. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  94249. * This is dynamic to allow compat with webgl 1 and 2.
  94250. * You will need to pass the name of the uniform as well as the value.
  94251. */
  94252. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  94253. /**
  94254. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  94255. * This is dynamic to allow compat with webgl 1 and 2.
  94256. * You will need to pass the name of the uniform as well as the value.
  94257. */
  94258. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  94259. /**
  94260. * Lambda to Update a single float in a uniform buffer.
  94261. * This is dynamic to allow compat with webgl 1 and 2.
  94262. * You will need to pass the name of the uniform as well as the value.
  94263. */
  94264. updateFloat: (name: string, x: number) => void;
  94265. /**
  94266. * Lambda to Update a vec2 of float in a uniform buffer.
  94267. * This is dynamic to allow compat with webgl 1 and 2.
  94268. * You will need to pass the name of the uniform as well as the value.
  94269. */
  94270. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  94271. /**
  94272. * Lambda to Update a vec3 of float in a uniform buffer.
  94273. * This is dynamic to allow compat with webgl 1 and 2.
  94274. * You will need to pass the name of the uniform as well as the value.
  94275. */
  94276. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  94277. /**
  94278. * Lambda to Update a vec4 of float in a uniform buffer.
  94279. * This is dynamic to allow compat with webgl 1 and 2.
  94280. * You will need to pass the name of the uniform as well as the value.
  94281. */
  94282. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  94283. /**
  94284. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  94285. * This is dynamic to allow compat with webgl 1 and 2.
  94286. * You will need to pass the name of the uniform as well as the value.
  94287. */
  94288. updateMatrix: (name: string, mat: Matrix) => void;
  94289. /**
  94290. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  94291. * This is dynamic to allow compat with webgl 1 and 2.
  94292. * You will need to pass the name of the uniform as well as the value.
  94293. */
  94294. updateVector3: (name: string, vector: Vector3) => void;
  94295. /**
  94296. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  94297. * This is dynamic to allow compat with webgl 1 and 2.
  94298. * You will need to pass the name of the uniform as well as the value.
  94299. */
  94300. updateVector4: (name: string, vector: Vector4) => void;
  94301. /**
  94302. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  94303. * This is dynamic to allow compat with webgl 1 and 2.
  94304. * You will need to pass the name of the uniform as well as the value.
  94305. */
  94306. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  94307. /**
  94308. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  94309. * This is dynamic to allow compat with webgl 1 and 2.
  94310. * You will need to pass the name of the uniform as well as the value.
  94311. */
  94312. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  94313. /**
  94314. * Instantiates a new Uniform buffer objects.
  94315. *
  94316. * Handles blocks of uniform on the GPU.
  94317. *
  94318. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  94319. *
  94320. * For more information, please refer to :
  94321. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  94322. * @param engine Define the engine the buffer is associated with
  94323. * @param data Define the data contained in the buffer
  94324. * @param dynamic Define if the buffer is updatable
  94325. */
  94326. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  94327. /**
  94328. * Indicates if the buffer is using the WebGL2 UBO implementation,
  94329. * or just falling back on setUniformXXX calls.
  94330. */
  94331. readonly useUbo: boolean;
  94332. /**
  94333. * Indicates if the WebGL underlying uniform buffer is in sync
  94334. * with the javascript cache data.
  94335. */
  94336. readonly isSync: boolean;
  94337. /**
  94338. * Indicates if the WebGL underlying uniform buffer is dynamic.
  94339. * Also, a dynamic UniformBuffer will disable cache verification and always
  94340. * update the underlying WebGL uniform buffer to the GPU.
  94341. * @returns if Dynamic, otherwise false
  94342. */
  94343. isDynamic(): boolean;
  94344. /**
  94345. * The data cache on JS side.
  94346. * @returns the underlying data as a float array
  94347. */
  94348. getData(): Float32Array;
  94349. /**
  94350. * The underlying WebGL Uniform buffer.
  94351. * @returns the webgl buffer
  94352. */
  94353. getBuffer(): Nullable<DataBuffer>;
  94354. /**
  94355. * std140 layout specifies how to align data within an UBO structure.
  94356. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  94357. * for specs.
  94358. */
  94359. private _fillAlignment;
  94360. /**
  94361. * Adds an uniform in the buffer.
  94362. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  94363. * for the layout to be correct !
  94364. * @param name Name of the uniform, as used in the uniform block in the shader.
  94365. * @param size Data size, or data directly.
  94366. */
  94367. addUniform(name: string, size: number | number[]): void;
  94368. /**
  94369. * Adds a Matrix 4x4 to the uniform buffer.
  94370. * @param name Name of the uniform, as used in the uniform block in the shader.
  94371. * @param mat A 4x4 matrix.
  94372. */
  94373. addMatrix(name: string, mat: Matrix): void;
  94374. /**
  94375. * Adds a vec2 to the uniform buffer.
  94376. * @param name Name of the uniform, as used in the uniform block in the shader.
  94377. * @param x Define the x component value of the vec2
  94378. * @param y Define the y component value of the vec2
  94379. */
  94380. addFloat2(name: string, x: number, y: number): void;
  94381. /**
  94382. * Adds a vec3 to the uniform buffer.
  94383. * @param name Name of the uniform, as used in the uniform block in the shader.
  94384. * @param x Define the x component value of the vec3
  94385. * @param y Define the y component value of the vec3
  94386. * @param z Define the z component value of the vec3
  94387. */
  94388. addFloat3(name: string, x: number, y: number, z: number): void;
  94389. /**
  94390. * Adds a vec3 to the uniform buffer.
  94391. * @param name Name of the uniform, as used in the uniform block in the shader.
  94392. * @param color Define the vec3 from a Color
  94393. */
  94394. addColor3(name: string, color: Color3): void;
  94395. /**
  94396. * Adds a vec4 to the uniform buffer.
  94397. * @param name Name of the uniform, as used in the uniform block in the shader.
  94398. * @param color Define the rgb components from a Color
  94399. * @param alpha Define the a component of the vec4
  94400. */
  94401. addColor4(name: string, color: Color3, alpha: number): void;
  94402. /**
  94403. * Adds a vec3 to the uniform buffer.
  94404. * @param name Name of the uniform, as used in the uniform block in the shader.
  94405. * @param vector Define the vec3 components from a Vector
  94406. */
  94407. addVector3(name: string, vector: Vector3): void;
  94408. /**
  94409. * Adds a Matrix 3x3 to the uniform buffer.
  94410. * @param name Name of the uniform, as used in the uniform block in the shader.
  94411. */
  94412. addMatrix3x3(name: string): void;
  94413. /**
  94414. * Adds a Matrix 2x2 to the uniform buffer.
  94415. * @param name Name of the uniform, as used in the uniform block in the shader.
  94416. */
  94417. addMatrix2x2(name: string): void;
  94418. /**
  94419. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  94420. */
  94421. create(): void;
  94422. /** @hidden */
  94423. _rebuild(): void;
  94424. /**
  94425. * Updates the WebGL Uniform Buffer on the GPU.
  94426. * If the `dynamic` flag is set to true, no cache comparison is done.
  94427. * Otherwise, the buffer will be updated only if the cache differs.
  94428. */
  94429. update(): void;
  94430. /**
  94431. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  94432. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  94433. * @param data Define the flattened data
  94434. * @param size Define the size of the data.
  94435. */
  94436. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  94437. private _valueCache;
  94438. private _cacheMatrix;
  94439. private _updateMatrix3x3ForUniform;
  94440. private _updateMatrix3x3ForEffect;
  94441. private _updateMatrix2x2ForEffect;
  94442. private _updateMatrix2x2ForUniform;
  94443. private _updateFloatForEffect;
  94444. private _updateFloatForUniform;
  94445. private _updateFloat2ForEffect;
  94446. private _updateFloat2ForUniform;
  94447. private _updateFloat3ForEffect;
  94448. private _updateFloat3ForUniform;
  94449. private _updateFloat4ForEffect;
  94450. private _updateFloat4ForUniform;
  94451. private _updateMatrixForEffect;
  94452. private _updateMatrixForUniform;
  94453. private _updateVector3ForEffect;
  94454. private _updateVector3ForUniform;
  94455. private _updateVector4ForEffect;
  94456. private _updateVector4ForUniform;
  94457. private _updateColor3ForEffect;
  94458. private _updateColor3ForUniform;
  94459. private _updateColor4ForEffect;
  94460. private _updateColor4ForUniform;
  94461. /**
  94462. * Sets a sampler uniform on the effect.
  94463. * @param name Define the name of the sampler.
  94464. * @param texture Define the texture to set in the sampler
  94465. */
  94466. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  94467. /**
  94468. * Directly updates the value of the uniform in the cache AND on the GPU.
  94469. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  94470. * @param data Define the flattened data
  94471. */
  94472. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  94473. /**
  94474. * Binds this uniform buffer to an effect.
  94475. * @param effect Define the effect to bind the buffer to
  94476. * @param name Name of the uniform block in the shader.
  94477. */
  94478. bindToEffect(effect: Effect, name: string): void;
  94479. /**
  94480. * Disposes the uniform buffer.
  94481. */
  94482. dispose(): void;
  94483. }
  94484. }
  94485. declare module BABYLON {
  94486. /**
  94487. * Class used to work with sound analyzer using fast fourier transform (FFT)
  94488. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  94489. */
  94490. export class Analyser {
  94491. /**
  94492. * Gets or sets the smoothing
  94493. * @ignorenaming
  94494. */
  94495. SMOOTHING: number;
  94496. /**
  94497. * Gets or sets the FFT table size
  94498. * @ignorenaming
  94499. */
  94500. FFT_SIZE: number;
  94501. /**
  94502. * Gets or sets the bar graph amplitude
  94503. * @ignorenaming
  94504. */
  94505. BARGRAPHAMPLITUDE: number;
  94506. /**
  94507. * Gets or sets the position of the debug canvas
  94508. * @ignorenaming
  94509. */
  94510. DEBUGCANVASPOS: {
  94511. x: number;
  94512. y: number;
  94513. };
  94514. /**
  94515. * Gets or sets the debug canvas size
  94516. * @ignorenaming
  94517. */
  94518. DEBUGCANVASSIZE: {
  94519. width: number;
  94520. height: number;
  94521. };
  94522. private _byteFreqs;
  94523. private _byteTime;
  94524. private _floatFreqs;
  94525. private _webAudioAnalyser;
  94526. private _debugCanvas;
  94527. private _debugCanvasContext;
  94528. private _scene;
  94529. private _registerFunc;
  94530. private _audioEngine;
  94531. /**
  94532. * Creates a new analyser
  94533. * @param scene defines hosting scene
  94534. */
  94535. constructor(scene: Scene);
  94536. /**
  94537. * Get the number of data values you will have to play with for the visualization
  94538. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  94539. * @returns a number
  94540. */
  94541. getFrequencyBinCount(): number;
  94542. /**
  94543. * Gets the current frequency data as a byte array
  94544. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  94545. * @returns a Uint8Array
  94546. */
  94547. getByteFrequencyData(): Uint8Array;
  94548. /**
  94549. * Gets the current waveform as a byte array
  94550. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  94551. * @returns a Uint8Array
  94552. */
  94553. getByteTimeDomainData(): Uint8Array;
  94554. /**
  94555. * Gets the current frequency data as a float array
  94556. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  94557. * @returns a Float32Array
  94558. */
  94559. getFloatFrequencyData(): Float32Array;
  94560. /**
  94561. * Renders the debug canvas
  94562. */
  94563. drawDebugCanvas(): void;
  94564. /**
  94565. * Stops rendering the debug canvas and removes it
  94566. */
  94567. stopDebugCanvas(): void;
  94568. /**
  94569. * Connects two audio nodes
  94570. * @param inputAudioNode defines first node to connect
  94571. * @param outputAudioNode defines second node to connect
  94572. */
  94573. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  94574. /**
  94575. * Releases all associated resources
  94576. */
  94577. dispose(): void;
  94578. }
  94579. }
  94580. declare module BABYLON {
  94581. /**
  94582. * This represents an audio engine and it is responsible
  94583. * to play, synchronize and analyse sounds throughout the application.
  94584. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  94585. */
  94586. export interface IAudioEngine extends IDisposable {
  94587. /**
  94588. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  94589. */
  94590. readonly canUseWebAudio: boolean;
  94591. /**
  94592. * Gets the current AudioContext if available.
  94593. */
  94594. readonly audioContext: Nullable<AudioContext>;
  94595. /**
  94596. * The master gain node defines the global audio volume of your audio engine.
  94597. */
  94598. readonly masterGain: GainNode;
  94599. /**
  94600. * Gets whether or not mp3 are supported by your browser.
  94601. */
  94602. readonly isMP3supported: boolean;
  94603. /**
  94604. * Gets whether or not ogg are supported by your browser.
  94605. */
  94606. readonly isOGGsupported: boolean;
  94607. /**
  94608. * Defines if Babylon should emit a warning if WebAudio is not supported.
  94609. * @ignoreNaming
  94610. */
  94611. WarnedWebAudioUnsupported: boolean;
  94612. /**
  94613. * Defines if the audio engine relies on a custom unlocked button.
  94614. * In this case, the embedded button will not be displayed.
  94615. */
  94616. useCustomUnlockedButton: boolean;
  94617. /**
  94618. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  94619. */
  94620. readonly unlocked: boolean;
  94621. /**
  94622. * Event raised when audio has been unlocked on the browser.
  94623. */
  94624. onAudioUnlockedObservable: Observable<AudioEngine>;
  94625. /**
  94626. * Event raised when audio has been locked on the browser.
  94627. */
  94628. onAudioLockedObservable: Observable<AudioEngine>;
  94629. /**
  94630. * Flags the audio engine in Locked state.
  94631. * This happens due to new browser policies preventing audio to autoplay.
  94632. */
  94633. lock(): void;
  94634. /**
  94635. * Unlocks the audio engine once a user action has been done on the dom.
  94636. * This is helpful to resume play once browser policies have been satisfied.
  94637. */
  94638. unlock(): void;
  94639. }
  94640. /**
  94641. * This represents the default audio engine used in babylon.
  94642. * It is responsible to play, synchronize and analyse sounds throughout the application.
  94643. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  94644. */
  94645. export class AudioEngine implements IAudioEngine {
  94646. private _audioContext;
  94647. private _audioContextInitialized;
  94648. private _muteButton;
  94649. private _hostElement;
  94650. /**
  94651. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  94652. */
  94653. canUseWebAudio: boolean;
  94654. /**
  94655. * The master gain node defines the global audio volume of your audio engine.
  94656. */
  94657. masterGain: GainNode;
  94658. /**
  94659. * Defines if Babylon should emit a warning if WebAudio is not supported.
  94660. * @ignoreNaming
  94661. */
  94662. WarnedWebAudioUnsupported: boolean;
  94663. /**
  94664. * Gets whether or not mp3 are supported by your browser.
  94665. */
  94666. isMP3supported: boolean;
  94667. /**
  94668. * Gets whether or not ogg are supported by your browser.
  94669. */
  94670. isOGGsupported: boolean;
  94671. /**
  94672. * Gets whether audio has been unlocked on the device.
  94673. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  94674. * a user interaction has happened.
  94675. */
  94676. unlocked: boolean;
  94677. /**
  94678. * Defines if the audio engine relies on a custom unlocked button.
  94679. * In this case, the embedded button will not be displayed.
  94680. */
  94681. useCustomUnlockedButton: boolean;
  94682. /**
  94683. * Event raised when audio has been unlocked on the browser.
  94684. */
  94685. onAudioUnlockedObservable: Observable<AudioEngine>;
  94686. /**
  94687. * Event raised when audio has been locked on the browser.
  94688. */
  94689. onAudioLockedObservable: Observable<AudioEngine>;
  94690. /**
  94691. * Gets the current AudioContext if available.
  94692. */
  94693. readonly audioContext: Nullable<AudioContext>;
  94694. private _connectedAnalyser;
  94695. /**
  94696. * Instantiates a new audio engine.
  94697. *
  94698. * There should be only one per page as some browsers restrict the number
  94699. * of audio contexts you can create.
  94700. * @param hostElement defines the host element where to display the mute icon if necessary
  94701. */
  94702. constructor(hostElement?: Nullable<HTMLElement>);
  94703. /**
  94704. * Flags the audio engine in Locked state.
  94705. * This happens due to new browser policies preventing audio to autoplay.
  94706. */
  94707. lock(): void;
  94708. /**
  94709. * Unlocks the audio engine once a user action has been done on the dom.
  94710. * This is helpful to resume play once browser policies have been satisfied.
  94711. */
  94712. unlock(): void;
  94713. private _resumeAudioContext;
  94714. private _initializeAudioContext;
  94715. private _tryToRun;
  94716. private _triggerRunningState;
  94717. private _triggerSuspendedState;
  94718. private _displayMuteButton;
  94719. private _moveButtonToTopLeft;
  94720. private _onResize;
  94721. private _hideMuteButton;
  94722. /**
  94723. * Destroy and release the resources associated with the audio ccontext.
  94724. */
  94725. dispose(): void;
  94726. /**
  94727. * Gets the global volume sets on the master gain.
  94728. * @returns the global volume if set or -1 otherwise
  94729. */
  94730. getGlobalVolume(): number;
  94731. /**
  94732. * Sets the global volume of your experience (sets on the master gain).
  94733. * @param newVolume Defines the new global volume of the application
  94734. */
  94735. setGlobalVolume(newVolume: number): void;
  94736. /**
  94737. * Connect the audio engine to an audio analyser allowing some amazing
  94738. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  94739. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  94740. * @param analyser The analyser to connect to the engine
  94741. */
  94742. connectToAnalyser(analyser: Analyser): void;
  94743. }
  94744. }
  94745. declare module BABYLON {
  94746. /**
  94747. * Interface used to present a loading screen while loading a scene
  94748. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  94749. */
  94750. export interface ILoadingScreen {
  94751. /**
  94752. * Function called to display the loading screen
  94753. */
  94754. displayLoadingUI: () => void;
  94755. /**
  94756. * Function called to hide the loading screen
  94757. */
  94758. hideLoadingUI: () => void;
  94759. /**
  94760. * Gets or sets the color to use for the background
  94761. */
  94762. loadingUIBackgroundColor: string;
  94763. /**
  94764. * Gets or sets the text to display while loading
  94765. */
  94766. loadingUIText: string;
  94767. }
  94768. /**
  94769. * Class used for the default loading screen
  94770. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  94771. */
  94772. export class DefaultLoadingScreen implements ILoadingScreen {
  94773. private _renderingCanvas;
  94774. private _loadingText;
  94775. private _loadingDivBackgroundColor;
  94776. private _loadingDiv;
  94777. private _loadingTextDiv;
  94778. /** Gets or sets the logo url to use for the default loading screen */
  94779. static DefaultLogoUrl: string;
  94780. /** Gets or sets the spinner url to use for the default loading screen */
  94781. static DefaultSpinnerUrl: string;
  94782. /**
  94783. * Creates a new default loading screen
  94784. * @param _renderingCanvas defines the canvas used to render the scene
  94785. * @param _loadingText defines the default text to display
  94786. * @param _loadingDivBackgroundColor defines the default background color
  94787. */
  94788. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  94789. /**
  94790. * Function called to display the loading screen
  94791. */
  94792. displayLoadingUI(): void;
  94793. /**
  94794. * Function called to hide the loading screen
  94795. */
  94796. hideLoadingUI(): void;
  94797. /**
  94798. * Gets or sets the text to display while loading
  94799. */
  94800. loadingUIText: string;
  94801. /**
  94802. * Gets or sets the color to use for the background
  94803. */
  94804. loadingUIBackgroundColor: string;
  94805. private _resizeLoadingUI;
  94806. }
  94807. }
  94808. declare module BABYLON {
  94809. /** @hidden */
  94810. export class WebGLPipelineContext implements IPipelineContext {
  94811. engine: Engine;
  94812. program: Nullable<WebGLProgram>;
  94813. context?: WebGLRenderingContext;
  94814. vertexShader?: WebGLShader;
  94815. fragmentShader?: WebGLShader;
  94816. isParallelCompiled: boolean;
  94817. onCompiled?: () => void;
  94818. transformFeedback?: WebGLTransformFeedback | null;
  94819. readonly isAsync: boolean;
  94820. readonly isReady: boolean;
  94821. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  94822. }
  94823. }
  94824. declare module BABYLON {
  94825. /** @hidden */
  94826. export class WebGLDataBuffer extends DataBuffer {
  94827. private _buffer;
  94828. constructor(resource: WebGLBuffer);
  94829. readonly underlyingResource: any;
  94830. }
  94831. }
  94832. declare module BABYLON {
  94833. /** @hidden */
  94834. export class WebGL2ShaderProcessor implements IShaderProcessor {
  94835. attributeProcessor(attribute: string): string;
  94836. varyingProcessor(varying: string, isFragment: boolean): string;
  94837. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  94838. }
  94839. }
  94840. declare module BABYLON {
  94841. /**
  94842. * This class is used to track a performance counter which is number based.
  94843. * The user has access to many properties which give statistics of different nature.
  94844. *
  94845. * The implementer can track two kinds of Performance Counter: time and count.
  94846. * 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.
  94847. * 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.
  94848. */
  94849. export class PerfCounter {
  94850. /**
  94851. * Gets or sets a global boolean to turn on and off all the counters
  94852. */
  94853. static Enabled: boolean;
  94854. /**
  94855. * Returns the smallest value ever
  94856. */
  94857. readonly min: number;
  94858. /**
  94859. * Returns the biggest value ever
  94860. */
  94861. readonly max: number;
  94862. /**
  94863. * Returns the average value since the performance counter is running
  94864. */
  94865. readonly average: number;
  94866. /**
  94867. * Returns the average value of the last second the counter was monitored
  94868. */
  94869. readonly lastSecAverage: number;
  94870. /**
  94871. * Returns the current value
  94872. */
  94873. readonly current: number;
  94874. /**
  94875. * Gets the accumulated total
  94876. */
  94877. readonly total: number;
  94878. /**
  94879. * Gets the total value count
  94880. */
  94881. readonly count: number;
  94882. /**
  94883. * Creates a new counter
  94884. */
  94885. constructor();
  94886. /**
  94887. * Call this method to start monitoring a new frame.
  94888. * 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.
  94889. */
  94890. fetchNewFrame(): void;
  94891. /**
  94892. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  94893. * @param newCount the count value to add to the monitored count
  94894. * @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.
  94895. */
  94896. addCount(newCount: number, fetchResult: boolean): void;
  94897. /**
  94898. * Start monitoring this performance counter
  94899. */
  94900. beginMonitoring(): void;
  94901. /**
  94902. * Compute the time lapsed since the previous beginMonitoring() call.
  94903. * @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
  94904. */
  94905. endMonitoring(newFrame?: boolean): void;
  94906. private _fetchResult;
  94907. private _startMonitoringTime;
  94908. private _min;
  94909. private _max;
  94910. private _average;
  94911. private _current;
  94912. private _totalValueCount;
  94913. private _totalAccumulated;
  94914. private _lastSecAverage;
  94915. private _lastSecAccumulated;
  94916. private _lastSecTime;
  94917. private _lastSecValueCount;
  94918. }
  94919. }
  94920. declare module BABYLON {
  94921. /**
  94922. * Interface for any object that can request an animation frame
  94923. */
  94924. export interface ICustomAnimationFrameRequester {
  94925. /**
  94926. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  94927. */
  94928. renderFunction?: Function;
  94929. /**
  94930. * Called to request the next frame to render to
  94931. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  94932. */
  94933. requestAnimationFrame: Function;
  94934. /**
  94935. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  94936. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  94937. */
  94938. requestID?: number;
  94939. }
  94940. }
  94941. declare module BABYLON {
  94942. /**
  94943. * Settings for finer control over video usage
  94944. */
  94945. export interface VideoTextureSettings {
  94946. /**
  94947. * Applies `autoplay` to video, if specified
  94948. */
  94949. autoPlay?: boolean;
  94950. /**
  94951. * Applies `loop` to video, if specified
  94952. */
  94953. loop?: boolean;
  94954. /**
  94955. * Automatically updates internal texture from video at every frame in the render loop
  94956. */
  94957. autoUpdateTexture: boolean;
  94958. /**
  94959. * Image src displayed during the video loading or until the user interacts with the video.
  94960. */
  94961. poster?: string;
  94962. }
  94963. /**
  94964. * If you want to display a video in your scene, this is the special texture for that.
  94965. * This special texture works similar to other textures, with the exception of a few parameters.
  94966. * @see https://doc.babylonjs.com/how_to/video_texture
  94967. */
  94968. export class VideoTexture extends Texture {
  94969. /**
  94970. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  94971. */
  94972. readonly autoUpdateTexture: boolean;
  94973. /**
  94974. * The video instance used by the texture internally
  94975. */
  94976. readonly video: HTMLVideoElement;
  94977. private _onUserActionRequestedObservable;
  94978. /**
  94979. * Event triggerd when a dom action is required by the user to play the video.
  94980. * This happens due to recent changes in browser policies preventing video to auto start.
  94981. */
  94982. readonly onUserActionRequestedObservable: Observable<Texture>;
  94983. private _generateMipMaps;
  94984. private _engine;
  94985. private _stillImageCaptured;
  94986. private _displayingPosterTexture;
  94987. private _settings;
  94988. private _createInternalTextureOnEvent;
  94989. private _frameId;
  94990. /**
  94991. * Creates a video texture.
  94992. * If you want to display a video in your scene, this is the special texture for that.
  94993. * This special texture works similar to other textures, with the exception of a few parameters.
  94994. * @see https://doc.babylonjs.com/how_to/video_texture
  94995. * @param name optional name, will detect from video source, if not defined
  94996. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  94997. * @param scene is obviously the current scene.
  94998. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  94999. * @param invertY is false by default but can be used to invert video on Y axis
  95000. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  95001. * @param settings allows finer control over video usage
  95002. */
  95003. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  95004. private _getName;
  95005. private _getVideo;
  95006. private _createInternalTexture;
  95007. private reset;
  95008. /**
  95009. * @hidden Internal method to initiate `update`.
  95010. */
  95011. _rebuild(): void;
  95012. /**
  95013. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  95014. */
  95015. update(): void;
  95016. /**
  95017. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  95018. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  95019. */
  95020. updateTexture(isVisible: boolean): void;
  95021. protected _updateInternalTexture: () => void;
  95022. /**
  95023. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  95024. * @param url New url.
  95025. */
  95026. updateURL(url: string): void;
  95027. /**
  95028. * Dispose the texture and release its associated resources.
  95029. */
  95030. dispose(): void;
  95031. /**
  95032. * Creates a video texture straight from a stream.
  95033. * @param scene Define the scene the texture should be created in
  95034. * @param stream Define the stream the texture should be created from
  95035. * @returns The created video texture as a promise
  95036. */
  95037. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  95038. /**
  95039. * Creates a video texture straight from your WebCam video feed.
  95040. * @param scene Define the scene the texture should be created in
  95041. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  95042. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  95043. * @returns The created video texture as a promise
  95044. */
  95045. static CreateFromWebCamAsync(scene: Scene, constraints: {
  95046. minWidth: number;
  95047. maxWidth: number;
  95048. minHeight: number;
  95049. maxHeight: number;
  95050. deviceId: string;
  95051. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  95052. /**
  95053. * Creates a video texture straight from your WebCam video feed.
  95054. * @param scene Define the scene the texture should be created in
  95055. * @param onReady Define a callback to triggered once the texture will be ready
  95056. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  95057. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  95058. */
  95059. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  95060. minWidth: number;
  95061. maxWidth: number;
  95062. minHeight: number;
  95063. maxHeight: number;
  95064. deviceId: string;
  95065. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  95066. }
  95067. }
  95068. declare module BABYLON {
  95069. /**
  95070. * Defines the interface used by objects containing a viewport (like a camera)
  95071. */
  95072. interface IViewportOwnerLike {
  95073. /**
  95074. * Gets or sets the viewport
  95075. */
  95076. viewport: IViewportLike;
  95077. }
  95078. /**
  95079. * Interface for attribute information associated with buffer instanciation
  95080. */
  95081. export class InstancingAttributeInfo {
  95082. /**
  95083. * Index/offset of the attribute in the vertex shader
  95084. */
  95085. index: number;
  95086. /**
  95087. * size of the attribute, 1, 2, 3 or 4
  95088. */
  95089. attributeSize: number;
  95090. /**
  95091. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  95092. * default is FLOAT
  95093. */
  95094. attribyteType: number;
  95095. /**
  95096. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  95097. */
  95098. normalized: boolean;
  95099. /**
  95100. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  95101. */
  95102. offset: number;
  95103. /**
  95104. * Name of the GLSL attribute, for debugging purpose only
  95105. */
  95106. attributeName: string;
  95107. }
  95108. /**
  95109. * Define options used to create a depth texture
  95110. */
  95111. export class DepthTextureCreationOptions {
  95112. /** Specifies whether or not a stencil should be allocated in the texture */
  95113. generateStencil?: boolean;
  95114. /** Specifies whether or not bilinear filtering is enable on the texture */
  95115. bilinearFiltering?: boolean;
  95116. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  95117. comparisonFunction?: number;
  95118. /** Specifies if the created texture is a cube texture */
  95119. isCube?: boolean;
  95120. }
  95121. /**
  95122. * Class used to describe the capabilities of the engine relatively to the current browser
  95123. */
  95124. export class EngineCapabilities {
  95125. /** Maximum textures units per fragment shader */
  95126. maxTexturesImageUnits: number;
  95127. /** Maximum texture units per vertex shader */
  95128. maxVertexTextureImageUnits: number;
  95129. /** Maximum textures units in the entire pipeline */
  95130. maxCombinedTexturesImageUnits: number;
  95131. /** Maximum texture size */
  95132. maxTextureSize: number;
  95133. /** Maximum cube texture size */
  95134. maxCubemapTextureSize: number;
  95135. /** Maximum render texture size */
  95136. maxRenderTextureSize: number;
  95137. /** Maximum number of vertex attributes */
  95138. maxVertexAttribs: number;
  95139. /** Maximum number of varyings */
  95140. maxVaryingVectors: number;
  95141. /** Maximum number of uniforms per vertex shader */
  95142. maxVertexUniformVectors: number;
  95143. /** Maximum number of uniforms per fragment shader */
  95144. maxFragmentUniformVectors: number;
  95145. /** Defines if standard derivates (dx/dy) are supported */
  95146. standardDerivatives: boolean;
  95147. /** Defines if s3tc texture compression is supported */
  95148. s3tc: Nullable<WEBGL_compressed_texture_s3tc>;
  95149. /** Defines if pvrtc texture compression is supported */
  95150. pvrtc: any;
  95151. /** Defines if etc1 texture compression is supported */
  95152. etc1: any;
  95153. /** Defines if etc2 texture compression is supported */
  95154. etc2: any;
  95155. /** Defines if astc texture compression is supported */
  95156. astc: any;
  95157. /** Defines if float textures are supported */
  95158. textureFloat: boolean;
  95159. /** Defines if vertex array objects are supported */
  95160. vertexArrayObject: boolean;
  95161. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  95162. textureAnisotropicFilterExtension: Nullable<EXT_texture_filter_anisotropic>;
  95163. /** Gets the maximum level of anisotropy supported */
  95164. maxAnisotropy: number;
  95165. /** Defines if instancing is supported */
  95166. instancedArrays: boolean;
  95167. /** Defines if 32 bits indices are supported */
  95168. uintIndices: boolean;
  95169. /** Defines if high precision shaders are supported */
  95170. highPrecisionShaderSupported: boolean;
  95171. /** Defines if depth reading in the fragment shader is supported */
  95172. fragmentDepthSupported: boolean;
  95173. /** Defines if float texture linear filtering is supported*/
  95174. textureFloatLinearFiltering: boolean;
  95175. /** Defines if rendering to float textures is supported */
  95176. textureFloatRender: boolean;
  95177. /** Defines if half float textures are supported*/
  95178. textureHalfFloat: boolean;
  95179. /** Defines if half float texture linear filtering is supported*/
  95180. textureHalfFloatLinearFiltering: boolean;
  95181. /** Defines if rendering to half float textures is supported */
  95182. textureHalfFloatRender: boolean;
  95183. /** Defines if textureLOD shader command is supported */
  95184. textureLOD: boolean;
  95185. /** Defines if draw buffers extension is supported */
  95186. drawBuffersExtension: boolean;
  95187. /** Defines if depth textures are supported */
  95188. depthTextureExtension: boolean;
  95189. /** Defines if float color buffer are supported */
  95190. colorBufferFloat: boolean;
  95191. /** Gets disjoint timer query extension (null if not supported) */
  95192. timerQuery: EXT_disjoint_timer_query;
  95193. /** Defines if timestamp can be used with timer query */
  95194. canUseTimestampForTimerQuery: boolean;
  95195. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  95196. multiview: any;
  95197. /** Function used to let the system compiles shaders in background */
  95198. parallelShaderCompile: {
  95199. COMPLETION_STATUS_KHR: number;
  95200. };
  95201. /** Max number of texture samples for MSAA */
  95202. maxMSAASamples: number;
  95203. }
  95204. /** Interface defining initialization parameters for Engine class */
  95205. export interface EngineOptions extends WebGLContextAttributes {
  95206. /**
  95207. * Defines if the engine should no exceed a specified device ratio
  95208. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  95209. */
  95210. limitDeviceRatio?: number;
  95211. /**
  95212. * Defines if webvr should be enabled automatically
  95213. * @see http://doc.babylonjs.com/how_to/webvr_camera
  95214. */
  95215. autoEnableWebVR?: boolean;
  95216. /**
  95217. * Defines if webgl2 should be turned off even if supported
  95218. * @see http://doc.babylonjs.com/features/webgl2
  95219. */
  95220. disableWebGL2Support?: boolean;
  95221. /**
  95222. * Defines if webaudio should be initialized as well
  95223. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  95224. */
  95225. audioEngine?: boolean;
  95226. /**
  95227. * Defines if animations should run using a deterministic lock step
  95228. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  95229. */
  95230. deterministicLockstep?: boolean;
  95231. /** Defines the maximum steps to use with deterministic lock step mode */
  95232. lockstepMaxSteps?: number;
  95233. /**
  95234. * Defines that engine should ignore context lost events
  95235. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  95236. */
  95237. doNotHandleContextLost?: boolean;
  95238. /**
  95239. * Defines that engine should ignore modifying touch action attribute and style
  95240. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  95241. */
  95242. doNotHandleTouchAction?: boolean;
  95243. /**
  95244. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  95245. */
  95246. useHighPrecisionFloats?: boolean;
  95247. }
  95248. /**
  95249. * Defines the interface used by display changed events
  95250. */
  95251. export interface IDisplayChangedEventArgs {
  95252. /** Gets the vrDisplay object (if any) */
  95253. vrDisplay: Nullable<any>;
  95254. /** Gets a boolean indicating if webVR is supported */
  95255. vrSupported: boolean;
  95256. }
  95257. /**
  95258. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  95259. */
  95260. export class Engine {
  95261. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  95262. static ExceptionList: ({
  95263. key: string;
  95264. capture: string;
  95265. captureConstraint: number;
  95266. targets: string[];
  95267. } | {
  95268. key: string;
  95269. capture: null;
  95270. captureConstraint: null;
  95271. targets: string[];
  95272. })[];
  95273. /** Gets the list of created engines */
  95274. static readonly Instances: Engine[];
  95275. /**
  95276. * Gets the latest created engine
  95277. */
  95278. static readonly LastCreatedEngine: Nullable<Engine>;
  95279. /**
  95280. * Gets the latest created scene
  95281. */
  95282. static readonly LastCreatedScene: Nullable<Scene>;
  95283. /**
  95284. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  95285. * @param flag defines which part of the materials must be marked as dirty
  95286. * @param predicate defines a predicate used to filter which materials should be affected
  95287. */
  95288. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  95289. /** @hidden */
  95290. static _TextureLoaders: IInternalTextureLoader[];
  95291. /** Defines that alpha blending is disabled */
  95292. static readonly ALPHA_DISABLE: number;
  95293. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  95294. static readonly ALPHA_ADD: number;
  95295. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  95296. static readonly ALPHA_COMBINE: number;
  95297. /** Defines that alpha blending to DEST - SRC * DEST */
  95298. static readonly ALPHA_SUBTRACT: number;
  95299. /** Defines that alpha blending to SRC * DEST */
  95300. static readonly ALPHA_MULTIPLY: number;
  95301. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  95302. static readonly ALPHA_MAXIMIZED: number;
  95303. /** Defines that alpha blending to SRC + DEST */
  95304. static readonly ALPHA_ONEONE: number;
  95305. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  95306. static readonly ALPHA_PREMULTIPLIED: number;
  95307. /**
  95308. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  95309. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  95310. */
  95311. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  95312. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  95313. static readonly ALPHA_INTERPOLATE: number;
  95314. /**
  95315. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  95316. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  95317. */
  95318. static readonly ALPHA_SCREENMODE: number;
  95319. /** Defines that the ressource is not delayed*/
  95320. static readonly DELAYLOADSTATE_NONE: number;
  95321. /** Defines that the ressource was successfully delay loaded */
  95322. static readonly DELAYLOADSTATE_LOADED: number;
  95323. /** Defines that the ressource is currently delay loading */
  95324. static readonly DELAYLOADSTATE_LOADING: number;
  95325. /** Defines that the ressource is delayed and has not started loading */
  95326. static readonly DELAYLOADSTATE_NOTLOADED: number;
  95327. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  95328. static readonly NEVER: number;
  95329. /** 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 */
  95330. static readonly ALWAYS: number;
  95331. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  95332. static readonly LESS: number;
  95333. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  95334. static readonly EQUAL: number;
  95335. /** 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 */
  95336. static readonly LEQUAL: number;
  95337. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  95338. static readonly GREATER: number;
  95339. /** 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 */
  95340. static readonly GEQUAL: number;
  95341. /** 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 */
  95342. static readonly NOTEQUAL: number;
  95343. /** Passed to stencilOperation to specify that stencil value must be kept */
  95344. static readonly KEEP: number;
  95345. /** Passed to stencilOperation to specify that stencil value must be replaced */
  95346. static readonly REPLACE: number;
  95347. /** Passed to stencilOperation to specify that stencil value must be incremented */
  95348. static readonly INCR: number;
  95349. /** Passed to stencilOperation to specify that stencil value must be decremented */
  95350. static readonly DECR: number;
  95351. /** Passed to stencilOperation to specify that stencil value must be inverted */
  95352. static readonly INVERT: number;
  95353. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  95354. static readonly INCR_WRAP: number;
  95355. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  95356. static readonly DECR_WRAP: number;
  95357. /** Texture is not repeating outside of 0..1 UVs */
  95358. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  95359. /** Texture is repeating outside of 0..1 UVs */
  95360. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  95361. /** Texture is repeating and mirrored */
  95362. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  95363. /** ALPHA */
  95364. static readonly TEXTUREFORMAT_ALPHA: number;
  95365. /** LUMINANCE */
  95366. static readonly TEXTUREFORMAT_LUMINANCE: number;
  95367. /** LUMINANCE_ALPHA */
  95368. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  95369. /** RGB */
  95370. static readonly TEXTUREFORMAT_RGB: number;
  95371. /** RGBA */
  95372. static readonly TEXTUREFORMAT_RGBA: number;
  95373. /** RED */
  95374. static readonly TEXTUREFORMAT_RED: number;
  95375. /** RED (2nd reference) */
  95376. static readonly TEXTUREFORMAT_R: number;
  95377. /** RG */
  95378. static readonly TEXTUREFORMAT_RG: number;
  95379. /** RED_INTEGER */
  95380. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  95381. /** RED_INTEGER (2nd reference) */
  95382. static readonly TEXTUREFORMAT_R_INTEGER: number;
  95383. /** RG_INTEGER */
  95384. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  95385. /** RGB_INTEGER */
  95386. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  95387. /** RGBA_INTEGER */
  95388. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  95389. /** UNSIGNED_BYTE */
  95390. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  95391. /** UNSIGNED_BYTE (2nd reference) */
  95392. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  95393. /** FLOAT */
  95394. static readonly TEXTURETYPE_FLOAT: number;
  95395. /** HALF_FLOAT */
  95396. static readonly TEXTURETYPE_HALF_FLOAT: number;
  95397. /** BYTE */
  95398. static readonly TEXTURETYPE_BYTE: number;
  95399. /** SHORT */
  95400. static readonly TEXTURETYPE_SHORT: number;
  95401. /** UNSIGNED_SHORT */
  95402. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  95403. /** INT */
  95404. static readonly TEXTURETYPE_INT: number;
  95405. /** UNSIGNED_INT */
  95406. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  95407. /** UNSIGNED_SHORT_4_4_4_4 */
  95408. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  95409. /** UNSIGNED_SHORT_5_5_5_1 */
  95410. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  95411. /** UNSIGNED_SHORT_5_6_5 */
  95412. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  95413. /** UNSIGNED_INT_2_10_10_10_REV */
  95414. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  95415. /** UNSIGNED_INT_24_8 */
  95416. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  95417. /** UNSIGNED_INT_10F_11F_11F_REV */
  95418. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  95419. /** UNSIGNED_INT_5_9_9_9_REV */
  95420. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  95421. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  95422. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  95423. /** nearest is mag = nearest and min = nearest and mip = linear */
  95424. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  95425. /** Bilinear is mag = linear and min = linear and mip = nearest */
  95426. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  95427. /** Trilinear is mag = linear and min = linear and mip = linear */
  95428. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  95429. /** nearest is mag = nearest and min = nearest and mip = linear */
  95430. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  95431. /** Bilinear is mag = linear and min = linear and mip = nearest */
  95432. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  95433. /** Trilinear is mag = linear and min = linear and mip = linear */
  95434. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  95435. /** mag = nearest and min = nearest and mip = nearest */
  95436. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  95437. /** mag = nearest and min = linear and mip = nearest */
  95438. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  95439. /** mag = nearest and min = linear and mip = linear */
  95440. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  95441. /** mag = nearest and min = linear and mip = none */
  95442. static readonly TEXTURE_NEAREST_LINEAR: number;
  95443. /** mag = nearest and min = nearest and mip = none */
  95444. static readonly TEXTURE_NEAREST_NEAREST: number;
  95445. /** mag = linear and min = nearest and mip = nearest */
  95446. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  95447. /** mag = linear and min = nearest and mip = linear */
  95448. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  95449. /** mag = linear and min = linear and mip = none */
  95450. static readonly TEXTURE_LINEAR_LINEAR: number;
  95451. /** mag = linear and min = nearest and mip = none */
  95452. static readonly TEXTURE_LINEAR_NEAREST: number;
  95453. /** Explicit coordinates mode */
  95454. static readonly TEXTURE_EXPLICIT_MODE: number;
  95455. /** Spherical coordinates mode */
  95456. static readonly TEXTURE_SPHERICAL_MODE: number;
  95457. /** Planar coordinates mode */
  95458. static readonly TEXTURE_PLANAR_MODE: number;
  95459. /** Cubic coordinates mode */
  95460. static readonly TEXTURE_CUBIC_MODE: number;
  95461. /** Projection coordinates mode */
  95462. static readonly TEXTURE_PROJECTION_MODE: number;
  95463. /** Skybox coordinates mode */
  95464. static readonly TEXTURE_SKYBOX_MODE: number;
  95465. /** Inverse Cubic coordinates mode */
  95466. static readonly TEXTURE_INVCUBIC_MODE: number;
  95467. /** Equirectangular coordinates mode */
  95468. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  95469. /** Equirectangular Fixed coordinates mode */
  95470. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  95471. /** Equirectangular Fixed Mirrored coordinates mode */
  95472. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  95473. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  95474. static readonly SCALEMODE_FLOOR: number;
  95475. /** Defines that texture rescaling will look for the nearest power of 2 size */
  95476. static readonly SCALEMODE_NEAREST: number;
  95477. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  95478. static readonly SCALEMODE_CEILING: number;
  95479. /**
  95480. * Returns the current npm package of the sdk
  95481. */
  95482. static readonly NpmPackage: string;
  95483. /**
  95484. * Returns the current version of the framework
  95485. */
  95486. static readonly Version: string;
  95487. /**
  95488. * Returns a string describing the current engine
  95489. */
  95490. readonly description: string;
  95491. /**
  95492. * Gets or sets the epsilon value used by collision engine
  95493. */
  95494. static CollisionsEpsilon: number;
  95495. /**
  95496. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  95497. */
  95498. static ShadersRepository: string;
  95499. /**
  95500. * Method called to create the default loading screen.
  95501. * This can be overriden in your own app.
  95502. * @param canvas The rendering canvas element
  95503. * @returns The loading screen
  95504. */
  95505. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  95506. /**
  95507. * Method called to create the default rescale post process on each engine.
  95508. */
  95509. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  95510. /** @hidden */
  95511. _shaderProcessor: IShaderProcessor;
  95512. /**
  95513. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  95514. */
  95515. forcePOTTextures: boolean;
  95516. /**
  95517. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  95518. */
  95519. isFullscreen: boolean;
  95520. /**
  95521. * Gets a boolean indicating if the pointer is currently locked
  95522. */
  95523. isPointerLock: boolean;
  95524. /**
  95525. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  95526. */
  95527. cullBackFaces: boolean;
  95528. /**
  95529. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  95530. */
  95531. renderEvenInBackground: boolean;
  95532. /**
  95533. * Gets or sets a boolean indicating that cache can be kept between frames
  95534. */
  95535. preventCacheWipeBetweenFrames: boolean;
  95536. /**
  95537. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  95538. **/
  95539. enableOfflineSupport: boolean;
  95540. /**
  95541. * 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)
  95542. **/
  95543. disableManifestCheck: boolean;
  95544. /**
  95545. * Gets the list of created scenes
  95546. */
  95547. scenes: Scene[];
  95548. /**
  95549. * Event raised when a new scene is created
  95550. */
  95551. onNewSceneAddedObservable: Observable<Scene>;
  95552. /**
  95553. * Gets the list of created postprocesses
  95554. */
  95555. postProcesses: PostProcess[];
  95556. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  95557. validateShaderPrograms: boolean;
  95558. /**
  95559. * Observable event triggered each time the rendering canvas is resized
  95560. */
  95561. onResizeObservable: Observable<Engine>;
  95562. /**
  95563. * Observable event triggered each time the canvas loses focus
  95564. */
  95565. onCanvasBlurObservable: Observable<Engine>;
  95566. /**
  95567. * Observable event triggered each time the canvas gains focus
  95568. */
  95569. onCanvasFocusObservable: Observable<Engine>;
  95570. /**
  95571. * Observable event triggered each time the canvas receives pointerout event
  95572. */
  95573. onCanvasPointerOutObservable: Observable<PointerEvent>;
  95574. /**
  95575. * Observable event triggered before each texture is initialized
  95576. */
  95577. onBeforeTextureInitObservable: Observable<Texture>;
  95578. /**
  95579. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  95580. */
  95581. disableUniformBuffers: boolean;
  95582. /** @hidden */
  95583. _uniformBuffers: UniformBuffer[];
  95584. /**
  95585. * Gets a boolean indicating that the engine supports uniform buffers
  95586. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  95587. */
  95588. readonly supportsUniformBuffers: boolean;
  95589. /**
  95590. * Observable raised when the engine begins a new frame
  95591. */
  95592. onBeginFrameObservable: Observable<Engine>;
  95593. /**
  95594. * If set, will be used to request the next animation frame for the render loop
  95595. */
  95596. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  95597. /**
  95598. * Observable raised when the engine ends the current frame
  95599. */
  95600. onEndFrameObservable: Observable<Engine>;
  95601. /**
  95602. * Observable raised when the engine is about to compile a shader
  95603. */
  95604. onBeforeShaderCompilationObservable: Observable<Engine>;
  95605. /**
  95606. * Observable raised when the engine has jsut compiled a shader
  95607. */
  95608. onAfterShaderCompilationObservable: Observable<Engine>;
  95609. /** @hidden */
  95610. _gl: WebGLRenderingContext;
  95611. private _renderingCanvas;
  95612. private _windowIsBackground;
  95613. protected _webGLVersion: number;
  95614. protected _highPrecisionShadersAllowed: boolean;
  95615. /** @hidden */
  95616. readonly _shouldUseHighPrecisionShader: boolean;
  95617. /**
  95618. * Gets a boolean indicating that only power of 2 textures are supported
  95619. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  95620. */
  95621. readonly needPOTTextures: boolean;
  95622. /** @hidden */
  95623. _badOS: boolean;
  95624. /** @hidden */
  95625. _badDesktopOS: boolean;
  95626. /**
  95627. * Gets the audio engine
  95628. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  95629. * @ignorenaming
  95630. */
  95631. static audioEngine: IAudioEngine;
  95632. /**
  95633. * Default AudioEngine factory responsible of creating the Audio Engine.
  95634. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  95635. */
  95636. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  95637. /**
  95638. * Default offline support factory responsible of creating a tool used to store data locally.
  95639. * By default, this will create a Database object if the workload has been embedded.
  95640. */
  95641. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  95642. private _onFocus;
  95643. private _onBlur;
  95644. private _onCanvasPointerOut;
  95645. private _onCanvasBlur;
  95646. private _onCanvasFocus;
  95647. private _onFullscreenChange;
  95648. private _onPointerLockChange;
  95649. private _hardwareScalingLevel;
  95650. /** @hidden */
  95651. _caps: EngineCapabilities;
  95652. private _pointerLockRequested;
  95653. private _isStencilEnable;
  95654. protected _colorWrite: boolean;
  95655. private _loadingScreen;
  95656. /** @hidden */
  95657. _drawCalls: PerfCounter;
  95658. private _glVersion;
  95659. private _glRenderer;
  95660. private _glVendor;
  95661. private _videoTextureSupported;
  95662. private _renderingQueueLaunched;
  95663. private _activeRenderLoops;
  95664. private _deterministicLockstep;
  95665. private _lockstepMaxSteps;
  95666. /**
  95667. * Observable signaled when a context lost event is raised
  95668. */
  95669. onContextLostObservable: Observable<Engine>;
  95670. /**
  95671. * Observable signaled when a context restored event is raised
  95672. */
  95673. onContextRestoredObservable: Observable<Engine>;
  95674. private _onContextLost;
  95675. private _onContextRestored;
  95676. private _contextWasLost;
  95677. /** @hidden */
  95678. _doNotHandleContextLost: boolean;
  95679. /**
  95680. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  95681. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  95682. */
  95683. doNotHandleContextLost: boolean;
  95684. private _performanceMonitor;
  95685. private _fps;
  95686. private _deltaTime;
  95687. /**
  95688. * Turn this value on if you want to pause FPS computation when in background
  95689. */
  95690. disablePerformanceMonitorInBackground: boolean;
  95691. /**
  95692. * Gets the performance monitor attached to this engine
  95693. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  95694. */
  95695. readonly performanceMonitor: PerformanceMonitor;
  95696. /**
  95697. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  95698. */
  95699. disableVertexArrayObjects: boolean;
  95700. /** @hidden */
  95701. protected _depthCullingState: _DepthCullingState;
  95702. /** @hidden */
  95703. protected _stencilState: _StencilState;
  95704. /** @hidden */
  95705. protected _alphaState: _AlphaState;
  95706. /** @hidden */
  95707. protected _alphaMode: number;
  95708. /** @hidden */
  95709. _internalTexturesCache: InternalTexture[];
  95710. /** @hidden */
  95711. protected _activeChannel: number;
  95712. private _currentTextureChannel;
  95713. /** @hidden */
  95714. protected _boundTexturesCache: {
  95715. [key: string]: Nullable<InternalTexture>;
  95716. };
  95717. /** @hidden */
  95718. protected _currentEffect: Nullable<Effect>;
  95719. /** @hidden */
  95720. protected _currentProgram: Nullable<WebGLProgram>;
  95721. private _compiledEffects;
  95722. private _vertexAttribArraysEnabled;
  95723. /** @hidden */
  95724. protected _cachedViewport: Nullable<IViewportLike>;
  95725. private _cachedVertexArrayObject;
  95726. /** @hidden */
  95727. protected _cachedVertexBuffers: any;
  95728. /** @hidden */
  95729. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  95730. /** @hidden */
  95731. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  95732. /** @hidden */
  95733. _currentRenderTarget: Nullable<InternalTexture>;
  95734. private _uintIndicesCurrentlySet;
  95735. private _currentBoundBuffer;
  95736. /** @hidden */
  95737. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  95738. private _currentBufferPointers;
  95739. private _currentInstanceLocations;
  95740. private _currentInstanceBuffers;
  95741. private _textureUnits;
  95742. /** @hidden */
  95743. _workingCanvas: Nullable<HTMLCanvasElement>;
  95744. /** @hidden */
  95745. _workingContext: Nullable<CanvasRenderingContext2D>;
  95746. private _rescalePostProcess;
  95747. private _dummyFramebuffer;
  95748. private _externalData;
  95749. /** @hidden */
  95750. _bindedRenderFunction: any;
  95751. private _vaoRecordInProgress;
  95752. private _mustWipeVertexAttributes;
  95753. private _emptyTexture;
  95754. private _emptyCubeTexture;
  95755. private _emptyTexture3D;
  95756. /** @hidden */
  95757. _frameHandler: number;
  95758. private _nextFreeTextureSlots;
  95759. private _maxSimultaneousTextures;
  95760. private _activeRequests;
  95761. private _texturesSupported;
  95762. /** @hidden */
  95763. _textureFormatInUse: Nullable<string>;
  95764. /**
  95765. * Gets the list of texture formats supported
  95766. */
  95767. readonly texturesSupported: Array<string>;
  95768. /**
  95769. * Gets the list of texture formats in use
  95770. */
  95771. readonly textureFormatInUse: Nullable<string>;
  95772. /**
  95773. * Gets the current viewport
  95774. */
  95775. readonly currentViewport: Nullable<IViewportLike>;
  95776. /**
  95777. * Gets the default empty texture
  95778. */
  95779. readonly emptyTexture: InternalTexture;
  95780. /**
  95781. * Gets the default empty 3D texture
  95782. */
  95783. readonly emptyTexture3D: InternalTexture;
  95784. /**
  95785. * Gets the default empty cube texture
  95786. */
  95787. readonly emptyCubeTexture: InternalTexture;
  95788. /**
  95789. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  95790. */
  95791. readonly premultipliedAlpha: boolean;
  95792. /**
  95793. * Creates a new engine
  95794. * @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
  95795. * @param antialias defines enable antialiasing (default: false)
  95796. * @param options defines further options to be sent to the getContext() function
  95797. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  95798. */
  95799. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  95800. /**
  95801. * Initializes a webVR display and starts listening to display change events
  95802. * The onVRDisplayChangedObservable will be notified upon these changes
  95803. * @returns The onVRDisplayChangedObservable
  95804. */
  95805. initWebVR(): Observable<IDisplayChangedEventArgs>;
  95806. /** @hidden */
  95807. _prepareVRComponent(): void;
  95808. /** @hidden */
  95809. _connectVREvents(canvas: HTMLCanvasElement, document: any): void;
  95810. /** @hidden */
  95811. _submitVRFrame(): void;
  95812. /**
  95813. * Call this function to leave webVR mode
  95814. * Will do nothing if webVR is not supported or if there is no webVR device
  95815. * @see http://doc.babylonjs.com/how_to/webvr_camera
  95816. */
  95817. disableVR(): void;
  95818. /**
  95819. * Gets a boolean indicating that the system is in VR mode and is presenting
  95820. * @returns true if VR mode is engaged
  95821. */
  95822. isVRPresenting(): boolean;
  95823. /** @hidden */
  95824. _requestVRFrame(): void;
  95825. private _disableTouchAction;
  95826. private _rebuildInternalTextures;
  95827. private _rebuildEffects;
  95828. /**
  95829. * Gets a boolean indicating if all created effects are ready
  95830. * @returns true if all effects are ready
  95831. */
  95832. areAllEffectsReady(): boolean;
  95833. private _rebuildBuffers;
  95834. private _initGLContext;
  95835. /**
  95836. * Gets version of the current webGL context
  95837. */
  95838. readonly webGLVersion: number;
  95839. /**
  95840. * Gets a string idenfifying the name of the class
  95841. * @returns "Engine" string
  95842. */
  95843. getClassName(): string;
  95844. /**
  95845. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  95846. */
  95847. readonly isStencilEnable: boolean;
  95848. /** @hidden */
  95849. _prepareWorkingCanvas(): void;
  95850. /**
  95851. * Reset the texture cache to empty state
  95852. */
  95853. resetTextureCache(): void;
  95854. /**
  95855. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  95856. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  95857. * @returns true if engine is in deterministic lock step mode
  95858. */
  95859. isDeterministicLockStep(): boolean;
  95860. /**
  95861. * Gets the max steps when engine is running in deterministic lock step
  95862. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  95863. * @returns the max steps
  95864. */
  95865. getLockstepMaxSteps(): number;
  95866. /**
  95867. * Gets an object containing information about the current webGL context
  95868. * @returns an object containing the vender, the renderer and the version of the current webGL context
  95869. */
  95870. getGlInfo(): {
  95871. vendor: string;
  95872. renderer: string;
  95873. version: string;
  95874. };
  95875. /**
  95876. * Gets current aspect ratio
  95877. * @param viewportOwner defines the camera to use to get the aspect ratio
  95878. * @param useScreen defines if screen size must be used (or the current render target if any)
  95879. * @returns a number defining the aspect ratio
  95880. */
  95881. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  95882. /**
  95883. * Gets current screen aspect ratio
  95884. * @returns a number defining the aspect ratio
  95885. */
  95886. getScreenAspectRatio(): number;
  95887. /**
  95888. * Gets the current render width
  95889. * @param useScreen defines if screen size must be used (or the current render target if any)
  95890. * @returns a number defining the current render width
  95891. */
  95892. getRenderWidth(useScreen?: boolean): number;
  95893. /**
  95894. * Gets the current render height
  95895. * @param useScreen defines if screen size must be used (or the current render target if any)
  95896. * @returns a number defining the current render height
  95897. */
  95898. getRenderHeight(useScreen?: boolean): number;
  95899. /**
  95900. * Gets the HTML canvas attached with the current webGL context
  95901. * @returns a HTML canvas
  95902. */
  95903. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  95904. /**
  95905. * Gets host window
  95906. * @returns the host window object
  95907. */
  95908. getHostWindow(): Window;
  95909. /**
  95910. * Gets host document
  95911. * @returns the host document object
  95912. */
  95913. getHostDocument(): Document;
  95914. /**
  95915. * Gets the client rect of the HTML canvas attached with the current webGL context
  95916. * @returns a client rectanglee
  95917. */
  95918. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  95919. /**
  95920. * Defines the hardware scaling level.
  95921. * By default the hardware scaling level is computed from the window device ratio.
  95922. * 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.
  95923. * @param level defines the level to use
  95924. */
  95925. setHardwareScalingLevel(level: number): void;
  95926. /**
  95927. * Gets the current hardware scaling level.
  95928. * By default the hardware scaling level is computed from the window device ratio.
  95929. * 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.
  95930. * @returns a number indicating the current hardware scaling level
  95931. */
  95932. getHardwareScalingLevel(): number;
  95933. /**
  95934. * Gets the list of loaded textures
  95935. * @returns an array containing all loaded textures
  95936. */
  95937. getLoadedTexturesCache(): InternalTexture[];
  95938. /**
  95939. * Gets the object containing all engine capabilities
  95940. * @returns the EngineCapabilities object
  95941. */
  95942. getCaps(): EngineCapabilities;
  95943. /**
  95944. * Gets the current depth function
  95945. * @returns a number defining the depth function
  95946. */
  95947. getDepthFunction(): Nullable<number>;
  95948. /**
  95949. * Sets the current depth function
  95950. * @param depthFunc defines the function to use
  95951. */
  95952. setDepthFunction(depthFunc: number): void;
  95953. /**
  95954. * Sets the current depth function to GREATER
  95955. */
  95956. setDepthFunctionToGreater(): void;
  95957. /**
  95958. * Sets the current depth function to GEQUAL
  95959. */
  95960. setDepthFunctionToGreaterOrEqual(): void;
  95961. /**
  95962. * Sets the current depth function to LESS
  95963. */
  95964. setDepthFunctionToLess(): void;
  95965. private _cachedStencilBuffer;
  95966. private _cachedStencilFunction;
  95967. private _cachedStencilMask;
  95968. private _cachedStencilOperationPass;
  95969. private _cachedStencilOperationFail;
  95970. private _cachedStencilOperationDepthFail;
  95971. private _cachedStencilReference;
  95972. /**
  95973. * Caches the the state of the stencil buffer
  95974. */
  95975. cacheStencilState(): void;
  95976. /**
  95977. * Restores the state of the stencil buffer
  95978. */
  95979. restoreStencilState(): void;
  95980. /**
  95981. * Sets the current depth function to LEQUAL
  95982. */
  95983. setDepthFunctionToLessOrEqual(): void;
  95984. /**
  95985. * Gets a boolean indicating if stencil buffer is enabled
  95986. * @returns the current stencil buffer state
  95987. */
  95988. getStencilBuffer(): boolean;
  95989. /**
  95990. * Enable or disable the stencil buffer
  95991. * @param enable defines if the stencil buffer must be enabled or disabled
  95992. */
  95993. setStencilBuffer(enable: boolean): void;
  95994. /**
  95995. * Gets the current stencil mask
  95996. * @returns a number defining the new stencil mask to use
  95997. */
  95998. getStencilMask(): number;
  95999. /**
  96000. * Sets the current stencil mask
  96001. * @param mask defines the new stencil mask to use
  96002. */
  96003. setStencilMask(mask: number): void;
  96004. /**
  96005. * Gets the current stencil function
  96006. * @returns a number defining the stencil function to use
  96007. */
  96008. getStencilFunction(): number;
  96009. /**
  96010. * Gets the current stencil reference value
  96011. * @returns a number defining the stencil reference value to use
  96012. */
  96013. getStencilFunctionReference(): number;
  96014. /**
  96015. * Gets the current stencil mask
  96016. * @returns a number defining the stencil mask to use
  96017. */
  96018. getStencilFunctionMask(): number;
  96019. /**
  96020. * Sets the current stencil function
  96021. * @param stencilFunc defines the new stencil function to use
  96022. */
  96023. setStencilFunction(stencilFunc: number): void;
  96024. /**
  96025. * Sets the current stencil reference
  96026. * @param reference defines the new stencil reference to use
  96027. */
  96028. setStencilFunctionReference(reference: number): void;
  96029. /**
  96030. * Sets the current stencil mask
  96031. * @param mask defines the new stencil mask to use
  96032. */
  96033. setStencilFunctionMask(mask: number): void;
  96034. /**
  96035. * Gets the current stencil operation when stencil fails
  96036. * @returns a number defining stencil operation to use when stencil fails
  96037. */
  96038. getStencilOperationFail(): number;
  96039. /**
  96040. * Gets the current stencil operation when depth fails
  96041. * @returns a number defining stencil operation to use when depth fails
  96042. */
  96043. getStencilOperationDepthFail(): number;
  96044. /**
  96045. * Gets the current stencil operation when stencil passes
  96046. * @returns a number defining stencil operation to use when stencil passes
  96047. */
  96048. getStencilOperationPass(): number;
  96049. /**
  96050. * Sets the stencil operation to use when stencil fails
  96051. * @param operation defines the stencil operation to use when stencil fails
  96052. */
  96053. setStencilOperationFail(operation: number): void;
  96054. /**
  96055. * Sets the stencil operation to use when depth fails
  96056. * @param operation defines the stencil operation to use when depth fails
  96057. */
  96058. setStencilOperationDepthFail(operation: number): void;
  96059. /**
  96060. * Sets the stencil operation to use when stencil passes
  96061. * @param operation defines the stencil operation to use when stencil passes
  96062. */
  96063. setStencilOperationPass(operation: number): void;
  96064. /**
  96065. * Sets a boolean indicating if the dithering state is enabled or disabled
  96066. * @param value defines the dithering state
  96067. */
  96068. setDitheringState(value: boolean): void;
  96069. /**
  96070. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  96071. * @param value defines the rasterizer state
  96072. */
  96073. setRasterizerState(value: boolean): void;
  96074. /**
  96075. * stop executing a render loop function and remove it from the execution array
  96076. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  96077. */
  96078. stopRenderLoop(renderFunction?: () => void): void;
  96079. /** @hidden */
  96080. _renderLoop(): void;
  96081. /**
  96082. * Can be used to override the current requestAnimationFrame requester.
  96083. * @hidden
  96084. */
  96085. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  96086. /**
  96087. * Register and execute a render loop. The engine can have more than one render function
  96088. * @param renderFunction defines the function to continuously execute
  96089. */
  96090. runRenderLoop(renderFunction: () => void): void;
  96091. /**
  96092. * Toggle full screen mode
  96093. * @param requestPointerLock defines if a pointer lock should be requested from the user
  96094. */
  96095. switchFullscreen(requestPointerLock: boolean): void;
  96096. /**
  96097. * Enters full screen mode
  96098. * @param requestPointerLock defines if a pointer lock should be requested from the user
  96099. */
  96100. enterFullscreen(requestPointerLock: boolean): void;
  96101. /**
  96102. * Exits full screen mode
  96103. */
  96104. exitFullscreen(): void;
  96105. /**
  96106. * Enters Pointerlock mode
  96107. */
  96108. enterPointerlock(): void;
  96109. /**
  96110. * Exits Pointerlock mode
  96111. */
  96112. exitPointerlock(): void;
  96113. /**
  96114. * Clear the current render buffer or the current render target (if any is set up)
  96115. * @param color defines the color to use
  96116. * @param backBuffer defines if the back buffer must be cleared
  96117. * @param depth defines if the depth buffer must be cleared
  96118. * @param stencil defines if the stencil buffer must be cleared
  96119. */
  96120. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  96121. /**
  96122. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  96123. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  96124. * @param y defines the y-coordinate of the corner of the clear rectangle
  96125. * @param width defines the width of the clear rectangle
  96126. * @param height defines the height of the clear rectangle
  96127. * @param clearColor defines the clear color
  96128. */
  96129. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  96130. /**
  96131. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  96132. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  96133. * @param y defines the y-coordinate of the corner of the clear rectangle
  96134. * @param width defines the width of the clear rectangle
  96135. * @param height defines the height of the clear rectangle
  96136. */
  96137. enableScissor(x: number, y: number, width: number, height: number): void;
  96138. /**
  96139. * Disable previously set scissor test rectangle
  96140. */
  96141. disableScissor(): void;
  96142. private _viewportCached;
  96143. /** @hidden */
  96144. _viewport(x: number, y: number, width: number, height: number): void;
  96145. /**
  96146. * Set the WebGL's viewport
  96147. * @param viewport defines the viewport element to be used
  96148. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  96149. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  96150. */
  96151. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  96152. /**
  96153. * Directly set the WebGL Viewport
  96154. * @param x defines the x coordinate of the viewport (in screen space)
  96155. * @param y defines the y coordinate of the viewport (in screen space)
  96156. * @param width defines the width of the viewport (in screen space)
  96157. * @param height defines the height of the viewport (in screen space)
  96158. * @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
  96159. */
  96160. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  96161. /**
  96162. * Begin a new frame
  96163. */
  96164. beginFrame(): void;
  96165. /**
  96166. * Enf the current frame
  96167. */
  96168. endFrame(): void;
  96169. /**
  96170. * Resize the view according to the canvas' size
  96171. */
  96172. resize(): void;
  96173. /**
  96174. * Force a specific size of the canvas
  96175. * @param width defines the new canvas' width
  96176. * @param height defines the new canvas' height
  96177. */
  96178. setSize(width: number, height: number): void;
  96179. /**
  96180. * Binds the frame buffer to the specified texture.
  96181. * @param texture The texture to render to or null for the default canvas
  96182. * @param faceIndex The face of the texture to render to in case of cube texture
  96183. * @param requiredWidth The width of the target to render to
  96184. * @param requiredHeight The height of the target to render to
  96185. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  96186. * @param depthStencilTexture The depth stencil texture to use to render
  96187. * @param lodLevel defines le lod level to bind to the frame buffer
  96188. */
  96189. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, depthStencilTexture?: InternalTexture, lodLevel?: number): void;
  96190. /** @hidden */
  96191. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  96192. /**
  96193. * Unbind the current render target texture from the webGL context
  96194. * @param texture defines the render target texture to unbind
  96195. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  96196. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  96197. */
  96198. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  96199. /**
  96200. * Force the mipmap generation for the given render target texture
  96201. * @param texture defines the render target texture to use
  96202. */
  96203. generateMipMapsForCubemap(texture: InternalTexture): void;
  96204. /**
  96205. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  96206. */
  96207. flushFramebuffer(): void;
  96208. /**
  96209. * Unbind the current render target and bind the default framebuffer
  96210. */
  96211. restoreDefaultFramebuffer(): void;
  96212. /**
  96213. * Create an uniform buffer
  96214. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  96215. * @param elements defines the content of the uniform buffer
  96216. * @returns the webGL uniform buffer
  96217. */
  96218. createUniformBuffer(elements: FloatArray): DataBuffer;
  96219. /**
  96220. * Create a dynamic uniform buffer
  96221. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  96222. * @param elements defines the content of the uniform buffer
  96223. * @returns the webGL uniform buffer
  96224. */
  96225. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  96226. /**
  96227. * Update an existing uniform buffer
  96228. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  96229. * @param uniformBuffer defines the target uniform buffer
  96230. * @param elements defines the content to update
  96231. * @param offset defines the offset in the uniform buffer where update should start
  96232. * @param count defines the size of the data to update
  96233. */
  96234. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  96235. private _resetVertexBufferBinding;
  96236. /**
  96237. * Creates a vertex buffer
  96238. * @param data the data for the vertex buffer
  96239. * @returns the new WebGL static buffer
  96240. */
  96241. createVertexBuffer(data: DataArray): DataBuffer;
  96242. /**
  96243. * Creates a dynamic vertex buffer
  96244. * @param data the data for the dynamic vertex buffer
  96245. * @returns the new WebGL dynamic buffer
  96246. */
  96247. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  96248. /**
  96249. * Update a dynamic index buffer
  96250. * @param indexBuffer defines the target index buffer
  96251. * @param indices defines the data to update
  96252. * @param offset defines the offset in the target index buffer where update should start
  96253. */
  96254. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  96255. /**
  96256. * Updates a dynamic vertex buffer.
  96257. * @param vertexBuffer the vertex buffer to update
  96258. * @param data the data used to update the vertex buffer
  96259. * @param byteOffset the byte offset of the data
  96260. * @param byteLength the byte length of the data
  96261. */
  96262. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  96263. private _resetIndexBufferBinding;
  96264. /**
  96265. * Creates a new index buffer
  96266. * @param indices defines the content of the index buffer
  96267. * @param updatable defines if the index buffer must be updatable
  96268. * @returns a new webGL buffer
  96269. */
  96270. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  96271. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  96272. /**
  96273. * Bind a webGL buffer to the webGL context
  96274. * @param buffer defines the buffer to bind
  96275. */
  96276. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  96277. /**
  96278. * Bind an uniform buffer to the current webGL context
  96279. * @param buffer defines the buffer to bind
  96280. */
  96281. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  96282. /**
  96283. * Bind a buffer to the current webGL context at a given location
  96284. * @param buffer defines the buffer to bind
  96285. * @param location defines the index where to bind the buffer
  96286. */
  96287. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  96288. /**
  96289. * Bind a specific block at a given index in a specific shader program
  96290. * @param pipelineContext defines the pipeline context to use
  96291. * @param blockName defines the block name
  96292. * @param index defines the index where to bind the block
  96293. */
  96294. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  96295. private bindIndexBuffer;
  96296. private bindBuffer;
  96297. /**
  96298. * update the bound buffer with the given data
  96299. * @param data defines the data to update
  96300. */
  96301. updateArrayBuffer(data: Float32Array): void;
  96302. private _vertexAttribPointer;
  96303. private _bindIndexBufferWithCache;
  96304. private _bindVertexBuffersAttributes;
  96305. /**
  96306. * Records a vertex array object
  96307. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  96308. * @param vertexBuffers defines the list of vertex buffers to store
  96309. * @param indexBuffer defines the index buffer to store
  96310. * @param effect defines the effect to store
  96311. * @returns the new vertex array object
  96312. */
  96313. recordVertexArrayObject(vertexBuffers: {
  96314. [key: string]: VertexBuffer;
  96315. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  96316. /**
  96317. * Bind a specific vertex array object
  96318. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  96319. * @param vertexArrayObject defines the vertex array object to bind
  96320. * @param indexBuffer defines the index buffer to bind
  96321. */
  96322. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  96323. /**
  96324. * Bind webGl buffers directly to the webGL context
  96325. * @param vertexBuffer defines the vertex buffer to bind
  96326. * @param indexBuffer defines the index buffer to bind
  96327. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  96328. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  96329. * @param effect defines the effect associated with the vertex buffer
  96330. */
  96331. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  96332. private _unbindVertexArrayObject;
  96333. /**
  96334. * Bind a list of vertex buffers to the webGL context
  96335. * @param vertexBuffers defines the list of vertex buffers to bind
  96336. * @param indexBuffer defines the index buffer to bind
  96337. * @param effect defines the effect associated with the vertex buffers
  96338. */
  96339. bindBuffers(vertexBuffers: {
  96340. [key: string]: Nullable<VertexBuffer>;
  96341. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  96342. /**
  96343. * Unbind all instance attributes
  96344. */
  96345. unbindInstanceAttributes(): void;
  96346. /**
  96347. * Release and free the memory of a vertex array object
  96348. * @param vao defines the vertex array object to delete
  96349. */
  96350. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  96351. /** @hidden */
  96352. _releaseBuffer(buffer: DataBuffer): boolean;
  96353. protected _deleteBuffer(buffer: DataBuffer): void;
  96354. /**
  96355. * Creates a webGL buffer to use with instanciation
  96356. * @param capacity defines the size of the buffer
  96357. * @returns the webGL buffer
  96358. */
  96359. createInstancesBuffer(capacity: number): DataBuffer;
  96360. /**
  96361. * Delete a webGL buffer used with instanciation
  96362. * @param buffer defines the webGL buffer to delete
  96363. */
  96364. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  96365. /**
  96366. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  96367. * @param instancesBuffer defines the webGL buffer to update and bind
  96368. * @param data defines the data to store in the buffer
  96369. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  96370. */
  96371. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  96372. /**
  96373. * Apply all cached states (depth, culling, stencil and alpha)
  96374. */
  96375. applyStates(): void;
  96376. /**
  96377. * Send a draw order
  96378. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  96379. * @param indexStart defines the starting index
  96380. * @param indexCount defines the number of index to draw
  96381. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  96382. */
  96383. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  96384. /**
  96385. * Draw a list of points
  96386. * @param verticesStart defines the index of first vertex to draw
  96387. * @param verticesCount defines the count of vertices to draw
  96388. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  96389. */
  96390. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  96391. /**
  96392. * Draw a list of unindexed primitives
  96393. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  96394. * @param verticesStart defines the index of first vertex to draw
  96395. * @param verticesCount defines the count of vertices to draw
  96396. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  96397. */
  96398. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  96399. /**
  96400. * Draw a list of indexed primitives
  96401. * @param fillMode defines the primitive to use
  96402. * @param indexStart defines the starting index
  96403. * @param indexCount defines the number of index to draw
  96404. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  96405. */
  96406. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  96407. /**
  96408. * Draw a list of unindexed primitives
  96409. * @param fillMode defines the primitive to use
  96410. * @param verticesStart defines the index of first vertex to draw
  96411. * @param verticesCount defines the count of vertices to draw
  96412. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  96413. */
  96414. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  96415. private _drawMode;
  96416. /** @hidden */
  96417. _releaseEffect(effect: Effect): void;
  96418. /** @hidden */
  96419. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  96420. /**
  96421. * Create a new effect (used to store vertex/fragment shaders)
  96422. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  96423. * @param attributesNamesOrOptions defines either a list of attribute names or an EffectCreationOptions object
  96424. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  96425. * @param samplers defines an array of string used to represent textures
  96426. * @param defines defines the string containing the defines to use to compile the shaders
  96427. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  96428. * @param onCompiled defines a function to call when the effect creation is successful
  96429. * @param onError defines a function to call when the effect creation has failed
  96430. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  96431. * @returns the new Effect
  96432. */
  96433. createEffect(baseName: any, attributesNamesOrOptions: string[] | EffectCreationOptions, uniformsNamesOrEngine: string[] | Engine, samplers?: string[], defines?: string, fallbacks?: EffectFallbacks, onCompiled?: Nullable<(effect: Effect) => void>, onError?: Nullable<(effect: Effect, errors: string) => void>, indexParameters?: any): Effect;
  96434. protected static _concatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  96435. private _compileShader;
  96436. private _compileRawShader;
  96437. /**
  96438. * Directly creates a webGL program
  96439. * @param pipelineContext defines the pipeline context to attach to
  96440. * @param vertexCode defines the vertex shader code to use
  96441. * @param fragmentCode defines the fragment shader code to use
  96442. * @param context defines the webGL context to use (if not set, the current one will be used)
  96443. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  96444. * @returns the new webGL program
  96445. */
  96446. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  96447. /**
  96448. * Creates a webGL program
  96449. * @param pipelineContext defines the pipeline context to attach to
  96450. * @param vertexCode defines the vertex shader code to use
  96451. * @param fragmentCode defines the fragment shader code to use
  96452. * @param defines defines the string containing the defines to use to compile the shaders
  96453. * @param context defines the webGL context to use (if not set, the current one will be used)
  96454. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  96455. * @returns the new webGL program
  96456. */
  96457. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  96458. /**
  96459. * Creates a new pipeline context
  96460. * @returns the new pipeline
  96461. */
  96462. createPipelineContext(): IPipelineContext;
  96463. private _createShaderProgram;
  96464. private _finalizePipelineContext;
  96465. /** @hidden */
  96466. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  96467. /** @hidden */
  96468. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  96469. /** @hidden */
  96470. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  96471. /**
  96472. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  96473. * @param pipelineContext defines the pipeline context to use
  96474. * @param uniformsNames defines the list of uniform names
  96475. * @returns an array of webGL uniform locations
  96476. */
  96477. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  96478. /**
  96479. * Gets the lsit of active attributes for a given webGL program
  96480. * @param pipelineContext defines the pipeline context to use
  96481. * @param attributesNames defines the list of attribute names to get
  96482. * @returns an array of indices indicating the offset of each attribute
  96483. */
  96484. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  96485. /**
  96486. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  96487. * @param effect defines the effect to activate
  96488. */
  96489. enableEffect(effect: Nullable<Effect>): void;
  96490. /**
  96491. * Set the value of an uniform to an array of int32
  96492. * @param uniform defines the webGL uniform location where to store the value
  96493. * @param array defines the array of int32 to store
  96494. */
  96495. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  96496. /**
  96497. * Set the value of an uniform to an array of int32 (stored as vec2)
  96498. * @param uniform defines the webGL uniform location where to store the value
  96499. * @param array defines the array of int32 to store
  96500. */
  96501. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  96502. /**
  96503. * Set the value of an uniform to an array of int32 (stored as vec3)
  96504. * @param uniform defines the webGL uniform location where to store the value
  96505. * @param array defines the array of int32 to store
  96506. */
  96507. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  96508. /**
  96509. * Set the value of an uniform to an array of int32 (stored as vec4)
  96510. * @param uniform defines the webGL uniform location where to store the value
  96511. * @param array defines the array of int32 to store
  96512. */
  96513. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  96514. /**
  96515. * Set the value of an uniform to an array of float32
  96516. * @param uniform defines the webGL uniform location where to store the value
  96517. * @param array defines the array of float32 to store
  96518. */
  96519. setFloatArray(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  96520. /**
  96521. * Set the value of an uniform to an array of float32 (stored as vec2)
  96522. * @param uniform defines the webGL uniform location where to store the value
  96523. * @param array defines the array of float32 to store
  96524. */
  96525. setFloatArray2(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  96526. /**
  96527. * Set the value of an uniform to an array of float32 (stored as vec3)
  96528. * @param uniform defines the webGL uniform location where to store the value
  96529. * @param array defines the array of float32 to store
  96530. */
  96531. setFloatArray3(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  96532. /**
  96533. * Set the value of an uniform to an array of float32 (stored as vec4)
  96534. * @param uniform defines the webGL uniform location where to store the value
  96535. * @param array defines the array of float32 to store
  96536. */
  96537. setFloatArray4(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  96538. /**
  96539. * Set the value of an uniform to an array of number
  96540. * @param uniform defines the webGL uniform location where to store the value
  96541. * @param array defines the array of number to store
  96542. */
  96543. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  96544. /**
  96545. * Set the value of an uniform to an array of number (stored as vec2)
  96546. * @param uniform defines the webGL uniform location where to store the value
  96547. * @param array defines the array of number to store
  96548. */
  96549. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  96550. /**
  96551. * Set the value of an uniform to an array of number (stored as vec3)
  96552. * @param uniform defines the webGL uniform location where to store the value
  96553. * @param array defines the array of number to store
  96554. */
  96555. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  96556. /**
  96557. * Set the value of an uniform to an array of number (stored as vec4)
  96558. * @param uniform defines the webGL uniform location where to store the value
  96559. * @param array defines the array of number to store
  96560. */
  96561. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  96562. /**
  96563. * Set the value of an uniform to an array of float32 (stored as matrices)
  96564. * @param uniform defines the webGL uniform location where to store the value
  96565. * @param matrices defines the array of float32 to store
  96566. */
  96567. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  96568. /**
  96569. * Set the value of an uniform to a matrix (3x3)
  96570. * @param uniform defines the webGL uniform location where to store the value
  96571. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  96572. */
  96573. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  96574. /**
  96575. * Set the value of an uniform to a matrix (2x2)
  96576. * @param uniform defines the webGL uniform location where to store the value
  96577. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  96578. */
  96579. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  96580. /**
  96581. * Set the value of an uniform to a number (int)
  96582. * @param uniform defines the webGL uniform location where to store the value
  96583. * @param value defines the int number to store
  96584. */
  96585. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  96586. /**
  96587. * Set the value of an uniform to a number (float)
  96588. * @param uniform defines the webGL uniform location where to store the value
  96589. * @param value defines the float number to store
  96590. */
  96591. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  96592. /**
  96593. * Set the value of an uniform to a vec2
  96594. * @param uniform defines the webGL uniform location where to store the value
  96595. * @param x defines the 1st component of the value
  96596. * @param y defines the 2nd component of the value
  96597. */
  96598. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  96599. /**
  96600. * Set the value of an uniform to a vec3
  96601. * @param uniform defines the webGL uniform location where to store the value
  96602. * @param x defines the 1st component of the value
  96603. * @param y defines the 2nd component of the value
  96604. * @param z defines the 3rd component of the value
  96605. */
  96606. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  96607. /**
  96608. * Set the value of an uniform to a boolean
  96609. * @param uniform defines the webGL uniform location where to store the value
  96610. * @param bool defines the boolean to store
  96611. */
  96612. setBool(uniform: Nullable<WebGLUniformLocation>, bool: number): void;
  96613. /**
  96614. * Set the value of an uniform to a vec4
  96615. * @param uniform defines the webGL uniform location where to store the value
  96616. * @param x defines the 1st component of the value
  96617. * @param y defines the 2nd component of the value
  96618. * @param z defines the 3rd component of the value
  96619. * @param w defines the 4th component of the value
  96620. */
  96621. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  96622. /**
  96623. * Sets a Color4 on a uniform variable
  96624. * @param uniform defines the uniform location
  96625. * @param color4 defines the value to be set
  96626. */
  96627. setDirectColor4(uniform: Nullable<WebGLUniformLocation>, color4: IColor4Like): void;
  96628. /**
  96629. * Set various states to the webGL context
  96630. * @param culling defines backface culling state
  96631. * @param zOffset defines the value to apply to zOffset (0 by default)
  96632. * @param force defines if states must be applied even if cache is up to date
  96633. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  96634. */
  96635. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  96636. /**
  96637. * Set the z offset to apply to current rendering
  96638. * @param value defines the offset to apply
  96639. */
  96640. setZOffset(value: number): void;
  96641. /**
  96642. * Gets the current value of the zOffset
  96643. * @returns the current zOffset state
  96644. */
  96645. getZOffset(): number;
  96646. /**
  96647. * Enable or disable depth buffering
  96648. * @param enable defines the state to set
  96649. */
  96650. setDepthBuffer(enable: boolean): void;
  96651. /**
  96652. * Gets a boolean indicating if depth writing is enabled
  96653. * @returns the current depth writing state
  96654. */
  96655. getDepthWrite(): boolean;
  96656. /**
  96657. * Enable or disable depth writing
  96658. * @param enable defines the state to set
  96659. */
  96660. setDepthWrite(enable: boolean): void;
  96661. /**
  96662. * Enable or disable color writing
  96663. * @param enable defines the state to set
  96664. */
  96665. setColorWrite(enable: boolean): void;
  96666. /**
  96667. * Gets a boolean indicating if color writing is enabled
  96668. * @returns the current color writing state
  96669. */
  96670. getColorWrite(): boolean;
  96671. /**
  96672. * Sets alpha constants used by some alpha blending modes
  96673. * @param r defines the red component
  96674. * @param g defines the green component
  96675. * @param b defines the blue component
  96676. * @param a defines the alpha component
  96677. */
  96678. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  96679. /**
  96680. * Sets the current alpha mode
  96681. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  96682. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  96683. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  96684. */
  96685. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  96686. /**
  96687. * Gets the current alpha mode
  96688. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  96689. * @returns the current alpha mode
  96690. */
  96691. getAlphaMode(): number;
  96692. /**
  96693. * Clears the list of texture accessible through engine.
  96694. * This can help preventing texture load conflict due to name collision.
  96695. */
  96696. clearInternalTexturesCache(): void;
  96697. /**
  96698. * Force the entire cache to be cleared
  96699. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  96700. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  96701. */
  96702. wipeCaches(bruteForce?: boolean): void;
  96703. /**
  96704. * Set the compressed texture format to use, based on the formats you have, and the formats
  96705. * supported by the hardware / browser.
  96706. *
  96707. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  96708. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  96709. * to API arguments needed to compressed textures. This puts the burden on the container
  96710. * generator to house the arcane code for determining these for current & future formats.
  96711. *
  96712. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  96713. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  96714. *
  96715. * Note: The result of this call is not taken into account when a texture is base64.
  96716. *
  96717. * @param formatsAvailable defines the list of those format families you have created
  96718. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  96719. *
  96720. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  96721. * @returns The extension selected.
  96722. */
  96723. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  96724. /** @hidden */
  96725. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  96726. min: number;
  96727. mag: number;
  96728. };
  96729. /** @hidden */
  96730. _createTexture(): WebGLTexture;
  96731. /**
  96732. * Usually called from Texture.ts.
  96733. * Passed information to create a WebGLTexture
  96734. * @param urlArg defines a value which contains one of the following:
  96735. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  96736. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  96737. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  96738. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  96739. * @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)
  96740. * @param scene needed for loading to the correct scene
  96741. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  96742. * @param onLoad optional callback to be called upon successful completion
  96743. * @param onError optional callback to be called upon failure
  96744. * @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
  96745. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  96746. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  96747. * @param forcedExtension defines the extension to use to pick the right loader
  96748. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  96749. * @returns a InternalTexture for assignment back into BABYLON.Texture
  96750. */
  96751. 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 | ArrayBufferView | HTMLImageElement | Blob>, fallback?: Nullable<InternalTexture>, format?: Nullable<number>, forcedExtension?: Nullable<string>, excludeLoaders?: Array<IInternalTextureLoader>): InternalTexture;
  96752. /**
  96753. * @hidden
  96754. * Rescales a texture
  96755. * @param source input texutre
  96756. * @param destination destination texture
  96757. * @param scene scene to use to render the resize
  96758. * @param internalFormat format to use when resizing
  96759. * @param onComplete callback to be called when resize has completed
  96760. */
  96761. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<Scene>, internalFormat: number, onComplete: () => void): void;
  96762. private _unpackFlipYCached;
  96763. /**
  96764. * In case you are sharing the context with other applications, it might
  96765. * be interested to not cache the unpack flip y state to ensure a consistent
  96766. * value would be set.
  96767. */
  96768. enableUnpackFlipYCached: boolean;
  96769. /** @hidden */
  96770. _unpackFlipY(value: boolean): void;
  96771. /** @hidden */
  96772. _getUnpackAlignement(): number;
  96773. /**
  96774. * Creates a dynamic texture
  96775. * @param width defines the width of the texture
  96776. * @param height defines the height of the texture
  96777. * @param generateMipMaps defines if the engine should generate the mip levels
  96778. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  96779. * @returns the dynamic texture inside an InternalTexture
  96780. */
  96781. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  96782. /**
  96783. * Update the sampling mode of a given texture
  96784. * @param samplingMode defines the required sampling mode
  96785. * @param texture defines the texture to update
  96786. */
  96787. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  96788. /**
  96789. * Update the content of a dynamic texture
  96790. * @param texture defines the texture to update
  96791. * @param canvas defines the canvas containing the source
  96792. * @param invertY defines if data must be stored with Y axis inverted
  96793. * @param premulAlpha defines if alpha is stored as premultiplied
  96794. * @param format defines the format of the data
  96795. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  96796. */
  96797. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  96798. /**
  96799. * Update a video texture
  96800. * @param texture defines the texture to update
  96801. * @param video defines the video element to use
  96802. * @param invertY defines if data must be stored with Y axis inverted
  96803. */
  96804. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  96805. /**
  96806. * Updates a depth texture Comparison Mode and Function.
  96807. * If the comparison Function is equal to 0, the mode will be set to none.
  96808. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  96809. * @param texture The texture to set the comparison function for
  96810. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  96811. */
  96812. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  96813. /** @hidden */
  96814. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  96815. width: number;
  96816. height: number;
  96817. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  96818. /**
  96819. * Creates a depth stencil texture.
  96820. * This is only available in WebGL 2 or with the depth texture extension available.
  96821. * @param size The size of face edge in the texture.
  96822. * @param options The options defining the texture.
  96823. * @returns The texture
  96824. */
  96825. createDepthStencilTexture(size: number | {
  96826. width: number;
  96827. height: number;
  96828. }, options: DepthTextureCreationOptions): InternalTexture;
  96829. /**
  96830. * Creates a depth stencil texture.
  96831. * This is only available in WebGL 2 or with the depth texture extension available.
  96832. * @param size The size of face edge in the texture.
  96833. * @param options The options defining the texture.
  96834. * @returns The texture
  96835. */
  96836. private _createDepthStencilTexture;
  96837. /**
  96838. * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
  96839. * @param renderTarget The render target to set the frame buffer for
  96840. */
  96841. setFrameBufferDepthStencilTexture(renderTarget: RenderTargetTexture): void;
  96842. /**
  96843. * Creates a new render target texture
  96844. * @param size defines the size of the texture
  96845. * @param options defines the options used to create the texture
  96846. * @returns a new render target texture stored in an InternalTexture
  96847. */
  96848. createRenderTargetTexture(size: number | {
  96849. width: number;
  96850. height: number;
  96851. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  96852. /** @hidden */
  96853. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  96854. /**
  96855. * Updates the sample count of a render target texture
  96856. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  96857. * @param texture defines the texture to update
  96858. * @param samples defines the sample count to set
  96859. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  96860. */
  96861. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  96862. /** @hidden */
  96863. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  96864. /** @hidden */
  96865. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  96866. /** @hidden */
  96867. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  96868. /** @hidden */
  96869. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  96870. /**
  96871. * @hidden
  96872. */
  96873. _setCubeMapTextureParams(loadMipmap: boolean): void;
  96874. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<Scene>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  96875. private _prepareWebGLTexture;
  96876. /** @hidden */
  96877. _convertRGBtoRGBATextureData(rgbData: any, width: number, height: number, textureType: number): ArrayBufferView;
  96878. /** @hidden */
  96879. _releaseFramebufferObjects(texture: InternalTexture): void;
  96880. /** @hidden */
  96881. _releaseTexture(texture: InternalTexture): void;
  96882. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  96883. protected _setProgram(program: WebGLProgram): void;
  96884. protected _boundUniforms: {
  96885. [key: number]: WebGLUniformLocation;
  96886. };
  96887. /**
  96888. * Binds an effect to the webGL context
  96889. * @param effect defines the effect to bind
  96890. */
  96891. bindSamplers(effect: Effect): void;
  96892. private _activateCurrentTexture;
  96893. /** @hidden */
  96894. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  96895. /** @hidden */
  96896. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  96897. /**
  96898. * Sets a texture to the webGL context from a postprocess
  96899. * @param channel defines the channel to use
  96900. * @param postProcess defines the source postprocess
  96901. */
  96902. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  96903. /**
  96904. * Binds the output of the passed in post process to the texture channel specified
  96905. * @param channel The channel the texture should be bound to
  96906. * @param postProcess The post process which's output should be bound
  96907. */
  96908. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  96909. /**
  96910. * Unbind all textures from the webGL context
  96911. */
  96912. unbindAllTextures(): void;
  96913. /**
  96914. * Sets a texture to the according uniform.
  96915. * @param channel The texture channel
  96916. * @param uniform The uniform to set
  96917. * @param texture The texture to apply
  96918. */
  96919. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  96920. /**
  96921. * Sets a depth stencil texture from a render target to the according uniform.
  96922. * @param channel The texture channel
  96923. * @param uniform The uniform to set
  96924. * @param texture The render target texture containing the depth stencil texture to apply
  96925. */
  96926. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  96927. private _bindSamplerUniformToChannel;
  96928. private _getTextureWrapMode;
  96929. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  96930. /**
  96931. * Sets an array of texture to the webGL context
  96932. * @param channel defines the channel where the texture array must be set
  96933. * @param uniform defines the associated uniform location
  96934. * @param textures defines the array of textures to bind
  96935. */
  96936. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  96937. /** @hidden */
  96938. _setAnisotropicLevel(target: number, texture: BaseTexture): void;
  96939. private _setTextureParameterFloat;
  96940. private _setTextureParameterInteger;
  96941. /**
  96942. * Reads pixels from the current frame buffer. Please note that this function can be slow
  96943. * @param x defines the x coordinate of the rectangle where pixels must be read
  96944. * @param y defines the y coordinate of the rectangle where pixels must be read
  96945. * @param width defines the width of the rectangle where pixels must be read
  96946. * @param height defines the height of the rectangle where pixels must be read
  96947. * @returns a Uint8Array containing RGBA colors
  96948. */
  96949. readPixels(x: number, y: number, width: number, height: number): Uint8Array;
  96950. /**
  96951. * Add an externaly attached data from its key.
  96952. * This method call will fail and return false, if such key already exists.
  96953. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  96954. * @param key the unique key that identifies the data
  96955. * @param data the data object to associate to the key for this Engine instance
  96956. * @return true if no such key were already present and the data was added successfully, false otherwise
  96957. */
  96958. addExternalData<T>(key: string, data: T): boolean;
  96959. /**
  96960. * Get an externaly attached data from its key
  96961. * @param key the unique key that identifies the data
  96962. * @return the associated data, if present (can be null), or undefined if not present
  96963. */
  96964. getExternalData<T>(key: string): T;
  96965. /**
  96966. * Get an externaly attached data from its key, create it using a factory if it's not already present
  96967. * @param key the unique key that identifies the data
  96968. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  96969. * @return the associated data, can be null if the factory returned null.
  96970. */
  96971. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  96972. /**
  96973. * Remove an externaly attached data from the Engine instance
  96974. * @param key the unique key that identifies the data
  96975. * @return true if the data was successfully removed, false if it doesn't exist
  96976. */
  96977. removeExternalData(key: string): boolean;
  96978. /**
  96979. * Unbind all vertex attributes from the webGL context
  96980. */
  96981. unbindAllAttributes(): void;
  96982. /**
  96983. * 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
  96984. */
  96985. releaseEffects(): void;
  96986. /**
  96987. * Dispose and release all associated resources
  96988. */
  96989. dispose(): void;
  96990. /**
  96991. * Display the loading screen
  96992. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  96993. */
  96994. displayLoadingUI(): void;
  96995. /**
  96996. * Hide the loading screen
  96997. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  96998. */
  96999. hideLoadingUI(): void;
  97000. /**
  97001. * Gets the current loading screen object
  97002. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  97003. */
  97004. /**
  97005. * Sets the current loading screen object
  97006. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  97007. */
  97008. loadingScreen: ILoadingScreen;
  97009. /**
  97010. * Sets the current loading screen text
  97011. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  97012. */
  97013. loadingUIText: string;
  97014. /**
  97015. * Sets the current loading screen background color
  97016. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  97017. */
  97018. loadingUIBackgroundColor: string;
  97019. /**
  97020. * Attach a new callback raised when context lost event is fired
  97021. * @param callback defines the callback to call
  97022. */
  97023. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  97024. /**
  97025. * Attach a new callback raised when context restored event is fired
  97026. * @param callback defines the callback to call
  97027. */
  97028. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  97029. /**
  97030. * Gets the source code of the vertex shader associated with a specific webGL program
  97031. * @param program defines the program to use
  97032. * @returns a string containing the source code of the vertex shader associated with the program
  97033. */
  97034. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  97035. /**
  97036. * Gets the source code of the fragment shader associated with a specific webGL program
  97037. * @param program defines the program to use
  97038. * @returns a string containing the source code of the fragment shader associated with the program
  97039. */
  97040. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  97041. /**
  97042. * Get the current error code of the webGL context
  97043. * @returns the error code
  97044. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  97045. */
  97046. getError(): number;
  97047. /**
  97048. * Gets the current framerate
  97049. * @returns a number representing the framerate
  97050. */
  97051. getFps(): number;
  97052. /**
  97053. * Gets the time spent between current and previous frame
  97054. * @returns a number representing the delta time in ms
  97055. */
  97056. getDeltaTime(): number;
  97057. private _measureFps;
  97058. /** @hidden */
  97059. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  97060. private _canRenderToFloatFramebuffer;
  97061. private _canRenderToHalfFloatFramebuffer;
  97062. private _canRenderToFramebuffer;
  97063. /** @hidden */
  97064. _getWebGLTextureType(type: number): number;
  97065. /** @hidden */
  97066. _getInternalFormat(format: number): number;
  97067. /** @hidden */
  97068. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  97069. /** @hidden */
  97070. _getRGBAMultiSampleBufferFormat(type: number): number;
  97071. /** @hidden */
  97072. _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;
  97073. /** @hidden */
  97074. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  97075. /**
  97076. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  97077. * @returns true if the engine can be created
  97078. * @ignorenaming
  97079. */
  97080. static isSupported(): boolean;
  97081. /**
  97082. * Find the next highest power of two.
  97083. * @param x Number to start search from.
  97084. * @return Next highest power of two.
  97085. */
  97086. static CeilingPOT(x: number): number;
  97087. /**
  97088. * Find the next lowest power of two.
  97089. * @param x Number to start search from.
  97090. * @return Next lowest power of two.
  97091. */
  97092. static FloorPOT(x: number): number;
  97093. /**
  97094. * Find the nearest power of two.
  97095. * @param x Number to start search from.
  97096. * @return Next nearest power of two.
  97097. */
  97098. static NearestPOT(x: number): number;
  97099. /**
  97100. * Get the closest exponent of two
  97101. * @param value defines the value to approximate
  97102. * @param max defines the maximum value to return
  97103. * @param mode defines how to define the closest value
  97104. * @returns closest exponent of two of the given value
  97105. */
  97106. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  97107. /**
  97108. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  97109. * @param func - the function to be called
  97110. * @param requester - the object that will request the next frame. Falls back to window.
  97111. * @returns frame number
  97112. */
  97113. static QueueNewFrame(func: () => void, requester?: any): number;
  97114. /**
  97115. * Ask the browser to promote the current element to pointerlock mode
  97116. * @param element defines the DOM element to promote
  97117. */
  97118. static _RequestPointerlock(element: HTMLElement): void;
  97119. /**
  97120. * Asks the browser to exit pointerlock mode
  97121. */
  97122. static _ExitPointerlock(): void;
  97123. /**
  97124. * Ask the browser to promote the current element to fullscreen rendering mode
  97125. * @param element defines the DOM element to promote
  97126. */
  97127. static _RequestFullscreen(element: HTMLElement): void;
  97128. /**
  97129. * Asks the browser to exit fullscreen mode
  97130. */
  97131. static _ExitFullscreen(): void;
  97132. }
  97133. }
  97134. declare module BABYLON {
  97135. /**
  97136. * The engine store class is responsible to hold all the instances of Engine and Scene created
  97137. * during the life time of the application.
  97138. */
  97139. export class EngineStore {
  97140. /** Gets the list of created engines */
  97141. static Instances: Engine[];
  97142. /** @hidden */
  97143. static _LastCreatedScene: Nullable<Scene>;
  97144. /**
  97145. * Gets the latest created engine
  97146. */
  97147. static readonly LastCreatedEngine: Nullable<Engine>;
  97148. /**
  97149. * Gets the latest created scene
  97150. */
  97151. static readonly LastCreatedScene: Nullable<Scene>;
  97152. /**
  97153. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  97154. * @ignorenaming
  97155. */
  97156. static UseFallbackTexture: boolean;
  97157. /**
  97158. * Texture content used if a texture cannot loaded
  97159. * @ignorenaming
  97160. */
  97161. static FallbackTexture: string;
  97162. }
  97163. }
  97164. declare module BABYLON {
  97165. /**
  97166. * Helper class that provides a small promise polyfill
  97167. */
  97168. export class PromisePolyfill {
  97169. /**
  97170. * Static function used to check if the polyfill is required
  97171. * If this is the case then the function will inject the polyfill to window.Promise
  97172. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  97173. */
  97174. static Apply(force?: boolean): void;
  97175. }
  97176. }
  97177. declare module BABYLON {
  97178. /**
  97179. * Interface for screenshot methods with describe argument called `size` as object with options
  97180. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  97181. */
  97182. export interface IScreenshotSize {
  97183. /**
  97184. * number in pixels for canvas height
  97185. */
  97186. height?: number;
  97187. /**
  97188. * multiplier allowing render at a higher or lower resolution
  97189. * If value is defined then height and width will be ignored and taken from camera
  97190. */
  97191. precision?: number;
  97192. /**
  97193. * number in pixels for canvas width
  97194. */
  97195. width?: number;
  97196. }
  97197. }
  97198. declare module BABYLON {
  97199. interface IColor4Like {
  97200. r: float;
  97201. g: float;
  97202. b: float;
  97203. a: float;
  97204. }
  97205. /**
  97206. * Class containing a set of static utilities functions
  97207. */
  97208. export class Tools {
  97209. /**
  97210. * Gets or sets the base URL to use to load assets
  97211. */
  97212. static BaseUrl: string;
  97213. /**
  97214. * Enable/Disable Custom HTTP Request Headers globally.
  97215. * default = false
  97216. * @see CustomRequestHeaders
  97217. */
  97218. static UseCustomRequestHeaders: boolean;
  97219. /**
  97220. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  97221. * i.e. when loading files, where the server/service expects an Authorization header
  97222. */
  97223. static CustomRequestHeaders: {
  97224. [key: string]: string;
  97225. };
  97226. /**
  97227. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  97228. */
  97229. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  97230. /**
  97231. * Default behaviour for cors in the application.
  97232. * It can be a string if the expected behavior is identical in the entire app.
  97233. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  97234. */
  97235. static CorsBehavior: string | ((url: string | string[]) => string);
  97236. /**
  97237. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  97238. * @ignorenaming
  97239. */
  97240. static UseFallbackTexture: boolean;
  97241. /**
  97242. * Use this object to register external classes like custom textures or material
  97243. * to allow the laoders to instantiate them
  97244. */
  97245. static RegisteredExternalClasses: {
  97246. [key: string]: Object;
  97247. };
  97248. /**
  97249. * Texture content used if a texture cannot loaded
  97250. * @ignorenaming
  97251. */
  97252. static fallbackTexture: string;
  97253. /**
  97254. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  97255. * @param u defines the coordinate on X axis
  97256. * @param v defines the coordinate on Y axis
  97257. * @param width defines the width of the source data
  97258. * @param height defines the height of the source data
  97259. * @param pixels defines the source byte array
  97260. * @param color defines the output color
  97261. */
  97262. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  97263. /**
  97264. * Interpolates between a and b via alpha
  97265. * @param a The lower value (returned when alpha = 0)
  97266. * @param b The upper value (returned when alpha = 1)
  97267. * @param alpha The interpolation-factor
  97268. * @return The mixed value
  97269. */
  97270. static Mix(a: number, b: number, alpha: number): number;
  97271. /**
  97272. * Tries to instantiate a new object from a given class name
  97273. * @param className defines the class name to instantiate
  97274. * @returns the new object or null if the system was not able to do the instantiation
  97275. */
  97276. static Instantiate(className: string): any;
  97277. /**
  97278. * Provides a slice function that will work even on IE
  97279. * @param data defines the array to slice
  97280. * @param start defines the start of the data (optional)
  97281. * @param end defines the end of the data (optional)
  97282. * @returns the new sliced array
  97283. */
  97284. static Slice<T>(data: T, start?: number, end?: number): T;
  97285. /**
  97286. * Polyfill for setImmediate
  97287. * @param action defines the action to execute after the current execution block
  97288. */
  97289. static SetImmediate(action: () => void): void;
  97290. /**
  97291. * Function indicating if a number is an exponent of 2
  97292. * @param value defines the value to test
  97293. * @returns true if the value is an exponent of 2
  97294. */
  97295. static IsExponentOfTwo(value: number): boolean;
  97296. private static _tmpFloatArray;
  97297. /**
  97298. * Returns the nearest 32-bit single precision float representation of a Number
  97299. * @param value A Number. If the parameter is of a different type, it will get converted
  97300. * to a number or to NaN if it cannot be converted
  97301. * @returns number
  97302. */
  97303. static FloatRound(value: number): number;
  97304. /**
  97305. * Extracts the filename from a path
  97306. * @param path defines the path to use
  97307. * @returns the filename
  97308. */
  97309. static GetFilename(path: string): string;
  97310. /**
  97311. * Extracts the "folder" part of a path (everything before the filename).
  97312. * @param uri The URI to extract the info from
  97313. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  97314. * @returns The "folder" part of the path
  97315. */
  97316. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  97317. /**
  97318. * Extracts text content from a DOM element hierarchy
  97319. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  97320. */
  97321. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  97322. /**
  97323. * Convert an angle in radians to degrees
  97324. * @param angle defines the angle to convert
  97325. * @returns the angle in degrees
  97326. */
  97327. static ToDegrees(angle: number): number;
  97328. /**
  97329. * Convert an angle in degrees to radians
  97330. * @param angle defines the angle to convert
  97331. * @returns the angle in radians
  97332. */
  97333. static ToRadians(angle: number): number;
  97334. /**
  97335. * Encode a buffer to a base64 string
  97336. * @param buffer defines the buffer to encode
  97337. * @returns the encoded string
  97338. */
  97339. static EncodeArrayBufferTobase64(buffer: ArrayBuffer): string;
  97340. /**
  97341. * Returns an array if obj is not an array
  97342. * @param obj defines the object to evaluate as an array
  97343. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  97344. * @returns either obj directly if obj is an array or a new array containing obj
  97345. */
  97346. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  97347. /**
  97348. * Gets the pointer prefix to use
  97349. * @returns "pointer" if touch is enabled. Else returns "mouse"
  97350. */
  97351. static GetPointerPrefix(): string;
  97352. /**
  97353. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  97354. * @param url define the url we are trying
  97355. * @param element define the dom element where to configure the cors policy
  97356. */
  97357. static SetCorsBehavior(url: string | string[], element: {
  97358. crossOrigin: string | null;
  97359. }): void;
  97360. /**
  97361. * Removes unwanted characters from an url
  97362. * @param url defines the url to clean
  97363. * @returns the cleaned url
  97364. */
  97365. static CleanUrl(url: string): string;
  97366. /**
  97367. * Gets or sets a function used to pre-process url before using them to load assets
  97368. */
  97369. static PreprocessUrl: (url: string) => string;
  97370. /**
  97371. * Loads an image as an HTMLImageElement.
  97372. * @param input url string, ArrayBuffer, or Blob to load
  97373. * @param onLoad callback called when the image successfully loads
  97374. * @param onError callback called when the image fails to load
  97375. * @param offlineProvider offline provider for caching
  97376. * @returns the HTMLImageElement of the loaded image
  97377. */
  97378. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>): HTMLImageElement;
  97379. /**
  97380. * Loads a file
  97381. * @param url url string, ArrayBuffer, or Blob to load
  97382. * @param onSuccess callback called when the file successfully loads
  97383. * @param onProgress callback called while file is loading (if the server supports this mode)
  97384. * @param offlineProvider defines the offline provider for caching
  97385. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  97386. * @param onError callback called when the file fails to load
  97387. * @returns a file request object
  97388. */
  97389. 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;
  97390. /**
  97391. * Loads a file from a url
  97392. * @param url the file url to load
  97393. * @returns a promise containing an ArrayBuffer corrisponding to the loaded file
  97394. */
  97395. static LoadFileAsync(url: string): Promise<ArrayBuffer>;
  97396. /**
  97397. * Load a script (identified by an url). When the url returns, the
  97398. * content of this file is added into a new script element, attached to the DOM (body element)
  97399. * @param scriptUrl defines the url of the script to laod
  97400. * @param onSuccess defines the callback called when the script is loaded
  97401. * @param onError defines the callback to call if an error occurs
  97402. * @param scriptId defines the id of the script element
  97403. */
  97404. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  97405. /**
  97406. * Load an asynchronous script (identified by an url). When the url returns, the
  97407. * content of this file is added into a new script element, attached to the DOM (body element)
  97408. * @param scriptUrl defines the url of the script to laod
  97409. * @param scriptId defines the id of the script element
  97410. * @returns a promise request object
  97411. */
  97412. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<boolean>;
  97413. /**
  97414. * Loads a file from a blob
  97415. * @param fileToLoad defines the blob to use
  97416. * @param callback defines the callback to call when data is loaded
  97417. * @param progressCallback defines the callback to call during loading process
  97418. * @returns a file request object
  97419. */
  97420. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  97421. /**
  97422. * Loads a file
  97423. * @param fileToLoad defines the file to load
  97424. * @param callback defines the callback to call when data is loaded
  97425. * @param progressCallBack defines the callback to call during loading process
  97426. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  97427. * @returns a file request object
  97428. */
  97429. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  97430. /**
  97431. * Creates a data url from a given string content
  97432. * @param content defines the content to convert
  97433. * @returns the new data url link
  97434. */
  97435. static FileAsURL(content: string): string;
  97436. /**
  97437. * Format the given number to a specific decimal format
  97438. * @param value defines the number to format
  97439. * @param decimals defines the number of decimals to use
  97440. * @returns the formatted string
  97441. */
  97442. static Format(value: number, decimals?: number): string;
  97443. /**
  97444. * Tries to copy an object by duplicating every property
  97445. * @param source defines the source object
  97446. * @param destination defines the target object
  97447. * @param doNotCopyList defines a list of properties to avoid
  97448. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  97449. */
  97450. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  97451. /**
  97452. * Gets a boolean indicating if the given object has no own property
  97453. * @param obj defines the object to test
  97454. * @returns true if object has no own property
  97455. */
  97456. static IsEmpty(obj: any): boolean;
  97457. /**
  97458. * Function used to register events at window level
  97459. * @param windowElement defines the Window object to use
  97460. * @param events defines the events to register
  97461. */
  97462. static RegisterTopRootEvents(windowElement: Window, events: {
  97463. name: string;
  97464. handler: Nullable<(e: FocusEvent) => any>;
  97465. }[]): void;
  97466. /**
  97467. * Function used to unregister events from window level
  97468. * @param windowElement defines the Window object to use
  97469. * @param events defines the events to unregister
  97470. */
  97471. static UnregisterTopRootEvents(windowElement: Window, events: {
  97472. name: string;
  97473. handler: Nullable<(e: FocusEvent) => any>;
  97474. }[]): void;
  97475. /**
  97476. * @ignore
  97477. */
  97478. static _ScreenshotCanvas: HTMLCanvasElement;
  97479. /**
  97480. * Dumps the current bound framebuffer
  97481. * @param width defines the rendering width
  97482. * @param height defines the rendering height
  97483. * @param engine defines the hosting engine
  97484. * @param successCallback defines the callback triggered once the data are available
  97485. * @param mimeType defines the mime type of the result
  97486. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  97487. */
  97488. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  97489. /**
  97490. * Converts the canvas data to blob.
  97491. * This acts as a polyfill for browsers not supporting the to blob function.
  97492. * @param canvas Defines the canvas to extract the data from
  97493. * @param successCallback Defines the callback triggered once the data are available
  97494. * @param mimeType Defines the mime type of the result
  97495. */
  97496. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  97497. /**
  97498. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  97499. * @param successCallback defines the callback triggered once the data are available
  97500. * @param mimeType defines the mime type of the result
  97501. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  97502. */
  97503. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  97504. /**
  97505. * Downloads a blob in the browser
  97506. * @param blob defines the blob to download
  97507. * @param fileName defines the name of the downloaded file
  97508. */
  97509. static Download(blob: Blob, fileName: string): void;
  97510. /**
  97511. * Captures a screenshot of the current rendering
  97512. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  97513. * @param engine defines the rendering engine
  97514. * @param camera defines the source camera
  97515. * @param size This parameter can be set to a single number or to an object with the
  97516. * following (optional) properties: precision, width, height. If a single number is passed,
  97517. * it will be used for both width and height. If an object is passed, the screenshot size
  97518. * will be derived from the parameters. The precision property is a multiplier allowing
  97519. * rendering at a higher or lower resolution
  97520. * @param successCallback defines the callback receives a single parameter which contains the
  97521. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  97522. * src parameter of an <img> to display it
  97523. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  97524. * Check your browser for supported MIME types
  97525. */
  97526. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  97527. /**
  97528. * Captures a screenshot of the current rendering
  97529. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  97530. * @param engine defines the rendering engine
  97531. * @param camera defines the source camera
  97532. * @param size This parameter can be set to a single number or to an object with the
  97533. * following (optional) properties: precision, width, height. If a single number is passed,
  97534. * it will be used for both width and height. If an object is passed, the screenshot size
  97535. * will be derived from the parameters. The precision property is a multiplier allowing
  97536. * rendering at a higher or lower resolution
  97537. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  97538. * Check your browser for supported MIME types
  97539. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  97540. * to the src parameter of an <img> to display it
  97541. */
  97542. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  97543. /**
  97544. * Generates an image screenshot from the specified camera.
  97545. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  97546. * @param engine The engine to use for rendering
  97547. * @param camera The camera to use for rendering
  97548. * @param size This parameter can be set to a single number or to an object with the
  97549. * following (optional) properties: precision, width, height. If a single number is passed,
  97550. * it will be used for both width and height. If an object is passed, the screenshot size
  97551. * will be derived from the parameters. The precision property is a multiplier allowing
  97552. * rendering at a higher or lower resolution
  97553. * @param successCallback The callback receives a single parameter which contains the
  97554. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  97555. * src parameter of an <img> to display it
  97556. * @param mimeType The MIME type of the screenshot image (default: image/png).
  97557. * Check your browser for supported MIME types
  97558. * @param samples Texture samples (default: 1)
  97559. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  97560. * @param fileName A name for for the downloaded file.
  97561. */
  97562. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  97563. /**
  97564. * Generates an image screenshot from the specified camera.
  97565. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  97566. * @param engine The engine to use for rendering
  97567. * @param camera The camera to use for rendering
  97568. * @param size This parameter can be set to a single number or to an object with the
  97569. * following (optional) properties: precision, width, height. If a single number is passed,
  97570. * it will be used for both width and height. If an object is passed, the screenshot size
  97571. * will be derived from the parameters. The precision property is a multiplier allowing
  97572. * rendering at a higher or lower resolution
  97573. * @param mimeType The MIME type of the screenshot image (default: image/png).
  97574. * Check your browser for supported MIME types
  97575. * @param samples Texture samples (default: 1)
  97576. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  97577. * @param fileName A name for for the downloaded file.
  97578. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  97579. * to the src parameter of an <img> to display it
  97580. */
  97581. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  97582. /**
  97583. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  97584. * Be aware Math.random() could cause collisions, but:
  97585. * "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"
  97586. * @returns a pseudo random id
  97587. */
  97588. static RandomId(): string;
  97589. /**
  97590. * Test if the given uri is a base64 string
  97591. * @param uri The uri to test
  97592. * @return True if the uri is a base64 string or false otherwise
  97593. */
  97594. static IsBase64(uri: string): boolean;
  97595. /**
  97596. * Decode the given base64 uri.
  97597. * @param uri The uri to decode
  97598. * @return The decoded base64 data.
  97599. */
  97600. static DecodeBase64(uri: string): ArrayBuffer;
  97601. /**
  97602. * Gets the absolute url.
  97603. * @param url the input url
  97604. * @return the absolute url
  97605. */
  97606. static GetAbsoluteUrl(url: string): string;
  97607. /**
  97608. * No log
  97609. */
  97610. static readonly NoneLogLevel: number;
  97611. /**
  97612. * Only message logs
  97613. */
  97614. static readonly MessageLogLevel: number;
  97615. /**
  97616. * Only warning logs
  97617. */
  97618. static readonly WarningLogLevel: number;
  97619. /**
  97620. * Only error logs
  97621. */
  97622. static readonly ErrorLogLevel: number;
  97623. /**
  97624. * All logs
  97625. */
  97626. static readonly AllLogLevel: number;
  97627. /**
  97628. * Gets a value indicating the number of loading errors
  97629. * @ignorenaming
  97630. */
  97631. static readonly errorsCount: number;
  97632. /**
  97633. * Callback called when a new log is added
  97634. */
  97635. static OnNewCacheEntry: (entry: string) => void;
  97636. /**
  97637. * Log a message to the console
  97638. * @param message defines the message to log
  97639. */
  97640. static Log(message: string): void;
  97641. /**
  97642. * Write a warning message to the console
  97643. * @param message defines the message to log
  97644. */
  97645. static Warn(message: string): void;
  97646. /**
  97647. * Write an error message to the console
  97648. * @param message defines the message to log
  97649. */
  97650. static Error(message: string): void;
  97651. /**
  97652. * Gets current log cache (list of logs)
  97653. */
  97654. static readonly LogCache: string;
  97655. /**
  97656. * Clears the log cache
  97657. */
  97658. static ClearLogCache(): void;
  97659. /**
  97660. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  97661. */
  97662. static LogLevels: number;
  97663. /**
  97664. * Checks if the window object exists
  97665. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  97666. */
  97667. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  97668. /**
  97669. * No performance log
  97670. */
  97671. static readonly PerformanceNoneLogLevel: number;
  97672. /**
  97673. * Use user marks to log performance
  97674. */
  97675. static readonly PerformanceUserMarkLogLevel: number;
  97676. /**
  97677. * Log performance to the console
  97678. */
  97679. static readonly PerformanceConsoleLogLevel: number;
  97680. private static _performance;
  97681. /**
  97682. * Sets the current performance log level
  97683. */
  97684. static PerformanceLogLevel: number;
  97685. private static _StartPerformanceCounterDisabled;
  97686. private static _EndPerformanceCounterDisabled;
  97687. private static _StartUserMark;
  97688. private static _EndUserMark;
  97689. private static _StartPerformanceConsole;
  97690. private static _EndPerformanceConsole;
  97691. /**
  97692. * Starts a performance counter
  97693. */
  97694. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  97695. /**
  97696. * Ends a specific performance coutner
  97697. */
  97698. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  97699. /**
  97700. * Gets either window.performance.now() if supported or Date.now() else
  97701. */
  97702. static readonly Now: number;
  97703. /**
  97704. * This method will return the name of the class used to create the instance of the given object.
  97705. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  97706. * @param object the object to get the class name from
  97707. * @param isType defines if the object is actually a type
  97708. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  97709. */
  97710. static GetClassName(object: any, isType?: boolean): string;
  97711. /**
  97712. * Gets the first element of an array satisfying a given predicate
  97713. * @param array defines the array to browse
  97714. * @param predicate defines the predicate to use
  97715. * @returns null if not found or the element
  97716. */
  97717. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  97718. /**
  97719. * This method will return the name of the full name of the class, including its owning module (if any).
  97720. * 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).
  97721. * @param object the object to get the class name from
  97722. * @param isType defines if the object is actually a type
  97723. * @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.
  97724. * @ignorenaming
  97725. */
  97726. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  97727. /**
  97728. * Returns a promise that resolves after the given amount of time.
  97729. * @param delay Number of milliseconds to delay
  97730. * @returns Promise that resolves after the given amount of time
  97731. */
  97732. static DelayAsync(delay: number): Promise<void>;
  97733. }
  97734. /**
  97735. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  97736. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  97737. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  97738. * @param name The name of the class, case should be preserved
  97739. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  97740. */
  97741. export function className(name: string, module?: string): (target: Object) => void;
  97742. /**
  97743. * An implementation of a loop for asynchronous functions.
  97744. */
  97745. export class AsyncLoop {
  97746. /**
  97747. * Defines the number of iterations for the loop
  97748. */
  97749. iterations: number;
  97750. /**
  97751. * Defines the current index of the loop.
  97752. */
  97753. index: number;
  97754. private _done;
  97755. private _fn;
  97756. private _successCallback;
  97757. /**
  97758. * Constructor.
  97759. * @param iterations the number of iterations.
  97760. * @param func the function to run each iteration
  97761. * @param successCallback the callback that will be called upon succesful execution
  97762. * @param offset starting offset.
  97763. */
  97764. constructor(
  97765. /**
  97766. * Defines the number of iterations for the loop
  97767. */
  97768. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  97769. /**
  97770. * Execute the next iteration. Must be called after the last iteration was finished.
  97771. */
  97772. executeNext(): void;
  97773. /**
  97774. * Break the loop and run the success callback.
  97775. */
  97776. breakLoop(): void;
  97777. /**
  97778. * Create and run an async loop.
  97779. * @param iterations the number of iterations.
  97780. * @param fn the function to run each iteration
  97781. * @param successCallback the callback that will be called upon succesful execution
  97782. * @param offset starting offset.
  97783. * @returns the created async loop object
  97784. */
  97785. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  97786. /**
  97787. * A for-loop that will run a given number of iterations synchronous and the rest async.
  97788. * @param iterations total number of iterations
  97789. * @param syncedIterations number of synchronous iterations in each async iteration.
  97790. * @param fn the function to call each iteration.
  97791. * @param callback a success call back that will be called when iterating stops.
  97792. * @param breakFunction a break condition (optional)
  97793. * @param timeout timeout settings for the setTimeout function. default - 0.
  97794. * @returns the created async loop object
  97795. */
  97796. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  97797. }
  97798. }
  97799. declare module BABYLON {
  97800. /** @hidden */
  97801. export interface ICollisionCoordinator {
  97802. createCollider(): Collider;
  97803. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  97804. init(scene: Scene): void;
  97805. }
  97806. /** @hidden */
  97807. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  97808. private _scene;
  97809. private _scaledPosition;
  97810. private _scaledVelocity;
  97811. private _finalPosition;
  97812. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  97813. createCollider(): Collider;
  97814. init(scene: Scene): void;
  97815. private _collideWithWorld;
  97816. }
  97817. }
  97818. declare module BABYLON {
  97819. /**
  97820. * Class used to manage all inputs for the scene.
  97821. */
  97822. export class InputManager {
  97823. /** The distance in pixel that you have to move to prevent some events */
  97824. static DragMovementThreshold: number;
  97825. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  97826. static LongPressDelay: number;
  97827. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  97828. static DoubleClickDelay: number;
  97829. /** If you need to check double click without raising a single click at first click, enable this flag */
  97830. static ExclusiveDoubleClickMode: boolean;
  97831. private _wheelEventName;
  97832. private _onPointerMove;
  97833. private _onPointerDown;
  97834. private _onPointerUp;
  97835. private _initClickEvent;
  97836. private _initActionManager;
  97837. private _delayedSimpleClick;
  97838. private _delayedSimpleClickTimeout;
  97839. private _previousDelayedSimpleClickTimeout;
  97840. private _meshPickProceed;
  97841. private _previousButtonPressed;
  97842. private _currentPickResult;
  97843. private _previousPickResult;
  97844. private _totalPointersPressed;
  97845. private _doubleClickOccured;
  97846. private _pointerOverMesh;
  97847. private _pickedDownMesh;
  97848. private _pickedUpMesh;
  97849. private _pointerX;
  97850. private _pointerY;
  97851. private _unTranslatedPointerX;
  97852. private _unTranslatedPointerY;
  97853. private _startingPointerPosition;
  97854. private _previousStartingPointerPosition;
  97855. private _startingPointerTime;
  97856. private _previousStartingPointerTime;
  97857. private _pointerCaptures;
  97858. private _onKeyDown;
  97859. private _onKeyUp;
  97860. private _onCanvasFocusObserver;
  97861. private _onCanvasBlurObserver;
  97862. private _scene;
  97863. /**
  97864. * Creates a new InputManager
  97865. * @param scene defines the hosting scene
  97866. */
  97867. constructor(scene: Scene);
  97868. /**
  97869. * Gets the mesh that is currently under the pointer
  97870. */
  97871. readonly meshUnderPointer: Nullable<AbstractMesh>;
  97872. /**
  97873. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  97874. */
  97875. readonly unTranslatedPointer: Vector2;
  97876. /**
  97877. * Gets or sets the current on-screen X position of the pointer
  97878. */
  97879. pointerX: number;
  97880. /**
  97881. * Gets or sets the current on-screen Y position of the pointer
  97882. */
  97883. pointerY: number;
  97884. private _updatePointerPosition;
  97885. private _processPointerMove;
  97886. private _setRayOnPointerInfo;
  97887. private _checkPrePointerObservable;
  97888. /**
  97889. * Use this method to simulate a pointer move on a mesh
  97890. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  97891. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  97892. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  97893. */
  97894. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  97895. /**
  97896. * Use this method to simulate a pointer down on a mesh
  97897. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  97898. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  97899. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  97900. */
  97901. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  97902. private _processPointerDown;
  97903. /** @hidden */
  97904. _isPointerSwiping(): boolean;
  97905. /**
  97906. * Use this method to simulate a pointer up on a mesh
  97907. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  97908. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  97909. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  97910. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  97911. */
  97912. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  97913. private _processPointerUp;
  97914. /**
  97915. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  97916. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  97917. * @returns true if the pointer was captured
  97918. */
  97919. isPointerCaptured(pointerId?: number): boolean;
  97920. /**
  97921. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  97922. * @param attachUp defines if you want to attach events to pointerup
  97923. * @param attachDown defines if you want to attach events to pointerdown
  97924. * @param attachMove defines if you want to attach events to pointermove
  97925. */
  97926. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  97927. /**
  97928. * Detaches all event handlers
  97929. */
  97930. detachControl(): void;
  97931. /**
  97932. * Force the value of meshUnderPointer
  97933. * @param mesh defines the mesh to use
  97934. */
  97935. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  97936. /**
  97937. * Gets the mesh under the pointer
  97938. * @returns a Mesh or null if no mesh is under the pointer
  97939. */
  97940. getPointerOverMesh(): Nullable<AbstractMesh>;
  97941. }
  97942. }
  97943. declare module BABYLON {
  97944. /**
  97945. * Helper class used to generate session unique ID
  97946. */
  97947. export class UniqueIdGenerator {
  97948. private static _UniqueIdCounter;
  97949. /**
  97950. * Gets an unique (relatively to the current scene) Id
  97951. */
  97952. static readonly UniqueId: number;
  97953. }
  97954. }
  97955. declare module BABYLON {
  97956. /**
  97957. * This class defines the direct association between an animation and a target
  97958. */
  97959. export class TargetedAnimation {
  97960. /**
  97961. * Animation to perform
  97962. */
  97963. animation: Animation;
  97964. /**
  97965. * Target to animate
  97966. */
  97967. target: any;
  97968. /**
  97969. * Serialize the object
  97970. * @returns the JSON object representing the current entity
  97971. */
  97972. serialize(): any;
  97973. }
  97974. /**
  97975. * Use this class to create coordinated animations on multiple targets
  97976. */
  97977. export class AnimationGroup implements IDisposable {
  97978. /** The name of the animation group */
  97979. name: string;
  97980. private _scene;
  97981. private _targetedAnimations;
  97982. private _animatables;
  97983. private _from;
  97984. private _to;
  97985. private _isStarted;
  97986. private _isPaused;
  97987. private _speedRatio;
  97988. private _loopAnimation;
  97989. /**
  97990. * Gets or sets the unique id of the node
  97991. */
  97992. uniqueId: number;
  97993. /**
  97994. * This observable will notify when one animation have ended
  97995. */
  97996. onAnimationEndObservable: Observable<TargetedAnimation>;
  97997. /**
  97998. * Observer raised when one animation loops
  97999. */
  98000. onAnimationLoopObservable: Observable<TargetedAnimation>;
  98001. /**
  98002. * This observable will notify when all animations have ended.
  98003. */
  98004. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  98005. /**
  98006. * This observable will notify when all animations have paused.
  98007. */
  98008. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  98009. /**
  98010. * This observable will notify when all animations are playing.
  98011. */
  98012. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  98013. /**
  98014. * Gets the first frame
  98015. */
  98016. readonly from: number;
  98017. /**
  98018. * Gets the last frame
  98019. */
  98020. readonly to: number;
  98021. /**
  98022. * Define if the animations are started
  98023. */
  98024. readonly isStarted: boolean;
  98025. /**
  98026. * Gets a value indicating that the current group is playing
  98027. */
  98028. readonly isPlaying: boolean;
  98029. /**
  98030. * Gets or sets the speed ratio to use for all animations
  98031. */
  98032. /**
  98033. * Gets or sets the speed ratio to use for all animations
  98034. */
  98035. speedRatio: number;
  98036. /**
  98037. * Gets or sets if all animations should loop or not
  98038. */
  98039. loopAnimation: boolean;
  98040. /**
  98041. * Gets the targeted animations for this animation group
  98042. */
  98043. readonly targetedAnimations: Array<TargetedAnimation>;
  98044. /**
  98045. * returning the list of animatables controlled by this animation group.
  98046. */
  98047. readonly animatables: Array<Animatable>;
  98048. /**
  98049. * Instantiates a new Animation Group.
  98050. * This helps managing several animations at once.
  98051. * @see http://doc.babylonjs.com/how_to/group
  98052. * @param name Defines the name of the group
  98053. * @param scene Defines the scene the group belongs to
  98054. */
  98055. constructor(
  98056. /** The name of the animation group */
  98057. name: string, scene?: Nullable<Scene>);
  98058. /**
  98059. * Add an animation (with its target) in the group
  98060. * @param animation defines the animation we want to add
  98061. * @param target defines the target of the animation
  98062. * @returns the TargetedAnimation object
  98063. */
  98064. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  98065. /**
  98066. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  98067. * It can add constant keys at begin or end
  98068. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  98069. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  98070. * @returns the animation group
  98071. */
  98072. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  98073. /**
  98074. * Start all animations on given targets
  98075. * @param loop defines if animations must loop
  98076. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  98077. * @param from defines the from key (optional)
  98078. * @param to defines the to key (optional)
  98079. * @returns the current animation group
  98080. */
  98081. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  98082. /**
  98083. * Pause all animations
  98084. * @returns the animation group
  98085. */
  98086. pause(): AnimationGroup;
  98087. /**
  98088. * Play all animations to initial state
  98089. * This function will start() the animations if they were not started or will restart() them if they were paused
  98090. * @param loop defines if animations must loop
  98091. * @returns the animation group
  98092. */
  98093. play(loop?: boolean): AnimationGroup;
  98094. /**
  98095. * Reset all animations to initial state
  98096. * @returns the animation group
  98097. */
  98098. reset(): AnimationGroup;
  98099. /**
  98100. * Restart animations from key 0
  98101. * @returns the animation group
  98102. */
  98103. restart(): AnimationGroup;
  98104. /**
  98105. * Stop all animations
  98106. * @returns the animation group
  98107. */
  98108. stop(): AnimationGroup;
  98109. /**
  98110. * Set animation weight for all animatables
  98111. * @param weight defines the weight to use
  98112. * @return the animationGroup
  98113. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  98114. */
  98115. setWeightForAllAnimatables(weight: number): AnimationGroup;
  98116. /**
  98117. * Synchronize and normalize all animatables with a source animatable
  98118. * @param root defines the root animatable to synchronize with
  98119. * @return the animationGroup
  98120. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  98121. */
  98122. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  98123. /**
  98124. * Goes to a specific frame in this animation group
  98125. * @param frame the frame number to go to
  98126. * @return the animationGroup
  98127. */
  98128. goToFrame(frame: number): AnimationGroup;
  98129. /**
  98130. * Dispose all associated resources
  98131. */
  98132. dispose(): void;
  98133. private _checkAnimationGroupEnded;
  98134. /**
  98135. * Clone the current animation group and returns a copy
  98136. * @param newName defines the name of the new group
  98137. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  98138. * @returns the new aniamtion group
  98139. */
  98140. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  98141. /**
  98142. * Serializes the animationGroup to an object
  98143. * @returns Serialized object
  98144. */
  98145. serialize(): any;
  98146. /**
  98147. * Returns a new AnimationGroup object parsed from the source provided.
  98148. * @param parsedAnimationGroup defines the source
  98149. * @param scene defines the scene that will receive the animationGroup
  98150. * @returns a new AnimationGroup
  98151. */
  98152. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  98153. /**
  98154. * Returns the string "AnimationGroup"
  98155. * @returns "AnimationGroup"
  98156. */
  98157. getClassName(): string;
  98158. /**
  98159. * Creates a detailled string about the object
  98160. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  98161. * @returns a string representing the object
  98162. */
  98163. toString(fullDetails?: boolean): string;
  98164. }
  98165. }
  98166. declare module BABYLON {
  98167. /**
  98168. * Define an interface for all classes that will hold resources
  98169. */
  98170. export interface IDisposable {
  98171. /**
  98172. * Releases all held resources
  98173. */
  98174. dispose(): void;
  98175. }
  98176. /** Interface defining initialization parameters for Scene class */
  98177. export interface SceneOptions {
  98178. /**
  98179. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  98180. * It will improve performance when the number of geometries becomes important.
  98181. */
  98182. useGeometryUniqueIdsMap?: boolean;
  98183. /**
  98184. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  98185. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  98186. */
  98187. useMaterialMeshMap?: boolean;
  98188. /**
  98189. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  98190. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  98191. */
  98192. useClonedMeshhMap?: boolean;
  98193. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  98194. virtual?: boolean;
  98195. }
  98196. /**
  98197. * Represents a scene to be rendered by the engine.
  98198. * @see http://doc.babylonjs.com/features/scene
  98199. */
  98200. export class Scene extends AbstractScene implements IAnimatable {
  98201. /** The fog is deactivated */
  98202. static readonly FOGMODE_NONE: number;
  98203. /** The fog density is following an exponential function */
  98204. static readonly FOGMODE_EXP: number;
  98205. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  98206. static readonly FOGMODE_EXP2: number;
  98207. /** The fog density is following a linear function. */
  98208. static readonly FOGMODE_LINEAR: number;
  98209. /**
  98210. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  98211. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  98212. */
  98213. static MinDeltaTime: number;
  98214. /**
  98215. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  98216. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  98217. */
  98218. static MaxDeltaTime: number;
  98219. /**
  98220. * Factory used to create the default material.
  98221. * @param name The name of the material to create
  98222. * @param scene The scene to create the material for
  98223. * @returns The default material
  98224. */
  98225. static DefaultMaterialFactory(scene: Scene): Material;
  98226. /**
  98227. * Factory used to create the a collision coordinator.
  98228. * @returns The collision coordinator
  98229. */
  98230. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  98231. /** @hidden */
  98232. _inputManager: InputManager;
  98233. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  98234. cameraToUseForPointers: Nullable<Camera>;
  98235. /** @hidden */
  98236. readonly _isScene: boolean;
  98237. /**
  98238. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  98239. */
  98240. autoClear: boolean;
  98241. /**
  98242. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  98243. */
  98244. autoClearDepthAndStencil: boolean;
  98245. /**
  98246. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  98247. */
  98248. clearColor: Color4;
  98249. /**
  98250. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  98251. */
  98252. ambientColor: Color3;
  98253. /**
  98254. * This is use to store the default BRDF lookup for PBR materials in your scene.
  98255. * It should only be one of the following (if not the default embedded one):
  98256. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  98257. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  98258. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  98259. * The material properties need to be setup according to the type of texture in use.
  98260. */
  98261. environmentBRDFTexture: BaseTexture;
  98262. /** @hidden */
  98263. protected _environmentTexture: Nullable<BaseTexture>;
  98264. /**
  98265. * Texture used in all pbr material as the reflection texture.
  98266. * As in the majority of the scene they are the same (exception for multi room and so on),
  98267. * this is easier to reference from here than from all the materials.
  98268. */
  98269. /**
  98270. * Texture used in all pbr material as the reflection texture.
  98271. * As in the majority of the scene they are the same (exception for multi room and so on),
  98272. * this is easier to set here than in all the materials.
  98273. */
  98274. environmentTexture: Nullable<BaseTexture>;
  98275. /** @hidden */
  98276. protected _environmentIntensity: number;
  98277. /**
  98278. * Intensity of the environment in all pbr material.
  98279. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  98280. * As in the majority of the scene they are the same (exception for multi room and so on),
  98281. * this is easier to reference from here than from all the materials.
  98282. */
  98283. /**
  98284. * Intensity of the environment in all pbr material.
  98285. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  98286. * As in the majority of the scene they are the same (exception for multi room and so on),
  98287. * this is easier to set here than in all the materials.
  98288. */
  98289. environmentIntensity: number;
  98290. /** @hidden */
  98291. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  98292. /**
  98293. * Default image processing configuration used either in the rendering
  98294. * Forward main pass or through the imageProcessingPostProcess if present.
  98295. * As in the majority of the scene they are the same (exception for multi camera),
  98296. * this is easier to reference from here than from all the materials and post process.
  98297. *
  98298. * No setter as we it is a shared configuration, you can set the values instead.
  98299. */
  98300. readonly imageProcessingConfiguration: ImageProcessingConfiguration;
  98301. private _forceWireframe;
  98302. /**
  98303. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  98304. */
  98305. forceWireframe: boolean;
  98306. private _forcePointsCloud;
  98307. /**
  98308. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  98309. */
  98310. forcePointsCloud: boolean;
  98311. /**
  98312. * Gets or sets the active clipplane 1
  98313. */
  98314. clipPlane: Nullable<Plane>;
  98315. /**
  98316. * Gets or sets the active clipplane 2
  98317. */
  98318. clipPlane2: Nullable<Plane>;
  98319. /**
  98320. * Gets or sets the active clipplane 3
  98321. */
  98322. clipPlane3: Nullable<Plane>;
  98323. /**
  98324. * Gets or sets the active clipplane 4
  98325. */
  98326. clipPlane4: Nullable<Plane>;
  98327. /**
  98328. * Gets or sets a boolean indicating if animations are enabled
  98329. */
  98330. animationsEnabled: boolean;
  98331. private _animationPropertiesOverride;
  98332. /**
  98333. * Gets or sets the animation properties override
  98334. */
  98335. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  98336. /**
  98337. * Gets or sets a boolean indicating if a constant deltatime has to be used
  98338. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  98339. */
  98340. useConstantAnimationDeltaTime: boolean;
  98341. /**
  98342. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  98343. * Please note that it requires to run a ray cast through the scene on every frame
  98344. */
  98345. constantlyUpdateMeshUnderPointer: boolean;
  98346. /**
  98347. * Defines the HTML cursor to use when hovering over interactive elements
  98348. */
  98349. hoverCursor: string;
  98350. /**
  98351. * Defines the HTML default cursor to use (empty by default)
  98352. */
  98353. defaultCursor: string;
  98354. /**
  98355. * This is used to call preventDefault() on pointer down
  98356. * in order to block unwanted artifacts like system double clicks
  98357. */
  98358. preventDefaultOnPointerDown: boolean;
  98359. /**
  98360. * This is used to call preventDefault() on pointer up
  98361. * in order to block unwanted artifacts like system double clicks
  98362. */
  98363. preventDefaultOnPointerUp: boolean;
  98364. /**
  98365. * Gets or sets user defined metadata
  98366. */
  98367. metadata: any;
  98368. /**
  98369. * For internal use only. Please do not use.
  98370. */
  98371. reservedDataStore: any;
  98372. /**
  98373. * Gets the name of the plugin used to load this scene (null by default)
  98374. */
  98375. loadingPluginName: string;
  98376. /**
  98377. * Use this array to add regular expressions used to disable offline support for specific urls
  98378. */
  98379. disableOfflineSupportExceptionRules: RegExp[];
  98380. /**
  98381. * An event triggered when the scene is disposed.
  98382. */
  98383. onDisposeObservable: Observable<Scene>;
  98384. private _onDisposeObserver;
  98385. /** Sets a function to be executed when this scene is disposed. */
  98386. onDispose: () => void;
  98387. /**
  98388. * An event triggered before rendering the scene (right after animations and physics)
  98389. */
  98390. onBeforeRenderObservable: Observable<Scene>;
  98391. private _onBeforeRenderObserver;
  98392. /** Sets a function to be executed before rendering this scene */
  98393. beforeRender: Nullable<() => void>;
  98394. /**
  98395. * An event triggered after rendering the scene
  98396. */
  98397. onAfterRenderObservable: Observable<Scene>;
  98398. /**
  98399. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  98400. */
  98401. onAfterRenderCameraObservable: Observable<Camera>;
  98402. private _onAfterRenderObserver;
  98403. /** Sets a function to be executed after rendering this scene */
  98404. afterRender: Nullable<() => void>;
  98405. /**
  98406. * An event triggered before animating the scene
  98407. */
  98408. onBeforeAnimationsObservable: Observable<Scene>;
  98409. /**
  98410. * An event triggered after animations processing
  98411. */
  98412. onAfterAnimationsObservable: Observable<Scene>;
  98413. /**
  98414. * An event triggered before draw calls are ready to be sent
  98415. */
  98416. onBeforeDrawPhaseObservable: Observable<Scene>;
  98417. /**
  98418. * An event triggered after draw calls have been sent
  98419. */
  98420. onAfterDrawPhaseObservable: Observable<Scene>;
  98421. /**
  98422. * An event triggered when the scene is ready
  98423. */
  98424. onReadyObservable: Observable<Scene>;
  98425. /**
  98426. * An event triggered before rendering a camera
  98427. */
  98428. onBeforeCameraRenderObservable: Observable<Camera>;
  98429. private _onBeforeCameraRenderObserver;
  98430. /** Sets a function to be executed before rendering a camera*/
  98431. beforeCameraRender: () => void;
  98432. /**
  98433. * An event triggered after rendering a camera
  98434. */
  98435. onAfterCameraRenderObservable: Observable<Camera>;
  98436. private _onAfterCameraRenderObserver;
  98437. /** Sets a function to be executed after rendering a camera*/
  98438. afterCameraRender: () => void;
  98439. /**
  98440. * An event triggered when active meshes evaluation is about to start
  98441. */
  98442. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  98443. /**
  98444. * An event triggered when active meshes evaluation is done
  98445. */
  98446. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  98447. /**
  98448. * An event triggered when particles rendering is about to start
  98449. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  98450. */
  98451. onBeforeParticlesRenderingObservable: Observable<Scene>;
  98452. /**
  98453. * An event triggered when particles rendering is done
  98454. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  98455. */
  98456. onAfterParticlesRenderingObservable: Observable<Scene>;
  98457. /**
  98458. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  98459. */
  98460. onDataLoadedObservable: Observable<Scene>;
  98461. /**
  98462. * An event triggered when a camera is created
  98463. */
  98464. onNewCameraAddedObservable: Observable<Camera>;
  98465. /**
  98466. * An event triggered when a camera is removed
  98467. */
  98468. onCameraRemovedObservable: Observable<Camera>;
  98469. /**
  98470. * An event triggered when a light is created
  98471. */
  98472. onNewLightAddedObservable: Observable<Light>;
  98473. /**
  98474. * An event triggered when a light is removed
  98475. */
  98476. onLightRemovedObservable: Observable<Light>;
  98477. /**
  98478. * An event triggered when a geometry is created
  98479. */
  98480. onNewGeometryAddedObservable: Observable<Geometry>;
  98481. /**
  98482. * An event triggered when a geometry is removed
  98483. */
  98484. onGeometryRemovedObservable: Observable<Geometry>;
  98485. /**
  98486. * An event triggered when a transform node is created
  98487. */
  98488. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  98489. /**
  98490. * An event triggered when a transform node is removed
  98491. */
  98492. onTransformNodeRemovedObservable: Observable<TransformNode>;
  98493. /**
  98494. * An event triggered when a mesh is created
  98495. */
  98496. onNewMeshAddedObservable: Observable<AbstractMesh>;
  98497. /**
  98498. * An event triggered when a mesh is removed
  98499. */
  98500. onMeshRemovedObservable: Observable<AbstractMesh>;
  98501. /**
  98502. * An event triggered when a skeleton is created
  98503. */
  98504. onNewSkeletonAddedObservable: Observable<Skeleton>;
  98505. /**
  98506. * An event triggered when a skeleton is removed
  98507. */
  98508. onSkeletonRemovedObservable: Observable<Skeleton>;
  98509. /**
  98510. * An event triggered when a material is created
  98511. */
  98512. onNewMaterialAddedObservable: Observable<Material>;
  98513. /**
  98514. * An event triggered when a material is removed
  98515. */
  98516. onMaterialRemovedObservable: Observable<Material>;
  98517. /**
  98518. * An event triggered when a texture is created
  98519. */
  98520. onNewTextureAddedObservable: Observable<BaseTexture>;
  98521. /**
  98522. * An event triggered when a texture is removed
  98523. */
  98524. onTextureRemovedObservable: Observable<BaseTexture>;
  98525. /**
  98526. * An event triggered when render targets are about to be rendered
  98527. * Can happen multiple times per frame.
  98528. */
  98529. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  98530. /**
  98531. * An event triggered when render targets were rendered.
  98532. * Can happen multiple times per frame.
  98533. */
  98534. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  98535. /**
  98536. * An event triggered before calculating deterministic simulation step
  98537. */
  98538. onBeforeStepObservable: Observable<Scene>;
  98539. /**
  98540. * An event triggered after calculating deterministic simulation step
  98541. */
  98542. onAfterStepObservable: Observable<Scene>;
  98543. /**
  98544. * An event triggered when the activeCamera property is updated
  98545. */
  98546. onActiveCameraChanged: Observable<Scene>;
  98547. /**
  98548. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  98549. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  98550. * 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)
  98551. */
  98552. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  98553. /**
  98554. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  98555. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  98556. * 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)
  98557. */
  98558. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  98559. /**
  98560. * This Observable will when a mesh has been imported into the scene.
  98561. */
  98562. onMeshImportedObservable: Observable<AbstractMesh>;
  98563. /**
  98564. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  98565. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  98566. */
  98567. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  98568. /** @hidden */
  98569. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  98570. /**
  98571. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  98572. */
  98573. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  98574. /**
  98575. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  98576. */
  98577. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  98578. /**
  98579. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  98580. */
  98581. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  98582. /** Callback called when a pointer move is detected */
  98583. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  98584. /** Callback called when a pointer down is detected */
  98585. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  98586. /** Callback called when a pointer up is detected */
  98587. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  98588. /** Callback called when a pointer pick is detected */
  98589. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  98590. /**
  98591. * 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).
  98592. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  98593. */
  98594. onPrePointerObservable: Observable<PointerInfoPre>;
  98595. /**
  98596. * Observable event triggered each time an input event is received from the rendering canvas
  98597. */
  98598. onPointerObservable: Observable<PointerInfo>;
  98599. /**
  98600. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  98601. */
  98602. readonly unTranslatedPointer: Vector2;
  98603. /**
  98604. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  98605. */
  98606. static DragMovementThreshold: number;
  98607. /**
  98608. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  98609. */
  98610. static LongPressDelay: number;
  98611. /**
  98612. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  98613. */
  98614. static DoubleClickDelay: number;
  98615. /** If you need to check double click without raising a single click at first click, enable this flag */
  98616. static ExclusiveDoubleClickMode: boolean;
  98617. /** @hidden */
  98618. _mirroredCameraPosition: Nullable<Vector3>;
  98619. /**
  98620. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  98621. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  98622. */
  98623. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  98624. /**
  98625. * Observable event triggered each time an keyboard event is received from the hosting window
  98626. */
  98627. onKeyboardObservable: Observable<KeyboardInfo>;
  98628. private _useRightHandedSystem;
  98629. /**
  98630. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  98631. */
  98632. useRightHandedSystem: boolean;
  98633. private _timeAccumulator;
  98634. private _currentStepId;
  98635. private _currentInternalStep;
  98636. /**
  98637. * Sets the step Id used by deterministic lock step
  98638. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  98639. * @param newStepId defines the step Id
  98640. */
  98641. setStepId(newStepId: number): void;
  98642. /**
  98643. * Gets the step Id used by deterministic lock step
  98644. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  98645. * @returns the step Id
  98646. */
  98647. getStepId(): number;
  98648. /**
  98649. * Gets the internal step used by deterministic lock step
  98650. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  98651. * @returns the internal step
  98652. */
  98653. getInternalStep(): number;
  98654. private _fogEnabled;
  98655. /**
  98656. * Gets or sets a boolean indicating if fog is enabled on this scene
  98657. * @see http://doc.babylonjs.com/babylon101/environment#fog
  98658. * (Default is true)
  98659. */
  98660. fogEnabled: boolean;
  98661. private _fogMode;
  98662. /**
  98663. * Gets or sets the fog mode to use
  98664. * @see http://doc.babylonjs.com/babylon101/environment#fog
  98665. * | mode | value |
  98666. * | --- | --- |
  98667. * | FOGMODE_NONE | 0 |
  98668. * | FOGMODE_EXP | 1 |
  98669. * | FOGMODE_EXP2 | 2 |
  98670. * | FOGMODE_LINEAR | 3 |
  98671. */
  98672. fogMode: number;
  98673. /**
  98674. * Gets or sets the fog color to use
  98675. * @see http://doc.babylonjs.com/babylon101/environment#fog
  98676. * (Default is Color3(0.2, 0.2, 0.3))
  98677. */
  98678. fogColor: Color3;
  98679. /**
  98680. * Gets or sets the fog density to use
  98681. * @see http://doc.babylonjs.com/babylon101/environment#fog
  98682. * (Default is 0.1)
  98683. */
  98684. fogDensity: number;
  98685. /**
  98686. * Gets or sets the fog start distance to use
  98687. * @see http://doc.babylonjs.com/babylon101/environment#fog
  98688. * (Default is 0)
  98689. */
  98690. fogStart: number;
  98691. /**
  98692. * Gets or sets the fog end distance to use
  98693. * @see http://doc.babylonjs.com/babylon101/environment#fog
  98694. * (Default is 1000)
  98695. */
  98696. fogEnd: number;
  98697. private _shadowsEnabled;
  98698. /**
  98699. * Gets or sets a boolean indicating if shadows are enabled on this scene
  98700. */
  98701. shadowsEnabled: boolean;
  98702. private _lightsEnabled;
  98703. /**
  98704. * Gets or sets a boolean indicating if lights are enabled on this scene
  98705. */
  98706. lightsEnabled: boolean;
  98707. /** All of the active cameras added to this scene. */
  98708. activeCameras: Camera[];
  98709. /** @hidden */
  98710. _activeCamera: Nullable<Camera>;
  98711. /** Gets or sets the current active camera */
  98712. activeCamera: Nullable<Camera>;
  98713. private _defaultMaterial;
  98714. /** The default material used on meshes when no material is affected */
  98715. /** The default material used on meshes when no material is affected */
  98716. defaultMaterial: Material;
  98717. private _texturesEnabled;
  98718. /**
  98719. * Gets or sets a boolean indicating if textures are enabled on this scene
  98720. */
  98721. texturesEnabled: boolean;
  98722. /**
  98723. * Gets or sets a boolean indicating if particles are enabled on this scene
  98724. */
  98725. particlesEnabled: boolean;
  98726. /**
  98727. * Gets or sets a boolean indicating if sprites are enabled on this scene
  98728. */
  98729. spritesEnabled: boolean;
  98730. private _skeletonsEnabled;
  98731. /**
  98732. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  98733. */
  98734. skeletonsEnabled: boolean;
  98735. /**
  98736. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  98737. */
  98738. lensFlaresEnabled: boolean;
  98739. /**
  98740. * Gets or sets a boolean indicating if collisions are enabled on this scene
  98741. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  98742. */
  98743. collisionsEnabled: boolean;
  98744. private _collisionCoordinator;
  98745. /** @hidden */
  98746. readonly collisionCoordinator: ICollisionCoordinator;
  98747. /**
  98748. * Defines the gravity applied to this scene (used only for collisions)
  98749. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  98750. */
  98751. gravity: Vector3;
  98752. /**
  98753. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  98754. */
  98755. postProcessesEnabled: boolean;
  98756. /**
  98757. * The list of postprocesses added to the scene
  98758. */
  98759. postProcesses: PostProcess[];
  98760. /**
  98761. * Gets the current postprocess manager
  98762. */
  98763. postProcessManager: PostProcessManager;
  98764. /**
  98765. * Gets or sets a boolean indicating if render targets are enabled on this scene
  98766. */
  98767. renderTargetsEnabled: boolean;
  98768. /**
  98769. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  98770. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  98771. */
  98772. dumpNextRenderTargets: boolean;
  98773. /**
  98774. * The list of user defined render targets added to the scene
  98775. */
  98776. customRenderTargets: RenderTargetTexture[];
  98777. /**
  98778. * Defines if texture loading must be delayed
  98779. * If true, textures will only be loaded when they need to be rendered
  98780. */
  98781. useDelayedTextureLoading: boolean;
  98782. /**
  98783. * Gets the list of meshes imported to the scene through SceneLoader
  98784. */
  98785. importedMeshesFiles: String[];
  98786. /**
  98787. * Gets or sets a boolean indicating if probes are enabled on this scene
  98788. */
  98789. probesEnabled: boolean;
  98790. /**
  98791. * Gets or sets the current offline provider to use to store scene data
  98792. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  98793. */
  98794. offlineProvider: IOfflineProvider;
  98795. /**
  98796. * Gets or sets the action manager associated with the scene
  98797. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  98798. */
  98799. actionManager: AbstractActionManager;
  98800. private _meshesForIntersections;
  98801. /**
  98802. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  98803. */
  98804. proceduralTexturesEnabled: boolean;
  98805. private _engine;
  98806. private _totalVertices;
  98807. /** @hidden */
  98808. _activeIndices: PerfCounter;
  98809. /** @hidden */
  98810. _activeParticles: PerfCounter;
  98811. /** @hidden */
  98812. _activeBones: PerfCounter;
  98813. private _animationRatio;
  98814. /** @hidden */
  98815. _animationTimeLast: number;
  98816. /** @hidden */
  98817. _animationTime: number;
  98818. /**
  98819. * Gets or sets a general scale for animation speed
  98820. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  98821. */
  98822. animationTimeScale: number;
  98823. /** @hidden */
  98824. _cachedMaterial: Nullable<Material>;
  98825. /** @hidden */
  98826. _cachedEffect: Nullable<Effect>;
  98827. /** @hidden */
  98828. _cachedVisibility: Nullable<number>;
  98829. private _renderId;
  98830. private _frameId;
  98831. private _executeWhenReadyTimeoutId;
  98832. private _intermediateRendering;
  98833. private _viewUpdateFlag;
  98834. private _projectionUpdateFlag;
  98835. /** @hidden */
  98836. _toBeDisposed: Nullable<IDisposable>[];
  98837. private _activeRequests;
  98838. /** @hidden */
  98839. _pendingData: any[];
  98840. private _isDisposed;
  98841. /**
  98842. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  98843. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  98844. */
  98845. dispatchAllSubMeshesOfActiveMeshes: boolean;
  98846. private _activeMeshes;
  98847. private _processedMaterials;
  98848. private _renderTargets;
  98849. /** @hidden */
  98850. _activeParticleSystems: SmartArray<IParticleSystem>;
  98851. private _activeSkeletons;
  98852. private _softwareSkinnedMeshes;
  98853. private _renderingManager;
  98854. /** @hidden */
  98855. _activeAnimatables: Animatable[];
  98856. private _transformMatrix;
  98857. private _sceneUbo;
  98858. /** @hidden */
  98859. _viewMatrix: Matrix;
  98860. private _projectionMatrix;
  98861. /** @hidden */
  98862. _forcedViewPosition: Nullable<Vector3>;
  98863. /** @hidden */
  98864. _frustumPlanes: Plane[];
  98865. /**
  98866. * Gets the list of frustum planes (built from the active camera)
  98867. */
  98868. readonly frustumPlanes: Plane[];
  98869. /**
  98870. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  98871. * This is useful if there are more lights that the maximum simulteanous authorized
  98872. */
  98873. requireLightSorting: boolean;
  98874. /** @hidden */
  98875. readonly useMaterialMeshMap: boolean;
  98876. /** @hidden */
  98877. readonly useClonedMeshhMap: boolean;
  98878. private _externalData;
  98879. private _uid;
  98880. /**
  98881. * @hidden
  98882. * Backing store of defined scene components.
  98883. */
  98884. _components: ISceneComponent[];
  98885. /**
  98886. * @hidden
  98887. * Backing store of defined scene components.
  98888. */
  98889. _serializableComponents: ISceneSerializableComponent[];
  98890. /**
  98891. * List of components to register on the next registration step.
  98892. */
  98893. private _transientComponents;
  98894. /**
  98895. * Registers the transient components if needed.
  98896. */
  98897. private _registerTransientComponents;
  98898. /**
  98899. * @hidden
  98900. * Add a component to the scene.
  98901. * Note that the ccomponent could be registered on th next frame if this is called after
  98902. * the register component stage.
  98903. * @param component Defines the component to add to the scene
  98904. */
  98905. _addComponent(component: ISceneComponent): void;
  98906. /**
  98907. * @hidden
  98908. * Gets a component from the scene.
  98909. * @param name defines the name of the component to retrieve
  98910. * @returns the component or null if not present
  98911. */
  98912. _getComponent(name: string): Nullable<ISceneComponent>;
  98913. /**
  98914. * @hidden
  98915. * Defines the actions happening before camera updates.
  98916. */
  98917. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  98918. /**
  98919. * @hidden
  98920. * Defines the actions happening before clear the canvas.
  98921. */
  98922. _beforeClearStage: Stage<SimpleStageAction>;
  98923. /**
  98924. * @hidden
  98925. * Defines the actions when collecting render targets for the frame.
  98926. */
  98927. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  98928. /**
  98929. * @hidden
  98930. * Defines the actions happening for one camera in the frame.
  98931. */
  98932. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  98933. /**
  98934. * @hidden
  98935. * Defines the actions happening during the per mesh ready checks.
  98936. */
  98937. _isReadyForMeshStage: Stage<MeshStageAction>;
  98938. /**
  98939. * @hidden
  98940. * Defines the actions happening before evaluate active mesh checks.
  98941. */
  98942. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  98943. /**
  98944. * @hidden
  98945. * Defines the actions happening during the evaluate sub mesh checks.
  98946. */
  98947. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  98948. /**
  98949. * @hidden
  98950. * Defines the actions happening during the active mesh stage.
  98951. */
  98952. _activeMeshStage: Stage<ActiveMeshStageAction>;
  98953. /**
  98954. * @hidden
  98955. * Defines the actions happening during the per camera render target step.
  98956. */
  98957. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  98958. /**
  98959. * @hidden
  98960. * Defines the actions happening just before the active camera is drawing.
  98961. */
  98962. _beforeCameraDrawStage: Stage<CameraStageAction>;
  98963. /**
  98964. * @hidden
  98965. * Defines the actions happening just before a render target is drawing.
  98966. */
  98967. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  98968. /**
  98969. * @hidden
  98970. * Defines the actions happening just before a rendering group is drawing.
  98971. */
  98972. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  98973. /**
  98974. * @hidden
  98975. * Defines the actions happening just before a mesh is drawing.
  98976. */
  98977. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  98978. /**
  98979. * @hidden
  98980. * Defines the actions happening just after a mesh has been drawn.
  98981. */
  98982. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  98983. /**
  98984. * @hidden
  98985. * Defines the actions happening just after a rendering group has been drawn.
  98986. */
  98987. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  98988. /**
  98989. * @hidden
  98990. * Defines the actions happening just after the active camera has been drawn.
  98991. */
  98992. _afterCameraDrawStage: Stage<CameraStageAction>;
  98993. /**
  98994. * @hidden
  98995. * Defines the actions happening just after a render target has been drawn.
  98996. */
  98997. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  98998. /**
  98999. * @hidden
  99000. * Defines the actions happening just after rendering all cameras and computing intersections.
  99001. */
  99002. _afterRenderStage: Stage<SimpleStageAction>;
  99003. /**
  99004. * @hidden
  99005. * Defines the actions happening when a pointer move event happens.
  99006. */
  99007. _pointerMoveStage: Stage<PointerMoveStageAction>;
  99008. /**
  99009. * @hidden
  99010. * Defines the actions happening when a pointer down event happens.
  99011. */
  99012. _pointerDownStage: Stage<PointerUpDownStageAction>;
  99013. /**
  99014. * @hidden
  99015. * Defines the actions happening when a pointer up event happens.
  99016. */
  99017. _pointerUpStage: Stage<PointerUpDownStageAction>;
  99018. /**
  99019. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  99020. */
  99021. private geometriesByUniqueId;
  99022. /**
  99023. * Creates a new Scene
  99024. * @param engine defines the engine to use to render this scene
  99025. * @param options defines the scene options
  99026. */
  99027. constructor(engine: Engine, options?: SceneOptions);
  99028. /**
  99029. * Gets a string idenfifying the name of the class
  99030. * @returns "Scene" string
  99031. */
  99032. getClassName(): string;
  99033. private _defaultMeshCandidates;
  99034. /**
  99035. * @hidden
  99036. */
  99037. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  99038. private _defaultSubMeshCandidates;
  99039. /**
  99040. * @hidden
  99041. */
  99042. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  99043. /**
  99044. * Sets the default candidate providers for the scene.
  99045. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  99046. * and getCollidingSubMeshCandidates to their default function
  99047. */
  99048. setDefaultCandidateProviders(): void;
  99049. /**
  99050. * Gets the mesh that is currently under the pointer
  99051. */
  99052. readonly meshUnderPointer: Nullable<AbstractMesh>;
  99053. /**
  99054. * Gets or sets the current on-screen X position of the pointer
  99055. */
  99056. pointerX: number;
  99057. /**
  99058. * Gets or sets the current on-screen Y position of the pointer
  99059. */
  99060. pointerY: number;
  99061. /**
  99062. * Gets the cached material (ie. the latest rendered one)
  99063. * @returns the cached material
  99064. */
  99065. getCachedMaterial(): Nullable<Material>;
  99066. /**
  99067. * Gets the cached effect (ie. the latest rendered one)
  99068. * @returns the cached effect
  99069. */
  99070. getCachedEffect(): Nullable<Effect>;
  99071. /**
  99072. * Gets the cached visibility state (ie. the latest rendered one)
  99073. * @returns the cached visibility state
  99074. */
  99075. getCachedVisibility(): Nullable<number>;
  99076. /**
  99077. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  99078. * @param material defines the current material
  99079. * @param effect defines the current effect
  99080. * @param visibility defines the current visibility state
  99081. * @returns true if one parameter is not cached
  99082. */
  99083. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  99084. /**
  99085. * Gets the engine associated with the scene
  99086. * @returns an Engine
  99087. */
  99088. getEngine(): Engine;
  99089. /**
  99090. * Gets the total number of vertices rendered per frame
  99091. * @returns the total number of vertices rendered per frame
  99092. */
  99093. getTotalVertices(): number;
  99094. /**
  99095. * Gets the performance counter for total vertices
  99096. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  99097. */
  99098. readonly totalVerticesPerfCounter: PerfCounter;
  99099. /**
  99100. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  99101. * @returns the total number of active indices rendered per frame
  99102. */
  99103. getActiveIndices(): number;
  99104. /**
  99105. * Gets the performance counter for active indices
  99106. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  99107. */
  99108. readonly totalActiveIndicesPerfCounter: PerfCounter;
  99109. /**
  99110. * Gets the total number of active particles rendered per frame
  99111. * @returns the total number of active particles rendered per frame
  99112. */
  99113. getActiveParticles(): number;
  99114. /**
  99115. * Gets the performance counter for active particles
  99116. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  99117. */
  99118. readonly activeParticlesPerfCounter: PerfCounter;
  99119. /**
  99120. * Gets the total number of active bones rendered per frame
  99121. * @returns the total number of active bones rendered per frame
  99122. */
  99123. getActiveBones(): number;
  99124. /**
  99125. * Gets the performance counter for active bones
  99126. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  99127. */
  99128. readonly activeBonesPerfCounter: PerfCounter;
  99129. /**
  99130. * Gets the array of active meshes
  99131. * @returns an array of AbstractMesh
  99132. */
  99133. getActiveMeshes(): SmartArray<AbstractMesh>;
  99134. /**
  99135. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  99136. * @returns a number
  99137. */
  99138. getAnimationRatio(): number;
  99139. /**
  99140. * Gets an unique Id for the current render phase
  99141. * @returns a number
  99142. */
  99143. getRenderId(): number;
  99144. /**
  99145. * Gets an unique Id for the current frame
  99146. * @returns a number
  99147. */
  99148. getFrameId(): number;
  99149. /** Call this function if you want to manually increment the render Id*/
  99150. incrementRenderId(): void;
  99151. private _createUbo;
  99152. /**
  99153. * Use this method to simulate a pointer move on a mesh
  99154. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  99155. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  99156. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  99157. * @returns the current scene
  99158. */
  99159. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  99160. /**
  99161. * Use this method to simulate a pointer down on a mesh
  99162. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  99163. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  99164. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  99165. * @returns the current scene
  99166. */
  99167. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  99168. /**
  99169. * Use this method to simulate a pointer up on a mesh
  99170. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  99171. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  99172. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  99173. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  99174. * @returns the current scene
  99175. */
  99176. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  99177. /**
  99178. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  99179. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  99180. * @returns true if the pointer was captured
  99181. */
  99182. isPointerCaptured(pointerId?: number): boolean;
  99183. /**
  99184. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  99185. * @param attachUp defines if you want to attach events to pointerup
  99186. * @param attachDown defines if you want to attach events to pointerdown
  99187. * @param attachMove defines if you want to attach events to pointermove
  99188. */
  99189. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  99190. /** Detaches all event handlers*/
  99191. detachControl(): void;
  99192. /**
  99193. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  99194. * Delay loaded resources are not taking in account
  99195. * @return true if all required resources are ready
  99196. */
  99197. isReady(): boolean;
  99198. /** Resets all cached information relative to material (including effect and visibility) */
  99199. resetCachedMaterial(): void;
  99200. /**
  99201. * Registers a function to be called before every frame render
  99202. * @param func defines the function to register
  99203. */
  99204. registerBeforeRender(func: () => void): void;
  99205. /**
  99206. * Unregisters a function called before every frame render
  99207. * @param func defines the function to unregister
  99208. */
  99209. unregisterBeforeRender(func: () => void): void;
  99210. /**
  99211. * Registers a function to be called after every frame render
  99212. * @param func defines the function to register
  99213. */
  99214. registerAfterRender(func: () => void): void;
  99215. /**
  99216. * Unregisters a function called after every frame render
  99217. * @param func defines the function to unregister
  99218. */
  99219. unregisterAfterRender(func: () => void): void;
  99220. private _executeOnceBeforeRender;
  99221. /**
  99222. * The provided function will run before render once and will be disposed afterwards.
  99223. * A timeout delay can be provided so that the function will be executed in N ms.
  99224. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  99225. * @param func The function to be executed.
  99226. * @param timeout optional delay in ms
  99227. */
  99228. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  99229. /** @hidden */
  99230. _addPendingData(data: any): void;
  99231. /** @hidden */
  99232. _removePendingData(data: any): void;
  99233. /**
  99234. * Returns the number of items waiting to be loaded
  99235. * @returns the number of items waiting to be loaded
  99236. */
  99237. getWaitingItemsCount(): number;
  99238. /**
  99239. * Returns a boolean indicating if the scene is still loading data
  99240. */
  99241. readonly isLoading: boolean;
  99242. /**
  99243. * Registers a function to be executed when the scene is ready
  99244. * @param {Function} func - the function to be executed
  99245. */
  99246. executeWhenReady(func: () => void): void;
  99247. /**
  99248. * Returns a promise that resolves when the scene is ready
  99249. * @returns A promise that resolves when the scene is ready
  99250. */
  99251. whenReadyAsync(): Promise<void>;
  99252. /** @hidden */
  99253. _checkIsReady(): void;
  99254. /**
  99255. * Gets all animatable attached to the scene
  99256. */
  99257. readonly animatables: Animatable[];
  99258. /**
  99259. * Resets the last animation time frame.
  99260. * Useful to override when animations start running when loading a scene for the first time.
  99261. */
  99262. resetLastAnimationTimeFrame(): void;
  99263. /**
  99264. * Gets the current view matrix
  99265. * @returns a Matrix
  99266. */
  99267. getViewMatrix(): Matrix;
  99268. /**
  99269. * Gets the current projection matrix
  99270. * @returns a Matrix
  99271. */
  99272. getProjectionMatrix(): Matrix;
  99273. /**
  99274. * Gets the current transform matrix
  99275. * @returns a Matrix made of View * Projection
  99276. */
  99277. getTransformMatrix(): Matrix;
  99278. /**
  99279. * Sets the current transform matrix
  99280. * @param viewL defines the View matrix to use
  99281. * @param projectionL defines the Projection matrix to use
  99282. * @param viewR defines the right View matrix to use (if provided)
  99283. * @param projectionR defines the right Projection matrix to use (if provided)
  99284. */
  99285. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  99286. /**
  99287. * Gets the uniform buffer used to store scene data
  99288. * @returns a UniformBuffer
  99289. */
  99290. getSceneUniformBuffer(): UniformBuffer;
  99291. /**
  99292. * Gets an unique (relatively to the current scene) Id
  99293. * @returns an unique number for the scene
  99294. */
  99295. getUniqueId(): number;
  99296. /**
  99297. * Add a mesh to the list of scene's meshes
  99298. * @param newMesh defines the mesh to add
  99299. * @param recursive if all child meshes should also be added to the scene
  99300. */
  99301. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  99302. /**
  99303. * Remove a mesh for the list of scene's meshes
  99304. * @param toRemove defines the mesh to remove
  99305. * @param recursive if all child meshes should also be removed from the scene
  99306. * @returns the index where the mesh was in the mesh list
  99307. */
  99308. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  99309. /**
  99310. * Add a transform node to the list of scene's transform nodes
  99311. * @param newTransformNode defines the transform node to add
  99312. */
  99313. addTransformNode(newTransformNode: TransformNode): void;
  99314. /**
  99315. * Remove a transform node for the list of scene's transform nodes
  99316. * @param toRemove defines the transform node to remove
  99317. * @returns the index where the transform node was in the transform node list
  99318. */
  99319. removeTransformNode(toRemove: TransformNode): number;
  99320. /**
  99321. * Remove a skeleton for the list of scene's skeletons
  99322. * @param toRemove defines the skeleton to remove
  99323. * @returns the index where the skeleton was in the skeleton list
  99324. */
  99325. removeSkeleton(toRemove: Skeleton): number;
  99326. /**
  99327. * Remove a morph target for the list of scene's morph targets
  99328. * @param toRemove defines the morph target to remove
  99329. * @returns the index where the morph target was in the morph target list
  99330. */
  99331. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  99332. /**
  99333. * Remove a light for the list of scene's lights
  99334. * @param toRemove defines the light to remove
  99335. * @returns the index where the light was in the light list
  99336. */
  99337. removeLight(toRemove: Light): number;
  99338. /**
  99339. * Remove a camera for the list of scene's cameras
  99340. * @param toRemove defines the camera to remove
  99341. * @returns the index where the camera was in the camera list
  99342. */
  99343. removeCamera(toRemove: Camera): number;
  99344. /**
  99345. * Remove a particle system for the list of scene's particle systems
  99346. * @param toRemove defines the particle system to remove
  99347. * @returns the index where the particle system was in the particle system list
  99348. */
  99349. removeParticleSystem(toRemove: IParticleSystem): number;
  99350. /**
  99351. * Remove a animation for the list of scene's animations
  99352. * @param toRemove defines the animation to remove
  99353. * @returns the index where the animation was in the animation list
  99354. */
  99355. removeAnimation(toRemove: Animation): number;
  99356. /**
  99357. * Will stop the animation of the given target
  99358. * @param target - the target
  99359. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  99360. * @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)
  99361. */
  99362. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  99363. /**
  99364. * Removes the given animation group from this scene.
  99365. * @param toRemove The animation group to remove
  99366. * @returns The index of the removed animation group
  99367. */
  99368. removeAnimationGroup(toRemove: AnimationGroup): number;
  99369. /**
  99370. * Removes the given multi-material from this scene.
  99371. * @param toRemove The multi-material to remove
  99372. * @returns The index of the removed multi-material
  99373. */
  99374. removeMultiMaterial(toRemove: MultiMaterial): number;
  99375. /**
  99376. * Removes the given material from this scene.
  99377. * @param toRemove The material to remove
  99378. * @returns The index of the removed material
  99379. */
  99380. removeMaterial(toRemove: Material): number;
  99381. /**
  99382. * Removes the given action manager from this scene.
  99383. * @param toRemove The action manager to remove
  99384. * @returns The index of the removed action manager
  99385. */
  99386. removeActionManager(toRemove: AbstractActionManager): number;
  99387. /**
  99388. * Removes the given texture from this scene.
  99389. * @param toRemove The texture to remove
  99390. * @returns The index of the removed texture
  99391. */
  99392. removeTexture(toRemove: BaseTexture): number;
  99393. /**
  99394. * Adds the given light to this scene
  99395. * @param newLight The light to add
  99396. */
  99397. addLight(newLight: Light): void;
  99398. /**
  99399. * Sorts the list list based on light priorities
  99400. */
  99401. sortLightsByPriority(): void;
  99402. /**
  99403. * Adds the given camera to this scene
  99404. * @param newCamera The camera to add
  99405. */
  99406. addCamera(newCamera: Camera): void;
  99407. /**
  99408. * Adds the given skeleton to this scene
  99409. * @param newSkeleton The skeleton to add
  99410. */
  99411. addSkeleton(newSkeleton: Skeleton): void;
  99412. /**
  99413. * Adds the given particle system to this scene
  99414. * @param newParticleSystem The particle system to add
  99415. */
  99416. addParticleSystem(newParticleSystem: IParticleSystem): void;
  99417. /**
  99418. * Adds the given animation to this scene
  99419. * @param newAnimation The animation to add
  99420. */
  99421. addAnimation(newAnimation: Animation): void;
  99422. /**
  99423. * Adds the given animation group to this scene.
  99424. * @param newAnimationGroup The animation group to add
  99425. */
  99426. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  99427. /**
  99428. * Adds the given multi-material to this scene
  99429. * @param newMultiMaterial The multi-material to add
  99430. */
  99431. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  99432. /**
  99433. * Adds the given material to this scene
  99434. * @param newMaterial The material to add
  99435. */
  99436. addMaterial(newMaterial: Material): void;
  99437. /**
  99438. * Adds the given morph target to this scene
  99439. * @param newMorphTargetManager The morph target to add
  99440. */
  99441. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  99442. /**
  99443. * Adds the given geometry to this scene
  99444. * @param newGeometry The geometry to add
  99445. */
  99446. addGeometry(newGeometry: Geometry): void;
  99447. /**
  99448. * Adds the given action manager to this scene
  99449. * @param newActionManager The action manager to add
  99450. */
  99451. addActionManager(newActionManager: AbstractActionManager): void;
  99452. /**
  99453. * Adds the given texture to this scene.
  99454. * @param newTexture The texture to add
  99455. */
  99456. addTexture(newTexture: BaseTexture): void;
  99457. /**
  99458. * Switch active camera
  99459. * @param newCamera defines the new active camera
  99460. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  99461. */
  99462. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  99463. /**
  99464. * sets the active camera of the scene using its ID
  99465. * @param id defines the camera's ID
  99466. * @return the new active camera or null if none found.
  99467. */
  99468. setActiveCameraByID(id: string): Nullable<Camera>;
  99469. /**
  99470. * sets the active camera of the scene using its name
  99471. * @param name defines the camera's name
  99472. * @returns the new active camera or null if none found.
  99473. */
  99474. setActiveCameraByName(name: string): Nullable<Camera>;
  99475. /**
  99476. * get an animation group using its name
  99477. * @param name defines the material's name
  99478. * @return the animation group or null if none found.
  99479. */
  99480. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  99481. /**
  99482. * Get a material using its unique id
  99483. * @param uniqueId defines the material's unique id
  99484. * @return the material or null if none found.
  99485. */
  99486. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  99487. /**
  99488. * get a material using its id
  99489. * @param id defines the material's ID
  99490. * @return the material or null if none found.
  99491. */
  99492. getMaterialByID(id: string): Nullable<Material>;
  99493. /**
  99494. * Gets a the last added material using a given id
  99495. * @param id defines the material's ID
  99496. * @return the last material with the given id or null if none found.
  99497. */
  99498. getLastMaterialByID(id: string): Nullable<Material>;
  99499. /**
  99500. * Gets a material using its name
  99501. * @param name defines the material's name
  99502. * @return the material or null if none found.
  99503. */
  99504. getMaterialByName(name: string): Nullable<Material>;
  99505. /**
  99506. * Get a texture using its unique id
  99507. * @param uniqueId defines the texture's unique id
  99508. * @return the texture or null if none found.
  99509. */
  99510. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  99511. /**
  99512. * Gets a camera using its id
  99513. * @param id defines the id to look for
  99514. * @returns the camera or null if not found
  99515. */
  99516. getCameraByID(id: string): Nullable<Camera>;
  99517. /**
  99518. * Gets a camera using its unique id
  99519. * @param uniqueId defines the unique id to look for
  99520. * @returns the camera or null if not found
  99521. */
  99522. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  99523. /**
  99524. * Gets a camera using its name
  99525. * @param name defines the camera's name
  99526. * @return the camera or null if none found.
  99527. */
  99528. getCameraByName(name: string): Nullable<Camera>;
  99529. /**
  99530. * Gets a bone using its id
  99531. * @param id defines the bone's id
  99532. * @return the bone or null if not found
  99533. */
  99534. getBoneByID(id: string): Nullable<Bone>;
  99535. /**
  99536. * Gets a bone using its id
  99537. * @param name defines the bone's name
  99538. * @return the bone or null if not found
  99539. */
  99540. getBoneByName(name: string): Nullable<Bone>;
  99541. /**
  99542. * Gets a light node using its name
  99543. * @param name defines the the light's name
  99544. * @return the light or null if none found.
  99545. */
  99546. getLightByName(name: string): Nullable<Light>;
  99547. /**
  99548. * Gets a light node using its id
  99549. * @param id defines the light's id
  99550. * @return the light or null if none found.
  99551. */
  99552. getLightByID(id: string): Nullable<Light>;
  99553. /**
  99554. * Gets a light node using its scene-generated unique ID
  99555. * @param uniqueId defines the light's unique id
  99556. * @return the light or null if none found.
  99557. */
  99558. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  99559. /**
  99560. * Gets a particle system by id
  99561. * @param id defines the particle system id
  99562. * @return the corresponding system or null if none found
  99563. */
  99564. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  99565. /**
  99566. * Gets a geometry using its ID
  99567. * @param id defines the geometry's id
  99568. * @return the geometry or null if none found.
  99569. */
  99570. getGeometryByID(id: string): Nullable<Geometry>;
  99571. private _getGeometryByUniqueID;
  99572. /**
  99573. * Add a new geometry to this scene
  99574. * @param geometry defines the geometry to be added to the scene.
  99575. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  99576. * @return a boolean defining if the geometry was added or not
  99577. */
  99578. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  99579. /**
  99580. * Removes an existing geometry
  99581. * @param geometry defines the geometry to be removed from the scene
  99582. * @return a boolean defining if the geometry was removed or not
  99583. */
  99584. removeGeometry(geometry: Geometry): boolean;
  99585. /**
  99586. * Gets the list of geometries attached to the scene
  99587. * @returns an array of Geometry
  99588. */
  99589. getGeometries(): Geometry[];
  99590. /**
  99591. * Gets the first added mesh found of a given ID
  99592. * @param id defines the id to search for
  99593. * @return the mesh found or null if not found at all
  99594. */
  99595. getMeshByID(id: string): Nullable<AbstractMesh>;
  99596. /**
  99597. * Gets a list of meshes using their id
  99598. * @param id defines the id to search for
  99599. * @returns a list of meshes
  99600. */
  99601. getMeshesByID(id: string): Array<AbstractMesh>;
  99602. /**
  99603. * Gets the first added transform node found of a given ID
  99604. * @param id defines the id to search for
  99605. * @return the found transform node or null if not found at all.
  99606. */
  99607. getTransformNodeByID(id: string): Nullable<TransformNode>;
  99608. /**
  99609. * Gets a transform node with its auto-generated unique id
  99610. * @param uniqueId efines the unique id to search for
  99611. * @return the found transform node or null if not found at all.
  99612. */
  99613. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  99614. /**
  99615. * Gets a list of transform nodes using their id
  99616. * @param id defines the id to search for
  99617. * @returns a list of transform nodes
  99618. */
  99619. getTransformNodesByID(id: string): Array<TransformNode>;
  99620. /**
  99621. * Gets a mesh with its auto-generated unique id
  99622. * @param uniqueId defines the unique id to search for
  99623. * @return the found mesh or null if not found at all.
  99624. */
  99625. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  99626. /**
  99627. * Gets a the last added mesh using a given id
  99628. * @param id defines the id to search for
  99629. * @return the found mesh or null if not found at all.
  99630. */
  99631. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  99632. /**
  99633. * Gets a the last added node (Mesh, Camera, Light) using a given id
  99634. * @param id defines the id to search for
  99635. * @return the found node or null if not found at all
  99636. */
  99637. getLastEntryByID(id: string): Nullable<Node>;
  99638. /**
  99639. * Gets a node (Mesh, Camera, Light) using a given id
  99640. * @param id defines the id to search for
  99641. * @return the found node or null if not found at all
  99642. */
  99643. getNodeByID(id: string): Nullable<Node>;
  99644. /**
  99645. * Gets a node (Mesh, Camera, Light) using a given name
  99646. * @param name defines the name to search for
  99647. * @return the found node or null if not found at all.
  99648. */
  99649. getNodeByName(name: string): Nullable<Node>;
  99650. /**
  99651. * Gets a mesh using a given name
  99652. * @param name defines the name to search for
  99653. * @return the found mesh or null if not found at all.
  99654. */
  99655. getMeshByName(name: string): Nullable<AbstractMesh>;
  99656. /**
  99657. * Gets a transform node using a given name
  99658. * @param name defines the name to search for
  99659. * @return the found transform node or null if not found at all.
  99660. */
  99661. getTransformNodeByName(name: string): Nullable<TransformNode>;
  99662. /**
  99663. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  99664. * @param id defines the id to search for
  99665. * @return the found skeleton or null if not found at all.
  99666. */
  99667. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  99668. /**
  99669. * Gets a skeleton using a given auto generated unique id
  99670. * @param uniqueId defines the unique id to search for
  99671. * @return the found skeleton or null if not found at all.
  99672. */
  99673. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  99674. /**
  99675. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  99676. * @param id defines the id to search for
  99677. * @return the found skeleton or null if not found at all.
  99678. */
  99679. getSkeletonById(id: string): Nullable<Skeleton>;
  99680. /**
  99681. * Gets a skeleton using a given name
  99682. * @param name defines the name to search for
  99683. * @return the found skeleton or null if not found at all.
  99684. */
  99685. getSkeletonByName(name: string): Nullable<Skeleton>;
  99686. /**
  99687. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  99688. * @param id defines the id to search for
  99689. * @return the found morph target manager or null if not found at all.
  99690. */
  99691. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  99692. /**
  99693. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  99694. * @param id defines the id to search for
  99695. * @return the found morph target or null if not found at all.
  99696. */
  99697. getMorphTargetById(id: string): Nullable<MorphTarget>;
  99698. /**
  99699. * Gets a boolean indicating if the given mesh is active
  99700. * @param mesh defines the mesh to look for
  99701. * @returns true if the mesh is in the active list
  99702. */
  99703. isActiveMesh(mesh: AbstractMesh): boolean;
  99704. /**
  99705. * Return a unique id as a string which can serve as an identifier for the scene
  99706. */
  99707. readonly uid: string;
  99708. /**
  99709. * Add an externaly attached data from its key.
  99710. * This method call will fail and return false, if such key already exists.
  99711. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  99712. * @param key the unique key that identifies the data
  99713. * @param data the data object to associate to the key for this Engine instance
  99714. * @return true if no such key were already present and the data was added successfully, false otherwise
  99715. */
  99716. addExternalData<T>(key: string, data: T): boolean;
  99717. /**
  99718. * Get an externaly attached data from its key
  99719. * @param key the unique key that identifies the data
  99720. * @return the associated data, if present (can be null), or undefined if not present
  99721. */
  99722. getExternalData<T>(key: string): Nullable<T>;
  99723. /**
  99724. * Get an externaly attached data from its key, create it using a factory if it's not already present
  99725. * @param key the unique key that identifies the data
  99726. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  99727. * @return the associated data, can be null if the factory returned null.
  99728. */
  99729. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  99730. /**
  99731. * Remove an externaly attached data from the Engine instance
  99732. * @param key the unique key that identifies the data
  99733. * @return true if the data was successfully removed, false if it doesn't exist
  99734. */
  99735. removeExternalData(key: string): boolean;
  99736. private _evaluateSubMesh;
  99737. /**
  99738. * Clear the processed materials smart array preventing retention point in material dispose.
  99739. */
  99740. freeProcessedMaterials(): void;
  99741. private _preventFreeActiveMeshesAndRenderingGroups;
  99742. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  99743. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  99744. * when disposing several meshes in a row or a hierarchy of meshes.
  99745. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  99746. */
  99747. blockfreeActiveMeshesAndRenderingGroups: boolean;
  99748. /**
  99749. * Clear the active meshes smart array preventing retention point in mesh dispose.
  99750. */
  99751. freeActiveMeshes(): void;
  99752. /**
  99753. * Clear the info related to rendering groups preventing retention points during dispose.
  99754. */
  99755. freeRenderingGroups(): void;
  99756. /** @hidden */
  99757. _isInIntermediateRendering(): boolean;
  99758. /**
  99759. * Lambda returning the list of potentially active meshes.
  99760. */
  99761. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  99762. /**
  99763. * Lambda returning the list of potentially active sub meshes.
  99764. */
  99765. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  99766. /**
  99767. * Lambda returning the list of potentially intersecting sub meshes.
  99768. */
  99769. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  99770. /**
  99771. * Lambda returning the list of potentially colliding sub meshes.
  99772. */
  99773. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  99774. private _activeMeshesFrozen;
  99775. /**
  99776. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  99777. * @returns the current scene
  99778. */
  99779. freezeActiveMeshes(): Scene;
  99780. /**
  99781. * Use this function to restart evaluating active meshes on every frame
  99782. * @returns the current scene
  99783. */
  99784. unfreezeActiveMeshes(): Scene;
  99785. private _evaluateActiveMeshes;
  99786. private _activeMesh;
  99787. /**
  99788. * Update the transform matrix to update from the current active camera
  99789. * @param force defines a boolean used to force the update even if cache is up to date
  99790. */
  99791. updateTransformMatrix(force?: boolean): void;
  99792. private _bindFrameBuffer;
  99793. /** @hidden */
  99794. _allowPostProcessClearColor: boolean;
  99795. /** @hidden */
  99796. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  99797. private _processSubCameras;
  99798. private _checkIntersections;
  99799. /** @hidden */
  99800. _advancePhysicsEngineStep(step: number): void;
  99801. /**
  99802. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  99803. */
  99804. getDeterministicFrameTime: () => number;
  99805. /** @hidden */
  99806. _animate(): void;
  99807. /** Execute all animations (for a frame) */
  99808. animate(): void;
  99809. /**
  99810. * Render the scene
  99811. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  99812. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  99813. */
  99814. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  99815. /**
  99816. * Freeze all materials
  99817. * A frozen material will not be updatable but should be faster to render
  99818. */
  99819. freezeMaterials(): void;
  99820. /**
  99821. * Unfreeze all materials
  99822. * A frozen material will not be updatable but should be faster to render
  99823. */
  99824. unfreezeMaterials(): void;
  99825. /**
  99826. * Releases all held ressources
  99827. */
  99828. dispose(): void;
  99829. /**
  99830. * Gets if the scene is already disposed
  99831. */
  99832. readonly isDisposed: boolean;
  99833. /**
  99834. * Call this function to reduce memory footprint of the scene.
  99835. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  99836. */
  99837. clearCachedVertexData(): void;
  99838. /**
  99839. * This function will remove the local cached buffer data from texture.
  99840. * It will save memory but will prevent the texture from being rebuilt
  99841. */
  99842. cleanCachedTextureBuffer(): void;
  99843. /**
  99844. * Get the world extend vectors with an optional filter
  99845. *
  99846. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  99847. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  99848. */
  99849. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  99850. min: Vector3;
  99851. max: Vector3;
  99852. };
  99853. /**
  99854. * Creates a ray that can be used to pick in the scene
  99855. * @param x defines the x coordinate of the origin (on-screen)
  99856. * @param y defines the y coordinate of the origin (on-screen)
  99857. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  99858. * @param camera defines the camera to use for the picking
  99859. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  99860. * @returns a Ray
  99861. */
  99862. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  99863. /**
  99864. * Creates a ray that can be used to pick in the scene
  99865. * @param x defines the x coordinate of the origin (on-screen)
  99866. * @param y defines the y coordinate of the origin (on-screen)
  99867. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  99868. * @param result defines the ray where to store the picking ray
  99869. * @param camera defines the camera to use for the picking
  99870. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  99871. * @returns the current scene
  99872. */
  99873. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  99874. /**
  99875. * Creates a ray that can be used to pick in the scene
  99876. * @param x defines the x coordinate of the origin (on-screen)
  99877. * @param y defines the y coordinate of the origin (on-screen)
  99878. * @param camera defines the camera to use for the picking
  99879. * @returns a Ray
  99880. */
  99881. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  99882. /**
  99883. * Creates a ray that can be used to pick in the scene
  99884. * @param x defines the x coordinate of the origin (on-screen)
  99885. * @param y defines the y coordinate of the origin (on-screen)
  99886. * @param result defines the ray where to store the picking ray
  99887. * @param camera defines the camera to use for the picking
  99888. * @returns the current scene
  99889. */
  99890. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  99891. /** Launch a ray to try to pick a mesh in the scene
  99892. * @param x position on screen
  99893. * @param y position on screen
  99894. * @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
  99895. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  99896. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  99897. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  99898. * @returns a PickingInfo
  99899. */
  99900. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  99901. /** Use the given ray to pick a mesh in the scene
  99902. * @param ray The ray to use to pick meshes
  99903. * @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
  99904. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  99905. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  99906. * @returns a PickingInfo
  99907. */
  99908. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  99909. /**
  99910. * Launch a ray to try to pick a mesh in the scene
  99911. * @param x X position on screen
  99912. * @param y Y position on screen
  99913. * @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
  99914. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  99915. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  99916. * @returns an array of PickingInfo
  99917. */
  99918. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  99919. /**
  99920. * Launch a ray to try to pick a mesh in the scene
  99921. * @param ray Ray to use
  99922. * @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
  99923. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  99924. * @returns an array of PickingInfo
  99925. */
  99926. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  99927. /**
  99928. * Force the value of meshUnderPointer
  99929. * @param mesh defines the mesh to use
  99930. */
  99931. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  99932. /**
  99933. * Gets the mesh under the pointer
  99934. * @returns a Mesh or null if no mesh is under the pointer
  99935. */
  99936. getPointerOverMesh(): Nullable<AbstractMesh>;
  99937. /** @hidden */
  99938. _rebuildGeometries(): void;
  99939. /** @hidden */
  99940. _rebuildTextures(): void;
  99941. private _getByTags;
  99942. /**
  99943. * Get a list of meshes by tags
  99944. * @param tagsQuery defines the tags query to use
  99945. * @param forEach defines a predicate used to filter results
  99946. * @returns an array of Mesh
  99947. */
  99948. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  99949. /**
  99950. * Get a list of cameras by tags
  99951. * @param tagsQuery defines the tags query to use
  99952. * @param forEach defines a predicate used to filter results
  99953. * @returns an array of Camera
  99954. */
  99955. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  99956. /**
  99957. * Get a list of lights by tags
  99958. * @param tagsQuery defines the tags query to use
  99959. * @param forEach defines a predicate used to filter results
  99960. * @returns an array of Light
  99961. */
  99962. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  99963. /**
  99964. * Get a list of materials by tags
  99965. * @param tagsQuery defines the tags query to use
  99966. * @param forEach defines a predicate used to filter results
  99967. * @returns an array of Material
  99968. */
  99969. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  99970. /**
  99971. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  99972. * This allowed control for front to back rendering or reversly depending of the special needs.
  99973. *
  99974. * @param renderingGroupId The rendering group id corresponding to its index
  99975. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  99976. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  99977. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  99978. */
  99979. 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;
  99980. /**
  99981. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  99982. *
  99983. * @param renderingGroupId The rendering group id corresponding to its index
  99984. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  99985. * @param depth Automatically clears depth between groups if true and autoClear is true.
  99986. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  99987. */
  99988. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  99989. /**
  99990. * Gets the current auto clear configuration for one rendering group of the rendering
  99991. * manager.
  99992. * @param index the rendering group index to get the information for
  99993. * @returns The auto clear setup for the requested rendering group
  99994. */
  99995. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  99996. private _blockMaterialDirtyMechanism;
  99997. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  99998. blockMaterialDirtyMechanism: boolean;
  99999. /**
  100000. * Will flag all materials as dirty to trigger new shader compilation
  100001. * @param flag defines the flag used to specify which material part must be marked as dirty
  100002. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  100003. */
  100004. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  100005. /** @hidden */
  100006. _loadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onError?: (request?: WebRequest, exception?: any) => void): IFileRequest;
  100007. /** @hidden */
  100008. _loadFileAsync(url: string, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  100009. }
  100010. }
  100011. declare module BABYLON {
  100012. /**
  100013. * Set of assets to keep when moving a scene into an asset container.
  100014. */
  100015. export class KeepAssets extends AbstractScene {
  100016. }
  100017. /**
  100018. * Container with a set of assets that can be added or removed from a scene.
  100019. */
  100020. export class AssetContainer extends AbstractScene {
  100021. /**
  100022. * The scene the AssetContainer belongs to.
  100023. */
  100024. scene: Scene;
  100025. /**
  100026. * Instantiates an AssetContainer.
  100027. * @param scene The scene the AssetContainer belongs to.
  100028. */
  100029. constructor(scene: Scene);
  100030. /**
  100031. * Adds all the assets from the container to the scene.
  100032. */
  100033. addAllToScene(): void;
  100034. /**
  100035. * Removes all the assets in the container from the scene
  100036. */
  100037. removeAllFromScene(): void;
  100038. /**
  100039. * Disposes all the assets in the container
  100040. */
  100041. dispose(): void;
  100042. private _moveAssets;
  100043. /**
  100044. * Removes all the assets contained in the scene and adds them to the container.
  100045. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  100046. */
  100047. moveAllFromScene(keepAssets?: KeepAssets): void;
  100048. /**
  100049. * 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.
  100050. * @returns the root mesh
  100051. */
  100052. createRootMesh(): Mesh;
  100053. }
  100054. }
  100055. declare module BABYLON {
  100056. /**
  100057. * Defines how the parser contract is defined.
  100058. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  100059. */
  100060. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  100061. /**
  100062. * Defines how the individual parser contract is defined.
  100063. * These parser can parse an individual asset
  100064. */
  100065. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  100066. /**
  100067. * Base class of the scene acting as a container for the different elements composing a scene.
  100068. * This class is dynamically extended by the different components of the scene increasing
  100069. * flexibility and reducing coupling
  100070. */
  100071. export abstract class AbstractScene {
  100072. /**
  100073. * Stores the list of available parsers in the application.
  100074. */
  100075. private static _BabylonFileParsers;
  100076. /**
  100077. * Stores the list of available individual parsers in the application.
  100078. */
  100079. private static _IndividualBabylonFileParsers;
  100080. /**
  100081. * Adds a parser in the list of available ones
  100082. * @param name Defines the name of the parser
  100083. * @param parser Defines the parser to add
  100084. */
  100085. static AddParser(name: string, parser: BabylonFileParser): void;
  100086. /**
  100087. * Gets a general parser from the list of avaialble ones
  100088. * @param name Defines the name of the parser
  100089. * @returns the requested parser or null
  100090. */
  100091. static GetParser(name: string): Nullable<BabylonFileParser>;
  100092. /**
  100093. * Adds n individual parser in the list of available ones
  100094. * @param name Defines the name of the parser
  100095. * @param parser Defines the parser to add
  100096. */
  100097. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  100098. /**
  100099. * Gets an individual parser from the list of avaialble ones
  100100. * @param name Defines the name of the parser
  100101. * @returns the requested parser or null
  100102. */
  100103. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  100104. /**
  100105. * Parser json data and populate both a scene and its associated container object
  100106. * @param jsonData Defines the data to parse
  100107. * @param scene Defines the scene to parse the data for
  100108. * @param container Defines the container attached to the parsing sequence
  100109. * @param rootUrl Defines the root url of the data
  100110. */
  100111. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  100112. /**
  100113. * Gets the list of root nodes (ie. nodes with no parent)
  100114. */
  100115. rootNodes: Node[];
  100116. /** All of the cameras added to this scene
  100117. * @see http://doc.babylonjs.com/babylon101/cameras
  100118. */
  100119. cameras: Camera[];
  100120. /**
  100121. * All of the lights added to this scene
  100122. * @see http://doc.babylonjs.com/babylon101/lights
  100123. */
  100124. lights: Light[];
  100125. /**
  100126. * All of the (abstract) meshes added to this scene
  100127. */
  100128. meshes: AbstractMesh[];
  100129. /**
  100130. * The list of skeletons added to the scene
  100131. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  100132. */
  100133. skeletons: Skeleton[];
  100134. /**
  100135. * All of the particle systems added to this scene
  100136. * @see http://doc.babylonjs.com/babylon101/particles
  100137. */
  100138. particleSystems: IParticleSystem[];
  100139. /**
  100140. * Gets a list of Animations associated with the scene
  100141. */
  100142. animations: Animation[];
  100143. /**
  100144. * All of the animation groups added to this scene
  100145. * @see http://doc.babylonjs.com/how_to/group
  100146. */
  100147. animationGroups: AnimationGroup[];
  100148. /**
  100149. * All of the multi-materials added to this scene
  100150. * @see http://doc.babylonjs.com/how_to/multi_materials
  100151. */
  100152. multiMaterials: MultiMaterial[];
  100153. /**
  100154. * All of the materials added to this scene
  100155. * In the context of a Scene, it is not supposed to be modified manually.
  100156. * Any addition or removal should be done using the addMaterial and removeMAterial Scene methods.
  100157. * Note also that the order of the Material wihin the array is not significant and might change.
  100158. * @see http://doc.babylonjs.com/babylon101/materials
  100159. */
  100160. materials: Material[];
  100161. /**
  100162. * The list of morph target managers added to the scene
  100163. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  100164. */
  100165. morphTargetManagers: MorphTargetManager[];
  100166. /**
  100167. * The list of geometries used in the scene.
  100168. */
  100169. geometries: Geometry[];
  100170. /**
  100171. * All of the tranform nodes added to this scene
  100172. * In the context of a Scene, it is not supposed to be modified manually.
  100173. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  100174. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  100175. * @see http://doc.babylonjs.com/how_to/transformnode
  100176. */
  100177. transformNodes: TransformNode[];
  100178. /**
  100179. * ActionManagers available on the scene.
  100180. */
  100181. actionManagers: AbstractActionManager[];
  100182. /**
  100183. * Textures to keep.
  100184. */
  100185. textures: BaseTexture[];
  100186. /**
  100187. * Environment texture for the scene
  100188. */
  100189. environmentTexture: Nullable<BaseTexture>;
  100190. }
  100191. }
  100192. declare module BABYLON {
  100193. /**
  100194. * Interface used to define options for Sound class
  100195. */
  100196. export interface ISoundOptions {
  100197. /**
  100198. * Does the sound autoplay once loaded.
  100199. */
  100200. autoplay?: boolean;
  100201. /**
  100202. * Does the sound loop after it finishes playing once.
  100203. */
  100204. loop?: boolean;
  100205. /**
  100206. * Sound's volume
  100207. */
  100208. volume?: number;
  100209. /**
  100210. * Is it a spatial sound?
  100211. */
  100212. spatialSound?: boolean;
  100213. /**
  100214. * Maximum distance to hear that sound
  100215. */
  100216. maxDistance?: number;
  100217. /**
  100218. * Uses user defined attenuation function
  100219. */
  100220. useCustomAttenuation?: boolean;
  100221. /**
  100222. * Define the roll off factor of spatial sounds.
  100223. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  100224. */
  100225. rolloffFactor?: number;
  100226. /**
  100227. * Define the reference distance the sound should be heard perfectly.
  100228. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  100229. */
  100230. refDistance?: number;
  100231. /**
  100232. * Define the distance attenuation model the sound will follow.
  100233. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  100234. */
  100235. distanceModel?: string;
  100236. /**
  100237. * Defines the playback speed (1 by default)
  100238. */
  100239. playbackRate?: number;
  100240. /**
  100241. * Defines if the sound is from a streaming source
  100242. */
  100243. streaming?: boolean;
  100244. /**
  100245. * Defines an optional length (in seconds) inside the sound file
  100246. */
  100247. length?: number;
  100248. /**
  100249. * Defines an optional offset (in seconds) inside the sound file
  100250. */
  100251. offset?: number;
  100252. /**
  100253. * If true, URLs will not be required to state the audio file codec to use.
  100254. */
  100255. skipCodecCheck?: boolean;
  100256. }
  100257. /**
  100258. * Defines a sound that can be played in the application.
  100259. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  100260. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  100261. */
  100262. export class Sound {
  100263. /**
  100264. * The name of the sound in the scene.
  100265. */
  100266. name: string;
  100267. /**
  100268. * Does the sound autoplay once loaded.
  100269. */
  100270. autoplay: boolean;
  100271. /**
  100272. * Does the sound loop after it finishes playing once.
  100273. */
  100274. loop: boolean;
  100275. /**
  100276. * Does the sound use a custom attenuation curve to simulate the falloff
  100277. * happening when the source gets further away from the camera.
  100278. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  100279. */
  100280. useCustomAttenuation: boolean;
  100281. /**
  100282. * The sound track id this sound belongs to.
  100283. */
  100284. soundTrackId: number;
  100285. /**
  100286. * Is this sound currently played.
  100287. */
  100288. isPlaying: boolean;
  100289. /**
  100290. * Is this sound currently paused.
  100291. */
  100292. isPaused: boolean;
  100293. /**
  100294. * Does this sound enables spatial sound.
  100295. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  100296. */
  100297. spatialSound: boolean;
  100298. /**
  100299. * Define the reference distance the sound should be heard perfectly.
  100300. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  100301. */
  100302. refDistance: number;
  100303. /**
  100304. * Define the roll off factor of spatial sounds.
  100305. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  100306. */
  100307. rolloffFactor: number;
  100308. /**
  100309. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  100310. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  100311. */
  100312. maxDistance: number;
  100313. /**
  100314. * Define the distance attenuation model the sound will follow.
  100315. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  100316. */
  100317. distanceModel: string;
  100318. /**
  100319. * @hidden
  100320. * Back Compat
  100321. **/
  100322. onended: () => any;
  100323. /**
  100324. * Observable event when the current playing sound finishes.
  100325. */
  100326. onEndedObservable: Observable<Sound>;
  100327. private _panningModel;
  100328. private _playbackRate;
  100329. private _streaming;
  100330. private _startTime;
  100331. private _startOffset;
  100332. private _position;
  100333. /** @hidden */
  100334. _positionInEmitterSpace: boolean;
  100335. private _localDirection;
  100336. private _volume;
  100337. private _isReadyToPlay;
  100338. private _isDirectional;
  100339. private _readyToPlayCallback;
  100340. private _audioBuffer;
  100341. private _soundSource;
  100342. private _streamingSource;
  100343. private _soundPanner;
  100344. private _soundGain;
  100345. private _inputAudioNode;
  100346. private _outputAudioNode;
  100347. private _coneInnerAngle;
  100348. private _coneOuterAngle;
  100349. private _coneOuterGain;
  100350. private _scene;
  100351. private _connectedTransformNode;
  100352. private _customAttenuationFunction;
  100353. private _registerFunc;
  100354. private _isOutputConnected;
  100355. private _htmlAudioElement;
  100356. private _urlType;
  100357. private _length?;
  100358. private _offset?;
  100359. /** @hidden */
  100360. static _SceneComponentInitialization: (scene: Scene) => void;
  100361. /**
  100362. * Create a sound and attach it to a scene
  100363. * @param name Name of your sound
  100364. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  100365. * @param scene defines the scene the sound belongs to
  100366. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  100367. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  100368. */
  100369. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  100370. /**
  100371. * Release the sound and its associated resources
  100372. */
  100373. dispose(): void;
  100374. /**
  100375. * Gets if the sounds is ready to be played or not.
  100376. * @returns true if ready, otherwise false
  100377. */
  100378. isReady(): boolean;
  100379. private _soundLoaded;
  100380. /**
  100381. * Sets the data of the sound from an audiobuffer
  100382. * @param audioBuffer The audioBuffer containing the data
  100383. */
  100384. setAudioBuffer(audioBuffer: AudioBuffer): void;
  100385. /**
  100386. * Updates the current sounds options such as maxdistance, loop...
  100387. * @param options A JSON object containing values named as the object properties
  100388. */
  100389. updateOptions(options: ISoundOptions): void;
  100390. private _createSpatialParameters;
  100391. private _updateSpatialParameters;
  100392. /**
  100393. * Switch the panning model to HRTF:
  100394. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  100395. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  100396. */
  100397. switchPanningModelToHRTF(): void;
  100398. /**
  100399. * Switch the panning model to Equal Power:
  100400. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  100401. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  100402. */
  100403. switchPanningModelToEqualPower(): void;
  100404. private _switchPanningModel;
  100405. /**
  100406. * Connect this sound to a sound track audio node like gain...
  100407. * @param soundTrackAudioNode the sound track audio node to connect to
  100408. */
  100409. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  100410. /**
  100411. * Transform this sound into a directional source
  100412. * @param coneInnerAngle Size of the inner cone in degree
  100413. * @param coneOuterAngle Size of the outer cone in degree
  100414. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  100415. */
  100416. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  100417. /**
  100418. * Gets or sets the inner angle for the directional cone.
  100419. */
  100420. /**
  100421. * Gets or sets the inner angle for the directional cone.
  100422. */
  100423. directionalConeInnerAngle: number;
  100424. /**
  100425. * Gets or sets the outer angle for the directional cone.
  100426. */
  100427. /**
  100428. * Gets or sets the outer angle for the directional cone.
  100429. */
  100430. directionalConeOuterAngle: number;
  100431. /**
  100432. * Sets the position of the emitter if spatial sound is enabled
  100433. * @param newPosition Defines the new posisiton
  100434. */
  100435. setPosition(newPosition: Vector3): void;
  100436. /**
  100437. * Sets the local direction of the emitter if spatial sound is enabled
  100438. * @param newLocalDirection Defines the new local direction
  100439. */
  100440. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  100441. private _updateDirection;
  100442. /** @hidden */
  100443. updateDistanceFromListener(): void;
  100444. /**
  100445. * Sets a new custom attenuation function for the sound.
  100446. * @param callback Defines the function used for the attenuation
  100447. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  100448. */
  100449. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  100450. /**
  100451. * Play the sound
  100452. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  100453. * @param offset (optional) Start the sound at a specific time in seconds
  100454. * @param length (optional) Sound duration (in seconds)
  100455. */
  100456. play(time?: number, offset?: number, length?: number): void;
  100457. private _onended;
  100458. /**
  100459. * Stop the sound
  100460. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  100461. */
  100462. stop(time?: number): void;
  100463. /**
  100464. * Put the sound in pause
  100465. */
  100466. pause(): void;
  100467. /**
  100468. * Sets a dedicated volume for this sounds
  100469. * @param newVolume Define the new volume of the sound
  100470. * @param time Define time for gradual change to new volume
  100471. */
  100472. setVolume(newVolume: number, time?: number): void;
  100473. /**
  100474. * Set the sound play back rate
  100475. * @param newPlaybackRate Define the playback rate the sound should be played at
  100476. */
  100477. setPlaybackRate(newPlaybackRate: number): void;
  100478. /**
  100479. * Gets the volume of the sound.
  100480. * @returns the volume of the sound
  100481. */
  100482. getVolume(): number;
  100483. /**
  100484. * Attach the sound to a dedicated mesh
  100485. * @param transformNode The transform node to connect the sound with
  100486. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  100487. */
  100488. attachToMesh(transformNode: TransformNode): void;
  100489. /**
  100490. * Detach the sound from the previously attached mesh
  100491. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  100492. */
  100493. detachFromMesh(): void;
  100494. private _onRegisterAfterWorldMatrixUpdate;
  100495. /**
  100496. * Clone the current sound in the scene.
  100497. * @returns the new sound clone
  100498. */
  100499. clone(): Nullable<Sound>;
  100500. /**
  100501. * Gets the current underlying audio buffer containing the data
  100502. * @returns the audio buffer
  100503. */
  100504. getAudioBuffer(): Nullable<AudioBuffer>;
  100505. /**
  100506. * Serializes the Sound in a JSON representation
  100507. * @returns the JSON representation of the sound
  100508. */
  100509. serialize(): any;
  100510. /**
  100511. * Parse a JSON representation of a sound to innstantiate in a given scene
  100512. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  100513. * @param scene Define the scene the new parsed sound should be created in
  100514. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  100515. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  100516. * @returns the newly parsed sound
  100517. */
  100518. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  100519. }
  100520. }
  100521. declare module BABYLON {
  100522. /**
  100523. * This defines an action helpful to play a defined sound on a triggered action.
  100524. */
  100525. export class PlaySoundAction extends Action {
  100526. private _sound;
  100527. /**
  100528. * Instantiate the action
  100529. * @param triggerOptions defines the trigger options
  100530. * @param sound defines the sound to play
  100531. * @param condition defines the trigger related conditions
  100532. */
  100533. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  100534. /** @hidden */
  100535. _prepare(): void;
  100536. /**
  100537. * Execute the action and play the sound.
  100538. */
  100539. execute(): void;
  100540. /**
  100541. * Serializes the actions and its related information.
  100542. * @param parent defines the object to serialize in
  100543. * @returns the serialized object
  100544. */
  100545. serialize(parent: any): any;
  100546. }
  100547. /**
  100548. * This defines an action helpful to stop a defined sound on a triggered action.
  100549. */
  100550. export class StopSoundAction extends Action {
  100551. private _sound;
  100552. /**
  100553. * Instantiate the action
  100554. * @param triggerOptions defines the trigger options
  100555. * @param sound defines the sound to stop
  100556. * @param condition defines the trigger related conditions
  100557. */
  100558. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  100559. /** @hidden */
  100560. _prepare(): void;
  100561. /**
  100562. * Execute the action and stop the sound.
  100563. */
  100564. execute(): void;
  100565. /**
  100566. * Serializes the actions and its related information.
  100567. * @param parent defines the object to serialize in
  100568. * @returns the serialized object
  100569. */
  100570. serialize(parent: any): any;
  100571. }
  100572. }
  100573. declare module BABYLON {
  100574. /**
  100575. * This defines an action responsible to change the value of a property
  100576. * by interpolating between its current value and the newly set one once triggered.
  100577. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  100578. */
  100579. export class InterpolateValueAction extends Action {
  100580. /**
  100581. * Defines the path of the property where the value should be interpolated
  100582. */
  100583. propertyPath: string;
  100584. /**
  100585. * Defines the target value at the end of the interpolation.
  100586. */
  100587. value: any;
  100588. /**
  100589. * Defines the time it will take for the property to interpolate to the value.
  100590. */
  100591. duration: number;
  100592. /**
  100593. * Defines if the other scene animations should be stopped when the action has been triggered
  100594. */
  100595. stopOtherAnimations?: boolean;
  100596. /**
  100597. * Defines a callback raised once the interpolation animation has been done.
  100598. */
  100599. onInterpolationDone?: () => void;
  100600. /**
  100601. * Observable triggered once the interpolation animation has been done.
  100602. */
  100603. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  100604. private _target;
  100605. private _effectiveTarget;
  100606. private _property;
  100607. /**
  100608. * Instantiate the action
  100609. * @param triggerOptions defines the trigger options
  100610. * @param target defines the object containing the value to interpolate
  100611. * @param propertyPath defines the path to the property in the target object
  100612. * @param value defines the target value at the end of the interpolation
  100613. * @param duration deines the time it will take for the property to interpolate to the value.
  100614. * @param condition defines the trigger related conditions
  100615. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  100616. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  100617. */
  100618. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  100619. /** @hidden */
  100620. _prepare(): void;
  100621. /**
  100622. * Execute the action starts the value interpolation.
  100623. */
  100624. execute(): void;
  100625. /**
  100626. * Serializes the actions and its related information.
  100627. * @param parent defines the object to serialize in
  100628. * @returns the serialized object
  100629. */
  100630. serialize(parent: any): any;
  100631. }
  100632. }
  100633. declare module BABYLON {
  100634. /**
  100635. * Options allowed during the creation of a sound track.
  100636. */
  100637. export interface ISoundTrackOptions {
  100638. /**
  100639. * The volume the sound track should take during creation
  100640. */
  100641. volume?: number;
  100642. /**
  100643. * Define if the sound track is the main sound track of the scene
  100644. */
  100645. mainTrack?: boolean;
  100646. }
  100647. /**
  100648. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  100649. * It will be also used in a future release to apply effects on a specific track.
  100650. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  100651. */
  100652. export class SoundTrack {
  100653. /**
  100654. * The unique identifier of the sound track in the scene.
  100655. */
  100656. id: number;
  100657. /**
  100658. * The list of sounds included in the sound track.
  100659. */
  100660. soundCollection: Array<Sound>;
  100661. private _outputAudioNode;
  100662. private _scene;
  100663. private _isMainTrack;
  100664. private _connectedAnalyser;
  100665. private _options;
  100666. private _isInitialized;
  100667. /**
  100668. * Creates a new sound track.
  100669. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  100670. * @param scene Define the scene the sound track belongs to
  100671. * @param options
  100672. */
  100673. constructor(scene: Scene, options?: ISoundTrackOptions);
  100674. private _initializeSoundTrackAudioGraph;
  100675. /**
  100676. * Release the sound track and its associated resources
  100677. */
  100678. dispose(): void;
  100679. /**
  100680. * Adds a sound to this sound track
  100681. * @param sound define the cound to add
  100682. * @ignoreNaming
  100683. */
  100684. AddSound(sound: Sound): void;
  100685. /**
  100686. * Removes a sound to this sound track
  100687. * @param sound define the cound to remove
  100688. * @ignoreNaming
  100689. */
  100690. RemoveSound(sound: Sound): void;
  100691. /**
  100692. * Set a global volume for the full sound track.
  100693. * @param newVolume Define the new volume of the sound track
  100694. */
  100695. setVolume(newVolume: number): void;
  100696. /**
  100697. * Switch the panning model to HRTF:
  100698. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  100699. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  100700. */
  100701. switchPanningModelToHRTF(): void;
  100702. /**
  100703. * Switch the panning model to Equal Power:
  100704. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  100705. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  100706. */
  100707. switchPanningModelToEqualPower(): void;
  100708. /**
  100709. * Connect the sound track to an audio analyser allowing some amazing
  100710. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  100711. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  100712. * @param analyser The analyser to connect to the engine
  100713. */
  100714. connectToAnalyser(analyser: Analyser): void;
  100715. }
  100716. }
  100717. declare module BABYLON {
  100718. interface AbstractScene {
  100719. /**
  100720. * The list of sounds used in the scene.
  100721. */
  100722. sounds: Nullable<Array<Sound>>;
  100723. }
  100724. interface Scene {
  100725. /**
  100726. * @hidden
  100727. * Backing field
  100728. */
  100729. _mainSoundTrack: SoundTrack;
  100730. /**
  100731. * The main sound track played by the scene.
  100732. * It cotains your primary collection of sounds.
  100733. */
  100734. mainSoundTrack: SoundTrack;
  100735. /**
  100736. * The list of sound tracks added to the scene
  100737. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  100738. */
  100739. soundTracks: Nullable<Array<SoundTrack>>;
  100740. /**
  100741. * Gets a sound using a given name
  100742. * @param name defines the name to search for
  100743. * @return the found sound or null if not found at all.
  100744. */
  100745. getSoundByName(name: string): Nullable<Sound>;
  100746. /**
  100747. * Gets or sets if audio support is enabled
  100748. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  100749. */
  100750. audioEnabled: boolean;
  100751. /**
  100752. * Gets or sets if audio will be output to headphones
  100753. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  100754. */
  100755. headphone: boolean;
  100756. /**
  100757. * Gets or sets custom audio listener position provider
  100758. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  100759. */
  100760. audioListenerPositionProvider: Nullable<() => Vector3>;
  100761. }
  100762. /**
  100763. * Defines the sound scene component responsible to manage any sounds
  100764. * in a given scene.
  100765. */
  100766. export class AudioSceneComponent implements ISceneSerializableComponent {
  100767. /**
  100768. * The component name helpfull to identify the component in the list of scene components.
  100769. */
  100770. readonly name: string;
  100771. /**
  100772. * The scene the component belongs to.
  100773. */
  100774. scene: Scene;
  100775. private _audioEnabled;
  100776. /**
  100777. * Gets whether audio is enabled or not.
  100778. * Please use related enable/disable method to switch state.
  100779. */
  100780. readonly audioEnabled: boolean;
  100781. private _headphone;
  100782. /**
  100783. * Gets whether audio is outputing to headphone or not.
  100784. * Please use the according Switch methods to change output.
  100785. */
  100786. readonly headphone: boolean;
  100787. private _audioListenerPositionProvider;
  100788. /**
  100789. * Gets the current audio listener position provider
  100790. */
  100791. /**
  100792. * Sets a custom listener position for all sounds in the scene
  100793. * By default, this is the position of the first active camera
  100794. */
  100795. audioListenerPositionProvider: Nullable<() => Vector3>;
  100796. /**
  100797. * Creates a new instance of the component for the given scene
  100798. * @param scene Defines the scene to register the component in
  100799. */
  100800. constructor(scene: Scene);
  100801. /**
  100802. * Registers the component in a given scene
  100803. */
  100804. register(): void;
  100805. /**
  100806. * Rebuilds the elements related to this component in case of
  100807. * context lost for instance.
  100808. */
  100809. rebuild(): void;
  100810. /**
  100811. * Serializes the component data to the specified json object
  100812. * @param serializationObject The object to serialize to
  100813. */
  100814. serialize(serializationObject: any): void;
  100815. /**
  100816. * Adds all the elements from the container to the scene
  100817. * @param container the container holding the elements
  100818. */
  100819. addFromContainer(container: AbstractScene): void;
  100820. /**
  100821. * Removes all the elements in the container from the scene
  100822. * @param container contains the elements to remove
  100823. * @param dispose if the removed element should be disposed (default: false)
  100824. */
  100825. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  100826. /**
  100827. * Disposes the component and the associated ressources.
  100828. */
  100829. dispose(): void;
  100830. /**
  100831. * Disables audio in the associated scene.
  100832. */
  100833. disableAudio(): void;
  100834. /**
  100835. * Enables audio in the associated scene.
  100836. */
  100837. enableAudio(): void;
  100838. /**
  100839. * Switch audio to headphone output.
  100840. */
  100841. switchAudioModeForHeadphones(): void;
  100842. /**
  100843. * Switch audio to normal speakers.
  100844. */
  100845. switchAudioModeForNormalSpeakers(): void;
  100846. private _afterRender;
  100847. }
  100848. }
  100849. declare module BABYLON {
  100850. /**
  100851. * Wraps one or more Sound objects and selects one with random weight for playback.
  100852. */
  100853. export class WeightedSound {
  100854. /** When true a Sound will be selected and played when the current playing Sound completes. */
  100855. loop: boolean;
  100856. private _coneInnerAngle;
  100857. private _coneOuterAngle;
  100858. private _volume;
  100859. /** A Sound is currently playing. */
  100860. isPlaying: boolean;
  100861. /** A Sound is currently paused. */
  100862. isPaused: boolean;
  100863. private _sounds;
  100864. private _weights;
  100865. private _currentIndex?;
  100866. /**
  100867. * Creates a new WeightedSound from the list of sounds given.
  100868. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  100869. * @param sounds Array of Sounds that will be selected from.
  100870. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  100871. */
  100872. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  100873. /**
  100874. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  100875. */
  100876. /**
  100877. * The size of cone in degress for a directional sound in which there will be no attenuation.
  100878. */
  100879. directionalConeInnerAngle: number;
  100880. /**
  100881. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  100882. * Listener angles between innerAngle and outerAngle will falloff linearly.
  100883. */
  100884. /**
  100885. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  100886. * Listener angles between innerAngle and outerAngle will falloff linearly.
  100887. */
  100888. directionalConeOuterAngle: number;
  100889. /**
  100890. * Playback volume.
  100891. */
  100892. /**
  100893. * Playback volume.
  100894. */
  100895. volume: number;
  100896. private _onended;
  100897. /**
  100898. * Suspend playback
  100899. */
  100900. pause(): void;
  100901. /**
  100902. * Stop playback
  100903. */
  100904. stop(): void;
  100905. /**
  100906. * Start playback.
  100907. * @param startOffset Position the clip head at a specific time in seconds.
  100908. */
  100909. play(startOffset?: number): void;
  100910. }
  100911. }
  100912. declare module BABYLON {
  100913. /**
  100914. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  100915. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  100916. */
  100917. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  100918. /**
  100919. * Gets the name of the behavior.
  100920. */
  100921. readonly name: string;
  100922. /**
  100923. * The easing function used by animations
  100924. */
  100925. static EasingFunction: BackEase;
  100926. /**
  100927. * The easing mode used by animations
  100928. */
  100929. static EasingMode: number;
  100930. /**
  100931. * The duration of the animation, in milliseconds
  100932. */
  100933. transitionDuration: number;
  100934. /**
  100935. * Length of the distance animated by the transition when lower radius is reached
  100936. */
  100937. lowerRadiusTransitionRange: number;
  100938. /**
  100939. * Length of the distance animated by the transition when upper radius is reached
  100940. */
  100941. upperRadiusTransitionRange: number;
  100942. private _autoTransitionRange;
  100943. /**
  100944. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  100945. */
  100946. /**
  100947. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  100948. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  100949. */
  100950. autoTransitionRange: boolean;
  100951. private _attachedCamera;
  100952. private _onAfterCheckInputsObserver;
  100953. private _onMeshTargetChangedObserver;
  100954. /**
  100955. * Initializes the behavior.
  100956. */
  100957. init(): void;
  100958. /**
  100959. * Attaches the behavior to its arc rotate camera.
  100960. * @param camera Defines the camera to attach the behavior to
  100961. */
  100962. attach(camera: ArcRotateCamera): void;
  100963. /**
  100964. * Detaches the behavior from its current arc rotate camera.
  100965. */
  100966. detach(): void;
  100967. private _radiusIsAnimating;
  100968. private _radiusBounceTransition;
  100969. private _animatables;
  100970. private _cachedWheelPrecision;
  100971. /**
  100972. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  100973. * @param radiusLimit The limit to check against.
  100974. * @return Bool to indicate if at limit.
  100975. */
  100976. private _isRadiusAtLimit;
  100977. /**
  100978. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  100979. * @param radiusDelta The delta by which to animate to. Can be negative.
  100980. */
  100981. private _applyBoundRadiusAnimation;
  100982. /**
  100983. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  100984. */
  100985. protected _clearAnimationLocks(): void;
  100986. /**
  100987. * Stops and removes all animations that have been applied to the camera
  100988. */
  100989. stopAllAnimations(): void;
  100990. }
  100991. }
  100992. declare module BABYLON {
  100993. /**
  100994. * 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.
  100995. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  100996. */
  100997. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  100998. /**
  100999. * Gets the name of the behavior.
  101000. */
  101001. readonly name: string;
  101002. private _mode;
  101003. private _radiusScale;
  101004. private _positionScale;
  101005. private _defaultElevation;
  101006. private _elevationReturnTime;
  101007. private _elevationReturnWaitTime;
  101008. private _zoomStopsAnimation;
  101009. private _framingTime;
  101010. /**
  101011. * The easing function used by animations
  101012. */
  101013. static EasingFunction: ExponentialEase;
  101014. /**
  101015. * The easing mode used by animations
  101016. */
  101017. static EasingMode: number;
  101018. /**
  101019. * Sets the current mode used by the behavior
  101020. */
  101021. /**
  101022. * Gets current mode used by the behavior.
  101023. */
  101024. mode: number;
  101025. /**
  101026. * Sets the scale applied to the radius (1 by default)
  101027. */
  101028. /**
  101029. * Gets the scale applied to the radius
  101030. */
  101031. radiusScale: number;
  101032. /**
  101033. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  101034. */
  101035. /**
  101036. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  101037. */
  101038. positionScale: number;
  101039. /**
  101040. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  101041. * behaviour is triggered, in radians.
  101042. */
  101043. /**
  101044. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  101045. * behaviour is triggered, in radians.
  101046. */
  101047. defaultElevation: number;
  101048. /**
  101049. * Sets the time (in milliseconds) taken to return to the default beta position.
  101050. * Negative value indicates camera should not return to default.
  101051. */
  101052. /**
  101053. * Gets the time (in milliseconds) taken to return to the default beta position.
  101054. * Negative value indicates camera should not return to default.
  101055. */
  101056. elevationReturnTime: number;
  101057. /**
  101058. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  101059. */
  101060. /**
  101061. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  101062. */
  101063. elevationReturnWaitTime: number;
  101064. /**
  101065. * Sets the flag that indicates if user zooming should stop animation.
  101066. */
  101067. /**
  101068. * Gets the flag that indicates if user zooming should stop animation.
  101069. */
  101070. zoomStopsAnimation: boolean;
  101071. /**
  101072. * Sets the transition time when framing the mesh, in milliseconds
  101073. */
  101074. /**
  101075. * Gets the transition time when framing the mesh, in milliseconds
  101076. */
  101077. framingTime: number;
  101078. /**
  101079. * Define if the behavior should automatically change the configured
  101080. * camera limits and sensibilities.
  101081. */
  101082. autoCorrectCameraLimitsAndSensibility: boolean;
  101083. private _onPrePointerObservableObserver;
  101084. private _onAfterCheckInputsObserver;
  101085. private _onMeshTargetChangedObserver;
  101086. private _attachedCamera;
  101087. private _isPointerDown;
  101088. private _lastInteractionTime;
  101089. /**
  101090. * Initializes the behavior.
  101091. */
  101092. init(): void;
  101093. /**
  101094. * Attaches the behavior to its arc rotate camera.
  101095. * @param camera Defines the camera to attach the behavior to
  101096. */
  101097. attach(camera: ArcRotateCamera): void;
  101098. /**
  101099. * Detaches the behavior from its current arc rotate camera.
  101100. */
  101101. detach(): void;
  101102. private _animatables;
  101103. private _betaIsAnimating;
  101104. private _betaTransition;
  101105. private _radiusTransition;
  101106. private _vectorTransition;
  101107. /**
  101108. * Targets the given mesh and updates zoom level accordingly.
  101109. * @param mesh The mesh to target.
  101110. * @param radius Optional. If a cached radius position already exists, overrides default.
  101111. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  101112. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  101113. * @param onAnimationEnd Callback triggered at the end of the framing animation
  101114. */
  101115. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  101116. /**
  101117. * Targets the given mesh with its children and updates zoom level accordingly.
  101118. * @param mesh The mesh to target.
  101119. * @param radius Optional. If a cached radius position already exists, overrides default.
  101120. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  101121. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  101122. * @param onAnimationEnd Callback triggered at the end of the framing animation
  101123. */
  101124. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  101125. /**
  101126. * Targets the given meshes with their children and updates zoom level accordingly.
  101127. * @param meshes The mesh to target.
  101128. * @param radius Optional. If a cached radius position already exists, overrides default.
  101129. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  101130. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  101131. * @param onAnimationEnd Callback triggered at the end of the framing animation
  101132. */
  101133. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  101134. /**
  101135. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  101136. * @param minimumWorld Determines the smaller position of the bounding box extend
  101137. * @param maximumWorld Determines the bigger position of the bounding box extend
  101138. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  101139. * @param onAnimationEnd Callback triggered at the end of the framing animation
  101140. */
  101141. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  101142. /**
  101143. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  101144. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  101145. * frustum width.
  101146. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  101147. * to fully enclose the mesh in the viewing frustum.
  101148. */
  101149. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  101150. /**
  101151. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  101152. * is automatically returned to its default position (expected to be above ground plane).
  101153. */
  101154. private _maintainCameraAboveGround;
  101155. /**
  101156. * Returns the frustum slope based on the canvas ratio and camera FOV
  101157. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  101158. */
  101159. private _getFrustumSlope;
  101160. /**
  101161. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  101162. */
  101163. private _clearAnimationLocks;
  101164. /**
  101165. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  101166. */
  101167. private _applyUserInteraction;
  101168. /**
  101169. * Stops and removes all animations that have been applied to the camera
  101170. */
  101171. stopAllAnimations(): void;
  101172. /**
  101173. * Gets a value indicating if the user is moving the camera
  101174. */
  101175. readonly isUserIsMoving: boolean;
  101176. /**
  101177. * The camera can move all the way towards the mesh.
  101178. */
  101179. static IgnoreBoundsSizeMode: number;
  101180. /**
  101181. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  101182. */
  101183. static FitFrustumSidesMode: number;
  101184. }
  101185. }
  101186. declare module BABYLON {
  101187. /**
  101188. * Base class for Camera Pointer Inputs.
  101189. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  101190. * for example usage.
  101191. */
  101192. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  101193. /**
  101194. * Defines the camera the input is attached to.
  101195. */
  101196. abstract camera: Camera;
  101197. /**
  101198. * Whether keyboard modifier keys are pressed at time of last mouse event.
  101199. */
  101200. protected _altKey: boolean;
  101201. protected _ctrlKey: boolean;
  101202. protected _metaKey: boolean;
  101203. protected _shiftKey: boolean;
  101204. /**
  101205. * Which mouse buttons were pressed at time of last mouse event.
  101206. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  101207. */
  101208. protected _buttonsPressed: number;
  101209. /**
  101210. * Defines the buttons associated with the input to handle camera move.
  101211. */
  101212. buttons: number[];
  101213. /**
  101214. * Attach the input controls to a specific dom element to get the input from.
  101215. * @param element Defines the element the controls should be listened from
  101216. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  101217. */
  101218. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  101219. /**
  101220. * Detach the current controls from the specified dom element.
  101221. * @param element Defines the element to stop listening the inputs from
  101222. */
  101223. detachControl(element: Nullable<HTMLElement>): void;
  101224. /**
  101225. * Gets the class name of the current input.
  101226. * @returns the class name
  101227. */
  101228. getClassName(): string;
  101229. /**
  101230. * Get the friendly name associated with the input class.
  101231. * @returns the input friendly name
  101232. */
  101233. getSimpleName(): string;
  101234. /**
  101235. * Called on pointer POINTERDOUBLETAP event.
  101236. * Override this method to provide functionality on POINTERDOUBLETAP event.
  101237. */
  101238. protected onDoubleTap(type: string): void;
  101239. /**
  101240. * Called on pointer POINTERMOVE event if only a single touch is active.
  101241. * Override this method to provide functionality.
  101242. */
  101243. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  101244. /**
  101245. * Called on pointer POINTERMOVE event if multiple touches are active.
  101246. * Override this method to provide functionality.
  101247. */
  101248. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  101249. /**
  101250. * Called on JS contextmenu event.
  101251. * Override this method to provide functionality.
  101252. */
  101253. protected onContextMenu(evt: PointerEvent): void;
  101254. /**
  101255. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  101256. * press.
  101257. * Override this method to provide functionality.
  101258. */
  101259. protected onButtonDown(evt: PointerEvent): void;
  101260. /**
  101261. * Called each time a new POINTERUP event occurs. Ie, for each button
  101262. * release.
  101263. * Override this method to provide functionality.
  101264. */
  101265. protected onButtonUp(evt: PointerEvent): void;
  101266. /**
  101267. * Called when window becomes inactive.
  101268. * Override this method to provide functionality.
  101269. */
  101270. protected onLostFocus(): void;
  101271. private _pointerInput;
  101272. private _observer;
  101273. private _onLostFocus;
  101274. private pointA;
  101275. private pointB;
  101276. }
  101277. }
  101278. declare module BABYLON {
  101279. /**
  101280. * Manage the pointers inputs to control an arc rotate camera.
  101281. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  101282. */
  101283. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  101284. /**
  101285. * Defines the camera the input is attached to.
  101286. */
  101287. camera: ArcRotateCamera;
  101288. /**
  101289. * Gets the class name of the current input.
  101290. * @returns the class name
  101291. */
  101292. getClassName(): string;
  101293. /**
  101294. * Defines the buttons associated with the input to handle camera move.
  101295. */
  101296. buttons: number[];
  101297. /**
  101298. * Defines the pointer angular sensibility along the X axis or how fast is
  101299. * the camera rotating.
  101300. */
  101301. angularSensibilityX: number;
  101302. /**
  101303. * Defines the pointer angular sensibility along the Y axis or how fast is
  101304. * the camera rotating.
  101305. */
  101306. angularSensibilityY: number;
  101307. /**
  101308. * Defines the pointer pinch precision or how fast is the camera zooming.
  101309. */
  101310. pinchPrecision: number;
  101311. /**
  101312. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  101313. * from 0.
  101314. * It defines the percentage of current camera.radius to use as delta when
  101315. * pinch zoom is used.
  101316. */
  101317. pinchDeltaPercentage: number;
  101318. /**
  101319. * Defines the pointer panning sensibility or how fast is the camera moving.
  101320. */
  101321. panningSensibility: number;
  101322. /**
  101323. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  101324. */
  101325. multiTouchPanning: boolean;
  101326. /**
  101327. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  101328. * zoom (pinch) through multitouch.
  101329. */
  101330. multiTouchPanAndZoom: boolean;
  101331. /**
  101332. * Revers pinch action direction.
  101333. */
  101334. pinchInwards: boolean;
  101335. private _isPanClick;
  101336. private _twoFingerActivityCount;
  101337. private _isPinching;
  101338. /**
  101339. * Called on pointer POINTERMOVE event if only a single touch is active.
  101340. */
  101341. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  101342. /**
  101343. * Called on pointer POINTERDOUBLETAP event.
  101344. */
  101345. protected onDoubleTap(type: string): void;
  101346. /**
  101347. * Called on pointer POINTERMOVE event if multiple touches are active.
  101348. */
  101349. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  101350. /**
  101351. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  101352. * press.
  101353. */
  101354. protected onButtonDown(evt: PointerEvent): void;
  101355. /**
  101356. * Called each time a new POINTERUP event occurs. Ie, for each button
  101357. * release.
  101358. */
  101359. protected onButtonUp(evt: PointerEvent): void;
  101360. /**
  101361. * Called when window becomes inactive.
  101362. */
  101363. protected onLostFocus(): void;
  101364. }
  101365. }
  101366. declare module BABYLON {
  101367. /**
  101368. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  101369. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  101370. */
  101371. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  101372. /**
  101373. * Defines the camera the input is attached to.
  101374. */
  101375. camera: ArcRotateCamera;
  101376. /**
  101377. * Defines the list of key codes associated with the up action (increase alpha)
  101378. */
  101379. keysUp: number[];
  101380. /**
  101381. * Defines the list of key codes associated with the down action (decrease alpha)
  101382. */
  101383. keysDown: number[];
  101384. /**
  101385. * Defines the list of key codes associated with the left action (increase beta)
  101386. */
  101387. keysLeft: number[];
  101388. /**
  101389. * Defines the list of key codes associated with the right action (decrease beta)
  101390. */
  101391. keysRight: number[];
  101392. /**
  101393. * Defines the list of key codes associated with the reset action.
  101394. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  101395. */
  101396. keysReset: number[];
  101397. /**
  101398. * Defines the panning sensibility of the inputs.
  101399. * (How fast is the camera paning)
  101400. */
  101401. panningSensibility: number;
  101402. /**
  101403. * Defines the zooming sensibility of the inputs.
  101404. * (How fast is the camera zooming)
  101405. */
  101406. zoomingSensibility: number;
  101407. /**
  101408. * Defines wether maintaining the alt key down switch the movement mode from
  101409. * orientation to zoom.
  101410. */
  101411. useAltToZoom: boolean;
  101412. /**
  101413. * Rotation speed of the camera
  101414. */
  101415. angularSpeed: number;
  101416. private _keys;
  101417. private _ctrlPressed;
  101418. private _altPressed;
  101419. private _onCanvasBlurObserver;
  101420. private _onKeyboardObserver;
  101421. private _engine;
  101422. private _scene;
  101423. /**
  101424. * Attach the input controls to a specific dom element to get the input from.
  101425. * @param element Defines the element the controls should be listened from
  101426. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  101427. */
  101428. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  101429. /**
  101430. * Detach the current controls from the specified dom element.
  101431. * @param element Defines the element to stop listening the inputs from
  101432. */
  101433. detachControl(element: Nullable<HTMLElement>): void;
  101434. /**
  101435. * Update the current camera state depending on the inputs that have been used this frame.
  101436. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  101437. */
  101438. checkInputs(): void;
  101439. /**
  101440. * Gets the class name of the current intput.
  101441. * @returns the class name
  101442. */
  101443. getClassName(): string;
  101444. /**
  101445. * Get the friendly name associated with the input class.
  101446. * @returns the input friendly name
  101447. */
  101448. getSimpleName(): string;
  101449. }
  101450. }
  101451. declare module BABYLON {
  101452. /**
  101453. * Manage the mouse wheel inputs to control an arc rotate camera.
  101454. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  101455. */
  101456. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  101457. /**
  101458. * Defines the camera the input is attached to.
  101459. */
  101460. camera: ArcRotateCamera;
  101461. /**
  101462. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  101463. */
  101464. wheelPrecision: number;
  101465. /**
  101466. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  101467. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  101468. */
  101469. wheelDeltaPercentage: number;
  101470. private _wheel;
  101471. private _observer;
  101472. private computeDeltaFromMouseWheelLegacyEvent;
  101473. /**
  101474. * Attach the input controls to a specific dom element to get the input from.
  101475. * @param element Defines the element the controls should be listened from
  101476. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  101477. */
  101478. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  101479. /**
  101480. * Detach the current controls from the specified dom element.
  101481. * @param element Defines the element to stop listening the inputs from
  101482. */
  101483. detachControl(element: Nullable<HTMLElement>): void;
  101484. /**
  101485. * Gets the class name of the current intput.
  101486. * @returns the class name
  101487. */
  101488. getClassName(): string;
  101489. /**
  101490. * Get the friendly name associated with the input class.
  101491. * @returns the input friendly name
  101492. */
  101493. getSimpleName(): string;
  101494. }
  101495. }
  101496. declare module BABYLON {
  101497. /**
  101498. * Default Inputs manager for the ArcRotateCamera.
  101499. * It groups all the default supported inputs for ease of use.
  101500. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  101501. */
  101502. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  101503. /**
  101504. * Instantiates a new ArcRotateCameraInputsManager.
  101505. * @param camera Defines the camera the inputs belong to
  101506. */
  101507. constructor(camera: ArcRotateCamera);
  101508. /**
  101509. * Add mouse wheel input support to the input manager.
  101510. * @returns the current input manager
  101511. */
  101512. addMouseWheel(): ArcRotateCameraInputsManager;
  101513. /**
  101514. * Add pointers input support to the input manager.
  101515. * @returns the current input manager
  101516. */
  101517. addPointers(): ArcRotateCameraInputsManager;
  101518. /**
  101519. * Add keyboard input support to the input manager.
  101520. * @returns the current input manager
  101521. */
  101522. addKeyboard(): ArcRotateCameraInputsManager;
  101523. }
  101524. }
  101525. declare module BABYLON {
  101526. /**
  101527. * This represents an orbital type of camera.
  101528. *
  101529. * 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.
  101530. * 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.
  101531. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  101532. */
  101533. export class ArcRotateCamera extends TargetCamera {
  101534. /**
  101535. * Defines the rotation angle of the camera along the longitudinal axis.
  101536. */
  101537. alpha: number;
  101538. /**
  101539. * Defines the rotation angle of the camera along the latitudinal axis.
  101540. */
  101541. beta: number;
  101542. /**
  101543. * Defines the radius of the camera from it s target point.
  101544. */
  101545. radius: number;
  101546. protected _target: Vector3;
  101547. protected _targetHost: Nullable<AbstractMesh>;
  101548. /**
  101549. * Defines the target point of the camera.
  101550. * The camera looks towards it form the radius distance.
  101551. */
  101552. target: Vector3;
  101553. /**
  101554. * Define the current local position of the camera in the scene
  101555. */
  101556. position: Vector3;
  101557. protected _upVector: Vector3;
  101558. protected _upToYMatrix: Matrix;
  101559. protected _YToUpMatrix: Matrix;
  101560. /**
  101561. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  101562. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  101563. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  101564. */
  101565. upVector: Vector3;
  101566. /**
  101567. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  101568. */
  101569. setMatUp(): void;
  101570. /**
  101571. * Current inertia value on the longitudinal axis.
  101572. * The bigger this number the longer it will take for the camera to stop.
  101573. */
  101574. inertialAlphaOffset: number;
  101575. /**
  101576. * Current inertia value on the latitudinal axis.
  101577. * The bigger this number the longer it will take for the camera to stop.
  101578. */
  101579. inertialBetaOffset: number;
  101580. /**
  101581. * Current inertia value on the radius axis.
  101582. * The bigger this number the longer it will take for the camera to stop.
  101583. */
  101584. inertialRadiusOffset: number;
  101585. /**
  101586. * Minimum allowed angle on the longitudinal axis.
  101587. * This can help limiting how the Camera is able to move in the scene.
  101588. */
  101589. lowerAlphaLimit: Nullable<number>;
  101590. /**
  101591. * Maximum allowed angle on the longitudinal axis.
  101592. * This can help limiting how the Camera is able to move in the scene.
  101593. */
  101594. upperAlphaLimit: Nullable<number>;
  101595. /**
  101596. * Minimum allowed angle on the latitudinal axis.
  101597. * This can help limiting how the Camera is able to move in the scene.
  101598. */
  101599. lowerBetaLimit: number;
  101600. /**
  101601. * Maximum allowed angle on the latitudinal axis.
  101602. * This can help limiting how the Camera is able to move in the scene.
  101603. */
  101604. upperBetaLimit: number;
  101605. /**
  101606. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  101607. * This can help limiting how the Camera is able to move in the scene.
  101608. */
  101609. lowerRadiusLimit: Nullable<number>;
  101610. /**
  101611. * Maximum allowed distance of the camera to the target (The camera can not get further).
  101612. * This can help limiting how the Camera is able to move in the scene.
  101613. */
  101614. upperRadiusLimit: Nullable<number>;
  101615. /**
  101616. * Defines the current inertia value used during panning of the camera along the X axis.
  101617. */
  101618. inertialPanningX: number;
  101619. /**
  101620. * Defines the current inertia value used during panning of the camera along the Y axis.
  101621. */
  101622. inertialPanningY: number;
  101623. /**
  101624. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  101625. * Basically if your fingers moves away from more than this distance you will be considered
  101626. * in pinch mode.
  101627. */
  101628. pinchToPanMaxDistance: number;
  101629. /**
  101630. * Defines the maximum distance the camera can pan.
  101631. * This could help keeping the cammera always in your scene.
  101632. */
  101633. panningDistanceLimit: Nullable<number>;
  101634. /**
  101635. * Defines the target of the camera before paning.
  101636. */
  101637. panningOriginTarget: Vector3;
  101638. /**
  101639. * Defines the value of the inertia used during panning.
  101640. * 0 would mean stop inertia and one would mean no decelleration at all.
  101641. */
  101642. panningInertia: number;
  101643. /**
  101644. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  101645. */
  101646. angularSensibilityX: number;
  101647. /**
  101648. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  101649. */
  101650. angularSensibilityY: number;
  101651. /**
  101652. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  101653. */
  101654. pinchPrecision: number;
  101655. /**
  101656. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  101657. * It will be used instead of pinchDeltaPrecision if different from 0.
  101658. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  101659. */
  101660. pinchDeltaPercentage: number;
  101661. /**
  101662. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  101663. */
  101664. panningSensibility: number;
  101665. /**
  101666. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  101667. */
  101668. keysUp: number[];
  101669. /**
  101670. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  101671. */
  101672. keysDown: number[];
  101673. /**
  101674. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  101675. */
  101676. keysLeft: number[];
  101677. /**
  101678. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  101679. */
  101680. keysRight: number[];
  101681. /**
  101682. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  101683. */
  101684. wheelPrecision: number;
  101685. /**
  101686. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  101687. * It will be used instead of pinchDeltaPrecision if different from 0.
  101688. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  101689. */
  101690. wheelDeltaPercentage: number;
  101691. /**
  101692. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  101693. */
  101694. zoomOnFactor: number;
  101695. /**
  101696. * Defines a screen offset for the camera position.
  101697. */
  101698. targetScreenOffset: Vector2;
  101699. /**
  101700. * Allows the camera to be completely reversed.
  101701. * If false the camera can not arrive upside down.
  101702. */
  101703. allowUpsideDown: boolean;
  101704. /**
  101705. * Define if double tap/click is used to restore the previously saved state of the camera.
  101706. */
  101707. useInputToRestoreState: boolean;
  101708. /** @hidden */
  101709. _viewMatrix: Matrix;
  101710. /** @hidden */
  101711. _useCtrlForPanning: boolean;
  101712. /** @hidden */
  101713. _panningMouseButton: number;
  101714. /**
  101715. * Defines the input associated to the camera.
  101716. */
  101717. inputs: ArcRotateCameraInputsManager;
  101718. /** @hidden */
  101719. _reset: () => void;
  101720. /**
  101721. * Defines the allowed panning axis.
  101722. */
  101723. panningAxis: Vector3;
  101724. protected _localDirection: Vector3;
  101725. protected _transformedDirection: Vector3;
  101726. private _bouncingBehavior;
  101727. /**
  101728. * Gets the bouncing behavior of the camera if it has been enabled.
  101729. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  101730. */
  101731. readonly bouncingBehavior: Nullable<BouncingBehavior>;
  101732. /**
  101733. * Defines if the bouncing behavior of the camera is enabled on the camera.
  101734. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  101735. */
  101736. useBouncingBehavior: boolean;
  101737. private _framingBehavior;
  101738. /**
  101739. * Gets the framing behavior of the camera if it has been enabled.
  101740. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  101741. */
  101742. readonly framingBehavior: Nullable<FramingBehavior>;
  101743. /**
  101744. * Defines if the framing behavior of the camera is enabled on the camera.
  101745. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  101746. */
  101747. useFramingBehavior: boolean;
  101748. private _autoRotationBehavior;
  101749. /**
  101750. * Gets the auto rotation behavior of the camera if it has been enabled.
  101751. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  101752. */
  101753. readonly autoRotationBehavior: Nullable<AutoRotationBehavior>;
  101754. /**
  101755. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  101756. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  101757. */
  101758. useAutoRotationBehavior: boolean;
  101759. /**
  101760. * Observable triggered when the mesh target has been changed on the camera.
  101761. */
  101762. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  101763. /**
  101764. * Event raised when the camera is colliding with a mesh.
  101765. */
  101766. onCollide: (collidedMesh: AbstractMesh) => void;
  101767. /**
  101768. * Defines whether the camera should check collision with the objects oh the scene.
  101769. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  101770. */
  101771. checkCollisions: boolean;
  101772. /**
  101773. * Defines the collision radius of the camera.
  101774. * This simulates a sphere around the camera.
  101775. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  101776. */
  101777. collisionRadius: Vector3;
  101778. protected _collider: Collider;
  101779. protected _previousPosition: Vector3;
  101780. protected _collisionVelocity: Vector3;
  101781. protected _newPosition: Vector3;
  101782. protected _previousAlpha: number;
  101783. protected _previousBeta: number;
  101784. protected _previousRadius: number;
  101785. protected _collisionTriggered: boolean;
  101786. protected _targetBoundingCenter: Nullable<Vector3>;
  101787. private _computationVector;
  101788. /**
  101789. * Instantiates a new ArcRotateCamera in a given scene
  101790. * @param name Defines the name of the camera
  101791. * @param alpha Defines the camera rotation along the logitudinal axis
  101792. * @param beta Defines the camera rotation along the latitudinal axis
  101793. * @param radius Defines the camera distance from its target
  101794. * @param target Defines the camera target
  101795. * @param scene Defines the scene the camera belongs to
  101796. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  101797. */
  101798. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  101799. /** @hidden */
  101800. _initCache(): void;
  101801. /** @hidden */
  101802. _updateCache(ignoreParentClass?: boolean): void;
  101803. protected _getTargetPosition(): Vector3;
  101804. private _storedAlpha;
  101805. private _storedBeta;
  101806. private _storedRadius;
  101807. private _storedTarget;
  101808. private _storedTargetScreenOffset;
  101809. /**
  101810. * Stores the current state of the camera (alpha, beta, radius and target)
  101811. * @returns the camera itself
  101812. */
  101813. storeState(): Camera;
  101814. /**
  101815. * @hidden
  101816. * Restored camera state. You must call storeState() first
  101817. */
  101818. _restoreStateValues(): boolean;
  101819. /** @hidden */
  101820. _isSynchronizedViewMatrix(): boolean;
  101821. /**
  101822. * Attached controls to the current camera.
  101823. * @param element Defines the element the controls should be listened from
  101824. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  101825. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  101826. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  101827. */
  101828. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  101829. /**
  101830. * Detach the current controls from the camera.
  101831. * The camera will stop reacting to inputs.
  101832. * @param element Defines the element to stop listening the inputs from
  101833. */
  101834. detachControl(element: HTMLElement): void;
  101835. /** @hidden */
  101836. _checkInputs(): void;
  101837. protected _checkLimits(): void;
  101838. /**
  101839. * Rebuilds angles (alpha, beta) and radius from the give position and target
  101840. */
  101841. rebuildAnglesAndRadius(): void;
  101842. /**
  101843. * Use a position to define the current camera related information like aplha, beta and radius
  101844. * @param position Defines the position to set the camera at
  101845. */
  101846. setPosition(position: Vector3): void;
  101847. /**
  101848. * Defines the target the camera should look at.
  101849. * This will automatically adapt alpha beta and radius to fit within the new target.
  101850. * @param target Defines the new target as a Vector or a mesh
  101851. * @param toBoundingCenter In case of a mesh target, defines wether to target the mesh position or its bounding information center
  101852. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  101853. */
  101854. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  101855. /** @hidden */
  101856. _getViewMatrix(): Matrix;
  101857. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  101858. /**
  101859. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  101860. * @param meshes Defines the mesh to zoom on
  101861. * @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)
  101862. */
  101863. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  101864. /**
  101865. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  101866. * The target will be changed but the radius
  101867. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  101868. * @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)
  101869. */
  101870. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  101871. min: Vector3;
  101872. max: Vector3;
  101873. distance: number;
  101874. }, doNotUpdateMaxZ?: boolean): void;
  101875. /**
  101876. * @override
  101877. * Override Camera.createRigCamera
  101878. */
  101879. createRigCamera(name: string, cameraIndex: number): Camera;
  101880. /**
  101881. * @hidden
  101882. * @override
  101883. * Override Camera._updateRigCameras
  101884. */
  101885. _updateRigCameras(): void;
  101886. /**
  101887. * Destroy the camera and release the current resources hold by it.
  101888. */
  101889. dispose(): void;
  101890. /**
  101891. * Gets the current object class name.
  101892. * @return the class name
  101893. */
  101894. getClassName(): string;
  101895. }
  101896. }
  101897. declare module BABYLON {
  101898. /**
  101899. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  101900. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  101901. */
  101902. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  101903. /**
  101904. * Gets the name of the behavior.
  101905. */
  101906. readonly name: string;
  101907. private _zoomStopsAnimation;
  101908. private _idleRotationSpeed;
  101909. private _idleRotationWaitTime;
  101910. private _idleRotationSpinupTime;
  101911. /**
  101912. * Sets the flag that indicates if user zooming should stop animation.
  101913. */
  101914. /**
  101915. * Gets the flag that indicates if user zooming should stop animation.
  101916. */
  101917. zoomStopsAnimation: boolean;
  101918. /**
  101919. * Sets the default speed at which the camera rotates around the model.
  101920. */
  101921. /**
  101922. * Gets the default speed at which the camera rotates around the model.
  101923. */
  101924. idleRotationSpeed: number;
  101925. /**
  101926. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  101927. */
  101928. /**
  101929. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  101930. */
  101931. idleRotationWaitTime: number;
  101932. /**
  101933. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  101934. */
  101935. /**
  101936. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  101937. */
  101938. idleRotationSpinupTime: number;
  101939. /**
  101940. * Gets a value indicating if the camera is currently rotating because of this behavior
  101941. */
  101942. readonly rotationInProgress: boolean;
  101943. private _onPrePointerObservableObserver;
  101944. private _onAfterCheckInputsObserver;
  101945. private _attachedCamera;
  101946. private _isPointerDown;
  101947. private _lastFrameTime;
  101948. private _lastInteractionTime;
  101949. private _cameraRotationSpeed;
  101950. /**
  101951. * Initializes the behavior.
  101952. */
  101953. init(): void;
  101954. /**
  101955. * Attaches the behavior to its arc rotate camera.
  101956. * @param camera Defines the camera to attach the behavior to
  101957. */
  101958. attach(camera: ArcRotateCamera): void;
  101959. /**
  101960. * Detaches the behavior from its current arc rotate camera.
  101961. */
  101962. detach(): void;
  101963. /**
  101964. * Returns true if user is scrolling.
  101965. * @return true if user is scrolling.
  101966. */
  101967. private _userIsZooming;
  101968. private _lastFrameRadius;
  101969. private _shouldAnimationStopForInteraction;
  101970. /**
  101971. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  101972. */
  101973. private _applyUserInteraction;
  101974. private _userIsMoving;
  101975. }
  101976. }
  101977. declare module BABYLON {
  101978. /**
  101979. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  101980. */
  101981. export class AttachToBoxBehavior implements Behavior<Mesh> {
  101982. private ui;
  101983. /**
  101984. * The name of the behavior
  101985. */
  101986. name: string;
  101987. /**
  101988. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  101989. */
  101990. distanceAwayFromFace: number;
  101991. /**
  101992. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  101993. */
  101994. distanceAwayFromBottomOfFace: number;
  101995. private _faceVectors;
  101996. private _target;
  101997. private _scene;
  101998. private _onRenderObserver;
  101999. private _tmpMatrix;
  102000. private _tmpVector;
  102001. /**
  102002. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  102003. * @param ui The transform node that should be attched to the mesh
  102004. */
  102005. constructor(ui: TransformNode);
  102006. /**
  102007. * Initializes the behavior
  102008. */
  102009. init(): void;
  102010. private _closestFace;
  102011. private _zeroVector;
  102012. private _lookAtTmpMatrix;
  102013. private _lookAtToRef;
  102014. /**
  102015. * Attaches the AttachToBoxBehavior to the passed in mesh
  102016. * @param target The mesh that the specified node will be attached to
  102017. */
  102018. attach(target: Mesh): void;
  102019. /**
  102020. * Detaches the behavior from the mesh
  102021. */
  102022. detach(): void;
  102023. }
  102024. }
  102025. declare module BABYLON {
  102026. /**
  102027. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  102028. */
  102029. export class FadeInOutBehavior implements Behavior<Mesh> {
  102030. /**
  102031. * Time in milliseconds to delay before fading in (Default: 0)
  102032. */
  102033. delay: number;
  102034. /**
  102035. * Time in milliseconds for the mesh to fade in (Default: 300)
  102036. */
  102037. fadeInTime: number;
  102038. private _millisecondsPerFrame;
  102039. private _hovered;
  102040. private _hoverValue;
  102041. private _ownerNode;
  102042. /**
  102043. * Instatiates the FadeInOutBehavior
  102044. */
  102045. constructor();
  102046. /**
  102047. * The name of the behavior
  102048. */
  102049. readonly name: string;
  102050. /**
  102051. * Initializes the behavior
  102052. */
  102053. init(): void;
  102054. /**
  102055. * Attaches the fade behavior on the passed in mesh
  102056. * @param ownerNode The mesh that will be faded in/out once attached
  102057. */
  102058. attach(ownerNode: Mesh): void;
  102059. /**
  102060. * Detaches the behavior from the mesh
  102061. */
  102062. detach(): void;
  102063. /**
  102064. * Triggers the mesh to begin fading in or out
  102065. * @param value if the object should fade in or out (true to fade in)
  102066. */
  102067. fadeIn(value: boolean): void;
  102068. private _update;
  102069. private _setAllVisibility;
  102070. }
  102071. }
  102072. declare module BABYLON {
  102073. /**
  102074. * Class containing a set of static utilities functions for managing Pivots
  102075. * @hidden
  102076. */
  102077. export class PivotTools {
  102078. private static _PivotCached;
  102079. private static _OldPivotPoint;
  102080. private static _PivotTranslation;
  102081. private static _PivotTmpVector;
  102082. /** @hidden */
  102083. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  102084. /** @hidden */
  102085. static _RestorePivotPoint(mesh: AbstractMesh): void;
  102086. }
  102087. }
  102088. declare module BABYLON {
  102089. /**
  102090. * Class containing static functions to help procedurally build meshes
  102091. */
  102092. export class PlaneBuilder {
  102093. /**
  102094. * Creates a plane mesh
  102095. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  102096. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  102097. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  102098. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  102099. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  102100. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  102101. * @param name defines the name of the mesh
  102102. * @param options defines the options used to create the mesh
  102103. * @param scene defines the hosting scene
  102104. * @returns the plane mesh
  102105. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  102106. */
  102107. static CreatePlane(name: string, options: {
  102108. size?: number;
  102109. width?: number;
  102110. height?: number;
  102111. sideOrientation?: number;
  102112. frontUVs?: Vector4;
  102113. backUVs?: Vector4;
  102114. updatable?: boolean;
  102115. sourcePlane?: Plane;
  102116. }, scene?: Nullable<Scene>): Mesh;
  102117. }
  102118. }
  102119. declare module BABYLON {
  102120. /**
  102121. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  102122. */
  102123. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  102124. private static _AnyMouseID;
  102125. /**
  102126. * Abstract mesh the behavior is set on
  102127. */
  102128. attachedNode: AbstractMesh;
  102129. private _dragPlane;
  102130. private _scene;
  102131. private _pointerObserver;
  102132. private _beforeRenderObserver;
  102133. private static _planeScene;
  102134. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  102135. /**
  102136. * 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)
  102137. */
  102138. maxDragAngle: number;
  102139. /**
  102140. * @hidden
  102141. */
  102142. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  102143. /**
  102144. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  102145. */
  102146. currentDraggingPointerID: number;
  102147. /**
  102148. * The last position where the pointer hit the drag plane in world space
  102149. */
  102150. lastDragPosition: Vector3;
  102151. /**
  102152. * If the behavior is currently in a dragging state
  102153. */
  102154. dragging: boolean;
  102155. /**
  102156. * 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)
  102157. */
  102158. dragDeltaRatio: number;
  102159. /**
  102160. * If the drag plane orientation should be updated during the dragging (Default: true)
  102161. */
  102162. updateDragPlane: boolean;
  102163. private _debugMode;
  102164. private _moving;
  102165. /**
  102166. * Fires each time the attached mesh is dragged with the pointer
  102167. * * delta between last drag position and current drag position in world space
  102168. * * dragDistance along the drag axis
  102169. * * dragPlaneNormal normal of the current drag plane used during the drag
  102170. * * dragPlanePoint in world space where the drag intersects the drag plane
  102171. */
  102172. onDragObservable: Observable<{
  102173. delta: Vector3;
  102174. dragPlanePoint: Vector3;
  102175. dragPlaneNormal: Vector3;
  102176. dragDistance: number;
  102177. pointerId: number;
  102178. }>;
  102179. /**
  102180. * Fires each time a drag begins (eg. mouse down on mesh)
  102181. */
  102182. onDragStartObservable: Observable<{
  102183. dragPlanePoint: Vector3;
  102184. pointerId: number;
  102185. }>;
  102186. /**
  102187. * Fires each time a drag ends (eg. mouse release after drag)
  102188. */
  102189. onDragEndObservable: Observable<{
  102190. dragPlanePoint: Vector3;
  102191. pointerId: number;
  102192. }>;
  102193. /**
  102194. * If the attached mesh should be moved when dragged
  102195. */
  102196. moveAttached: boolean;
  102197. /**
  102198. * If the drag behavior will react to drag events (Default: true)
  102199. */
  102200. enabled: boolean;
  102201. /**
  102202. * If pointer events should start and release the drag (Default: true)
  102203. */
  102204. startAndReleaseDragOnPointerEvents: boolean;
  102205. /**
  102206. * If camera controls should be detached during the drag
  102207. */
  102208. detachCameraControls: boolean;
  102209. /**
  102210. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  102211. */
  102212. useObjectOrienationForDragging: boolean;
  102213. private _options;
  102214. /**
  102215. * Creates a pointer drag behavior that can be attached to a mesh
  102216. * @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)
  102217. */
  102218. constructor(options?: {
  102219. dragAxis?: Vector3;
  102220. dragPlaneNormal?: Vector3;
  102221. });
  102222. /**
  102223. * Predicate to determine if it is valid to move the object to a new position when it is moved
  102224. */
  102225. validateDrag: (targetPosition: Vector3) => boolean;
  102226. /**
  102227. * The name of the behavior
  102228. */
  102229. readonly name: string;
  102230. /**
  102231. * Initializes the behavior
  102232. */
  102233. init(): void;
  102234. private _tmpVector;
  102235. private _alternatePickedPoint;
  102236. private _worldDragAxis;
  102237. private _targetPosition;
  102238. private _attachedElement;
  102239. /**
  102240. * Attaches the drag behavior the passed in mesh
  102241. * @param ownerNode The mesh that will be dragged around once attached
  102242. */
  102243. attach(ownerNode: AbstractMesh): void;
  102244. /**
  102245. * Force relase the drag action by code.
  102246. */
  102247. releaseDrag(): void;
  102248. private _startDragRay;
  102249. private _lastPointerRay;
  102250. /**
  102251. * Simulates the start of a pointer drag event on the behavior
  102252. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  102253. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  102254. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  102255. */
  102256. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  102257. private _startDrag;
  102258. private _dragDelta;
  102259. private _moveDrag;
  102260. private _pickWithRayOnDragPlane;
  102261. private _pointA;
  102262. private _pointB;
  102263. private _pointC;
  102264. private _lineA;
  102265. private _lineB;
  102266. private _localAxis;
  102267. private _lookAt;
  102268. private _updateDragPlanePosition;
  102269. /**
  102270. * Detaches the behavior from the mesh
  102271. */
  102272. detach(): void;
  102273. }
  102274. }
  102275. declare module BABYLON {
  102276. /**
  102277. * A behavior that when attached to a mesh will allow the mesh to be scaled
  102278. */
  102279. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  102280. private _dragBehaviorA;
  102281. private _dragBehaviorB;
  102282. private _startDistance;
  102283. private _initialScale;
  102284. private _targetScale;
  102285. private _ownerNode;
  102286. private _sceneRenderObserver;
  102287. /**
  102288. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  102289. */
  102290. constructor();
  102291. /**
  102292. * The name of the behavior
  102293. */
  102294. readonly name: string;
  102295. /**
  102296. * Initializes the behavior
  102297. */
  102298. init(): void;
  102299. private _getCurrentDistance;
  102300. /**
  102301. * Attaches the scale behavior the passed in mesh
  102302. * @param ownerNode The mesh that will be scaled around once attached
  102303. */
  102304. attach(ownerNode: Mesh): void;
  102305. /**
  102306. * Detaches the behavior from the mesh
  102307. */
  102308. detach(): void;
  102309. }
  102310. }
  102311. declare module BABYLON {
  102312. /**
  102313. * 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
  102314. */
  102315. export class SixDofDragBehavior implements Behavior<Mesh> {
  102316. private static _virtualScene;
  102317. private _ownerNode;
  102318. private _sceneRenderObserver;
  102319. private _scene;
  102320. private _targetPosition;
  102321. private _virtualOriginMesh;
  102322. private _virtualDragMesh;
  102323. private _pointerObserver;
  102324. private _moving;
  102325. private _startingOrientation;
  102326. /**
  102327. * 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)
  102328. */
  102329. private zDragFactor;
  102330. /**
  102331. * If the object should rotate to face the drag origin
  102332. */
  102333. rotateDraggedObject: boolean;
  102334. /**
  102335. * If the behavior is currently in a dragging state
  102336. */
  102337. dragging: boolean;
  102338. /**
  102339. * 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)
  102340. */
  102341. dragDeltaRatio: number;
  102342. /**
  102343. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  102344. */
  102345. currentDraggingPointerID: number;
  102346. /**
  102347. * If camera controls should be detached during the drag
  102348. */
  102349. detachCameraControls: boolean;
  102350. /**
  102351. * Fires each time a drag starts
  102352. */
  102353. onDragStartObservable: Observable<{}>;
  102354. /**
  102355. * Fires each time a drag ends (eg. mouse release after drag)
  102356. */
  102357. onDragEndObservable: Observable<{}>;
  102358. /**
  102359. * 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
  102360. */
  102361. constructor();
  102362. /**
  102363. * The name of the behavior
  102364. */
  102365. readonly name: string;
  102366. /**
  102367. * Initializes the behavior
  102368. */
  102369. init(): void;
  102370. /**
  102371. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  102372. */
  102373. private readonly _pointerCamera;
  102374. /**
  102375. * Attaches the scale behavior the passed in mesh
  102376. * @param ownerNode The mesh that will be scaled around once attached
  102377. */
  102378. attach(ownerNode: Mesh): void;
  102379. /**
  102380. * Detaches the behavior from the mesh
  102381. */
  102382. detach(): void;
  102383. }
  102384. }
  102385. declare module BABYLON {
  102386. /**
  102387. * Class used to apply inverse kinematics to bones
  102388. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  102389. */
  102390. export class BoneIKController {
  102391. private static _tmpVecs;
  102392. private static _tmpQuat;
  102393. private static _tmpMats;
  102394. /**
  102395. * Gets or sets the target mesh
  102396. */
  102397. targetMesh: AbstractMesh;
  102398. /** Gets or sets the mesh used as pole */
  102399. poleTargetMesh: AbstractMesh;
  102400. /**
  102401. * Gets or sets the bone used as pole
  102402. */
  102403. poleTargetBone: Nullable<Bone>;
  102404. /**
  102405. * Gets or sets the target position
  102406. */
  102407. targetPosition: Vector3;
  102408. /**
  102409. * Gets or sets the pole target position
  102410. */
  102411. poleTargetPosition: Vector3;
  102412. /**
  102413. * Gets or sets the pole target local offset
  102414. */
  102415. poleTargetLocalOffset: Vector3;
  102416. /**
  102417. * Gets or sets the pole angle
  102418. */
  102419. poleAngle: number;
  102420. /**
  102421. * Gets or sets the mesh associated with the controller
  102422. */
  102423. mesh: AbstractMesh;
  102424. /**
  102425. * 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)
  102426. */
  102427. slerpAmount: number;
  102428. private _bone1Quat;
  102429. private _bone1Mat;
  102430. private _bone2Ang;
  102431. private _bone1;
  102432. private _bone2;
  102433. private _bone1Length;
  102434. private _bone2Length;
  102435. private _maxAngle;
  102436. private _maxReach;
  102437. private _rightHandedSystem;
  102438. private _bendAxis;
  102439. private _slerping;
  102440. private _adjustRoll;
  102441. /**
  102442. * Gets or sets maximum allowed angle
  102443. */
  102444. maxAngle: number;
  102445. /**
  102446. * Creates a new BoneIKController
  102447. * @param mesh defines the mesh to control
  102448. * @param bone defines the bone to control
  102449. * @param options defines options to set up the controller
  102450. */
  102451. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  102452. targetMesh?: AbstractMesh;
  102453. poleTargetMesh?: AbstractMesh;
  102454. poleTargetBone?: Bone;
  102455. poleTargetLocalOffset?: Vector3;
  102456. poleAngle?: number;
  102457. bendAxis?: Vector3;
  102458. maxAngle?: number;
  102459. slerpAmount?: number;
  102460. });
  102461. private _setMaxAngle;
  102462. /**
  102463. * Force the controller to update the bones
  102464. */
  102465. update(): void;
  102466. }
  102467. }
  102468. declare module BABYLON {
  102469. /**
  102470. * Class used to make a bone look toward a point in space
  102471. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  102472. */
  102473. export class BoneLookController {
  102474. private static _tmpVecs;
  102475. private static _tmpQuat;
  102476. private static _tmpMats;
  102477. /**
  102478. * The target Vector3 that the bone will look at
  102479. */
  102480. target: Vector3;
  102481. /**
  102482. * The mesh that the bone is attached to
  102483. */
  102484. mesh: AbstractMesh;
  102485. /**
  102486. * The bone that will be looking to the target
  102487. */
  102488. bone: Bone;
  102489. /**
  102490. * The up axis of the coordinate system that is used when the bone is rotated
  102491. */
  102492. upAxis: Vector3;
  102493. /**
  102494. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  102495. */
  102496. upAxisSpace: Space;
  102497. /**
  102498. * Used to make an adjustment to the yaw of the bone
  102499. */
  102500. adjustYaw: number;
  102501. /**
  102502. * Used to make an adjustment to the pitch of the bone
  102503. */
  102504. adjustPitch: number;
  102505. /**
  102506. * Used to make an adjustment to the roll of the bone
  102507. */
  102508. adjustRoll: number;
  102509. /**
  102510. * 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)
  102511. */
  102512. slerpAmount: number;
  102513. private _minYaw;
  102514. private _maxYaw;
  102515. private _minPitch;
  102516. private _maxPitch;
  102517. private _minYawSin;
  102518. private _minYawCos;
  102519. private _maxYawSin;
  102520. private _maxYawCos;
  102521. private _midYawConstraint;
  102522. private _minPitchTan;
  102523. private _maxPitchTan;
  102524. private _boneQuat;
  102525. private _slerping;
  102526. private _transformYawPitch;
  102527. private _transformYawPitchInv;
  102528. private _firstFrameSkipped;
  102529. private _yawRange;
  102530. private _fowardAxis;
  102531. /**
  102532. * Gets or sets the minimum yaw angle that the bone can look to
  102533. */
  102534. minYaw: number;
  102535. /**
  102536. * Gets or sets the maximum yaw angle that the bone can look to
  102537. */
  102538. maxYaw: number;
  102539. /**
  102540. * Gets or sets the minimum pitch angle that the bone can look to
  102541. */
  102542. minPitch: number;
  102543. /**
  102544. * Gets or sets the maximum pitch angle that the bone can look to
  102545. */
  102546. maxPitch: number;
  102547. /**
  102548. * Create a BoneLookController
  102549. * @param mesh the mesh that the bone belongs to
  102550. * @param bone the bone that will be looking to the target
  102551. * @param target the target Vector3 to look at
  102552. * @param options optional settings:
  102553. * * maxYaw: the maximum angle the bone will yaw to
  102554. * * minYaw: the minimum angle the bone will yaw to
  102555. * * maxPitch: the maximum angle the bone will pitch to
  102556. * * minPitch: the minimum angle the bone will yaw to
  102557. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  102558. * * upAxis: the up axis of the coordinate system
  102559. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  102560. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  102561. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  102562. * * adjustYaw: used to make an adjustment to the yaw of the bone
  102563. * * adjustPitch: used to make an adjustment to the pitch of the bone
  102564. * * adjustRoll: used to make an adjustment to the roll of the bone
  102565. **/
  102566. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  102567. maxYaw?: number;
  102568. minYaw?: number;
  102569. maxPitch?: number;
  102570. minPitch?: number;
  102571. slerpAmount?: number;
  102572. upAxis?: Vector3;
  102573. upAxisSpace?: Space;
  102574. yawAxis?: Vector3;
  102575. pitchAxis?: Vector3;
  102576. adjustYaw?: number;
  102577. adjustPitch?: number;
  102578. adjustRoll?: number;
  102579. });
  102580. /**
  102581. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  102582. */
  102583. update(): void;
  102584. private _getAngleDiff;
  102585. private _getAngleBetween;
  102586. private _isAngleBetween;
  102587. }
  102588. }
  102589. declare module BABYLON {
  102590. /**
  102591. * Manage the gamepad inputs to control an arc rotate camera.
  102592. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  102593. */
  102594. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  102595. /**
  102596. * Defines the camera the input is attached to.
  102597. */
  102598. camera: ArcRotateCamera;
  102599. /**
  102600. * Defines the gamepad the input is gathering event from.
  102601. */
  102602. gamepad: Nullable<Gamepad>;
  102603. /**
  102604. * Defines the gamepad rotation sensiblity.
  102605. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  102606. */
  102607. gamepadRotationSensibility: number;
  102608. /**
  102609. * Defines the gamepad move sensiblity.
  102610. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  102611. */
  102612. gamepadMoveSensibility: number;
  102613. private _onGamepadConnectedObserver;
  102614. private _onGamepadDisconnectedObserver;
  102615. /**
  102616. * Attach the input controls to a specific dom element to get the input from.
  102617. * @param element Defines the element the controls should be listened from
  102618. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  102619. */
  102620. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  102621. /**
  102622. * Detach the current controls from the specified dom element.
  102623. * @param element Defines the element to stop listening the inputs from
  102624. */
  102625. detachControl(element: Nullable<HTMLElement>): void;
  102626. /**
  102627. * Update the current camera state depending on the inputs that have been used this frame.
  102628. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  102629. */
  102630. checkInputs(): void;
  102631. /**
  102632. * Gets the class name of the current intput.
  102633. * @returns the class name
  102634. */
  102635. getClassName(): string;
  102636. /**
  102637. * Get the friendly name associated with the input class.
  102638. * @returns the input friendly name
  102639. */
  102640. getSimpleName(): string;
  102641. }
  102642. }
  102643. declare module BABYLON {
  102644. interface ArcRotateCameraInputsManager {
  102645. /**
  102646. * Add orientation input support to the input manager.
  102647. * @returns the current input manager
  102648. */
  102649. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  102650. }
  102651. /**
  102652. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  102653. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  102654. */
  102655. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  102656. /**
  102657. * Defines the camera the input is attached to.
  102658. */
  102659. camera: ArcRotateCamera;
  102660. /**
  102661. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  102662. */
  102663. alphaCorrection: number;
  102664. /**
  102665. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  102666. */
  102667. gammaCorrection: number;
  102668. private _alpha;
  102669. private _gamma;
  102670. private _dirty;
  102671. private _deviceOrientationHandler;
  102672. /**
  102673. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  102674. */
  102675. constructor();
  102676. /**
  102677. * Attach the input controls to a specific dom element to get the input from.
  102678. * @param element Defines the element the controls should be listened from
  102679. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  102680. */
  102681. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  102682. /** @hidden */
  102683. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  102684. /**
  102685. * Update the current camera state depending on the inputs that have been used this frame.
  102686. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  102687. */
  102688. checkInputs(): void;
  102689. /**
  102690. * Detach the current controls from the specified dom element.
  102691. * @param element Defines the element to stop listening the inputs from
  102692. */
  102693. detachControl(element: Nullable<HTMLElement>): void;
  102694. /**
  102695. * Gets the class name of the current intput.
  102696. * @returns the class name
  102697. */
  102698. getClassName(): string;
  102699. /**
  102700. * Get the friendly name associated with the input class.
  102701. * @returns the input friendly name
  102702. */
  102703. getSimpleName(): string;
  102704. }
  102705. }
  102706. declare module BABYLON {
  102707. /**
  102708. * Listen to mouse events to control the camera.
  102709. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  102710. */
  102711. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  102712. /**
  102713. * Defines the camera the input is attached to.
  102714. */
  102715. camera: FlyCamera;
  102716. /**
  102717. * Defines if touch is enabled. (Default is true.)
  102718. */
  102719. touchEnabled: boolean;
  102720. /**
  102721. * Defines the buttons associated with the input to handle camera rotation.
  102722. */
  102723. buttons: number[];
  102724. /**
  102725. * Assign buttons for Yaw control.
  102726. */
  102727. buttonsYaw: number[];
  102728. /**
  102729. * Assign buttons for Pitch control.
  102730. */
  102731. buttonsPitch: number[];
  102732. /**
  102733. * Assign buttons for Roll control.
  102734. */
  102735. buttonsRoll: number[];
  102736. /**
  102737. * Detect if any button is being pressed while mouse is moved.
  102738. * -1 = Mouse locked.
  102739. * 0 = Left button.
  102740. * 1 = Middle Button.
  102741. * 2 = Right Button.
  102742. */
  102743. activeButton: number;
  102744. /**
  102745. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  102746. * Higher values reduce its sensitivity.
  102747. */
  102748. angularSensibility: number;
  102749. private _mousemoveCallback;
  102750. private _observer;
  102751. private _rollObserver;
  102752. private previousPosition;
  102753. private noPreventDefault;
  102754. private element;
  102755. /**
  102756. * Listen to mouse events to control the camera.
  102757. * @param touchEnabled Define if touch is enabled. (Default is true.)
  102758. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  102759. */
  102760. constructor(touchEnabled?: boolean);
  102761. /**
  102762. * Attach the mouse control to the HTML DOM element.
  102763. * @param element Defines the element that listens to the input events.
  102764. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  102765. */
  102766. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  102767. /**
  102768. * Detach the current controls from the specified dom element.
  102769. * @param element Defines the element to stop listening the inputs from
  102770. */
  102771. detachControl(element: Nullable<HTMLElement>): void;
  102772. /**
  102773. * Gets the class name of the current input.
  102774. * @returns the class name.
  102775. */
  102776. getClassName(): string;
  102777. /**
  102778. * Get the friendly name associated with the input class.
  102779. * @returns the input's friendly name.
  102780. */
  102781. getSimpleName(): string;
  102782. private _pointerInput;
  102783. private _onMouseMove;
  102784. /**
  102785. * Rotate camera by mouse offset.
  102786. */
  102787. private rotateCamera;
  102788. }
  102789. }
  102790. declare module BABYLON {
  102791. /**
  102792. * Default Inputs manager for the FlyCamera.
  102793. * It groups all the default supported inputs for ease of use.
  102794. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  102795. */
  102796. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  102797. /**
  102798. * Instantiates a new FlyCameraInputsManager.
  102799. * @param camera Defines the camera the inputs belong to.
  102800. */
  102801. constructor(camera: FlyCamera);
  102802. /**
  102803. * Add keyboard input support to the input manager.
  102804. * @returns the new FlyCameraKeyboardMoveInput().
  102805. */
  102806. addKeyboard(): FlyCameraInputsManager;
  102807. /**
  102808. * Add mouse input support to the input manager.
  102809. * @param touchEnabled Enable touch screen support.
  102810. * @returns the new FlyCameraMouseInput().
  102811. */
  102812. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  102813. }
  102814. }
  102815. declare module BABYLON {
  102816. /**
  102817. * This is a flying camera, designed for 3D movement and rotation in all directions,
  102818. * such as in a 3D Space Shooter or a Flight Simulator.
  102819. */
  102820. export class FlyCamera extends TargetCamera {
  102821. /**
  102822. * Define the collision ellipsoid of the camera.
  102823. * This is helpful for simulating a camera body, like a player's body.
  102824. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  102825. */
  102826. ellipsoid: Vector3;
  102827. /**
  102828. * Define an offset for the position of the ellipsoid around the camera.
  102829. * This can be helpful if the camera is attached away from the player's body center,
  102830. * such as at its head.
  102831. */
  102832. ellipsoidOffset: Vector3;
  102833. /**
  102834. * Enable or disable collisions of the camera with the rest of the scene objects.
  102835. */
  102836. checkCollisions: boolean;
  102837. /**
  102838. * Enable or disable gravity on the camera.
  102839. */
  102840. applyGravity: boolean;
  102841. /**
  102842. * Define the current direction the camera is moving to.
  102843. */
  102844. cameraDirection: Vector3;
  102845. /**
  102846. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  102847. * This overrides and empties cameraRotation.
  102848. */
  102849. rotationQuaternion: Quaternion;
  102850. /**
  102851. * Track Roll to maintain the wanted Rolling when looking around.
  102852. */
  102853. _trackRoll: number;
  102854. /**
  102855. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  102856. */
  102857. rollCorrect: number;
  102858. /**
  102859. * Mimic a banked turn, Rolling the camera when Yawing.
  102860. * It's recommended to use rollCorrect = 10 for faster banking correction.
  102861. */
  102862. bankedTurn: boolean;
  102863. /**
  102864. * Limit in radians for how much Roll banking will add. (Default: 90°)
  102865. */
  102866. bankedTurnLimit: number;
  102867. /**
  102868. * Value of 0 disables the banked Roll.
  102869. * Value of 1 is equal to the Yaw angle in radians.
  102870. */
  102871. bankedTurnMultiplier: number;
  102872. /**
  102873. * The inputs manager loads all the input sources, such as keyboard and mouse.
  102874. */
  102875. inputs: FlyCameraInputsManager;
  102876. /**
  102877. * Gets the input sensibility for mouse input.
  102878. * Higher values reduce sensitivity.
  102879. */
  102880. /**
  102881. * Sets the input sensibility for a mouse input.
  102882. * Higher values reduce sensitivity.
  102883. */
  102884. angularSensibility: number;
  102885. /**
  102886. * Get the keys for camera movement forward.
  102887. */
  102888. /**
  102889. * Set the keys for camera movement forward.
  102890. */
  102891. keysForward: number[];
  102892. /**
  102893. * Get the keys for camera movement backward.
  102894. */
  102895. keysBackward: number[];
  102896. /**
  102897. * Get the keys for camera movement up.
  102898. */
  102899. /**
  102900. * Set the keys for camera movement up.
  102901. */
  102902. keysUp: number[];
  102903. /**
  102904. * Get the keys for camera movement down.
  102905. */
  102906. /**
  102907. * Set the keys for camera movement down.
  102908. */
  102909. keysDown: number[];
  102910. /**
  102911. * Get the keys for camera movement left.
  102912. */
  102913. /**
  102914. * Set the keys for camera movement left.
  102915. */
  102916. keysLeft: number[];
  102917. /**
  102918. * Set the keys for camera movement right.
  102919. */
  102920. /**
  102921. * Set the keys for camera movement right.
  102922. */
  102923. keysRight: number[];
  102924. /**
  102925. * Event raised when the camera collides with a mesh in the scene.
  102926. */
  102927. onCollide: (collidedMesh: AbstractMesh) => void;
  102928. private _collider;
  102929. private _needMoveForGravity;
  102930. private _oldPosition;
  102931. private _diffPosition;
  102932. private _newPosition;
  102933. /** @hidden */
  102934. _localDirection: Vector3;
  102935. /** @hidden */
  102936. _transformedDirection: Vector3;
  102937. /**
  102938. * Instantiates a FlyCamera.
  102939. * This is a flying camera, designed for 3D movement and rotation in all directions,
  102940. * such as in a 3D Space Shooter or a Flight Simulator.
  102941. * @param name Define the name of the camera in the scene.
  102942. * @param position Define the starting position of the camera in the scene.
  102943. * @param scene Define the scene the camera belongs to.
  102944. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  102945. */
  102946. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  102947. /**
  102948. * Attach a control to the HTML DOM element.
  102949. * @param element Defines the element that listens to the input events.
  102950. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  102951. */
  102952. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  102953. /**
  102954. * Detach a control from the HTML DOM element.
  102955. * The camera will stop reacting to that input.
  102956. * @param element Defines the element that listens to the input events.
  102957. */
  102958. detachControl(element: HTMLElement): void;
  102959. private _collisionMask;
  102960. /**
  102961. * Get the mask that the camera ignores in collision events.
  102962. */
  102963. /**
  102964. * Set the mask that the camera ignores in collision events.
  102965. */
  102966. collisionMask: number;
  102967. /** @hidden */
  102968. _collideWithWorld(displacement: Vector3): void;
  102969. /** @hidden */
  102970. private _onCollisionPositionChange;
  102971. /** @hidden */
  102972. _checkInputs(): void;
  102973. /** @hidden */
  102974. _decideIfNeedsToMove(): boolean;
  102975. /** @hidden */
  102976. _updatePosition(): void;
  102977. /**
  102978. * Restore the Roll to its target value at the rate specified.
  102979. * @param rate - Higher means slower restoring.
  102980. * @hidden
  102981. */
  102982. restoreRoll(rate: number): void;
  102983. /**
  102984. * Destroy the camera and release the current resources held by it.
  102985. */
  102986. dispose(): void;
  102987. /**
  102988. * Get the current object class name.
  102989. * @returns the class name.
  102990. */
  102991. getClassName(): string;
  102992. }
  102993. }
  102994. declare module BABYLON {
  102995. /**
  102996. * Listen to keyboard events to control the camera.
  102997. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  102998. */
  102999. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  103000. /**
  103001. * Defines the camera the input is attached to.
  103002. */
  103003. camera: FlyCamera;
  103004. /**
  103005. * The list of keyboard keys used to control the forward move of the camera.
  103006. */
  103007. keysForward: number[];
  103008. /**
  103009. * The list of keyboard keys used to control the backward move of the camera.
  103010. */
  103011. keysBackward: number[];
  103012. /**
  103013. * The list of keyboard keys used to control the forward move of the camera.
  103014. */
  103015. keysUp: number[];
  103016. /**
  103017. * The list of keyboard keys used to control the backward move of the camera.
  103018. */
  103019. keysDown: number[];
  103020. /**
  103021. * The list of keyboard keys used to control the right strafe move of the camera.
  103022. */
  103023. keysRight: number[];
  103024. /**
  103025. * The list of keyboard keys used to control the left strafe move of the camera.
  103026. */
  103027. keysLeft: number[];
  103028. private _keys;
  103029. private _onCanvasBlurObserver;
  103030. private _onKeyboardObserver;
  103031. private _engine;
  103032. private _scene;
  103033. /**
  103034. * Attach the input controls to a specific dom element to get the input from.
  103035. * @param element Defines the element the controls should be listened from
  103036. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  103037. */
  103038. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  103039. /**
  103040. * Detach the current controls from the specified dom element.
  103041. * @param element Defines the element to stop listening the inputs from
  103042. */
  103043. detachControl(element: Nullable<HTMLElement>): void;
  103044. /**
  103045. * Gets the class name of the current intput.
  103046. * @returns the class name
  103047. */
  103048. getClassName(): string;
  103049. /** @hidden */
  103050. _onLostFocus(e: FocusEvent): void;
  103051. /**
  103052. * Get the friendly name associated with the input class.
  103053. * @returns the input friendly name
  103054. */
  103055. getSimpleName(): string;
  103056. /**
  103057. * Update the current camera state depending on the inputs that have been used this frame.
  103058. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  103059. */
  103060. checkInputs(): void;
  103061. }
  103062. }
  103063. declare module BABYLON {
  103064. /**
  103065. * Manage the mouse wheel inputs to control a follow camera.
  103066. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  103067. */
  103068. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  103069. /**
  103070. * Defines the camera the input is attached to.
  103071. */
  103072. camera: FollowCamera;
  103073. /**
  103074. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  103075. */
  103076. axisControlRadius: boolean;
  103077. /**
  103078. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  103079. */
  103080. axisControlHeight: boolean;
  103081. /**
  103082. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  103083. */
  103084. axisControlRotation: boolean;
  103085. /**
  103086. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  103087. * relation to mouseWheel events.
  103088. */
  103089. wheelPrecision: number;
  103090. /**
  103091. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  103092. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  103093. */
  103094. wheelDeltaPercentage: number;
  103095. private _wheel;
  103096. private _observer;
  103097. /**
  103098. * Attach the input controls to a specific dom element to get the input from.
  103099. * @param element Defines the element the controls should be listened from
  103100. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  103101. */
  103102. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  103103. /**
  103104. * Detach the current controls from the specified dom element.
  103105. * @param element Defines the element to stop listening the inputs from
  103106. */
  103107. detachControl(element: Nullable<HTMLElement>): void;
  103108. /**
  103109. * Gets the class name of the current intput.
  103110. * @returns the class name
  103111. */
  103112. getClassName(): string;
  103113. /**
  103114. * Get the friendly name associated with the input class.
  103115. * @returns the input friendly name
  103116. */
  103117. getSimpleName(): string;
  103118. }
  103119. }
  103120. declare module BABYLON {
  103121. /**
  103122. * Manage the pointers inputs to control an follow camera.
  103123. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  103124. */
  103125. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  103126. /**
  103127. * Defines the camera the input is attached to.
  103128. */
  103129. camera: FollowCamera;
  103130. /**
  103131. * Gets the class name of the current input.
  103132. * @returns the class name
  103133. */
  103134. getClassName(): string;
  103135. /**
  103136. * Defines the pointer angular sensibility along the X axis or how fast is
  103137. * the camera rotating.
  103138. * A negative number will reverse the axis direction.
  103139. */
  103140. angularSensibilityX: number;
  103141. /**
  103142. * Defines the pointer angular sensibility along the Y axis or how fast is
  103143. * the camera rotating.
  103144. * A negative number will reverse the axis direction.
  103145. */
  103146. angularSensibilityY: number;
  103147. /**
  103148. * Defines the pointer pinch precision or how fast is the camera zooming.
  103149. * A negative number will reverse the axis direction.
  103150. */
  103151. pinchPrecision: number;
  103152. /**
  103153. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  103154. * from 0.
  103155. * It defines the percentage of current camera.radius to use as delta when
  103156. * pinch zoom is used.
  103157. */
  103158. pinchDeltaPercentage: number;
  103159. /**
  103160. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  103161. */
  103162. axisXControlRadius: boolean;
  103163. /**
  103164. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  103165. */
  103166. axisXControlHeight: boolean;
  103167. /**
  103168. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  103169. */
  103170. axisXControlRotation: boolean;
  103171. /**
  103172. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  103173. */
  103174. axisYControlRadius: boolean;
  103175. /**
  103176. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  103177. */
  103178. axisYControlHeight: boolean;
  103179. /**
  103180. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  103181. */
  103182. axisYControlRotation: boolean;
  103183. /**
  103184. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  103185. */
  103186. axisPinchControlRadius: boolean;
  103187. /**
  103188. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  103189. */
  103190. axisPinchControlHeight: boolean;
  103191. /**
  103192. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  103193. */
  103194. axisPinchControlRotation: boolean;
  103195. /**
  103196. * Log error messages if basic misconfiguration has occurred.
  103197. */
  103198. warningEnable: boolean;
  103199. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  103200. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  103201. private _warningCounter;
  103202. private _warning;
  103203. }
  103204. }
  103205. declare module BABYLON {
  103206. /**
  103207. * Default Inputs manager for the FollowCamera.
  103208. * It groups all the default supported inputs for ease of use.
  103209. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  103210. */
  103211. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  103212. /**
  103213. * Instantiates a new FollowCameraInputsManager.
  103214. * @param camera Defines the camera the inputs belong to
  103215. */
  103216. constructor(camera: FollowCamera);
  103217. /**
  103218. * Add keyboard input support to the input manager.
  103219. * @returns the current input manager
  103220. */
  103221. addKeyboard(): FollowCameraInputsManager;
  103222. /**
  103223. * Add mouse wheel input support to the input manager.
  103224. * @returns the current input manager
  103225. */
  103226. addMouseWheel(): FollowCameraInputsManager;
  103227. /**
  103228. * Add pointers input support to the input manager.
  103229. * @returns the current input manager
  103230. */
  103231. addPointers(): FollowCameraInputsManager;
  103232. /**
  103233. * Add orientation input support to the input manager.
  103234. * @returns the current input manager
  103235. */
  103236. addVRDeviceOrientation(): FollowCameraInputsManager;
  103237. }
  103238. }
  103239. declare module BABYLON {
  103240. /**
  103241. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  103242. * an arc rotate version arcFollowCamera are available.
  103243. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  103244. */
  103245. export class FollowCamera extends TargetCamera {
  103246. /**
  103247. * Distance the follow camera should follow an object at
  103248. */
  103249. radius: number;
  103250. /**
  103251. * Minimum allowed distance of the camera to the axis of rotation
  103252. * (The camera can not get closer).
  103253. * This can help limiting how the Camera is able to move in the scene.
  103254. */
  103255. lowerRadiusLimit: Nullable<number>;
  103256. /**
  103257. * Maximum allowed distance of the camera to the axis of rotation
  103258. * (The camera can not get further).
  103259. * This can help limiting how the Camera is able to move in the scene.
  103260. */
  103261. upperRadiusLimit: Nullable<number>;
  103262. /**
  103263. * Define a rotation offset between the camera and the object it follows
  103264. */
  103265. rotationOffset: number;
  103266. /**
  103267. * Minimum allowed angle to camera position relative to target object.
  103268. * This can help limiting how the Camera is able to move in the scene.
  103269. */
  103270. lowerRotationOffsetLimit: Nullable<number>;
  103271. /**
  103272. * Maximum allowed angle to camera position relative to target object.
  103273. * This can help limiting how the Camera is able to move in the scene.
  103274. */
  103275. upperRotationOffsetLimit: Nullable<number>;
  103276. /**
  103277. * Define a height offset between the camera and the object it follows.
  103278. * It can help following an object from the top (like a car chaing a plane)
  103279. */
  103280. heightOffset: number;
  103281. /**
  103282. * Minimum allowed height of camera position relative to target object.
  103283. * This can help limiting how the Camera is able to move in the scene.
  103284. */
  103285. lowerHeightOffsetLimit: Nullable<number>;
  103286. /**
  103287. * Maximum allowed height of camera position relative to target object.
  103288. * This can help limiting how the Camera is able to move in the scene.
  103289. */
  103290. upperHeightOffsetLimit: Nullable<number>;
  103291. /**
  103292. * Define how fast the camera can accelerate to follow it s target.
  103293. */
  103294. cameraAcceleration: number;
  103295. /**
  103296. * Define the speed limit of the camera following an object.
  103297. */
  103298. maxCameraSpeed: number;
  103299. /**
  103300. * Define the target of the camera.
  103301. */
  103302. lockedTarget: Nullable<AbstractMesh>;
  103303. /**
  103304. * Defines the input associated with the camera.
  103305. */
  103306. inputs: FollowCameraInputsManager;
  103307. /**
  103308. * Instantiates the follow camera.
  103309. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  103310. * @param name Define the name of the camera in the scene
  103311. * @param position Define the position of the camera
  103312. * @param scene Define the scene the camera belong to
  103313. * @param lockedTarget Define the target of the camera
  103314. */
  103315. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  103316. private _follow;
  103317. /**
  103318. * Attached controls to the current camera.
  103319. * @param element Defines the element the controls should be listened from
  103320. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  103321. */
  103322. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  103323. /**
  103324. * Detach the current controls from the camera.
  103325. * The camera will stop reacting to inputs.
  103326. * @param element Defines the element to stop listening the inputs from
  103327. */
  103328. detachControl(element: HTMLElement): void;
  103329. /** @hidden */
  103330. _checkInputs(): void;
  103331. private _checkLimits;
  103332. /**
  103333. * Gets the camera class name.
  103334. * @returns the class name
  103335. */
  103336. getClassName(): string;
  103337. }
  103338. /**
  103339. * Arc Rotate version of the follow camera.
  103340. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  103341. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  103342. */
  103343. export class ArcFollowCamera extends TargetCamera {
  103344. /** The longitudinal angle of the camera */
  103345. alpha: number;
  103346. /** The latitudinal angle of the camera */
  103347. beta: number;
  103348. /** The radius of the camera from its target */
  103349. radius: number;
  103350. /** Define the camera target (the messh it should follow) */
  103351. target: Nullable<AbstractMesh>;
  103352. private _cartesianCoordinates;
  103353. /**
  103354. * Instantiates a new ArcFollowCamera
  103355. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  103356. * @param name Define the name of the camera
  103357. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  103358. * @param beta Define the rotation angle of the camera around the elevation axis
  103359. * @param radius Define the radius of the camera from its target point
  103360. * @param target Define the target of the camera
  103361. * @param scene Define the scene the camera belongs to
  103362. */
  103363. constructor(name: string,
  103364. /** The longitudinal angle of the camera */
  103365. alpha: number,
  103366. /** The latitudinal angle of the camera */
  103367. beta: number,
  103368. /** The radius of the camera from its target */
  103369. radius: number,
  103370. /** Define the camera target (the messh it should follow) */
  103371. target: Nullable<AbstractMesh>, scene: Scene);
  103372. private _follow;
  103373. /** @hidden */
  103374. _checkInputs(): void;
  103375. /**
  103376. * Returns the class name of the object.
  103377. * It is mostly used internally for serialization purposes.
  103378. */
  103379. getClassName(): string;
  103380. }
  103381. }
  103382. declare module BABYLON {
  103383. /**
  103384. * Manage the keyboard inputs to control the movement of a follow camera.
  103385. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  103386. */
  103387. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  103388. /**
  103389. * Defines the camera the input is attached to.
  103390. */
  103391. camera: FollowCamera;
  103392. /**
  103393. * Defines the list of key codes associated with the up action (increase heightOffset)
  103394. */
  103395. keysHeightOffsetIncr: number[];
  103396. /**
  103397. * Defines the list of key codes associated with the down action (decrease heightOffset)
  103398. */
  103399. keysHeightOffsetDecr: number[];
  103400. /**
  103401. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  103402. */
  103403. keysHeightOffsetModifierAlt: boolean;
  103404. /**
  103405. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  103406. */
  103407. keysHeightOffsetModifierCtrl: boolean;
  103408. /**
  103409. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  103410. */
  103411. keysHeightOffsetModifierShift: boolean;
  103412. /**
  103413. * Defines the list of key codes associated with the left action (increase rotationOffset)
  103414. */
  103415. keysRotationOffsetIncr: number[];
  103416. /**
  103417. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  103418. */
  103419. keysRotationOffsetDecr: number[];
  103420. /**
  103421. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  103422. */
  103423. keysRotationOffsetModifierAlt: boolean;
  103424. /**
  103425. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  103426. */
  103427. keysRotationOffsetModifierCtrl: boolean;
  103428. /**
  103429. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  103430. */
  103431. keysRotationOffsetModifierShift: boolean;
  103432. /**
  103433. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  103434. */
  103435. keysRadiusIncr: number[];
  103436. /**
  103437. * Defines the list of key codes associated with the zoom-out action (increase radius)
  103438. */
  103439. keysRadiusDecr: number[];
  103440. /**
  103441. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  103442. */
  103443. keysRadiusModifierAlt: boolean;
  103444. /**
  103445. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  103446. */
  103447. keysRadiusModifierCtrl: boolean;
  103448. /**
  103449. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  103450. */
  103451. keysRadiusModifierShift: boolean;
  103452. /**
  103453. * Defines the rate of change of heightOffset.
  103454. */
  103455. heightSensibility: number;
  103456. /**
  103457. * Defines the rate of change of rotationOffset.
  103458. */
  103459. rotationSensibility: number;
  103460. /**
  103461. * Defines the rate of change of radius.
  103462. */
  103463. radiusSensibility: number;
  103464. private _keys;
  103465. private _ctrlPressed;
  103466. private _altPressed;
  103467. private _shiftPressed;
  103468. private _onCanvasBlurObserver;
  103469. private _onKeyboardObserver;
  103470. private _engine;
  103471. private _scene;
  103472. /**
  103473. * Attach the input controls to a specific dom element to get the input from.
  103474. * @param element Defines the element the controls should be listened from
  103475. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  103476. */
  103477. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  103478. /**
  103479. * Detach the current controls from the specified dom element.
  103480. * @param element Defines the element to stop listening the inputs from
  103481. */
  103482. detachControl(element: Nullable<HTMLElement>): void;
  103483. /**
  103484. * Update the current camera state depending on the inputs that have been used this frame.
  103485. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  103486. */
  103487. checkInputs(): void;
  103488. /**
  103489. * Gets the class name of the current input.
  103490. * @returns the class name
  103491. */
  103492. getClassName(): string;
  103493. /**
  103494. * Get the friendly name associated with the input class.
  103495. * @returns the input friendly name
  103496. */
  103497. getSimpleName(): string;
  103498. /**
  103499. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  103500. * allow modification of the heightOffset value.
  103501. */
  103502. private _modifierHeightOffset;
  103503. /**
  103504. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  103505. * allow modification of the rotationOffset value.
  103506. */
  103507. private _modifierRotationOffset;
  103508. /**
  103509. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  103510. * allow modification of the radius value.
  103511. */
  103512. private _modifierRadius;
  103513. }
  103514. }
  103515. declare module BABYLON {
  103516. interface FreeCameraInputsManager {
  103517. /**
  103518. * @hidden
  103519. */
  103520. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  103521. /**
  103522. * Add orientation input support to the input manager.
  103523. * @returns the current input manager
  103524. */
  103525. addDeviceOrientation(): FreeCameraInputsManager;
  103526. }
  103527. /**
  103528. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  103529. * Screen rotation is taken into account.
  103530. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  103531. */
  103532. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  103533. private _camera;
  103534. private _screenOrientationAngle;
  103535. private _constantTranform;
  103536. private _screenQuaternion;
  103537. private _alpha;
  103538. private _beta;
  103539. private _gamma;
  103540. /**
  103541. * Can be used to detect if a device orientation sensor is availible on a device
  103542. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  103543. * @returns a promise that will resolve on orientation change
  103544. */
  103545. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  103546. /**
  103547. * @hidden
  103548. */
  103549. _onDeviceOrientationChangedObservable: Observable<void>;
  103550. /**
  103551. * Instantiates a new input
  103552. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  103553. */
  103554. constructor();
  103555. /**
  103556. * Define the camera controlled by the input.
  103557. */
  103558. camera: FreeCamera;
  103559. /**
  103560. * Attach the input controls to a specific dom element to get the input from.
  103561. * @param element Defines the element the controls should be listened from
  103562. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  103563. */
  103564. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  103565. private _orientationChanged;
  103566. private _deviceOrientation;
  103567. /**
  103568. * Detach the current controls from the specified dom element.
  103569. * @param element Defines the element to stop listening the inputs from
  103570. */
  103571. detachControl(element: Nullable<HTMLElement>): void;
  103572. /**
  103573. * Update the current camera state depending on the inputs that have been used this frame.
  103574. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  103575. */
  103576. checkInputs(): void;
  103577. /**
  103578. * Gets the class name of the current intput.
  103579. * @returns the class name
  103580. */
  103581. getClassName(): string;
  103582. /**
  103583. * Get the friendly name associated with the input class.
  103584. * @returns the input friendly name
  103585. */
  103586. getSimpleName(): string;
  103587. }
  103588. }
  103589. declare module BABYLON {
  103590. /**
  103591. * Manage the gamepad inputs to control a free camera.
  103592. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  103593. */
  103594. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  103595. /**
  103596. * Define the camera the input is attached to.
  103597. */
  103598. camera: FreeCamera;
  103599. /**
  103600. * Define the Gamepad controlling the input
  103601. */
  103602. gamepad: Nullable<Gamepad>;
  103603. /**
  103604. * Defines the gamepad rotation sensiblity.
  103605. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  103606. */
  103607. gamepadAngularSensibility: number;
  103608. /**
  103609. * Defines the gamepad move sensiblity.
  103610. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  103611. */
  103612. gamepadMoveSensibility: number;
  103613. private _onGamepadConnectedObserver;
  103614. private _onGamepadDisconnectedObserver;
  103615. private _cameraTransform;
  103616. private _deltaTransform;
  103617. private _vector3;
  103618. private _vector2;
  103619. /**
  103620. * Attach the input controls to a specific dom element to get the input from.
  103621. * @param element Defines the element the controls should be listened from
  103622. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  103623. */
  103624. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  103625. /**
  103626. * Detach the current controls from the specified dom element.
  103627. * @param element Defines the element to stop listening the inputs from
  103628. */
  103629. detachControl(element: Nullable<HTMLElement>): void;
  103630. /**
  103631. * Update the current camera state depending on the inputs that have been used this frame.
  103632. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  103633. */
  103634. checkInputs(): void;
  103635. /**
  103636. * Gets the class name of the current intput.
  103637. * @returns the class name
  103638. */
  103639. getClassName(): string;
  103640. /**
  103641. * Get the friendly name associated with the input class.
  103642. * @returns the input friendly name
  103643. */
  103644. getSimpleName(): string;
  103645. }
  103646. }
  103647. declare module BABYLON {
  103648. /**
  103649. * Defines the potential axis of a Joystick
  103650. */
  103651. export enum JoystickAxis {
  103652. /** X axis */
  103653. X = 0,
  103654. /** Y axis */
  103655. Y = 1,
  103656. /** Z axis */
  103657. Z = 2
  103658. }
  103659. /**
  103660. * Class used to define virtual joystick (used in touch mode)
  103661. */
  103662. export class VirtualJoystick {
  103663. /**
  103664. * Gets or sets a boolean indicating that left and right values must be inverted
  103665. */
  103666. reverseLeftRight: boolean;
  103667. /**
  103668. * Gets or sets a boolean indicating that up and down values must be inverted
  103669. */
  103670. reverseUpDown: boolean;
  103671. /**
  103672. * Gets the offset value for the position (ie. the change of the position value)
  103673. */
  103674. deltaPosition: Vector3;
  103675. /**
  103676. * Gets a boolean indicating if the virtual joystick was pressed
  103677. */
  103678. pressed: boolean;
  103679. /**
  103680. * Canvas the virtual joystick will render onto, default z-index of this is 5
  103681. */
  103682. static Canvas: Nullable<HTMLCanvasElement>;
  103683. private static _globalJoystickIndex;
  103684. private static vjCanvasContext;
  103685. private static vjCanvasWidth;
  103686. private static vjCanvasHeight;
  103687. private static halfWidth;
  103688. private _action;
  103689. private _axisTargetedByLeftAndRight;
  103690. private _axisTargetedByUpAndDown;
  103691. private _joystickSensibility;
  103692. private _inversedSensibility;
  103693. private _joystickPointerID;
  103694. private _joystickColor;
  103695. private _joystickPointerPos;
  103696. private _joystickPreviousPointerPos;
  103697. private _joystickPointerStartPos;
  103698. private _deltaJoystickVector;
  103699. private _leftJoystick;
  103700. private _touches;
  103701. private _onPointerDownHandlerRef;
  103702. private _onPointerMoveHandlerRef;
  103703. private _onPointerUpHandlerRef;
  103704. private _onResize;
  103705. /**
  103706. * Creates a new virtual joystick
  103707. * @param leftJoystick defines that the joystick is for left hand (false by default)
  103708. */
  103709. constructor(leftJoystick?: boolean);
  103710. /**
  103711. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  103712. * @param newJoystickSensibility defines the new sensibility
  103713. */
  103714. setJoystickSensibility(newJoystickSensibility: number): void;
  103715. private _onPointerDown;
  103716. private _onPointerMove;
  103717. private _onPointerUp;
  103718. /**
  103719. * Change the color of the virtual joystick
  103720. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  103721. */
  103722. setJoystickColor(newColor: string): void;
  103723. /**
  103724. * Defines a callback to call when the joystick is touched
  103725. * @param action defines the callback
  103726. */
  103727. setActionOnTouch(action: () => any): void;
  103728. /**
  103729. * Defines which axis you'd like to control for left & right
  103730. * @param axis defines the axis to use
  103731. */
  103732. setAxisForLeftRight(axis: JoystickAxis): void;
  103733. /**
  103734. * Defines which axis you'd like to control for up & down
  103735. * @param axis defines the axis to use
  103736. */
  103737. setAxisForUpDown(axis: JoystickAxis): void;
  103738. private _drawVirtualJoystick;
  103739. /**
  103740. * Release internal HTML canvas
  103741. */
  103742. releaseCanvas(): void;
  103743. }
  103744. }
  103745. declare module BABYLON {
  103746. interface FreeCameraInputsManager {
  103747. /**
  103748. * Add virtual joystick input support to the input manager.
  103749. * @returns the current input manager
  103750. */
  103751. addVirtualJoystick(): FreeCameraInputsManager;
  103752. }
  103753. /**
  103754. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  103755. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  103756. */
  103757. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  103758. /**
  103759. * Defines the camera the input is attached to.
  103760. */
  103761. camera: FreeCamera;
  103762. private _leftjoystick;
  103763. private _rightjoystick;
  103764. /**
  103765. * Gets the left stick of the virtual joystick.
  103766. * @returns The virtual Joystick
  103767. */
  103768. getLeftJoystick(): VirtualJoystick;
  103769. /**
  103770. * Gets the right stick of the virtual joystick.
  103771. * @returns The virtual Joystick
  103772. */
  103773. getRightJoystick(): VirtualJoystick;
  103774. /**
  103775. * Update the current camera state depending on the inputs that have been used this frame.
  103776. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  103777. */
  103778. checkInputs(): void;
  103779. /**
  103780. * Attach the input controls to a specific dom element to get the input from.
  103781. * @param element Defines the element the controls should be listened from
  103782. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  103783. */
  103784. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  103785. /**
  103786. * Detach the current controls from the specified dom element.
  103787. * @param element Defines the element to stop listening the inputs from
  103788. */
  103789. detachControl(element: Nullable<HTMLElement>): void;
  103790. /**
  103791. * Gets the class name of the current intput.
  103792. * @returns the class name
  103793. */
  103794. getClassName(): string;
  103795. /**
  103796. * Get the friendly name associated with the input class.
  103797. * @returns the input friendly name
  103798. */
  103799. getSimpleName(): string;
  103800. }
  103801. }
  103802. declare module BABYLON {
  103803. /**
  103804. * This represents a FPS type of camera controlled by touch.
  103805. * This is like a universal camera minus the Gamepad controls.
  103806. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  103807. */
  103808. export class TouchCamera extends FreeCamera {
  103809. /**
  103810. * Defines the touch sensibility for rotation.
  103811. * The higher the faster.
  103812. */
  103813. touchAngularSensibility: number;
  103814. /**
  103815. * Defines the touch sensibility for move.
  103816. * The higher the faster.
  103817. */
  103818. touchMoveSensibility: number;
  103819. /**
  103820. * Instantiates a new touch camera.
  103821. * This represents a FPS type of camera controlled by touch.
  103822. * This is like a universal camera minus the Gamepad controls.
  103823. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  103824. * @param name Define the name of the camera in the scene
  103825. * @param position Define the start position of the camera in the scene
  103826. * @param scene Define the scene the camera belongs to
  103827. */
  103828. constructor(name: string, position: Vector3, scene: Scene);
  103829. /**
  103830. * Gets the current object class name.
  103831. * @return the class name
  103832. */
  103833. getClassName(): string;
  103834. /** @hidden */
  103835. _setupInputs(): void;
  103836. }
  103837. }
  103838. declare module BABYLON {
  103839. /**
  103840. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  103841. * being tilted forward or back and left or right.
  103842. */
  103843. export class DeviceOrientationCamera extends FreeCamera {
  103844. private _initialQuaternion;
  103845. private _quaternionCache;
  103846. private _tmpDragQuaternion;
  103847. private _disablePointerInputWhenUsingDeviceOrientation;
  103848. /**
  103849. * Creates a new device orientation camera
  103850. * @param name The name of the camera
  103851. * @param position The start position camera
  103852. * @param scene The scene the camera belongs to
  103853. */
  103854. constructor(name: string, position: Vector3, scene: Scene);
  103855. /**
  103856. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  103857. */
  103858. disablePointerInputWhenUsingDeviceOrientation: boolean;
  103859. private _dragFactor;
  103860. /**
  103861. * Enabled turning on the y axis when the orientation sensor is active
  103862. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  103863. */
  103864. enableHorizontalDragging(dragFactor?: number): void;
  103865. /**
  103866. * Gets the current instance class name ("DeviceOrientationCamera").
  103867. * This helps avoiding instanceof at run time.
  103868. * @returns the class name
  103869. */
  103870. getClassName(): string;
  103871. /**
  103872. * @hidden
  103873. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  103874. */
  103875. _checkInputs(): void;
  103876. /**
  103877. * Reset the camera to its default orientation on the specified axis only.
  103878. * @param axis The axis to reset
  103879. */
  103880. resetToCurrentRotation(axis?: Axis): void;
  103881. }
  103882. }
  103883. declare module BABYLON {
  103884. /**
  103885. * Defines supported buttons for XBox360 compatible gamepads
  103886. */
  103887. export enum Xbox360Button {
  103888. /** A */
  103889. A = 0,
  103890. /** B */
  103891. B = 1,
  103892. /** X */
  103893. X = 2,
  103894. /** Y */
  103895. Y = 3,
  103896. /** Start */
  103897. Start = 4,
  103898. /** Back */
  103899. Back = 5,
  103900. /** Left button */
  103901. LB = 6,
  103902. /** Right button */
  103903. RB = 7,
  103904. /** Left stick */
  103905. LeftStick = 8,
  103906. /** Right stick */
  103907. RightStick = 9
  103908. }
  103909. /** Defines values for XBox360 DPad */
  103910. export enum Xbox360Dpad {
  103911. /** Up */
  103912. Up = 0,
  103913. /** Down */
  103914. Down = 1,
  103915. /** Left */
  103916. Left = 2,
  103917. /** Right */
  103918. Right = 3
  103919. }
  103920. /**
  103921. * Defines a XBox360 gamepad
  103922. */
  103923. export class Xbox360Pad extends Gamepad {
  103924. private _leftTrigger;
  103925. private _rightTrigger;
  103926. private _onlefttriggerchanged;
  103927. private _onrighttriggerchanged;
  103928. private _onbuttondown;
  103929. private _onbuttonup;
  103930. private _ondpaddown;
  103931. private _ondpadup;
  103932. /** Observable raised when a button is pressed */
  103933. onButtonDownObservable: Observable<Xbox360Button>;
  103934. /** Observable raised when a button is released */
  103935. onButtonUpObservable: Observable<Xbox360Button>;
  103936. /** Observable raised when a pad is pressed */
  103937. onPadDownObservable: Observable<Xbox360Dpad>;
  103938. /** Observable raised when a pad is released */
  103939. onPadUpObservable: Observable<Xbox360Dpad>;
  103940. private _buttonA;
  103941. private _buttonB;
  103942. private _buttonX;
  103943. private _buttonY;
  103944. private _buttonBack;
  103945. private _buttonStart;
  103946. private _buttonLB;
  103947. private _buttonRB;
  103948. private _buttonLeftStick;
  103949. private _buttonRightStick;
  103950. private _dPadUp;
  103951. private _dPadDown;
  103952. private _dPadLeft;
  103953. private _dPadRight;
  103954. private _isXboxOnePad;
  103955. /**
  103956. * Creates a new XBox360 gamepad object
  103957. * @param id defines the id of this gamepad
  103958. * @param index defines its index
  103959. * @param gamepad defines the internal HTML gamepad object
  103960. * @param xboxOne defines if it is a XBox One gamepad
  103961. */
  103962. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  103963. /**
  103964. * Defines the callback to call when left trigger is pressed
  103965. * @param callback defines the callback to use
  103966. */
  103967. onlefttriggerchanged(callback: (value: number) => void): void;
  103968. /**
  103969. * Defines the callback to call when right trigger is pressed
  103970. * @param callback defines the callback to use
  103971. */
  103972. onrighttriggerchanged(callback: (value: number) => void): void;
  103973. /**
  103974. * Gets the left trigger value
  103975. */
  103976. /**
  103977. * Sets the left trigger value
  103978. */
  103979. leftTrigger: number;
  103980. /**
  103981. * Gets the right trigger value
  103982. */
  103983. /**
  103984. * Sets the right trigger value
  103985. */
  103986. rightTrigger: number;
  103987. /**
  103988. * Defines the callback to call when a button is pressed
  103989. * @param callback defines the callback to use
  103990. */
  103991. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  103992. /**
  103993. * Defines the callback to call when a button is released
  103994. * @param callback defines the callback to use
  103995. */
  103996. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  103997. /**
  103998. * Defines the callback to call when a pad is pressed
  103999. * @param callback defines the callback to use
  104000. */
  104001. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  104002. /**
  104003. * Defines the callback to call when a pad is released
  104004. * @param callback defines the callback to use
  104005. */
  104006. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  104007. private _setButtonValue;
  104008. private _setDPadValue;
  104009. /**
  104010. * Gets the value of the `A` button
  104011. */
  104012. /**
  104013. * Sets the value of the `A` button
  104014. */
  104015. buttonA: number;
  104016. /**
  104017. * Gets the value of the `B` button
  104018. */
  104019. /**
  104020. * Sets the value of the `B` button
  104021. */
  104022. buttonB: number;
  104023. /**
  104024. * Gets the value of the `X` button
  104025. */
  104026. /**
  104027. * Sets the value of the `X` button
  104028. */
  104029. buttonX: number;
  104030. /**
  104031. * Gets the value of the `Y` button
  104032. */
  104033. /**
  104034. * Sets the value of the `Y` button
  104035. */
  104036. buttonY: number;
  104037. /**
  104038. * Gets the value of the `Start` button
  104039. */
  104040. /**
  104041. * Sets the value of the `Start` button
  104042. */
  104043. buttonStart: number;
  104044. /**
  104045. * Gets the value of the `Back` button
  104046. */
  104047. /**
  104048. * Sets the value of the `Back` button
  104049. */
  104050. buttonBack: number;
  104051. /**
  104052. * Gets the value of the `Left` button
  104053. */
  104054. /**
  104055. * Sets the value of the `Left` button
  104056. */
  104057. buttonLB: number;
  104058. /**
  104059. * Gets the value of the `Right` button
  104060. */
  104061. /**
  104062. * Sets the value of the `Right` button
  104063. */
  104064. buttonRB: number;
  104065. /**
  104066. * Gets the value of the Left joystick
  104067. */
  104068. /**
  104069. * Sets the value of the Left joystick
  104070. */
  104071. buttonLeftStick: number;
  104072. /**
  104073. * Gets the value of the Right joystick
  104074. */
  104075. /**
  104076. * Sets the value of the Right joystick
  104077. */
  104078. buttonRightStick: number;
  104079. /**
  104080. * Gets the value of D-pad up
  104081. */
  104082. /**
  104083. * Sets the value of D-pad up
  104084. */
  104085. dPadUp: number;
  104086. /**
  104087. * Gets the value of D-pad down
  104088. */
  104089. /**
  104090. * Sets the value of D-pad down
  104091. */
  104092. dPadDown: number;
  104093. /**
  104094. * Gets the value of D-pad left
  104095. */
  104096. /**
  104097. * Sets the value of D-pad left
  104098. */
  104099. dPadLeft: number;
  104100. /**
  104101. * Gets the value of D-pad right
  104102. */
  104103. /**
  104104. * Sets the value of D-pad right
  104105. */
  104106. dPadRight: number;
  104107. /**
  104108. * Force the gamepad to synchronize with device values
  104109. */
  104110. update(): void;
  104111. /**
  104112. * Disposes the gamepad
  104113. */
  104114. dispose(): void;
  104115. }
  104116. }
  104117. declare module BABYLON {
  104118. /**
  104119. * Defines supported buttons for DualShock compatible gamepads
  104120. */
  104121. export enum DualShockButton {
  104122. /** Cross */
  104123. Cross = 0,
  104124. /** Circle */
  104125. Circle = 1,
  104126. /** Square */
  104127. Square = 2,
  104128. /** Triangle */
  104129. Triangle = 3,
  104130. /** Options */
  104131. Options = 4,
  104132. /** Share */
  104133. Share = 5,
  104134. /** L1 */
  104135. L1 = 6,
  104136. /** R1 */
  104137. R1 = 7,
  104138. /** Left stick */
  104139. LeftStick = 8,
  104140. /** Right stick */
  104141. RightStick = 9
  104142. }
  104143. /** Defines values for DualShock DPad */
  104144. export enum DualShockDpad {
  104145. /** Up */
  104146. Up = 0,
  104147. /** Down */
  104148. Down = 1,
  104149. /** Left */
  104150. Left = 2,
  104151. /** Right */
  104152. Right = 3
  104153. }
  104154. /**
  104155. * Defines a DualShock gamepad
  104156. */
  104157. export class DualShockPad extends Gamepad {
  104158. private _leftTrigger;
  104159. private _rightTrigger;
  104160. private _onlefttriggerchanged;
  104161. private _onrighttriggerchanged;
  104162. private _onbuttondown;
  104163. private _onbuttonup;
  104164. private _ondpaddown;
  104165. private _ondpadup;
  104166. /** Observable raised when a button is pressed */
  104167. onButtonDownObservable: Observable<DualShockButton>;
  104168. /** Observable raised when a button is released */
  104169. onButtonUpObservable: Observable<DualShockButton>;
  104170. /** Observable raised when a pad is pressed */
  104171. onPadDownObservable: Observable<DualShockDpad>;
  104172. /** Observable raised when a pad is released */
  104173. onPadUpObservable: Observable<DualShockDpad>;
  104174. private _buttonCross;
  104175. private _buttonCircle;
  104176. private _buttonSquare;
  104177. private _buttonTriangle;
  104178. private _buttonShare;
  104179. private _buttonOptions;
  104180. private _buttonL1;
  104181. private _buttonR1;
  104182. private _buttonLeftStick;
  104183. private _buttonRightStick;
  104184. private _dPadUp;
  104185. private _dPadDown;
  104186. private _dPadLeft;
  104187. private _dPadRight;
  104188. /**
  104189. * Creates a new DualShock gamepad object
  104190. * @param id defines the id of this gamepad
  104191. * @param index defines its index
  104192. * @param gamepad defines the internal HTML gamepad object
  104193. */
  104194. constructor(id: string, index: number, gamepad: any);
  104195. /**
  104196. * Defines the callback to call when left trigger is pressed
  104197. * @param callback defines the callback to use
  104198. */
  104199. onlefttriggerchanged(callback: (value: number) => void): void;
  104200. /**
  104201. * Defines the callback to call when right trigger is pressed
  104202. * @param callback defines the callback to use
  104203. */
  104204. onrighttriggerchanged(callback: (value: number) => void): void;
  104205. /**
  104206. * Gets the left trigger value
  104207. */
  104208. /**
  104209. * Sets the left trigger value
  104210. */
  104211. leftTrigger: number;
  104212. /**
  104213. * Gets the right trigger value
  104214. */
  104215. /**
  104216. * Sets the right trigger value
  104217. */
  104218. rightTrigger: number;
  104219. /**
  104220. * Defines the callback to call when a button is pressed
  104221. * @param callback defines the callback to use
  104222. */
  104223. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  104224. /**
  104225. * Defines the callback to call when a button is released
  104226. * @param callback defines the callback to use
  104227. */
  104228. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  104229. /**
  104230. * Defines the callback to call when a pad is pressed
  104231. * @param callback defines the callback to use
  104232. */
  104233. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  104234. /**
  104235. * Defines the callback to call when a pad is released
  104236. * @param callback defines the callback to use
  104237. */
  104238. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  104239. private _setButtonValue;
  104240. private _setDPadValue;
  104241. /**
  104242. * Gets the value of the `Cross` button
  104243. */
  104244. /**
  104245. * Sets the value of the `Cross` button
  104246. */
  104247. buttonCross: number;
  104248. /**
  104249. * Gets the value of the `Circle` button
  104250. */
  104251. /**
  104252. * Sets the value of the `Circle` button
  104253. */
  104254. buttonCircle: number;
  104255. /**
  104256. * Gets the value of the `Square` button
  104257. */
  104258. /**
  104259. * Sets the value of the `Square` button
  104260. */
  104261. buttonSquare: number;
  104262. /**
  104263. * Gets the value of the `Triangle` button
  104264. */
  104265. /**
  104266. * Sets the value of the `Triangle` button
  104267. */
  104268. buttonTriangle: number;
  104269. /**
  104270. * Gets the value of the `Options` button
  104271. */
  104272. /**
  104273. * Sets the value of the `Options` button
  104274. */
  104275. buttonOptions: number;
  104276. /**
  104277. * Gets the value of the `Share` button
  104278. */
  104279. /**
  104280. * Sets the value of the `Share` button
  104281. */
  104282. buttonShare: number;
  104283. /**
  104284. * Gets the value of the `L1` button
  104285. */
  104286. /**
  104287. * Sets the value of the `L1` button
  104288. */
  104289. buttonL1: number;
  104290. /**
  104291. * Gets the value of the `R1` button
  104292. */
  104293. /**
  104294. * Sets the value of the `R1` button
  104295. */
  104296. buttonR1: number;
  104297. /**
  104298. * Gets the value of the Left joystick
  104299. */
  104300. /**
  104301. * Sets the value of the Left joystick
  104302. */
  104303. buttonLeftStick: number;
  104304. /**
  104305. * Gets the value of the Right joystick
  104306. */
  104307. /**
  104308. * Sets the value of the Right joystick
  104309. */
  104310. buttonRightStick: number;
  104311. /**
  104312. * Gets the value of D-pad up
  104313. */
  104314. /**
  104315. * Sets the value of D-pad up
  104316. */
  104317. dPadUp: number;
  104318. /**
  104319. * Gets the value of D-pad down
  104320. */
  104321. /**
  104322. * Sets the value of D-pad down
  104323. */
  104324. dPadDown: number;
  104325. /**
  104326. * Gets the value of D-pad left
  104327. */
  104328. /**
  104329. * Sets the value of D-pad left
  104330. */
  104331. dPadLeft: number;
  104332. /**
  104333. * Gets the value of D-pad right
  104334. */
  104335. /**
  104336. * Sets the value of D-pad right
  104337. */
  104338. dPadRight: number;
  104339. /**
  104340. * Force the gamepad to synchronize with device values
  104341. */
  104342. update(): void;
  104343. /**
  104344. * Disposes the gamepad
  104345. */
  104346. dispose(): void;
  104347. }
  104348. }
  104349. declare module BABYLON {
  104350. /**
  104351. * Manager for handling gamepads
  104352. */
  104353. export class GamepadManager {
  104354. private _scene?;
  104355. private _babylonGamepads;
  104356. private _oneGamepadConnected;
  104357. /** @hidden */
  104358. _isMonitoring: boolean;
  104359. private _gamepadEventSupported;
  104360. private _gamepadSupport;
  104361. /**
  104362. * observable to be triggered when the gamepad controller has been connected
  104363. */
  104364. onGamepadConnectedObservable: Observable<Gamepad>;
  104365. /**
  104366. * observable to be triggered when the gamepad controller has been disconnected
  104367. */
  104368. onGamepadDisconnectedObservable: Observable<Gamepad>;
  104369. private _onGamepadConnectedEvent;
  104370. private _onGamepadDisconnectedEvent;
  104371. /**
  104372. * Initializes the gamepad manager
  104373. * @param _scene BabylonJS scene
  104374. */
  104375. constructor(_scene?: Scene | undefined);
  104376. /**
  104377. * The gamepads in the game pad manager
  104378. */
  104379. readonly gamepads: Gamepad[];
  104380. /**
  104381. * Get the gamepad controllers based on type
  104382. * @param type The type of gamepad controller
  104383. * @returns Nullable gamepad
  104384. */
  104385. getGamepadByType(type?: number): Nullable<Gamepad>;
  104386. /**
  104387. * Disposes the gamepad manager
  104388. */
  104389. dispose(): void;
  104390. private _addNewGamepad;
  104391. private _startMonitoringGamepads;
  104392. private _stopMonitoringGamepads;
  104393. /** @hidden */
  104394. _checkGamepadsStatus(): void;
  104395. private _updateGamepadObjects;
  104396. }
  104397. }
  104398. declare module BABYLON {
  104399. interface Scene {
  104400. /** @hidden */
  104401. _gamepadManager: Nullable<GamepadManager>;
  104402. /**
  104403. * Gets the gamepad manager associated with the scene
  104404. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  104405. */
  104406. gamepadManager: GamepadManager;
  104407. }
  104408. /**
  104409. * Interface representing a free camera inputs manager
  104410. */
  104411. interface FreeCameraInputsManager {
  104412. /**
  104413. * Adds gamepad input support to the FreeCameraInputsManager.
  104414. * @returns the FreeCameraInputsManager
  104415. */
  104416. addGamepad(): FreeCameraInputsManager;
  104417. }
  104418. /**
  104419. * Interface representing an arc rotate camera inputs manager
  104420. */
  104421. interface ArcRotateCameraInputsManager {
  104422. /**
  104423. * Adds gamepad input support to the ArcRotateCamera InputManager.
  104424. * @returns the camera inputs manager
  104425. */
  104426. addGamepad(): ArcRotateCameraInputsManager;
  104427. }
  104428. /**
  104429. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  104430. */
  104431. export class GamepadSystemSceneComponent implements ISceneComponent {
  104432. /**
  104433. * The component name helpfull to identify the component in the list of scene components.
  104434. */
  104435. readonly name: string;
  104436. /**
  104437. * The scene the component belongs to.
  104438. */
  104439. scene: Scene;
  104440. /**
  104441. * Creates a new instance of the component for the given scene
  104442. * @param scene Defines the scene to register the component in
  104443. */
  104444. constructor(scene: Scene);
  104445. /**
  104446. * Registers the component in a given scene
  104447. */
  104448. register(): void;
  104449. /**
  104450. * Rebuilds the elements related to this component in case of
  104451. * context lost for instance.
  104452. */
  104453. rebuild(): void;
  104454. /**
  104455. * Disposes the component and the associated ressources
  104456. */
  104457. dispose(): void;
  104458. private _beforeCameraUpdate;
  104459. }
  104460. }
  104461. declare module BABYLON {
  104462. /**
  104463. * 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,
  104464. * which still works and will still be found in many Playgrounds.
  104465. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  104466. */
  104467. export class UniversalCamera extends TouchCamera {
  104468. /**
  104469. * Defines the gamepad rotation sensiblity.
  104470. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  104471. */
  104472. gamepadAngularSensibility: number;
  104473. /**
  104474. * Defines the gamepad move sensiblity.
  104475. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  104476. */
  104477. gamepadMoveSensibility: number;
  104478. /**
  104479. * 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,
  104480. * which still works and will still be found in many Playgrounds.
  104481. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  104482. * @param name Define the name of the camera in the scene
  104483. * @param position Define the start position of the camera in the scene
  104484. * @param scene Define the scene the camera belongs to
  104485. */
  104486. constructor(name: string, position: Vector3, scene: Scene);
  104487. /**
  104488. * Gets the current object class name.
  104489. * @return the class name
  104490. */
  104491. getClassName(): string;
  104492. }
  104493. }
  104494. declare module BABYLON {
  104495. /**
  104496. * This represents a FPS type of camera. This is only here for back compat purpose.
  104497. * Please use the UniversalCamera instead as both are identical.
  104498. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  104499. */
  104500. export class GamepadCamera extends UniversalCamera {
  104501. /**
  104502. * Instantiates a new Gamepad Camera
  104503. * This represents a FPS type of camera. This is only here for back compat purpose.
  104504. * Please use the UniversalCamera instead as both are identical.
  104505. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  104506. * @param name Define the name of the camera in the scene
  104507. * @param position Define the start position of the camera in the scene
  104508. * @param scene Define the scene the camera belongs to
  104509. */
  104510. constructor(name: string, position: Vector3, scene: Scene);
  104511. /**
  104512. * Gets the current object class name.
  104513. * @return the class name
  104514. */
  104515. getClassName(): string;
  104516. }
  104517. }
  104518. declare module BABYLON {
  104519. /** @hidden */
  104520. export var passPixelShader: {
  104521. name: string;
  104522. shader: string;
  104523. };
  104524. }
  104525. declare module BABYLON {
  104526. /** @hidden */
  104527. export var passCubePixelShader: {
  104528. name: string;
  104529. shader: string;
  104530. };
  104531. }
  104532. declare module BABYLON {
  104533. /**
  104534. * PassPostProcess which produces an output the same as it's input
  104535. */
  104536. export class PassPostProcess extends PostProcess {
  104537. /**
  104538. * Creates the PassPostProcess
  104539. * @param name The name of the effect.
  104540. * @param options The required width/height ratio to downsize to before computing the render pass.
  104541. * @param camera The camera to apply the render pass to.
  104542. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  104543. * @param engine The engine which the post process will be applied. (default: current engine)
  104544. * @param reusable If the post process can be reused on the same frame. (default: false)
  104545. * @param textureType The type of texture to be used when performing the post processing.
  104546. * @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)
  104547. */
  104548. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  104549. }
  104550. /**
  104551. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  104552. */
  104553. export class PassCubePostProcess extends PostProcess {
  104554. private _face;
  104555. /**
  104556. * Gets or sets the cube face to display.
  104557. * * 0 is +X
  104558. * * 1 is -X
  104559. * * 2 is +Y
  104560. * * 3 is -Y
  104561. * * 4 is +Z
  104562. * * 5 is -Z
  104563. */
  104564. face: number;
  104565. /**
  104566. * Creates the PassCubePostProcess
  104567. * @param name The name of the effect.
  104568. * @param options The required width/height ratio to downsize to before computing the render pass.
  104569. * @param camera The camera to apply the render pass to.
  104570. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  104571. * @param engine The engine which the post process will be applied. (default: current engine)
  104572. * @param reusable If the post process can be reused on the same frame. (default: false)
  104573. * @param textureType The type of texture to be used when performing the post processing.
  104574. * @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)
  104575. */
  104576. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  104577. }
  104578. }
  104579. declare module BABYLON {
  104580. /** @hidden */
  104581. export var anaglyphPixelShader: {
  104582. name: string;
  104583. shader: string;
  104584. };
  104585. }
  104586. declare module BABYLON {
  104587. /**
  104588. * Postprocess used to generate anaglyphic rendering
  104589. */
  104590. export class AnaglyphPostProcess extends PostProcess {
  104591. private _passedProcess;
  104592. /**
  104593. * Creates a new AnaglyphPostProcess
  104594. * @param name defines postprocess name
  104595. * @param options defines creation options or target ratio scale
  104596. * @param rigCameras defines cameras using this postprocess
  104597. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  104598. * @param engine defines hosting engine
  104599. * @param reusable defines if the postprocess will be reused multiple times per frame
  104600. */
  104601. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  104602. }
  104603. }
  104604. declare module BABYLON {
  104605. /**
  104606. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  104607. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  104608. */
  104609. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  104610. /**
  104611. * Creates a new AnaglyphArcRotateCamera
  104612. * @param name defines camera name
  104613. * @param alpha defines alpha angle (in radians)
  104614. * @param beta defines beta angle (in radians)
  104615. * @param radius defines radius
  104616. * @param target defines camera target
  104617. * @param interaxialDistance defines distance between each color axis
  104618. * @param scene defines the hosting scene
  104619. */
  104620. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  104621. /**
  104622. * Gets camera class name
  104623. * @returns AnaglyphArcRotateCamera
  104624. */
  104625. getClassName(): string;
  104626. }
  104627. }
  104628. declare module BABYLON {
  104629. /**
  104630. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  104631. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  104632. */
  104633. export class AnaglyphFreeCamera extends FreeCamera {
  104634. /**
  104635. * Creates a new AnaglyphFreeCamera
  104636. * @param name defines camera name
  104637. * @param position defines initial position
  104638. * @param interaxialDistance defines distance between each color axis
  104639. * @param scene defines the hosting scene
  104640. */
  104641. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  104642. /**
  104643. * Gets camera class name
  104644. * @returns AnaglyphFreeCamera
  104645. */
  104646. getClassName(): string;
  104647. }
  104648. }
  104649. declare module BABYLON {
  104650. /**
  104651. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  104652. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  104653. */
  104654. export class AnaglyphGamepadCamera extends GamepadCamera {
  104655. /**
  104656. * Creates a new AnaglyphGamepadCamera
  104657. * @param name defines camera name
  104658. * @param position defines initial position
  104659. * @param interaxialDistance defines distance between each color axis
  104660. * @param scene defines the hosting scene
  104661. */
  104662. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  104663. /**
  104664. * Gets camera class name
  104665. * @returns AnaglyphGamepadCamera
  104666. */
  104667. getClassName(): string;
  104668. }
  104669. }
  104670. declare module BABYLON {
  104671. /**
  104672. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  104673. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  104674. */
  104675. export class AnaglyphUniversalCamera extends UniversalCamera {
  104676. /**
  104677. * Creates a new AnaglyphUniversalCamera
  104678. * @param name defines camera name
  104679. * @param position defines initial position
  104680. * @param interaxialDistance defines distance between each color axis
  104681. * @param scene defines the hosting scene
  104682. */
  104683. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  104684. /**
  104685. * Gets camera class name
  104686. * @returns AnaglyphUniversalCamera
  104687. */
  104688. getClassName(): string;
  104689. }
  104690. }
  104691. declare module BABYLON {
  104692. /** @hidden */
  104693. export var stereoscopicInterlacePixelShader: {
  104694. name: string;
  104695. shader: string;
  104696. };
  104697. }
  104698. declare module BABYLON {
  104699. /**
  104700. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  104701. */
  104702. export class StereoscopicInterlacePostProcess extends PostProcess {
  104703. private _stepSize;
  104704. private _passedProcess;
  104705. /**
  104706. * Initializes a StereoscopicInterlacePostProcess
  104707. * @param name The name of the effect.
  104708. * @param rigCameras The rig cameras to be appled to the post process
  104709. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  104710. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  104711. * @param engine The engine which the post process will be applied. (default: current engine)
  104712. * @param reusable If the post process can be reused on the same frame. (default: false)
  104713. */
  104714. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  104715. }
  104716. }
  104717. declare module BABYLON {
  104718. /**
  104719. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  104720. * @see http://doc.babylonjs.com/features/cameras
  104721. */
  104722. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  104723. /**
  104724. * Creates a new StereoscopicArcRotateCamera
  104725. * @param name defines camera name
  104726. * @param alpha defines alpha angle (in radians)
  104727. * @param beta defines beta angle (in radians)
  104728. * @param radius defines radius
  104729. * @param target defines camera target
  104730. * @param interaxialDistance defines distance between each color axis
  104731. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  104732. * @param scene defines the hosting scene
  104733. */
  104734. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  104735. /**
  104736. * Gets camera class name
  104737. * @returns StereoscopicArcRotateCamera
  104738. */
  104739. getClassName(): string;
  104740. }
  104741. }
  104742. declare module BABYLON {
  104743. /**
  104744. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  104745. * @see http://doc.babylonjs.com/features/cameras
  104746. */
  104747. export class StereoscopicFreeCamera extends FreeCamera {
  104748. /**
  104749. * Creates a new StereoscopicFreeCamera
  104750. * @param name defines camera name
  104751. * @param position defines initial position
  104752. * @param interaxialDistance defines distance between each color axis
  104753. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  104754. * @param scene defines the hosting scene
  104755. */
  104756. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  104757. /**
  104758. * Gets camera class name
  104759. * @returns StereoscopicFreeCamera
  104760. */
  104761. getClassName(): string;
  104762. }
  104763. }
  104764. declare module BABYLON {
  104765. /**
  104766. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  104767. * @see http://doc.babylonjs.com/features/cameras
  104768. */
  104769. export class StereoscopicGamepadCamera extends GamepadCamera {
  104770. /**
  104771. * Creates a new StereoscopicGamepadCamera
  104772. * @param name defines camera name
  104773. * @param position defines initial position
  104774. * @param interaxialDistance defines distance between each color axis
  104775. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  104776. * @param scene defines the hosting scene
  104777. */
  104778. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  104779. /**
  104780. * Gets camera class name
  104781. * @returns StereoscopicGamepadCamera
  104782. */
  104783. getClassName(): string;
  104784. }
  104785. }
  104786. declare module BABYLON {
  104787. /**
  104788. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  104789. * @see http://doc.babylonjs.com/features/cameras
  104790. */
  104791. export class StereoscopicUniversalCamera extends UniversalCamera {
  104792. /**
  104793. * Creates a new StereoscopicUniversalCamera
  104794. * @param name defines camera name
  104795. * @param position defines initial position
  104796. * @param interaxialDistance defines distance between each color axis
  104797. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  104798. * @param scene defines the hosting scene
  104799. */
  104800. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  104801. /**
  104802. * Gets camera class name
  104803. * @returns StereoscopicUniversalCamera
  104804. */
  104805. getClassName(): string;
  104806. }
  104807. }
  104808. declare module BABYLON {
  104809. /**
  104810. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  104811. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  104812. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  104813. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  104814. */
  104815. export class VirtualJoysticksCamera extends FreeCamera {
  104816. /**
  104817. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  104818. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  104819. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  104820. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  104821. * @param name Define the name of the camera in the scene
  104822. * @param position Define the start position of the camera in the scene
  104823. * @param scene Define the scene the camera belongs to
  104824. */
  104825. constructor(name: string, position: Vector3, scene: Scene);
  104826. /**
  104827. * Gets the current object class name.
  104828. * @return the class name
  104829. */
  104830. getClassName(): string;
  104831. }
  104832. }
  104833. declare module BABYLON {
  104834. /**
  104835. * This represents all the required metrics to create a VR camera.
  104836. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  104837. */
  104838. export class VRCameraMetrics {
  104839. /**
  104840. * Define the horizontal resolution off the screen.
  104841. */
  104842. hResolution: number;
  104843. /**
  104844. * Define the vertical resolution off the screen.
  104845. */
  104846. vResolution: number;
  104847. /**
  104848. * Define the horizontal screen size.
  104849. */
  104850. hScreenSize: number;
  104851. /**
  104852. * Define the vertical screen size.
  104853. */
  104854. vScreenSize: number;
  104855. /**
  104856. * Define the vertical screen center position.
  104857. */
  104858. vScreenCenter: number;
  104859. /**
  104860. * Define the distance of the eyes to the screen.
  104861. */
  104862. eyeToScreenDistance: number;
  104863. /**
  104864. * Define the distance between both lenses
  104865. */
  104866. lensSeparationDistance: number;
  104867. /**
  104868. * Define the distance between both viewer's eyes.
  104869. */
  104870. interpupillaryDistance: number;
  104871. /**
  104872. * Define the distortion factor of the VR postprocess.
  104873. * Please, touch with care.
  104874. */
  104875. distortionK: number[];
  104876. /**
  104877. * Define the chromatic aberration correction factors for the VR post process.
  104878. */
  104879. chromaAbCorrection: number[];
  104880. /**
  104881. * Define the scale factor of the post process.
  104882. * The smaller the better but the slower.
  104883. */
  104884. postProcessScaleFactor: number;
  104885. /**
  104886. * Define an offset for the lens center.
  104887. */
  104888. lensCenterOffset: number;
  104889. /**
  104890. * Define if the current vr camera should compensate the distortion of the lense or not.
  104891. */
  104892. compensateDistortion: boolean;
  104893. /**
  104894. * Defines if multiview should be enabled when rendering (Default: false)
  104895. */
  104896. multiviewEnabled: boolean;
  104897. /**
  104898. * Gets the rendering aspect ratio based on the provided resolutions.
  104899. */
  104900. readonly aspectRatio: number;
  104901. /**
  104902. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  104903. */
  104904. readonly aspectRatioFov: number;
  104905. /**
  104906. * @hidden
  104907. */
  104908. readonly leftHMatrix: Matrix;
  104909. /**
  104910. * @hidden
  104911. */
  104912. readonly rightHMatrix: Matrix;
  104913. /**
  104914. * @hidden
  104915. */
  104916. readonly leftPreViewMatrix: Matrix;
  104917. /**
  104918. * @hidden
  104919. */
  104920. readonly rightPreViewMatrix: Matrix;
  104921. /**
  104922. * Get the default VRMetrics based on the most generic setup.
  104923. * @returns the default vr metrics
  104924. */
  104925. static GetDefault(): VRCameraMetrics;
  104926. }
  104927. }
  104928. declare module BABYLON {
  104929. /** @hidden */
  104930. export var vrDistortionCorrectionPixelShader: {
  104931. name: string;
  104932. shader: string;
  104933. };
  104934. }
  104935. declare module BABYLON {
  104936. /**
  104937. * VRDistortionCorrectionPostProcess used for mobile VR
  104938. */
  104939. export class VRDistortionCorrectionPostProcess extends PostProcess {
  104940. private _isRightEye;
  104941. private _distortionFactors;
  104942. private _postProcessScaleFactor;
  104943. private _lensCenterOffset;
  104944. private _scaleIn;
  104945. private _scaleFactor;
  104946. private _lensCenter;
  104947. /**
  104948. * Initializes the VRDistortionCorrectionPostProcess
  104949. * @param name The name of the effect.
  104950. * @param camera The camera to apply the render pass to.
  104951. * @param isRightEye If this is for the right eye distortion
  104952. * @param vrMetrics All the required metrics for the VR camera
  104953. */
  104954. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  104955. }
  104956. }
  104957. declare module BABYLON {
  104958. /**
  104959. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  104960. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  104961. */
  104962. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  104963. /**
  104964. * Creates a new VRDeviceOrientationArcRotateCamera
  104965. * @param name defines camera name
  104966. * @param alpha defines the camera rotation along the logitudinal axis
  104967. * @param beta defines the camera rotation along the latitudinal axis
  104968. * @param radius defines the camera distance from its target
  104969. * @param target defines the camera target
  104970. * @param scene defines the scene the camera belongs to
  104971. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  104972. * @param vrCameraMetrics defines the vr metrics associated to the camera
  104973. */
  104974. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  104975. /**
  104976. * Gets camera class name
  104977. * @returns VRDeviceOrientationArcRotateCamera
  104978. */
  104979. getClassName(): string;
  104980. }
  104981. }
  104982. declare module BABYLON {
  104983. /**
  104984. * Camera used to simulate VR rendering (based on FreeCamera)
  104985. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  104986. */
  104987. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  104988. /**
  104989. * Creates a new VRDeviceOrientationFreeCamera
  104990. * @param name defines camera name
  104991. * @param position defines the start position of the camera
  104992. * @param scene defines the scene the camera belongs to
  104993. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  104994. * @param vrCameraMetrics defines the vr metrics associated to the camera
  104995. */
  104996. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  104997. /**
  104998. * Gets camera class name
  104999. * @returns VRDeviceOrientationFreeCamera
  105000. */
  105001. getClassName(): string;
  105002. }
  105003. }
  105004. declare module BABYLON {
  105005. /**
  105006. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  105007. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  105008. */
  105009. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  105010. /**
  105011. * Creates a new VRDeviceOrientationGamepadCamera
  105012. * @param name defines camera name
  105013. * @param position defines the start position of the camera
  105014. * @param scene defines the scene the camera belongs to
  105015. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  105016. * @param vrCameraMetrics defines the vr metrics associated to the camera
  105017. */
  105018. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  105019. /**
  105020. * Gets camera class name
  105021. * @returns VRDeviceOrientationGamepadCamera
  105022. */
  105023. getClassName(): string;
  105024. }
  105025. }
  105026. declare module BABYLON {
  105027. /**
  105028. * Base class of materials working in push mode in babylon JS
  105029. * @hidden
  105030. */
  105031. export class PushMaterial extends Material {
  105032. protected _activeEffect: Effect;
  105033. protected _normalMatrix: Matrix;
  105034. /**
  105035. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  105036. * This means that the material can keep using a previous shader while a new one is being compiled.
  105037. * This is mostly used when shader parallel compilation is supported (true by default)
  105038. */
  105039. allowShaderHotSwapping: boolean;
  105040. constructor(name: string, scene: Scene);
  105041. getEffect(): Effect;
  105042. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  105043. /**
  105044. * Binds the given world matrix to the active effect
  105045. *
  105046. * @param world the matrix to bind
  105047. */
  105048. bindOnlyWorldMatrix(world: Matrix): void;
  105049. /**
  105050. * Binds the given normal matrix to the active effect
  105051. *
  105052. * @param normalMatrix the matrix to bind
  105053. */
  105054. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  105055. bind(world: Matrix, mesh?: Mesh): void;
  105056. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  105057. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  105058. }
  105059. }
  105060. declare module BABYLON {
  105061. /**
  105062. * This groups all the flags used to control the materials channel.
  105063. */
  105064. export class MaterialFlags {
  105065. private static _DiffuseTextureEnabled;
  105066. /**
  105067. * Are diffuse textures enabled in the application.
  105068. */
  105069. static DiffuseTextureEnabled: boolean;
  105070. private static _AmbientTextureEnabled;
  105071. /**
  105072. * Are ambient textures enabled in the application.
  105073. */
  105074. static AmbientTextureEnabled: boolean;
  105075. private static _OpacityTextureEnabled;
  105076. /**
  105077. * Are opacity textures enabled in the application.
  105078. */
  105079. static OpacityTextureEnabled: boolean;
  105080. private static _ReflectionTextureEnabled;
  105081. /**
  105082. * Are reflection textures enabled in the application.
  105083. */
  105084. static ReflectionTextureEnabled: boolean;
  105085. private static _EmissiveTextureEnabled;
  105086. /**
  105087. * Are emissive textures enabled in the application.
  105088. */
  105089. static EmissiveTextureEnabled: boolean;
  105090. private static _SpecularTextureEnabled;
  105091. /**
  105092. * Are specular textures enabled in the application.
  105093. */
  105094. static SpecularTextureEnabled: boolean;
  105095. private static _BumpTextureEnabled;
  105096. /**
  105097. * Are bump textures enabled in the application.
  105098. */
  105099. static BumpTextureEnabled: boolean;
  105100. private static _LightmapTextureEnabled;
  105101. /**
  105102. * Are lightmap textures enabled in the application.
  105103. */
  105104. static LightmapTextureEnabled: boolean;
  105105. private static _RefractionTextureEnabled;
  105106. /**
  105107. * Are refraction textures enabled in the application.
  105108. */
  105109. static RefractionTextureEnabled: boolean;
  105110. private static _ColorGradingTextureEnabled;
  105111. /**
  105112. * Are color grading textures enabled in the application.
  105113. */
  105114. static ColorGradingTextureEnabled: boolean;
  105115. private static _FresnelEnabled;
  105116. /**
  105117. * Are fresnels enabled in the application.
  105118. */
  105119. static FresnelEnabled: boolean;
  105120. private static _ClearCoatTextureEnabled;
  105121. /**
  105122. * Are clear coat textures enabled in the application.
  105123. */
  105124. static ClearCoatTextureEnabled: boolean;
  105125. private static _ClearCoatBumpTextureEnabled;
  105126. /**
  105127. * Are clear coat bump textures enabled in the application.
  105128. */
  105129. static ClearCoatBumpTextureEnabled: boolean;
  105130. private static _ClearCoatTintTextureEnabled;
  105131. /**
  105132. * Are clear coat tint textures enabled in the application.
  105133. */
  105134. static ClearCoatTintTextureEnabled: boolean;
  105135. private static _SheenTextureEnabled;
  105136. /**
  105137. * Are sheen textures enabled in the application.
  105138. */
  105139. static SheenTextureEnabled: boolean;
  105140. private static _AnisotropicTextureEnabled;
  105141. /**
  105142. * Are anisotropic textures enabled in the application.
  105143. */
  105144. static AnisotropicTextureEnabled: boolean;
  105145. private static _ThicknessTextureEnabled;
  105146. /**
  105147. * Are thickness textures enabled in the application.
  105148. */
  105149. static ThicknessTextureEnabled: boolean;
  105150. }
  105151. }
  105152. declare module BABYLON {
  105153. /** @hidden */
  105154. export var defaultFragmentDeclaration: {
  105155. name: string;
  105156. shader: string;
  105157. };
  105158. }
  105159. declare module BABYLON {
  105160. /** @hidden */
  105161. export var defaultUboDeclaration: {
  105162. name: string;
  105163. shader: string;
  105164. };
  105165. }
  105166. declare module BABYLON {
  105167. /** @hidden */
  105168. export var lightFragmentDeclaration: {
  105169. name: string;
  105170. shader: string;
  105171. };
  105172. }
  105173. declare module BABYLON {
  105174. /** @hidden */
  105175. export var lightUboDeclaration: {
  105176. name: string;
  105177. shader: string;
  105178. };
  105179. }
  105180. declare module BABYLON {
  105181. /** @hidden */
  105182. export var lightsFragmentFunctions: {
  105183. name: string;
  105184. shader: string;
  105185. };
  105186. }
  105187. declare module BABYLON {
  105188. /** @hidden */
  105189. export var shadowsFragmentFunctions: {
  105190. name: string;
  105191. shader: string;
  105192. };
  105193. }
  105194. declare module BABYLON {
  105195. /** @hidden */
  105196. export var fresnelFunction: {
  105197. name: string;
  105198. shader: string;
  105199. };
  105200. }
  105201. declare module BABYLON {
  105202. /** @hidden */
  105203. export var reflectionFunction: {
  105204. name: string;
  105205. shader: string;
  105206. };
  105207. }
  105208. declare module BABYLON {
  105209. /** @hidden */
  105210. export var bumpFragmentFunctions: {
  105211. name: string;
  105212. shader: string;
  105213. };
  105214. }
  105215. declare module BABYLON {
  105216. /** @hidden */
  105217. export var logDepthDeclaration: {
  105218. name: string;
  105219. shader: string;
  105220. };
  105221. }
  105222. declare module BABYLON {
  105223. /** @hidden */
  105224. export var bumpFragment: {
  105225. name: string;
  105226. shader: string;
  105227. };
  105228. }
  105229. declare module BABYLON {
  105230. /** @hidden */
  105231. export var depthPrePass: {
  105232. name: string;
  105233. shader: string;
  105234. };
  105235. }
  105236. declare module BABYLON {
  105237. /** @hidden */
  105238. export var lightFragment: {
  105239. name: string;
  105240. shader: string;
  105241. };
  105242. }
  105243. declare module BABYLON {
  105244. /** @hidden */
  105245. export var logDepthFragment: {
  105246. name: string;
  105247. shader: string;
  105248. };
  105249. }
  105250. declare module BABYLON {
  105251. /** @hidden */
  105252. export var defaultPixelShader: {
  105253. name: string;
  105254. shader: string;
  105255. };
  105256. }
  105257. declare module BABYLON {
  105258. /** @hidden */
  105259. export var defaultVertexDeclaration: {
  105260. name: string;
  105261. shader: string;
  105262. };
  105263. }
  105264. declare module BABYLON {
  105265. /** @hidden */
  105266. export var bumpVertexDeclaration: {
  105267. name: string;
  105268. shader: string;
  105269. };
  105270. }
  105271. declare module BABYLON {
  105272. /** @hidden */
  105273. export var bumpVertex: {
  105274. name: string;
  105275. shader: string;
  105276. };
  105277. }
  105278. declare module BABYLON {
  105279. /** @hidden */
  105280. export var fogVertex: {
  105281. name: string;
  105282. shader: string;
  105283. };
  105284. }
  105285. declare module BABYLON {
  105286. /** @hidden */
  105287. export var shadowsVertex: {
  105288. name: string;
  105289. shader: string;
  105290. };
  105291. }
  105292. declare module BABYLON {
  105293. /** @hidden */
  105294. export var pointCloudVertex: {
  105295. name: string;
  105296. shader: string;
  105297. };
  105298. }
  105299. declare module BABYLON {
  105300. /** @hidden */
  105301. export var logDepthVertex: {
  105302. name: string;
  105303. shader: string;
  105304. };
  105305. }
  105306. declare module BABYLON {
  105307. /** @hidden */
  105308. export var defaultVertexShader: {
  105309. name: string;
  105310. shader: string;
  105311. };
  105312. }
  105313. declare module BABYLON {
  105314. /** @hidden */
  105315. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  105316. MAINUV1: boolean;
  105317. MAINUV2: boolean;
  105318. DIFFUSE: boolean;
  105319. DIFFUSEDIRECTUV: number;
  105320. AMBIENT: boolean;
  105321. AMBIENTDIRECTUV: number;
  105322. OPACITY: boolean;
  105323. OPACITYDIRECTUV: number;
  105324. OPACITYRGB: boolean;
  105325. REFLECTION: boolean;
  105326. EMISSIVE: boolean;
  105327. EMISSIVEDIRECTUV: number;
  105328. SPECULAR: boolean;
  105329. SPECULARDIRECTUV: number;
  105330. BUMP: boolean;
  105331. BUMPDIRECTUV: number;
  105332. PARALLAX: boolean;
  105333. PARALLAXOCCLUSION: boolean;
  105334. SPECULAROVERALPHA: boolean;
  105335. CLIPPLANE: boolean;
  105336. CLIPPLANE2: boolean;
  105337. CLIPPLANE3: boolean;
  105338. CLIPPLANE4: boolean;
  105339. ALPHATEST: boolean;
  105340. DEPTHPREPASS: boolean;
  105341. ALPHAFROMDIFFUSE: boolean;
  105342. POINTSIZE: boolean;
  105343. FOG: boolean;
  105344. SPECULARTERM: boolean;
  105345. DIFFUSEFRESNEL: boolean;
  105346. OPACITYFRESNEL: boolean;
  105347. REFLECTIONFRESNEL: boolean;
  105348. REFRACTIONFRESNEL: boolean;
  105349. EMISSIVEFRESNEL: boolean;
  105350. FRESNEL: boolean;
  105351. NORMAL: boolean;
  105352. UV1: boolean;
  105353. UV2: boolean;
  105354. VERTEXCOLOR: boolean;
  105355. VERTEXALPHA: boolean;
  105356. NUM_BONE_INFLUENCERS: number;
  105357. BonesPerMesh: number;
  105358. BONETEXTURE: boolean;
  105359. INSTANCES: boolean;
  105360. GLOSSINESS: boolean;
  105361. ROUGHNESS: boolean;
  105362. EMISSIVEASILLUMINATION: boolean;
  105363. LINKEMISSIVEWITHDIFFUSE: boolean;
  105364. REFLECTIONFRESNELFROMSPECULAR: boolean;
  105365. LIGHTMAP: boolean;
  105366. LIGHTMAPDIRECTUV: number;
  105367. OBJECTSPACE_NORMALMAP: boolean;
  105368. USELIGHTMAPASSHADOWMAP: boolean;
  105369. REFLECTIONMAP_3D: boolean;
  105370. REFLECTIONMAP_SPHERICAL: boolean;
  105371. REFLECTIONMAP_PLANAR: boolean;
  105372. REFLECTIONMAP_CUBIC: boolean;
  105373. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  105374. REFLECTIONMAP_PROJECTION: boolean;
  105375. REFLECTIONMAP_SKYBOX: boolean;
  105376. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  105377. REFLECTIONMAP_EXPLICIT: boolean;
  105378. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  105379. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  105380. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  105381. INVERTCUBICMAP: boolean;
  105382. LOGARITHMICDEPTH: boolean;
  105383. REFRACTION: boolean;
  105384. REFRACTIONMAP_3D: boolean;
  105385. REFLECTIONOVERALPHA: boolean;
  105386. TWOSIDEDLIGHTING: boolean;
  105387. SHADOWFLOAT: boolean;
  105388. MORPHTARGETS: boolean;
  105389. MORPHTARGETS_NORMAL: boolean;
  105390. MORPHTARGETS_TANGENT: boolean;
  105391. MORPHTARGETS_UV: boolean;
  105392. NUM_MORPH_INFLUENCERS: number;
  105393. NONUNIFORMSCALING: boolean;
  105394. PREMULTIPLYALPHA: boolean;
  105395. IMAGEPROCESSING: boolean;
  105396. VIGNETTE: boolean;
  105397. VIGNETTEBLENDMODEMULTIPLY: boolean;
  105398. VIGNETTEBLENDMODEOPAQUE: boolean;
  105399. TONEMAPPING: boolean;
  105400. TONEMAPPING_ACES: boolean;
  105401. CONTRAST: boolean;
  105402. COLORCURVES: boolean;
  105403. COLORGRADING: boolean;
  105404. COLORGRADING3D: boolean;
  105405. SAMPLER3DGREENDEPTH: boolean;
  105406. SAMPLER3DBGRMAP: boolean;
  105407. IMAGEPROCESSINGPOSTPROCESS: boolean;
  105408. MULTIVIEW: boolean;
  105409. /**
  105410. * If the reflection texture on this material is in linear color space
  105411. * @hidden
  105412. */
  105413. IS_REFLECTION_LINEAR: boolean;
  105414. /**
  105415. * If the refraction texture on this material is in linear color space
  105416. * @hidden
  105417. */
  105418. IS_REFRACTION_LINEAR: boolean;
  105419. EXPOSURE: boolean;
  105420. constructor();
  105421. setReflectionMode(modeToEnable: string): void;
  105422. }
  105423. /**
  105424. * This is the default material used in Babylon. It is the best trade off between quality
  105425. * and performances.
  105426. * @see http://doc.babylonjs.com/babylon101/materials
  105427. */
  105428. export class StandardMaterial extends PushMaterial {
  105429. private _diffuseTexture;
  105430. /**
  105431. * The basic texture of the material as viewed under a light.
  105432. */
  105433. diffuseTexture: Nullable<BaseTexture>;
  105434. private _ambientTexture;
  105435. /**
  105436. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  105437. */
  105438. ambientTexture: Nullable<BaseTexture>;
  105439. private _opacityTexture;
  105440. /**
  105441. * Define the transparency of the material from a texture.
  105442. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  105443. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  105444. */
  105445. opacityTexture: Nullable<BaseTexture>;
  105446. private _reflectionTexture;
  105447. /**
  105448. * Define the texture used to display the reflection.
  105449. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  105450. */
  105451. reflectionTexture: Nullable<BaseTexture>;
  105452. private _emissiveTexture;
  105453. /**
  105454. * Define texture of the material as if self lit.
  105455. * This will be mixed in the final result even in the absence of light.
  105456. */
  105457. emissiveTexture: Nullable<BaseTexture>;
  105458. private _specularTexture;
  105459. /**
  105460. * Define how the color and intensity of the highlight given by the light in the material.
  105461. */
  105462. specularTexture: Nullable<BaseTexture>;
  105463. private _bumpTexture;
  105464. /**
  105465. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  105466. * 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.
  105467. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  105468. */
  105469. bumpTexture: Nullable<BaseTexture>;
  105470. private _lightmapTexture;
  105471. /**
  105472. * Complex lighting can be computationally expensive to compute at runtime.
  105473. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  105474. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  105475. */
  105476. lightmapTexture: Nullable<BaseTexture>;
  105477. private _refractionTexture;
  105478. /**
  105479. * Define the texture used to display the refraction.
  105480. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  105481. */
  105482. refractionTexture: Nullable<BaseTexture>;
  105483. /**
  105484. * The color of the material lit by the environmental background lighting.
  105485. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  105486. */
  105487. ambientColor: Color3;
  105488. /**
  105489. * The basic color of the material as viewed under a light.
  105490. */
  105491. diffuseColor: Color3;
  105492. /**
  105493. * Define how the color and intensity of the highlight given by the light in the material.
  105494. */
  105495. specularColor: Color3;
  105496. /**
  105497. * Define the color of the material as if self lit.
  105498. * This will be mixed in the final result even in the absence of light.
  105499. */
  105500. emissiveColor: Color3;
  105501. /**
  105502. * Defines how sharp are the highlights in the material.
  105503. * The bigger the value the sharper giving a more glossy feeling to the result.
  105504. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  105505. */
  105506. specularPower: number;
  105507. private _useAlphaFromDiffuseTexture;
  105508. /**
  105509. * Does the transparency come from the diffuse texture alpha channel.
  105510. */
  105511. useAlphaFromDiffuseTexture: boolean;
  105512. private _useEmissiveAsIllumination;
  105513. /**
  105514. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  105515. */
  105516. useEmissiveAsIllumination: boolean;
  105517. private _linkEmissiveWithDiffuse;
  105518. /**
  105519. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  105520. * the emissive level when the final color is close to one.
  105521. */
  105522. linkEmissiveWithDiffuse: boolean;
  105523. private _useSpecularOverAlpha;
  105524. /**
  105525. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  105526. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  105527. */
  105528. useSpecularOverAlpha: boolean;
  105529. private _useReflectionOverAlpha;
  105530. /**
  105531. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  105532. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  105533. */
  105534. useReflectionOverAlpha: boolean;
  105535. private _disableLighting;
  105536. /**
  105537. * Does lights from the scene impacts this material.
  105538. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  105539. */
  105540. disableLighting: boolean;
  105541. private _useObjectSpaceNormalMap;
  105542. /**
  105543. * Allows using an object space normal map (instead of tangent space).
  105544. */
  105545. useObjectSpaceNormalMap: boolean;
  105546. private _useParallax;
  105547. /**
  105548. * Is parallax enabled or not.
  105549. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  105550. */
  105551. useParallax: boolean;
  105552. private _useParallaxOcclusion;
  105553. /**
  105554. * Is parallax occlusion enabled or not.
  105555. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  105556. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  105557. */
  105558. useParallaxOcclusion: boolean;
  105559. /**
  105560. * 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.
  105561. */
  105562. parallaxScaleBias: number;
  105563. private _roughness;
  105564. /**
  105565. * Helps to define how blurry the reflections should appears in the material.
  105566. */
  105567. roughness: number;
  105568. /**
  105569. * In case of refraction, define the value of the index of refraction.
  105570. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  105571. */
  105572. indexOfRefraction: number;
  105573. /**
  105574. * Invert the refraction texture alongside the y axis.
  105575. * It can be useful with procedural textures or probe for instance.
  105576. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  105577. */
  105578. invertRefractionY: boolean;
  105579. /**
  105580. * Defines the alpha limits in alpha test mode.
  105581. */
  105582. alphaCutOff: number;
  105583. private _useLightmapAsShadowmap;
  105584. /**
  105585. * In case of light mapping, define whether the map contains light or shadow informations.
  105586. */
  105587. useLightmapAsShadowmap: boolean;
  105588. private _diffuseFresnelParameters;
  105589. /**
  105590. * Define the diffuse fresnel parameters of the material.
  105591. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  105592. */
  105593. diffuseFresnelParameters: FresnelParameters;
  105594. private _opacityFresnelParameters;
  105595. /**
  105596. * Define the opacity fresnel parameters of the material.
  105597. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  105598. */
  105599. opacityFresnelParameters: FresnelParameters;
  105600. private _reflectionFresnelParameters;
  105601. /**
  105602. * Define the reflection fresnel parameters of the material.
  105603. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  105604. */
  105605. reflectionFresnelParameters: FresnelParameters;
  105606. private _refractionFresnelParameters;
  105607. /**
  105608. * Define the refraction fresnel parameters of the material.
  105609. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  105610. */
  105611. refractionFresnelParameters: FresnelParameters;
  105612. private _emissiveFresnelParameters;
  105613. /**
  105614. * Define the emissive fresnel parameters of the material.
  105615. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  105616. */
  105617. emissiveFresnelParameters: FresnelParameters;
  105618. private _useReflectionFresnelFromSpecular;
  105619. /**
  105620. * If true automatically deducts the fresnels values from the material specularity.
  105621. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  105622. */
  105623. useReflectionFresnelFromSpecular: boolean;
  105624. private _useGlossinessFromSpecularMapAlpha;
  105625. /**
  105626. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  105627. */
  105628. useGlossinessFromSpecularMapAlpha: boolean;
  105629. private _maxSimultaneousLights;
  105630. /**
  105631. * Defines the maximum number of lights that can be used in the material
  105632. */
  105633. maxSimultaneousLights: number;
  105634. private _invertNormalMapX;
  105635. /**
  105636. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  105637. */
  105638. invertNormalMapX: boolean;
  105639. private _invertNormalMapY;
  105640. /**
  105641. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  105642. */
  105643. invertNormalMapY: boolean;
  105644. private _twoSidedLighting;
  105645. /**
  105646. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  105647. */
  105648. twoSidedLighting: boolean;
  105649. /**
  105650. * Default configuration related to image processing available in the standard Material.
  105651. */
  105652. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  105653. /**
  105654. * Gets the image processing configuration used either in this material.
  105655. */
  105656. /**
  105657. * Sets the Default image processing configuration used either in the this material.
  105658. *
  105659. * If sets to null, the scene one is in use.
  105660. */
  105661. imageProcessingConfiguration: ImageProcessingConfiguration;
  105662. /**
  105663. * Keep track of the image processing observer to allow dispose and replace.
  105664. */
  105665. private _imageProcessingObserver;
  105666. /**
  105667. * Attaches a new image processing configuration to the Standard Material.
  105668. * @param configuration
  105669. */
  105670. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  105671. /**
  105672. * Gets wether the color curves effect is enabled.
  105673. */
  105674. /**
  105675. * Sets wether the color curves effect is enabled.
  105676. */
  105677. cameraColorCurvesEnabled: boolean;
  105678. /**
  105679. * Gets wether the color grading effect is enabled.
  105680. */
  105681. /**
  105682. * Gets wether the color grading effect is enabled.
  105683. */
  105684. cameraColorGradingEnabled: boolean;
  105685. /**
  105686. * Gets wether tonemapping is enabled or not.
  105687. */
  105688. /**
  105689. * Sets wether tonemapping is enabled or not
  105690. */
  105691. cameraToneMappingEnabled: boolean;
  105692. /**
  105693. * The camera exposure used on this material.
  105694. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  105695. * This corresponds to a photographic exposure.
  105696. */
  105697. /**
  105698. * The camera exposure used on this material.
  105699. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  105700. * This corresponds to a photographic exposure.
  105701. */
  105702. cameraExposure: number;
  105703. /**
  105704. * Gets The camera contrast used on this material.
  105705. */
  105706. /**
  105707. * Sets The camera contrast used on this material.
  105708. */
  105709. cameraContrast: number;
  105710. /**
  105711. * Gets the Color Grading 2D Lookup Texture.
  105712. */
  105713. /**
  105714. * Sets the Color Grading 2D Lookup Texture.
  105715. */
  105716. cameraColorGradingTexture: Nullable<BaseTexture>;
  105717. /**
  105718. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  105719. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  105720. * 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;
  105721. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  105722. */
  105723. /**
  105724. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  105725. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  105726. * 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;
  105727. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  105728. */
  105729. cameraColorCurves: Nullable<ColorCurves>;
  105730. /**
  105731. * Custom callback helping to override the default shader used in the material.
  105732. */
  105733. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  105734. protected _renderTargets: SmartArray<RenderTargetTexture>;
  105735. protected _worldViewProjectionMatrix: Matrix;
  105736. protected _globalAmbientColor: Color3;
  105737. protected _useLogarithmicDepth: boolean;
  105738. protected _rebuildInParallel: boolean;
  105739. /**
  105740. * Instantiates a new standard material.
  105741. * This is the default material used in Babylon. It is the best trade off between quality
  105742. * and performances.
  105743. * @see http://doc.babylonjs.com/babylon101/materials
  105744. * @param name Define the name of the material in the scene
  105745. * @param scene Define the scene the material belong to
  105746. */
  105747. constructor(name: string, scene: Scene);
  105748. /**
  105749. * Gets a boolean indicating that current material needs to register RTT
  105750. */
  105751. readonly hasRenderTargetTextures: boolean;
  105752. /**
  105753. * Gets the current class name of the material e.g. "StandardMaterial"
  105754. * Mainly use in serialization.
  105755. * @returns the class name
  105756. */
  105757. getClassName(): string;
  105758. /**
  105759. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  105760. * You can try switching to logarithmic depth.
  105761. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  105762. */
  105763. useLogarithmicDepth: boolean;
  105764. /**
  105765. * Specifies if the material will require alpha blending
  105766. * @returns a boolean specifying if alpha blending is needed
  105767. */
  105768. needAlphaBlending(): boolean;
  105769. /**
  105770. * Specifies if this material should be rendered in alpha test mode
  105771. * @returns a boolean specifying if an alpha test is needed.
  105772. */
  105773. needAlphaTesting(): boolean;
  105774. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  105775. /**
  105776. * Get the texture used for alpha test purpose.
  105777. * @returns the diffuse texture in case of the standard material.
  105778. */
  105779. getAlphaTestTexture(): Nullable<BaseTexture>;
  105780. /**
  105781. * Get if the submesh is ready to be used and all its information available.
  105782. * Child classes can use it to update shaders
  105783. * @param mesh defines the mesh to check
  105784. * @param subMesh defines which submesh to check
  105785. * @param useInstances specifies that instances should be used
  105786. * @returns a boolean indicating that the submesh is ready or not
  105787. */
  105788. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  105789. /**
  105790. * Builds the material UBO layouts.
  105791. * Used internally during the effect preparation.
  105792. */
  105793. buildUniformLayout(): void;
  105794. /**
  105795. * Unbinds the material from the mesh
  105796. */
  105797. unbind(): void;
  105798. /**
  105799. * Binds the submesh to this material by preparing the effect and shader to draw
  105800. * @param world defines the world transformation matrix
  105801. * @param mesh defines the mesh containing the submesh
  105802. * @param subMesh defines the submesh to bind the material to
  105803. */
  105804. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  105805. /**
  105806. * Get the list of animatables in the material.
  105807. * @returns the list of animatables object used in the material
  105808. */
  105809. getAnimatables(): IAnimatable[];
  105810. /**
  105811. * Gets the active textures from the material
  105812. * @returns an array of textures
  105813. */
  105814. getActiveTextures(): BaseTexture[];
  105815. /**
  105816. * Specifies if the material uses a texture
  105817. * @param texture defines the texture to check against the material
  105818. * @returns a boolean specifying if the material uses the texture
  105819. */
  105820. hasTexture(texture: BaseTexture): boolean;
  105821. /**
  105822. * Disposes the material
  105823. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  105824. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  105825. */
  105826. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  105827. /**
  105828. * Makes a duplicate of the material, and gives it a new name
  105829. * @param name defines the new name for the duplicated material
  105830. * @returns the cloned material
  105831. */
  105832. clone(name: string): StandardMaterial;
  105833. /**
  105834. * Serializes this material in a JSON representation
  105835. * @returns the serialized material object
  105836. */
  105837. serialize(): any;
  105838. /**
  105839. * Creates a standard material from parsed material data
  105840. * @param source defines the JSON representation of the material
  105841. * @param scene defines the hosting scene
  105842. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  105843. * @returns a new standard material
  105844. */
  105845. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  105846. /**
  105847. * Are diffuse textures enabled in the application.
  105848. */
  105849. static DiffuseTextureEnabled: boolean;
  105850. /**
  105851. * Are ambient textures enabled in the application.
  105852. */
  105853. static AmbientTextureEnabled: boolean;
  105854. /**
  105855. * Are opacity textures enabled in the application.
  105856. */
  105857. static OpacityTextureEnabled: boolean;
  105858. /**
  105859. * Are reflection textures enabled in the application.
  105860. */
  105861. static ReflectionTextureEnabled: boolean;
  105862. /**
  105863. * Are emissive textures enabled in the application.
  105864. */
  105865. static EmissiveTextureEnabled: boolean;
  105866. /**
  105867. * Are specular textures enabled in the application.
  105868. */
  105869. static SpecularTextureEnabled: boolean;
  105870. /**
  105871. * Are bump textures enabled in the application.
  105872. */
  105873. static BumpTextureEnabled: boolean;
  105874. /**
  105875. * Are lightmap textures enabled in the application.
  105876. */
  105877. static LightmapTextureEnabled: boolean;
  105878. /**
  105879. * Are refraction textures enabled in the application.
  105880. */
  105881. static RefractionTextureEnabled: boolean;
  105882. /**
  105883. * Are color grading textures enabled in the application.
  105884. */
  105885. static ColorGradingTextureEnabled: boolean;
  105886. /**
  105887. * Are fresnels enabled in the application.
  105888. */
  105889. static FresnelEnabled: boolean;
  105890. }
  105891. }
  105892. declare module BABYLON {
  105893. /**
  105894. * A class extending Texture allowing drawing on a texture
  105895. * @see http://doc.babylonjs.com/how_to/dynamictexture
  105896. */
  105897. export class DynamicTexture extends Texture {
  105898. private _generateMipMaps;
  105899. private _canvas;
  105900. private _context;
  105901. private _engine;
  105902. /**
  105903. * Creates a DynamicTexture
  105904. * @param name defines the name of the texture
  105905. * @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
  105906. * @param scene defines the scene where you want the texture
  105907. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  105908. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  105909. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  105910. */
  105911. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  105912. /**
  105913. * Get the current class name of the texture useful for serialization or dynamic coding.
  105914. * @returns "DynamicTexture"
  105915. */
  105916. getClassName(): string;
  105917. /**
  105918. * Gets the current state of canRescale
  105919. */
  105920. readonly canRescale: boolean;
  105921. private _recreate;
  105922. /**
  105923. * Scales the texture
  105924. * @param ratio the scale factor to apply to both width and height
  105925. */
  105926. scale(ratio: number): void;
  105927. /**
  105928. * Resizes the texture
  105929. * @param width the new width
  105930. * @param height the new height
  105931. */
  105932. scaleTo(width: number, height: number): void;
  105933. /**
  105934. * Gets the context of the canvas used by the texture
  105935. * @returns the canvas context of the dynamic texture
  105936. */
  105937. getContext(): CanvasRenderingContext2D;
  105938. /**
  105939. * Clears the texture
  105940. */
  105941. clear(): void;
  105942. /**
  105943. * Updates the texture
  105944. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  105945. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  105946. */
  105947. update(invertY?: boolean, premulAlpha?: boolean): void;
  105948. /**
  105949. * Draws text onto the texture
  105950. * @param text defines the text to be drawn
  105951. * @param x defines the placement of the text from the left
  105952. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  105953. * @param font defines the font to be used with font-style, font-size, font-name
  105954. * @param color defines the color used for the text
  105955. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  105956. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  105957. * @param update defines whether texture is immediately update (default is true)
  105958. */
  105959. drawText(text: string, x: number, y: number, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  105960. /**
  105961. * Clones the texture
  105962. * @returns the clone of the texture.
  105963. */
  105964. clone(): DynamicTexture;
  105965. /**
  105966. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  105967. * @returns a serialized dynamic texture object
  105968. */
  105969. serialize(): any;
  105970. /** @hidden */
  105971. _rebuild(): void;
  105972. }
  105973. }
  105974. declare module BABYLON {
  105975. /** @hidden */
  105976. export var imageProcessingPixelShader: {
  105977. name: string;
  105978. shader: string;
  105979. };
  105980. }
  105981. declare module BABYLON {
  105982. /**
  105983. * ImageProcessingPostProcess
  105984. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  105985. */
  105986. export class ImageProcessingPostProcess extends PostProcess {
  105987. /**
  105988. * Default configuration related to image processing available in the PBR Material.
  105989. */
  105990. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  105991. /**
  105992. * Gets the image processing configuration used either in this material.
  105993. */
  105994. /**
  105995. * Sets the Default image processing configuration used either in the this material.
  105996. *
  105997. * If sets to null, the scene one is in use.
  105998. */
  105999. imageProcessingConfiguration: ImageProcessingConfiguration;
  106000. /**
  106001. * Keep track of the image processing observer to allow dispose and replace.
  106002. */
  106003. private _imageProcessingObserver;
  106004. /**
  106005. * Attaches a new image processing configuration to the PBR Material.
  106006. * @param configuration
  106007. */
  106008. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  106009. /**
  106010. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  106011. */
  106012. /**
  106013. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  106014. */
  106015. colorCurves: Nullable<ColorCurves>;
  106016. /**
  106017. * Gets wether the color curves effect is enabled.
  106018. */
  106019. /**
  106020. * Sets wether the color curves effect is enabled.
  106021. */
  106022. colorCurvesEnabled: boolean;
  106023. /**
  106024. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  106025. */
  106026. /**
  106027. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  106028. */
  106029. colorGradingTexture: Nullable<BaseTexture>;
  106030. /**
  106031. * Gets wether the color grading effect is enabled.
  106032. */
  106033. /**
  106034. * Gets wether the color grading effect is enabled.
  106035. */
  106036. colorGradingEnabled: boolean;
  106037. /**
  106038. * Gets exposure used in the effect.
  106039. */
  106040. /**
  106041. * Sets exposure used in the effect.
  106042. */
  106043. exposure: number;
  106044. /**
  106045. * Gets wether tonemapping is enabled or not.
  106046. */
  106047. /**
  106048. * Sets wether tonemapping is enabled or not
  106049. */
  106050. toneMappingEnabled: boolean;
  106051. /**
  106052. * Gets the type of tone mapping effect.
  106053. */
  106054. /**
  106055. * Sets the type of tone mapping effect.
  106056. */
  106057. toneMappingType: number;
  106058. /**
  106059. * Gets contrast used in the effect.
  106060. */
  106061. /**
  106062. * Sets contrast used in the effect.
  106063. */
  106064. contrast: number;
  106065. /**
  106066. * Gets Vignette stretch size.
  106067. */
  106068. /**
  106069. * Sets Vignette stretch size.
  106070. */
  106071. vignetteStretch: number;
  106072. /**
  106073. * Gets Vignette centre X Offset.
  106074. */
  106075. /**
  106076. * Sets Vignette centre X Offset.
  106077. */
  106078. vignetteCentreX: number;
  106079. /**
  106080. * Gets Vignette centre Y Offset.
  106081. */
  106082. /**
  106083. * Sets Vignette centre Y Offset.
  106084. */
  106085. vignetteCentreY: number;
  106086. /**
  106087. * Gets Vignette weight or intensity of the vignette effect.
  106088. */
  106089. /**
  106090. * Sets Vignette weight or intensity of the vignette effect.
  106091. */
  106092. vignetteWeight: number;
  106093. /**
  106094. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  106095. * if vignetteEnabled is set to true.
  106096. */
  106097. /**
  106098. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  106099. * if vignetteEnabled is set to true.
  106100. */
  106101. vignetteColor: Color4;
  106102. /**
  106103. * Gets Camera field of view used by the Vignette effect.
  106104. */
  106105. /**
  106106. * Sets Camera field of view used by the Vignette effect.
  106107. */
  106108. vignetteCameraFov: number;
  106109. /**
  106110. * Gets the vignette blend mode allowing different kind of effect.
  106111. */
  106112. /**
  106113. * Sets the vignette blend mode allowing different kind of effect.
  106114. */
  106115. vignetteBlendMode: number;
  106116. /**
  106117. * Gets wether the vignette effect is enabled.
  106118. */
  106119. /**
  106120. * Sets wether the vignette effect is enabled.
  106121. */
  106122. vignetteEnabled: boolean;
  106123. private _fromLinearSpace;
  106124. /**
  106125. * Gets wether the input of the processing is in Gamma or Linear Space.
  106126. */
  106127. /**
  106128. * Sets wether the input of the processing is in Gamma or Linear Space.
  106129. */
  106130. fromLinearSpace: boolean;
  106131. /**
  106132. * Defines cache preventing GC.
  106133. */
  106134. private _defines;
  106135. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  106136. /**
  106137. * "ImageProcessingPostProcess"
  106138. * @returns "ImageProcessingPostProcess"
  106139. */
  106140. getClassName(): string;
  106141. protected _updateParameters(): void;
  106142. dispose(camera?: Camera): void;
  106143. }
  106144. }
  106145. declare module BABYLON {
  106146. /**
  106147. * Class containing static functions to help procedurally build meshes
  106148. */
  106149. export class GroundBuilder {
  106150. /**
  106151. * Creates a ground mesh
  106152. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  106153. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  106154. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  106155. * @param name defines the name of the mesh
  106156. * @param options defines the options used to create the mesh
  106157. * @param scene defines the hosting scene
  106158. * @returns the ground mesh
  106159. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  106160. */
  106161. static CreateGround(name: string, options: {
  106162. width?: number;
  106163. height?: number;
  106164. subdivisions?: number;
  106165. subdivisionsX?: number;
  106166. subdivisionsY?: number;
  106167. updatable?: boolean;
  106168. }, scene: any): Mesh;
  106169. /**
  106170. * Creates a tiled ground mesh
  106171. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  106172. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  106173. * * 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
  106174. * * 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
  106175. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  106176. * @param name defines the name of the mesh
  106177. * @param options defines the options used to create the mesh
  106178. * @param scene defines the hosting scene
  106179. * @returns the tiled ground mesh
  106180. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  106181. */
  106182. static CreateTiledGround(name: string, options: {
  106183. xmin: number;
  106184. zmin: number;
  106185. xmax: number;
  106186. zmax: number;
  106187. subdivisions?: {
  106188. w: number;
  106189. h: number;
  106190. };
  106191. precision?: {
  106192. w: number;
  106193. h: number;
  106194. };
  106195. updatable?: boolean;
  106196. }, scene?: Nullable<Scene>): Mesh;
  106197. /**
  106198. * Creates a ground mesh from a height map
  106199. * * The parameter `url` sets the URL of the height map image resource.
  106200. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  106201. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  106202. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  106203. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  106204. * * 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.
  106205. * * 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).
  106206. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  106207. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  106208. * @param name defines the name of the mesh
  106209. * @param url defines the url to the height map
  106210. * @param options defines the options used to create the mesh
  106211. * @param scene defines the hosting scene
  106212. * @returns the ground mesh
  106213. * @see https://doc.babylonjs.com/babylon101/height_map
  106214. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  106215. */
  106216. static CreateGroundFromHeightMap(name: string, url: string, options: {
  106217. width?: number;
  106218. height?: number;
  106219. subdivisions?: number;
  106220. minHeight?: number;
  106221. maxHeight?: number;
  106222. colorFilter?: Color3;
  106223. alphaFilter?: number;
  106224. updatable?: boolean;
  106225. onReady?: (mesh: GroundMesh) => void;
  106226. }, scene?: Nullable<Scene>): GroundMesh;
  106227. }
  106228. }
  106229. declare module BABYLON {
  106230. /**
  106231. * Class containing static functions to help procedurally build meshes
  106232. */
  106233. export class TorusBuilder {
  106234. /**
  106235. * Creates a torus mesh
  106236. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  106237. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  106238. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  106239. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  106240. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  106241. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  106242. * @param name defines the name of the mesh
  106243. * @param options defines the options used to create the mesh
  106244. * @param scene defines the hosting scene
  106245. * @returns the torus mesh
  106246. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  106247. */
  106248. static CreateTorus(name: string, options: {
  106249. diameter?: number;
  106250. thickness?: number;
  106251. tessellation?: number;
  106252. updatable?: boolean;
  106253. sideOrientation?: number;
  106254. frontUVs?: Vector4;
  106255. backUVs?: Vector4;
  106256. }, scene: any): Mesh;
  106257. }
  106258. }
  106259. declare module BABYLON {
  106260. /**
  106261. * Class containing static functions to help procedurally build meshes
  106262. */
  106263. export class CylinderBuilder {
  106264. /**
  106265. * Creates a cylinder or a cone mesh
  106266. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  106267. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  106268. * * 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.
  106269. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  106270. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  106271. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  106272. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  106273. * * 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).
  106274. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  106275. * * 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).
  106276. * * 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
  106277. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  106278. * * 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
  106279. * * 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.
  106280. * * If `enclose` is false, a ring surface is one element.
  106281. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  106282. * * 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
  106283. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  106284. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  106285. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  106286. * @param name defines the name of the mesh
  106287. * @param options defines the options used to create the mesh
  106288. * @param scene defines the hosting scene
  106289. * @returns the cylinder mesh
  106290. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  106291. */
  106292. static CreateCylinder(name: string, options: {
  106293. height?: number;
  106294. diameterTop?: number;
  106295. diameterBottom?: number;
  106296. diameter?: number;
  106297. tessellation?: number;
  106298. subdivisions?: number;
  106299. arc?: number;
  106300. faceColors?: Color4[];
  106301. faceUV?: Vector4[];
  106302. updatable?: boolean;
  106303. hasRings?: boolean;
  106304. enclose?: boolean;
  106305. cap?: number;
  106306. sideOrientation?: number;
  106307. frontUVs?: Vector4;
  106308. backUVs?: Vector4;
  106309. }, scene: any): Mesh;
  106310. }
  106311. }
  106312. declare module BABYLON {
  106313. /**
  106314. * Options to modify the vr teleportation behavior.
  106315. */
  106316. export interface VRTeleportationOptions {
  106317. /**
  106318. * The name of the mesh which should be used as the teleportation floor. (default: null)
  106319. */
  106320. floorMeshName?: string;
  106321. /**
  106322. * A list of meshes to be used as the teleportation floor. (default: empty)
  106323. */
  106324. floorMeshes?: Mesh[];
  106325. }
  106326. /**
  106327. * Options to modify the vr experience helper's behavior.
  106328. */
  106329. export interface VRExperienceHelperOptions extends WebVROptions {
  106330. /**
  106331. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  106332. */
  106333. createDeviceOrientationCamera?: boolean;
  106334. /**
  106335. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  106336. */
  106337. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  106338. /**
  106339. * Uses the main button on the controller to toggle the laser casted. (default: true)
  106340. */
  106341. laserToggle?: boolean;
  106342. /**
  106343. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  106344. */
  106345. floorMeshes?: Mesh[];
  106346. /**
  106347. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  106348. */
  106349. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  106350. }
  106351. /**
  106352. * Event containing information after VR has been entered
  106353. */
  106354. export class OnAfterEnteringVRObservableEvent {
  106355. /**
  106356. * If entering vr was successful
  106357. */
  106358. success: boolean;
  106359. }
  106360. /**
  106361. * Helps to quickly add VR support to an existing scene.
  106362. * See http://doc.babylonjs.com/how_to/webvr_helper
  106363. */
  106364. export class VRExperienceHelper {
  106365. /** Options to modify the vr experience helper's behavior. */
  106366. webVROptions: VRExperienceHelperOptions;
  106367. private _scene;
  106368. private _position;
  106369. private _btnVR;
  106370. private _btnVRDisplayed;
  106371. private _webVRsupported;
  106372. private _webVRready;
  106373. private _webVRrequesting;
  106374. private _webVRpresenting;
  106375. private _hasEnteredVR;
  106376. private _fullscreenVRpresenting;
  106377. private _canvas;
  106378. private _webVRCamera;
  106379. private _vrDeviceOrientationCamera;
  106380. private _deviceOrientationCamera;
  106381. private _existingCamera;
  106382. private _onKeyDown;
  106383. private _onVrDisplayPresentChange;
  106384. private _onVRDisplayChanged;
  106385. private _onVRRequestPresentStart;
  106386. private _onVRRequestPresentComplete;
  106387. /**
  106388. * 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)
  106389. */
  106390. enableGazeEvenWhenNoPointerLock: boolean;
  106391. /**
  106392. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  106393. */
  106394. exitVROnDoubleTap: boolean;
  106395. /**
  106396. * Observable raised right before entering VR.
  106397. */
  106398. onEnteringVRObservable: Observable<VRExperienceHelper>;
  106399. /**
  106400. * Observable raised when entering VR has completed.
  106401. */
  106402. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  106403. /**
  106404. * Observable raised when exiting VR.
  106405. */
  106406. onExitingVRObservable: Observable<VRExperienceHelper>;
  106407. /**
  106408. * Observable raised when controller mesh is loaded.
  106409. */
  106410. onControllerMeshLoadedObservable: Observable<WebVRController>;
  106411. /** Return this.onEnteringVRObservable
  106412. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  106413. */
  106414. readonly onEnteringVR: Observable<VRExperienceHelper>;
  106415. /** Return this.onExitingVRObservable
  106416. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  106417. */
  106418. readonly onExitingVR: Observable<VRExperienceHelper>;
  106419. /** Return this.onControllerMeshLoadedObservable
  106420. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  106421. */
  106422. readonly onControllerMeshLoaded: Observable<WebVRController>;
  106423. private _rayLength;
  106424. private _useCustomVRButton;
  106425. private _teleportationRequested;
  106426. private _teleportActive;
  106427. private _floorMeshName;
  106428. private _floorMeshesCollection;
  106429. private _rotationAllowed;
  106430. private _teleportBackwardsVector;
  106431. private _teleportationTarget;
  106432. private _isDefaultTeleportationTarget;
  106433. private _postProcessMove;
  106434. private _teleportationFillColor;
  106435. private _teleportationBorderColor;
  106436. private _rotationAngle;
  106437. private _haloCenter;
  106438. private _cameraGazer;
  106439. private _padSensibilityUp;
  106440. private _padSensibilityDown;
  106441. private _leftController;
  106442. private _rightController;
  106443. /**
  106444. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  106445. */
  106446. onNewMeshSelected: Observable<AbstractMesh>;
  106447. /**
  106448. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  106449. * This observable will provide the mesh and the controller used to select the mesh
  106450. */
  106451. onMeshSelectedWithController: Observable<{
  106452. mesh: AbstractMesh;
  106453. controller: WebVRController;
  106454. }>;
  106455. /**
  106456. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  106457. */
  106458. onNewMeshPicked: Observable<PickingInfo>;
  106459. private _circleEase;
  106460. /**
  106461. * Observable raised before camera teleportation
  106462. */
  106463. onBeforeCameraTeleport: Observable<Vector3>;
  106464. /**
  106465. * Observable raised after camera teleportation
  106466. */
  106467. onAfterCameraTeleport: Observable<Vector3>;
  106468. /**
  106469. * Observable raised when current selected mesh gets unselected
  106470. */
  106471. onSelectedMeshUnselected: Observable<AbstractMesh>;
  106472. private _raySelectionPredicate;
  106473. /**
  106474. * To be optionaly changed by user to define custom ray selection
  106475. */
  106476. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  106477. /**
  106478. * To be optionaly changed by user to define custom selection logic (after ray selection)
  106479. */
  106480. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  106481. /**
  106482. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  106483. */
  106484. teleportationEnabled: boolean;
  106485. private _defaultHeight;
  106486. private _teleportationInitialized;
  106487. private _interactionsEnabled;
  106488. private _interactionsRequested;
  106489. private _displayGaze;
  106490. private _displayLaserPointer;
  106491. /**
  106492. * The mesh used to display where the user is going to teleport.
  106493. */
  106494. /**
  106495. * Sets the mesh to be used to display where the user is going to teleport.
  106496. */
  106497. teleportationTarget: Mesh;
  106498. /**
  106499. * 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
  106500. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  106501. * See http://doc.babylonjs.com/resources/baking_transformations
  106502. */
  106503. gazeTrackerMesh: Mesh;
  106504. /**
  106505. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  106506. */
  106507. updateGazeTrackerScale: boolean;
  106508. /**
  106509. * If the gaze trackers color should be updated when selecting meshes
  106510. */
  106511. updateGazeTrackerColor: boolean;
  106512. /**
  106513. * The gaze tracking mesh corresponding to the left controller
  106514. */
  106515. readonly leftControllerGazeTrackerMesh: Nullable<Mesh>;
  106516. /**
  106517. * The gaze tracking mesh corresponding to the right controller
  106518. */
  106519. readonly rightControllerGazeTrackerMesh: Nullable<Mesh>;
  106520. /**
  106521. * If the ray of the gaze should be displayed.
  106522. */
  106523. /**
  106524. * Sets if the ray of the gaze should be displayed.
  106525. */
  106526. displayGaze: boolean;
  106527. /**
  106528. * If the ray of the LaserPointer should be displayed.
  106529. */
  106530. /**
  106531. * Sets if the ray of the LaserPointer should be displayed.
  106532. */
  106533. displayLaserPointer: boolean;
  106534. /**
  106535. * The deviceOrientationCamera used as the camera when not in VR.
  106536. */
  106537. readonly deviceOrientationCamera: Nullable<DeviceOrientationCamera>;
  106538. /**
  106539. * Based on the current WebVR support, returns the current VR camera used.
  106540. */
  106541. readonly currentVRCamera: Nullable<Camera>;
  106542. /**
  106543. * The webVRCamera which is used when in VR.
  106544. */
  106545. readonly webVRCamera: WebVRFreeCamera;
  106546. /**
  106547. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  106548. */
  106549. readonly vrDeviceOrientationCamera: Nullable<VRDeviceOrientationFreeCamera>;
  106550. /**
  106551. * The html button that is used to trigger entering into VR.
  106552. */
  106553. readonly vrButton: Nullable<HTMLButtonElement>;
  106554. private readonly _teleportationRequestInitiated;
  106555. /**
  106556. * Defines wether or not Pointer lock should be requested when switching to
  106557. * full screen.
  106558. */
  106559. requestPointerLockOnFullScreen: boolean;
  106560. /**
  106561. * Instantiates a VRExperienceHelper.
  106562. * Helps to quickly add VR support to an existing scene.
  106563. * @param scene The scene the VRExperienceHelper belongs to.
  106564. * @param webVROptions Options to modify the vr experience helper's behavior.
  106565. */
  106566. constructor(scene: Scene,
  106567. /** Options to modify the vr experience helper's behavior. */
  106568. webVROptions?: VRExperienceHelperOptions);
  106569. private _onDefaultMeshLoaded;
  106570. private _onResize;
  106571. private _onFullscreenChange;
  106572. /**
  106573. * Gets a value indicating if we are currently in VR mode.
  106574. */
  106575. readonly isInVRMode: boolean;
  106576. private onVrDisplayPresentChange;
  106577. private onVRDisplayChanged;
  106578. private moveButtonToBottomRight;
  106579. private displayVRButton;
  106580. private updateButtonVisibility;
  106581. private _cachedAngularSensibility;
  106582. /**
  106583. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  106584. * Otherwise, will use the fullscreen API.
  106585. */
  106586. enterVR(): void;
  106587. /**
  106588. * Attempt to exit VR, or fullscreen.
  106589. */
  106590. exitVR(): void;
  106591. /**
  106592. * The position of the vr experience helper.
  106593. */
  106594. /**
  106595. * Sets the position of the vr experience helper.
  106596. */
  106597. position: Vector3;
  106598. /**
  106599. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  106600. */
  106601. enableInteractions(): void;
  106602. private readonly _noControllerIsActive;
  106603. private beforeRender;
  106604. private _isTeleportationFloor;
  106605. /**
  106606. * Adds a floor mesh to be used for teleportation.
  106607. * @param floorMesh the mesh to be used for teleportation.
  106608. */
  106609. addFloorMesh(floorMesh: Mesh): void;
  106610. /**
  106611. * Removes a floor mesh from being used for teleportation.
  106612. * @param floorMesh the mesh to be removed.
  106613. */
  106614. removeFloorMesh(floorMesh: Mesh): void;
  106615. /**
  106616. * Enables interactions and teleportation using the VR controllers and gaze.
  106617. * @param vrTeleportationOptions options to modify teleportation behavior.
  106618. */
  106619. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  106620. private _onNewGamepadConnected;
  106621. private _tryEnableInteractionOnController;
  106622. private _onNewGamepadDisconnected;
  106623. private _enableInteractionOnController;
  106624. private _checkTeleportWithRay;
  106625. private _checkRotate;
  106626. private _checkTeleportBackwards;
  106627. private _enableTeleportationOnController;
  106628. private _createTeleportationCircles;
  106629. private _displayTeleportationTarget;
  106630. private _hideTeleportationTarget;
  106631. private _rotateCamera;
  106632. private _moveTeleportationSelectorTo;
  106633. private _workingVector;
  106634. private _workingQuaternion;
  106635. private _workingMatrix;
  106636. /**
  106637. * Teleports the users feet to the desired location
  106638. * @param location The location where the user's feet should be placed
  106639. */
  106640. teleportCamera(location: Vector3): void;
  106641. private _convertNormalToDirectionOfRay;
  106642. private _castRayAndSelectObject;
  106643. private _notifySelectedMeshUnselected;
  106644. /**
  106645. * Sets the color of the laser ray from the vr controllers.
  106646. * @param color new color for the ray.
  106647. */
  106648. changeLaserColor(color: Color3): void;
  106649. /**
  106650. * Sets the color of the ray from the vr headsets gaze.
  106651. * @param color new color for the ray.
  106652. */
  106653. changeGazeColor(color: Color3): void;
  106654. /**
  106655. * Exits VR and disposes of the vr experience helper
  106656. */
  106657. dispose(): void;
  106658. /**
  106659. * Gets the name of the VRExperienceHelper class
  106660. * @returns "VRExperienceHelper"
  106661. */
  106662. getClassName(): string;
  106663. }
  106664. }
  106665. declare module BABYLON {
  106666. /**
  106667. * Manages an XRSession to work with Babylon's engine
  106668. * @see https://doc.babylonjs.com/how_to/webxr
  106669. */
  106670. export class WebXRSessionManager implements IDisposable {
  106671. private scene;
  106672. /**
  106673. * Fires every time a new xrFrame arrives which can be used to update the camera
  106674. */
  106675. onXRFrameObservable: Observable<any>;
  106676. /**
  106677. * Fires when the xr session is ended either by the device or manually done
  106678. */
  106679. onXRSessionEnded: Observable<any>;
  106680. /**
  106681. * Underlying xr session
  106682. */
  106683. session: XRSession;
  106684. /**
  106685. * Type of reference space used when creating the session
  106686. */
  106687. referenceSpace: XRReferenceSpace;
  106688. /** @hidden */
  106689. _sessionRenderTargetTexture: Nullable<RenderTargetTexture>;
  106690. /**
  106691. * Current XR frame
  106692. */
  106693. currentFrame: Nullable<XRFrame>;
  106694. private _xrNavigator;
  106695. private baseLayer;
  106696. /**
  106697. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  106698. * @param scene The scene which the session should be created for
  106699. */
  106700. constructor(scene: Scene);
  106701. /**
  106702. * Initializes the manager
  106703. * After initialization enterXR can be called to start an XR session
  106704. * @returns Promise which resolves after it is initialized
  106705. */
  106706. initializeAsync(): Promise<void>;
  106707. /**
  106708. * Initializes an xr session
  106709. * @param xrSessionMode mode to initialize
  106710. * @returns a promise which will resolve once the session has been initialized
  106711. */
  106712. initializeSessionAsync(xrSessionMode: XRSessionMode): any;
  106713. /**
  106714. * Sets the reference space on the xr session
  106715. * @param referenceSpace space to set
  106716. * @returns a promise that will resolve once the reference space has been set
  106717. */
  106718. setReferenceSpaceAsync(referenceSpace: XRReferenceSpaceType): Promise<void>;
  106719. /**
  106720. * Updates the render state of the session
  106721. * @param state state to set
  106722. * @returns a promise that resolves once the render state has been updated
  106723. */
  106724. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  106725. /**
  106726. * Starts rendering to the xr layer
  106727. * @returns a promise that will resolve once rendering has started
  106728. */
  106729. startRenderingToXRAsync(): Promise<void>;
  106730. /**
  106731. * Stops the xrSession and restores the renderloop
  106732. * @returns Promise which resolves after it exits XR
  106733. */
  106734. exitXRAsync(): Promise<unknown>;
  106735. /**
  106736. * Checks if a session would be supported for the creation options specified
  106737. * @param sessionMode session mode to check if supported eg. immersive-vr
  106738. * @returns true if supported
  106739. */
  106740. supportsSessionAsync(sessionMode: XRSessionMode): any;
  106741. /**
  106742. * @hidden
  106743. * Converts the render layer of xrSession to a render target
  106744. * @param session session to create render target for
  106745. * @param scene scene the new render target should be created for
  106746. */
  106747. static _CreateRenderTargetTextureFromSession(session: XRSession, scene: Scene, baseLayer: XRWebGLLayer): RenderTargetTexture;
  106748. /**
  106749. * Disposes of the session manager
  106750. */
  106751. dispose(): void;
  106752. }
  106753. }
  106754. declare module BABYLON {
  106755. /**
  106756. * WebXR Camera which holds the views for the xrSession
  106757. * @see https://doc.babylonjs.com/how_to/webxr
  106758. */
  106759. export class WebXRCamera extends FreeCamera {
  106760. private static _TmpMatrix;
  106761. /**
  106762. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  106763. * @param name the name of the camera
  106764. * @param scene the scene to add the camera to
  106765. */
  106766. constructor(name: string, scene: Scene);
  106767. private _updateNumberOfRigCameras;
  106768. /** @hidden */
  106769. _updateForDualEyeDebugging(pupilDistance?: number): void;
  106770. /**
  106771. * Updates the cameras position from the current pose information of the XR session
  106772. * @param xrSessionManager the session containing pose information
  106773. * @returns true if the camera has been updated, false if the session did not contain pose or frame data
  106774. */
  106775. updateFromXRSessionManager(xrSessionManager: WebXRSessionManager): boolean;
  106776. }
  106777. }
  106778. declare module BABYLON {
  106779. /**
  106780. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  106781. */
  106782. export class WebXRManagedOutputCanvas implements IDisposable {
  106783. private helper;
  106784. private _canvas;
  106785. /**
  106786. * xrpresent context of the canvas which can be used to display/mirror xr content
  106787. */
  106788. canvasContext: WebGLRenderingContext;
  106789. /**
  106790. * xr layer for the canvas
  106791. */
  106792. xrLayer: Nullable<XRWebGLLayer>;
  106793. /**
  106794. * Initializes the xr layer for the session
  106795. * @param xrSession xr session
  106796. * @returns a promise that will resolve once the XR Layer has been created
  106797. */
  106798. initializeXRLayerAsync(xrSession: any): any;
  106799. /**
  106800. * Initializes the canvas to be added/removed upon entering/exiting xr
  106801. * @param helper the xr experience helper used to trigger adding/removing of the canvas
  106802. * @param canvas The canvas to be added/removed (If not specified a full screen canvas will be created)
  106803. */
  106804. constructor(helper: WebXRExperienceHelper, canvas?: HTMLCanvasElement);
  106805. /**
  106806. * Disposes of the object
  106807. */
  106808. dispose(): void;
  106809. private _setManagedOutputCanvas;
  106810. private _addCanvas;
  106811. private _removeCanvas;
  106812. }
  106813. }
  106814. declare module BABYLON {
  106815. /**
  106816. * States of the webXR experience
  106817. */
  106818. export enum WebXRState {
  106819. /**
  106820. * Transitioning to being in XR mode
  106821. */
  106822. ENTERING_XR = 0,
  106823. /**
  106824. * Transitioning to non XR mode
  106825. */
  106826. EXITING_XR = 1,
  106827. /**
  106828. * In XR mode and presenting
  106829. */
  106830. IN_XR = 2,
  106831. /**
  106832. * Not entered XR mode
  106833. */
  106834. NOT_IN_XR = 3
  106835. }
  106836. /**
  106837. * Base set of functionality needed to create an XR experince (WebXRSessionManager, Camera, StateManagement, etc.)
  106838. * @see https://doc.babylonjs.com/how_to/webxr
  106839. */
  106840. export class WebXRExperienceHelper implements IDisposable {
  106841. private scene;
  106842. /**
  106843. * 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
  106844. */
  106845. container: AbstractMesh;
  106846. /**
  106847. * Camera used to render xr content
  106848. */
  106849. camera: WebXRCamera;
  106850. /**
  106851. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  106852. */
  106853. state: WebXRState;
  106854. private _setState;
  106855. private static _TmpVector;
  106856. /**
  106857. * Fires when the state of the experience helper has changed
  106858. */
  106859. onStateChangedObservable: Observable<WebXRState>;
  106860. /** Session manager used to keep track of xr session */
  106861. sessionManager: WebXRSessionManager;
  106862. private _nonVRCamera;
  106863. private _originalSceneAutoClear;
  106864. private _supported;
  106865. /**
  106866. * Creates the experience helper
  106867. * @param scene the scene to attach the experience helper to
  106868. * @returns a promise for the experience helper
  106869. */
  106870. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  106871. /**
  106872. * Creates a WebXRExperienceHelper
  106873. * @param scene The scene the helper should be created in
  106874. */
  106875. private constructor();
  106876. /**
  106877. * Exits XR mode and returns the scene to its original state
  106878. * @returns promise that resolves after xr mode has exited
  106879. */
  106880. exitXRAsync(): Promise<unknown>;
  106881. /**
  106882. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  106883. * @param sessionCreationOptions options for the XR session
  106884. * @param referenceSpaceType frame of reference of the XR session
  106885. * @param outputCanvas the output canvas that will be used to enter XR mode
  106886. * @returns promise that resolves after xr mode has entered
  106887. */
  106888. enterXRAsync(sessionCreationOptions: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, outputCanvas: WebXRManagedOutputCanvas): any;
  106889. /**
  106890. * Updates the global position of the camera by moving the camera's container
  106891. * This should be used instead of modifying the camera's position as it will be overwritten by an xrSessions's update frame
  106892. * @param position The desired global position of the camera
  106893. */
  106894. setPositionOfCameraUsingContainer(position: Vector3): void;
  106895. /**
  106896. * Rotates the xr camera by rotating the camera's container around the camera's position
  106897. * This should be used instead of modifying the camera's rotation as it will be overwritten by an xrSessions's update frame
  106898. * @param rotation the desired quaternion rotation to apply to the camera
  106899. */
  106900. rotateCameraByQuaternionUsingContainer(rotation: Quaternion): void;
  106901. /**
  106902. * Disposes of the experience helper
  106903. */
  106904. dispose(): void;
  106905. }
  106906. }
  106907. declare module BABYLON {
  106908. /**
  106909. * Button which can be used to enter a different mode of XR
  106910. */
  106911. export class WebXREnterExitUIButton {
  106912. /** button element */
  106913. element: HTMLElement;
  106914. /** XR initialization options for the button */
  106915. sessionMode: XRSessionMode;
  106916. /** Reference space type */
  106917. referenceSpaceType: XRReferenceSpaceType;
  106918. /**
  106919. * Creates a WebXREnterExitUIButton
  106920. * @param element button element
  106921. * @param sessionMode XR initialization session mode
  106922. * @param referenceSpaceType the type of reference space to be used
  106923. */
  106924. constructor(
  106925. /** button element */
  106926. element: HTMLElement,
  106927. /** XR initialization options for the button */
  106928. sessionMode: XRSessionMode,
  106929. /** Reference space type */
  106930. referenceSpaceType: XRReferenceSpaceType);
  106931. /**
  106932. * Overwritable function which can be used to update the button's visuals when the state changes
  106933. * @param activeButton the current active button in the UI
  106934. */
  106935. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  106936. }
  106937. /**
  106938. * Options to create the webXR UI
  106939. */
  106940. export class WebXREnterExitUIOptions {
  106941. /**
  106942. * Context to enter xr with
  106943. */
  106944. webXRManagedOutputCanvas?: Nullable<WebXRManagedOutputCanvas>;
  106945. /**
  106946. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  106947. */
  106948. customButtons?: Array<WebXREnterExitUIButton>;
  106949. }
  106950. /**
  106951. * UI to allow the user to enter/exit XR mode
  106952. */
  106953. export class WebXREnterExitUI implements IDisposable {
  106954. private scene;
  106955. private _overlay;
  106956. private _buttons;
  106957. private _activeButton;
  106958. /**
  106959. * Fired every time the active button is changed.
  106960. *
  106961. * When xr is entered via a button that launches xr that button will be the callback parameter
  106962. *
  106963. * When exiting xr the callback parameter will be null)
  106964. */
  106965. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  106966. /**
  106967. * Creates UI to allow the user to enter/exit XR mode
  106968. * @param scene the scene to add the ui to
  106969. * @param helper the xr experience helper to enter/exit xr with
  106970. * @param options options to configure the UI
  106971. * @returns the created ui
  106972. */
  106973. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  106974. private constructor();
  106975. private _updateButtons;
  106976. /**
  106977. * Disposes of the object
  106978. */
  106979. dispose(): void;
  106980. }
  106981. }
  106982. declare module BABYLON {
  106983. /**
  106984. * Represents an XR input
  106985. */
  106986. export class WebXRController {
  106987. private scene;
  106988. /** The underlying input source for the controller */
  106989. inputSource: XRInputSource;
  106990. private parentContainer;
  106991. /**
  106992. * 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
  106993. */
  106994. grip?: AbstractMesh;
  106995. /**
  106996. * Pointer which can be used to select objects or attach a visible laser to
  106997. */
  106998. pointer: AbstractMesh;
  106999. /**
  107000. * Event that fires when the controller is removed/disposed
  107001. */
  107002. onDisposeObservable: Observable<{}>;
  107003. private _tmpMatrix;
  107004. private _tmpQuaternion;
  107005. private _tmpVector;
  107006. /**
  107007. * Creates the controller
  107008. * @see https://doc.babylonjs.com/how_to/webxr
  107009. * @param scene the scene which the controller should be associated to
  107010. * @param inputSource the underlying input source for the controller
  107011. * @param parentContainer parent that the controller meshes should be children of
  107012. */
  107013. constructor(scene: Scene,
  107014. /** The underlying input source for the controller */
  107015. inputSource: XRInputSource, parentContainer?: Nullable<AbstractMesh>);
  107016. /**
  107017. * Updates the controller pose based on the given XRFrame
  107018. * @param xrFrame xr frame to update the pose with
  107019. * @param referenceSpace reference space to use
  107020. */
  107021. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  107022. /**
  107023. * Gets a world space ray coming from the controller
  107024. * @param result the resulting ray
  107025. */
  107026. getWorldPointerRayToRef(result: Ray): void;
  107027. /**
  107028. * Disposes of the object
  107029. */
  107030. dispose(): void;
  107031. }
  107032. }
  107033. declare module BABYLON {
  107034. /**
  107035. * XR input used to track XR inputs such as controllers/rays
  107036. */
  107037. export class WebXRInput implements IDisposable {
  107038. /**
  107039. * Base experience the input listens to
  107040. */
  107041. baseExperience: WebXRExperienceHelper;
  107042. /**
  107043. * XR controllers being tracked
  107044. */
  107045. controllers: Array<WebXRController>;
  107046. private _frameObserver;
  107047. private _stateObserver;
  107048. /**
  107049. * Event when a controller has been connected/added
  107050. */
  107051. onControllerAddedObservable: Observable<WebXRController>;
  107052. /**
  107053. * Event when a controller has been removed/disconnected
  107054. */
  107055. onControllerRemovedObservable: Observable<WebXRController>;
  107056. /**
  107057. * Initializes the WebXRInput
  107058. * @param baseExperience experience helper which the input should be created for
  107059. */
  107060. constructor(
  107061. /**
  107062. * Base experience the input listens to
  107063. */
  107064. baseExperience: WebXRExperienceHelper);
  107065. private _onInputSourcesChange;
  107066. private _addAndRemoveControllers;
  107067. /**
  107068. * Disposes of the object
  107069. */
  107070. dispose(): void;
  107071. }
  107072. }
  107073. declare module BABYLON {
  107074. /**
  107075. * Enables teleportation
  107076. */
  107077. export class WebXRControllerTeleportation {
  107078. private _teleportationFillColor;
  107079. private _teleportationBorderColor;
  107080. private _tmpRay;
  107081. private _tmpVector;
  107082. /**
  107083. * Creates a WebXRControllerTeleportation
  107084. * @param input input manager to add teleportation to
  107085. * @param floorMeshes floormeshes which can be teleported to
  107086. */
  107087. constructor(input: WebXRInput, floorMeshes?: Array<AbstractMesh>);
  107088. }
  107089. }
  107090. declare module BABYLON {
  107091. /**
  107092. * Handles pointer input automatically for the pointer of XR controllers
  107093. */
  107094. export class WebXRControllerPointerSelection {
  107095. private static _idCounter;
  107096. private _tmpRay;
  107097. /**
  107098. * Creates a WebXRControllerPointerSelection
  107099. * @param input input manager to setup pointer selection
  107100. */
  107101. constructor(input: WebXRInput);
  107102. private _convertNormalToDirectionOfRay;
  107103. private _updatePointerDistance;
  107104. }
  107105. }
  107106. declare module BABYLON {
  107107. /**
  107108. * Class used to represent data loading progression
  107109. */
  107110. export class SceneLoaderProgressEvent {
  107111. /** defines if data length to load can be evaluated */
  107112. readonly lengthComputable: boolean;
  107113. /** defines the loaded data length */
  107114. readonly loaded: number;
  107115. /** defines the data length to load */
  107116. readonly total: number;
  107117. /**
  107118. * Create a new progress event
  107119. * @param lengthComputable defines if data length to load can be evaluated
  107120. * @param loaded defines the loaded data length
  107121. * @param total defines the data length to load
  107122. */
  107123. constructor(
  107124. /** defines if data length to load can be evaluated */
  107125. lengthComputable: boolean,
  107126. /** defines the loaded data length */
  107127. loaded: number,
  107128. /** defines the data length to load */
  107129. total: number);
  107130. /**
  107131. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  107132. * @param event defines the source event
  107133. * @returns a new SceneLoaderProgressEvent
  107134. */
  107135. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  107136. }
  107137. /**
  107138. * Interface used by SceneLoader plugins to define supported file extensions
  107139. */
  107140. export interface ISceneLoaderPluginExtensions {
  107141. /**
  107142. * Defines the list of supported extensions
  107143. */
  107144. [extension: string]: {
  107145. isBinary: boolean;
  107146. };
  107147. }
  107148. /**
  107149. * Interface used by SceneLoader plugin factory
  107150. */
  107151. export interface ISceneLoaderPluginFactory {
  107152. /**
  107153. * Defines the name of the factory
  107154. */
  107155. name: string;
  107156. /**
  107157. * Function called to create a new plugin
  107158. * @return the new plugin
  107159. */
  107160. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  107161. /**
  107162. * Boolean indicating if the plugin can direct load specific data
  107163. */
  107164. canDirectLoad?: (data: string) => boolean;
  107165. }
  107166. /**
  107167. * Interface used to define a SceneLoader plugin
  107168. */
  107169. export interface ISceneLoaderPlugin {
  107170. /**
  107171. * The friendly name of this plugin.
  107172. */
  107173. name: string;
  107174. /**
  107175. * The file extensions supported by this plugin.
  107176. */
  107177. extensions: string | ISceneLoaderPluginExtensions;
  107178. /**
  107179. * Import meshes into a scene.
  107180. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  107181. * @param scene The scene to import into
  107182. * @param data The data to import
  107183. * @param rootUrl The root url for scene and resources
  107184. * @param meshes The meshes array to import into
  107185. * @param particleSystems The particle systems array to import into
  107186. * @param skeletons The skeletons array to import into
  107187. * @param onError The callback when import fails
  107188. * @returns True if successful or false otherwise
  107189. */
  107190. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  107191. /**
  107192. * Load into a scene.
  107193. * @param scene The scene to load into
  107194. * @param data The data to import
  107195. * @param rootUrl The root url for scene and resources
  107196. * @param onError The callback when import fails
  107197. * @returns true if successful or false otherwise
  107198. */
  107199. load(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  107200. /**
  107201. * The callback that returns true if the data can be directly loaded.
  107202. */
  107203. canDirectLoad?: (data: string) => boolean;
  107204. /**
  107205. * The callback that allows custom handling of the root url based on the response url.
  107206. */
  107207. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  107208. /**
  107209. * Load into an asset container.
  107210. * @param scene The scene to load into
  107211. * @param data The data to import
  107212. * @param rootUrl The root url for scene and resources
  107213. * @param onError The callback when import fails
  107214. * @returns The loaded asset container
  107215. */
  107216. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  107217. }
  107218. /**
  107219. * Interface used to define an async SceneLoader plugin
  107220. */
  107221. export interface ISceneLoaderPluginAsync {
  107222. /**
  107223. * The friendly name of this plugin.
  107224. */
  107225. name: string;
  107226. /**
  107227. * The file extensions supported by this plugin.
  107228. */
  107229. extensions: string | ISceneLoaderPluginExtensions;
  107230. /**
  107231. * Import meshes into a scene.
  107232. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  107233. * @param scene The scene to import into
  107234. * @param data The data to import
  107235. * @param rootUrl The root url for scene and resources
  107236. * @param onProgress The callback when the load progresses
  107237. * @param fileName Defines the name of the file to load
  107238. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  107239. */
  107240. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  107241. meshes: AbstractMesh[];
  107242. particleSystems: IParticleSystem[];
  107243. skeletons: Skeleton[];
  107244. animationGroups: AnimationGroup[];
  107245. }>;
  107246. /**
  107247. * Load into a scene.
  107248. * @param scene The scene to load into
  107249. * @param data The data to import
  107250. * @param rootUrl The root url for scene and resources
  107251. * @param onProgress The callback when the load progresses
  107252. * @param fileName Defines the name of the file to load
  107253. * @returns Nothing
  107254. */
  107255. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  107256. /**
  107257. * The callback that returns true if the data can be directly loaded.
  107258. */
  107259. canDirectLoad?: (data: string) => boolean;
  107260. /**
  107261. * The callback that allows custom handling of the root url based on the response url.
  107262. */
  107263. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  107264. /**
  107265. * Load into an asset container.
  107266. * @param scene The scene to load into
  107267. * @param data The data to import
  107268. * @param rootUrl The root url for scene and resources
  107269. * @param onProgress The callback when the load progresses
  107270. * @param fileName Defines the name of the file to load
  107271. * @returns The loaded asset container
  107272. */
  107273. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  107274. }
  107275. /**
  107276. * Class used to load scene from various file formats using registered plugins
  107277. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  107278. */
  107279. export class SceneLoader {
  107280. /**
  107281. * No logging while loading
  107282. */
  107283. static readonly NO_LOGGING: number;
  107284. /**
  107285. * Minimal logging while loading
  107286. */
  107287. static readonly MINIMAL_LOGGING: number;
  107288. /**
  107289. * Summary logging while loading
  107290. */
  107291. static readonly SUMMARY_LOGGING: number;
  107292. /**
  107293. * Detailled logging while loading
  107294. */
  107295. static readonly DETAILED_LOGGING: number;
  107296. /**
  107297. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  107298. */
  107299. static ForceFullSceneLoadingForIncremental: boolean;
  107300. /**
  107301. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  107302. */
  107303. static ShowLoadingScreen: boolean;
  107304. /**
  107305. * Defines the current logging level (while loading the scene)
  107306. * @ignorenaming
  107307. */
  107308. static loggingLevel: number;
  107309. /**
  107310. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  107311. */
  107312. static CleanBoneMatrixWeights: boolean;
  107313. /**
  107314. * Event raised when a plugin is used to load a scene
  107315. */
  107316. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  107317. private static _registeredPlugins;
  107318. private static _getDefaultPlugin;
  107319. private static _getPluginForExtension;
  107320. private static _getPluginForDirectLoad;
  107321. private static _getPluginForFilename;
  107322. private static _getDirectLoad;
  107323. private static _loadData;
  107324. private static _getFileInfo;
  107325. /**
  107326. * Gets a plugin that can load the given extension
  107327. * @param extension defines the extension to load
  107328. * @returns a plugin or null if none works
  107329. */
  107330. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  107331. /**
  107332. * Gets a boolean indicating that the given extension can be loaded
  107333. * @param extension defines the extension to load
  107334. * @returns true if the extension is supported
  107335. */
  107336. static IsPluginForExtensionAvailable(extension: string): boolean;
  107337. /**
  107338. * Adds a new plugin to the list of registered plugins
  107339. * @param plugin defines the plugin to add
  107340. */
  107341. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  107342. /**
  107343. * Import meshes into a scene
  107344. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  107345. * @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)
  107346. * @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)
  107347. * @param scene the instance of BABYLON.Scene to append to
  107348. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  107349. * @param onProgress a callback with a progress event for each file being loaded
  107350. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  107351. * @param pluginExtension the extension used to determine the plugin
  107352. * @returns The loaded plugin
  107353. */
  107354. 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>;
  107355. /**
  107356. * Import meshes into a scene
  107357. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  107358. * @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)
  107359. * @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)
  107360. * @param scene the instance of BABYLON.Scene to append to
  107361. * @param onProgress a callback with a progress event for each file being loaded
  107362. * @param pluginExtension the extension used to determine the plugin
  107363. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  107364. */
  107365. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  107366. meshes: AbstractMesh[];
  107367. particleSystems: IParticleSystem[];
  107368. skeletons: Skeleton[];
  107369. animationGroups: AnimationGroup[];
  107370. }>;
  107371. /**
  107372. * Load a scene
  107373. * @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)
  107374. * @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)
  107375. * @param engine is the instance of BABYLON.Engine to use to create the scene
  107376. * @param onSuccess a callback with the scene when import succeeds
  107377. * @param onProgress a callback with a progress event for each file being loaded
  107378. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  107379. * @param pluginExtension the extension used to determine the plugin
  107380. * @returns The loaded plugin
  107381. */
  107382. 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>;
  107383. /**
  107384. * Load a scene
  107385. * @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)
  107386. * @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)
  107387. * @param engine is the instance of BABYLON.Engine to use to create the scene
  107388. * @param onProgress a callback with a progress event for each file being loaded
  107389. * @param pluginExtension the extension used to determine the plugin
  107390. * @returns The loaded scene
  107391. */
  107392. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  107393. /**
  107394. * Append a scene
  107395. * @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)
  107396. * @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)
  107397. * @param scene is the instance of BABYLON.Scene to append to
  107398. * @param onSuccess a callback with the scene when import succeeds
  107399. * @param onProgress a callback with a progress event for each file being loaded
  107400. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  107401. * @param pluginExtension the extension used to determine the plugin
  107402. * @returns The loaded plugin
  107403. */
  107404. 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>;
  107405. /**
  107406. * Append a scene
  107407. * @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)
  107408. * @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)
  107409. * @param scene is the instance of BABYLON.Scene to append to
  107410. * @param onProgress a callback with a progress event for each file being loaded
  107411. * @param pluginExtension the extension used to determine the plugin
  107412. * @returns The given scene
  107413. */
  107414. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  107415. /**
  107416. * Load a scene into an asset container
  107417. * @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)
  107418. * @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)
  107419. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  107420. * @param onSuccess a callback with the scene when import succeeds
  107421. * @param onProgress a callback with a progress event for each file being loaded
  107422. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  107423. * @param pluginExtension the extension used to determine the plugin
  107424. * @returns The loaded plugin
  107425. */
  107426. 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>;
  107427. /**
  107428. * Load a scene into an asset container
  107429. * @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)
  107430. * @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)
  107431. * @param scene is the instance of Scene to append to
  107432. * @param onProgress a callback with a progress event for each file being loaded
  107433. * @param pluginExtension the extension used to determine the plugin
  107434. * @returns The loaded asset container
  107435. */
  107436. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  107437. }
  107438. }
  107439. declare module BABYLON {
  107440. /**
  107441. * Generic Controller
  107442. */
  107443. export class GenericController extends WebVRController {
  107444. /**
  107445. * Base Url for the controller model.
  107446. */
  107447. static readonly MODEL_BASE_URL: string;
  107448. /**
  107449. * File name for the controller model.
  107450. */
  107451. static readonly MODEL_FILENAME: string;
  107452. /**
  107453. * Creates a new GenericController from a gamepad
  107454. * @param vrGamepad the gamepad that the controller should be created from
  107455. */
  107456. constructor(vrGamepad: any);
  107457. /**
  107458. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  107459. * @param scene scene in which to add meshes
  107460. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  107461. */
  107462. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  107463. /**
  107464. * Called once for each button that changed state since the last frame
  107465. * @param buttonIdx Which button index changed
  107466. * @param state New state of the button
  107467. * @param changes Which properties on the state changed since last frame
  107468. */
  107469. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  107470. }
  107471. }
  107472. declare module BABYLON {
  107473. /**
  107474. * Defines the WindowsMotionController object that the state of the windows motion controller
  107475. */
  107476. export class WindowsMotionController extends WebVRController {
  107477. /**
  107478. * The base url used to load the left and right controller models
  107479. */
  107480. static MODEL_BASE_URL: string;
  107481. /**
  107482. * The name of the left controller model file
  107483. */
  107484. static MODEL_LEFT_FILENAME: string;
  107485. /**
  107486. * The name of the right controller model file
  107487. */
  107488. static MODEL_RIGHT_FILENAME: string;
  107489. /**
  107490. * The controller name prefix for this controller type
  107491. */
  107492. static readonly GAMEPAD_ID_PREFIX: string;
  107493. /**
  107494. * The controller id pattern for this controller type
  107495. */
  107496. private static readonly GAMEPAD_ID_PATTERN;
  107497. private _loadedMeshInfo;
  107498. private readonly _mapping;
  107499. /**
  107500. * Fired when the trackpad on this controller is clicked
  107501. */
  107502. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  107503. /**
  107504. * Fired when the trackpad on this controller is modified
  107505. */
  107506. onTrackpadValuesChangedObservable: Observable<StickValues>;
  107507. /**
  107508. * The current x and y values of this controller's trackpad
  107509. */
  107510. trackpad: StickValues;
  107511. /**
  107512. * Creates a new WindowsMotionController from a gamepad
  107513. * @param vrGamepad the gamepad that the controller should be created from
  107514. */
  107515. constructor(vrGamepad: any);
  107516. /**
  107517. * Fired when the trigger on this controller is modified
  107518. */
  107519. readonly onTriggerButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  107520. /**
  107521. * Fired when the menu button on this controller is modified
  107522. */
  107523. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  107524. /**
  107525. * Fired when the grip button on this controller is modified
  107526. */
  107527. readonly onGripButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  107528. /**
  107529. * Fired when the thumbstick button on this controller is modified
  107530. */
  107531. readonly onThumbstickButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  107532. /**
  107533. * Fired when the touchpad button on this controller is modified
  107534. */
  107535. readonly onTouchpadButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  107536. /**
  107537. * Fired when the touchpad values on this controller are modified
  107538. */
  107539. readonly onTouchpadValuesChangedObservable: Observable<StickValues>;
  107540. private _updateTrackpad;
  107541. /**
  107542. * Called once per frame by the engine.
  107543. */
  107544. update(): void;
  107545. /**
  107546. * Called once for each button that changed state since the last frame
  107547. * @param buttonIdx Which button index changed
  107548. * @param state New state of the button
  107549. * @param changes Which properties on the state changed since last frame
  107550. */
  107551. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  107552. /**
  107553. * Moves the buttons on the controller mesh based on their current state
  107554. * @param buttonName the name of the button to move
  107555. * @param buttonValue the value of the button which determines the buttons new position
  107556. */
  107557. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  107558. /**
  107559. * Moves the axis on the controller mesh based on its current state
  107560. * @param axis the index of the axis
  107561. * @param axisValue the value of the axis which determines the meshes new position
  107562. * @hidden
  107563. */
  107564. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  107565. /**
  107566. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  107567. * @param scene scene in which to add meshes
  107568. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  107569. */
  107570. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  107571. /**
  107572. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  107573. * can be transformed by button presses and axes values, based on this._mapping.
  107574. *
  107575. * @param scene scene in which the meshes exist
  107576. * @param meshes list of meshes that make up the controller model to process
  107577. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  107578. */
  107579. private processModel;
  107580. private createMeshInfo;
  107581. /**
  107582. * Gets the ray of the controller in the direction the controller is pointing
  107583. * @param length the length the resulting ray should be
  107584. * @returns a ray in the direction the controller is pointing
  107585. */
  107586. getForwardRay(length?: number): Ray;
  107587. /**
  107588. * Disposes of the controller
  107589. */
  107590. dispose(): void;
  107591. }
  107592. }
  107593. declare module BABYLON {
  107594. /**
  107595. * Oculus Touch Controller
  107596. */
  107597. export class OculusTouchController extends WebVRController {
  107598. /**
  107599. * Base Url for the controller model.
  107600. */
  107601. static MODEL_BASE_URL: string;
  107602. /**
  107603. * File name for the left controller model.
  107604. */
  107605. static MODEL_LEFT_FILENAME: string;
  107606. /**
  107607. * File name for the right controller model.
  107608. */
  107609. static MODEL_RIGHT_FILENAME: string;
  107610. /**
  107611. * Base Url for the Quest controller model.
  107612. */
  107613. static QUEST_MODEL_BASE_URL: string;
  107614. /**
  107615. * @hidden
  107616. * If the controllers are running on a device that needs the updated Quest controller models
  107617. */
  107618. static _IsQuest: boolean;
  107619. /**
  107620. * Fired when the secondary trigger on this controller is modified
  107621. */
  107622. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  107623. /**
  107624. * Fired when the thumb rest on this controller is modified
  107625. */
  107626. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  107627. /**
  107628. * Creates a new OculusTouchController from a gamepad
  107629. * @param vrGamepad the gamepad that the controller should be created from
  107630. */
  107631. constructor(vrGamepad: any);
  107632. /**
  107633. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  107634. * @param scene scene in which to add meshes
  107635. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  107636. */
  107637. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  107638. /**
  107639. * Fired when the A button on this controller is modified
  107640. */
  107641. readonly onAButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  107642. /**
  107643. * Fired when the B button on this controller is modified
  107644. */
  107645. readonly onBButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  107646. /**
  107647. * Fired when the X button on this controller is modified
  107648. */
  107649. readonly onXButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  107650. /**
  107651. * Fired when the Y button on this controller is modified
  107652. */
  107653. readonly onYButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  107654. /**
  107655. * Called once for each button that changed state since the last frame
  107656. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  107657. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  107658. * 2) secondary trigger (same)
  107659. * 3) A (right) X (left), touch, pressed = value
  107660. * 4) B / Y
  107661. * 5) thumb rest
  107662. * @param buttonIdx Which button index changed
  107663. * @param state New state of the button
  107664. * @param changes Which properties on the state changed since last frame
  107665. */
  107666. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  107667. }
  107668. }
  107669. declare module BABYLON {
  107670. /**
  107671. * Vive Controller
  107672. */
  107673. export class ViveController extends WebVRController {
  107674. /**
  107675. * Base Url for the controller model.
  107676. */
  107677. static MODEL_BASE_URL: string;
  107678. /**
  107679. * File name for the controller model.
  107680. */
  107681. static MODEL_FILENAME: string;
  107682. /**
  107683. * Creates a new ViveController from a gamepad
  107684. * @param vrGamepad the gamepad that the controller should be created from
  107685. */
  107686. constructor(vrGamepad: any);
  107687. /**
  107688. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  107689. * @param scene scene in which to add meshes
  107690. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  107691. */
  107692. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  107693. /**
  107694. * Fired when the left button on this controller is modified
  107695. */
  107696. readonly onLeftButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  107697. /**
  107698. * Fired when the right button on this controller is modified
  107699. */
  107700. readonly onRightButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  107701. /**
  107702. * Fired when the menu button on this controller is modified
  107703. */
  107704. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  107705. /**
  107706. * Called once for each button that changed state since the last frame
  107707. * Vive mapping:
  107708. * 0: touchpad
  107709. * 1: trigger
  107710. * 2: left AND right buttons
  107711. * 3: menu button
  107712. * @param buttonIdx Which button index changed
  107713. * @param state New state of the button
  107714. * @param changes Which properties on the state changed since last frame
  107715. */
  107716. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  107717. }
  107718. }
  107719. declare module BABYLON {
  107720. /**
  107721. * Loads a controller model and adds it as a child of the WebXRControllers grip when the controller is created
  107722. */
  107723. export class WebXRControllerModelLoader {
  107724. /**
  107725. * Creates the WebXRControllerModelLoader
  107726. * @param input xr input that creates the controllers
  107727. */
  107728. constructor(input: WebXRInput);
  107729. }
  107730. }
  107731. declare module BABYLON {
  107732. /**
  107733. * Contains an array of blocks representing the octree
  107734. */
  107735. export interface IOctreeContainer<T> {
  107736. /**
  107737. * Blocks within the octree
  107738. */
  107739. blocks: Array<OctreeBlock<T>>;
  107740. }
  107741. /**
  107742. * Class used to store a cell in an octree
  107743. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  107744. */
  107745. export class OctreeBlock<T> {
  107746. /**
  107747. * Gets the content of the current block
  107748. */
  107749. entries: T[];
  107750. /**
  107751. * Gets the list of block children
  107752. */
  107753. blocks: Array<OctreeBlock<T>>;
  107754. private _depth;
  107755. private _maxDepth;
  107756. private _capacity;
  107757. private _minPoint;
  107758. private _maxPoint;
  107759. private _boundingVectors;
  107760. private _creationFunc;
  107761. /**
  107762. * Creates a new block
  107763. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  107764. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  107765. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  107766. * @param depth defines the current depth of this block in the octree
  107767. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  107768. * @param creationFunc defines a callback to call when an element is added to the block
  107769. */
  107770. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  107771. /**
  107772. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  107773. */
  107774. readonly capacity: number;
  107775. /**
  107776. * Gets the minimum vector (in world space) of the block's bounding box
  107777. */
  107778. readonly minPoint: Vector3;
  107779. /**
  107780. * Gets the maximum vector (in world space) of the block's bounding box
  107781. */
  107782. readonly maxPoint: Vector3;
  107783. /**
  107784. * Add a new element to this block
  107785. * @param entry defines the element to add
  107786. */
  107787. addEntry(entry: T): void;
  107788. /**
  107789. * Remove an element from this block
  107790. * @param entry defines the element to remove
  107791. */
  107792. removeEntry(entry: T): void;
  107793. /**
  107794. * Add an array of elements to this block
  107795. * @param entries defines the array of elements to add
  107796. */
  107797. addEntries(entries: T[]): void;
  107798. /**
  107799. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  107800. * @param frustumPlanes defines the frustum planes to test
  107801. * @param selection defines the array to store current content if selection is positive
  107802. * @param allowDuplicate defines if the selection array can contains duplicated entries
  107803. */
  107804. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  107805. /**
  107806. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  107807. * @param sphereCenter defines the bounding sphere center
  107808. * @param sphereRadius defines the bounding sphere radius
  107809. * @param selection defines the array to store current content if selection is positive
  107810. * @param allowDuplicate defines if the selection array can contains duplicated entries
  107811. */
  107812. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  107813. /**
  107814. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  107815. * @param ray defines the ray to test with
  107816. * @param selection defines the array to store current content if selection is positive
  107817. */
  107818. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  107819. /**
  107820. * Subdivide the content into child blocks (this block will then be empty)
  107821. */
  107822. createInnerBlocks(): void;
  107823. /**
  107824. * @hidden
  107825. */
  107826. 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;
  107827. }
  107828. }
  107829. declare module BABYLON {
  107830. /**
  107831. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  107832. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  107833. */
  107834. export class Octree<T> {
  107835. /** 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.) */
  107836. maxDepth: number;
  107837. /**
  107838. * Blocks within the octree containing objects
  107839. */
  107840. blocks: Array<OctreeBlock<T>>;
  107841. /**
  107842. * Content stored in the octree
  107843. */
  107844. dynamicContent: T[];
  107845. private _maxBlockCapacity;
  107846. private _selectionContent;
  107847. private _creationFunc;
  107848. /**
  107849. * Creates a octree
  107850. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  107851. * @param creationFunc function to be used to instatiate the octree
  107852. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  107853. * @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.)
  107854. */
  107855. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  107856. /** 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.) */
  107857. maxDepth?: number);
  107858. /**
  107859. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  107860. * @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);
  107861. * @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);
  107862. * @param entries meshes to be added to the octree blocks
  107863. */
  107864. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  107865. /**
  107866. * Adds a mesh to the octree
  107867. * @param entry Mesh to add to the octree
  107868. */
  107869. addMesh(entry: T): void;
  107870. /**
  107871. * Remove an element from the octree
  107872. * @param entry defines the element to remove
  107873. */
  107874. removeMesh(entry: T): void;
  107875. /**
  107876. * Selects an array of meshes within the frustum
  107877. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  107878. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  107879. * @returns array of meshes within the frustum
  107880. */
  107881. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  107882. /**
  107883. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  107884. * @param sphereCenter defines the bounding sphere center
  107885. * @param sphereRadius defines the bounding sphere radius
  107886. * @param allowDuplicate defines if the selection array can contains duplicated entries
  107887. * @returns an array of objects that intersect the sphere
  107888. */
  107889. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  107890. /**
  107891. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  107892. * @param ray defines the ray to test with
  107893. * @returns array of intersected objects
  107894. */
  107895. intersectsRay(ray: Ray): SmartArray<T>;
  107896. /**
  107897. * Adds a mesh into the octree block if it intersects the block
  107898. */
  107899. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  107900. /**
  107901. * Adds a submesh into the octree block if it intersects the block
  107902. */
  107903. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  107904. }
  107905. }
  107906. declare module BABYLON {
  107907. interface Scene {
  107908. /**
  107909. * @hidden
  107910. * Backing Filed
  107911. */
  107912. _selectionOctree: Octree<AbstractMesh>;
  107913. /**
  107914. * Gets the octree used to boost mesh selection (picking)
  107915. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  107916. */
  107917. selectionOctree: Octree<AbstractMesh>;
  107918. /**
  107919. * Creates or updates the octree used to boost selection (picking)
  107920. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  107921. * @param maxCapacity defines the maximum capacity per leaf
  107922. * @param maxDepth defines the maximum depth of the octree
  107923. * @returns an octree of AbstractMesh
  107924. */
  107925. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  107926. }
  107927. interface AbstractMesh {
  107928. /**
  107929. * @hidden
  107930. * Backing Field
  107931. */
  107932. _submeshesOctree: Octree<SubMesh>;
  107933. /**
  107934. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  107935. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  107936. * @param maxCapacity defines the maximum size of each block (64 by default)
  107937. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  107938. * @returns the new octree
  107939. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  107940. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  107941. */
  107942. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  107943. }
  107944. /**
  107945. * Defines the octree scene component responsible to manage any octrees
  107946. * in a given scene.
  107947. */
  107948. export class OctreeSceneComponent {
  107949. /**
  107950. * The component name help to identify the component in the list of scene components.
  107951. */
  107952. readonly name: string;
  107953. /**
  107954. * The scene the component belongs to.
  107955. */
  107956. scene: Scene;
  107957. /**
  107958. * Indicates if the meshes have been checked to make sure they are isEnabled()
  107959. */
  107960. readonly checksIsEnabled: boolean;
  107961. /**
  107962. * Creates a new instance of the component for the given scene
  107963. * @param scene Defines the scene to register the component in
  107964. */
  107965. constructor(scene: Scene);
  107966. /**
  107967. * Registers the component in a given scene
  107968. */
  107969. register(): void;
  107970. /**
  107971. * Return the list of active meshes
  107972. * @returns the list of active meshes
  107973. */
  107974. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  107975. /**
  107976. * Return the list of active sub meshes
  107977. * @param mesh The mesh to get the candidates sub meshes from
  107978. * @returns the list of active sub meshes
  107979. */
  107980. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  107981. private _tempRay;
  107982. /**
  107983. * Return the list of sub meshes intersecting with a given local ray
  107984. * @param mesh defines the mesh to find the submesh for
  107985. * @param localRay defines the ray in local space
  107986. * @returns the list of intersecting sub meshes
  107987. */
  107988. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  107989. /**
  107990. * Return the list of sub meshes colliding with a collider
  107991. * @param mesh defines the mesh to find the submesh for
  107992. * @param collider defines the collider to evaluate the collision against
  107993. * @returns the list of colliding sub meshes
  107994. */
  107995. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  107996. /**
  107997. * Rebuilds the elements related to this component in case of
  107998. * context lost for instance.
  107999. */
  108000. rebuild(): void;
  108001. /**
  108002. * Disposes the component and the associated ressources.
  108003. */
  108004. dispose(): void;
  108005. }
  108006. }
  108007. declare module BABYLON {
  108008. /**
  108009. * Renders a layer on top of an existing scene
  108010. */
  108011. export class UtilityLayerRenderer implements IDisposable {
  108012. /** the original scene that will be rendered on top of */
  108013. originalScene: Scene;
  108014. private _pointerCaptures;
  108015. private _lastPointerEvents;
  108016. private static _DefaultUtilityLayer;
  108017. private static _DefaultKeepDepthUtilityLayer;
  108018. private _sharedGizmoLight;
  108019. private _renderCamera;
  108020. /**
  108021. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  108022. * @returns the camera that is used when rendering the utility layer
  108023. */
  108024. getRenderCamera(): Nullable<Camera>;
  108025. /**
  108026. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  108027. * @param cam the camera that should be used when rendering the utility layer
  108028. */
  108029. setRenderCamera(cam: Nullable<Camera>): void;
  108030. /**
  108031. * @hidden
  108032. * Light which used by gizmos to get light shading
  108033. */
  108034. _getSharedGizmoLight(): HemisphericLight;
  108035. /**
  108036. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  108037. */
  108038. pickUtilitySceneFirst: boolean;
  108039. /**
  108040. * 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)
  108041. */
  108042. static readonly DefaultUtilityLayer: UtilityLayerRenderer;
  108043. /**
  108044. * 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)
  108045. */
  108046. static readonly DefaultKeepDepthUtilityLayer: UtilityLayerRenderer;
  108047. /**
  108048. * The scene that is rendered on top of the original scene
  108049. */
  108050. utilityLayerScene: Scene;
  108051. /**
  108052. * If the utility layer should automatically be rendered on top of existing scene
  108053. */
  108054. shouldRender: boolean;
  108055. /**
  108056. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  108057. */
  108058. onlyCheckPointerDownEvents: boolean;
  108059. /**
  108060. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  108061. */
  108062. processAllEvents: boolean;
  108063. /**
  108064. * Observable raised when the pointer move from the utility layer scene to the main scene
  108065. */
  108066. onPointerOutObservable: Observable<number>;
  108067. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  108068. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  108069. private _afterRenderObserver;
  108070. private _sceneDisposeObserver;
  108071. private _originalPointerObserver;
  108072. /**
  108073. * Instantiates a UtilityLayerRenderer
  108074. * @param originalScene the original scene that will be rendered on top of
  108075. * @param handleEvents boolean indicating if the utility layer should handle events
  108076. */
  108077. constructor(
  108078. /** the original scene that will be rendered on top of */
  108079. originalScene: Scene, handleEvents?: boolean);
  108080. private _notifyObservers;
  108081. /**
  108082. * Renders the utility layers scene on top of the original scene
  108083. */
  108084. render(): void;
  108085. /**
  108086. * Disposes of the renderer
  108087. */
  108088. dispose(): void;
  108089. private _updateCamera;
  108090. }
  108091. }
  108092. declare module BABYLON {
  108093. /**
  108094. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  108095. */
  108096. export class Gizmo implements IDisposable {
  108097. /** The utility layer the gizmo will be added to */
  108098. gizmoLayer: UtilityLayerRenderer;
  108099. /**
  108100. * The root mesh of the gizmo
  108101. */
  108102. _rootMesh: Mesh;
  108103. private _attachedMesh;
  108104. /**
  108105. * Ratio for the scale of the gizmo (Default: 1)
  108106. */
  108107. scaleRatio: number;
  108108. /**
  108109. * If a custom mesh has been set (Default: false)
  108110. */
  108111. protected _customMeshSet: boolean;
  108112. /**
  108113. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  108114. * * When set, interactions will be enabled
  108115. */
  108116. attachedMesh: Nullable<AbstractMesh>;
  108117. /**
  108118. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  108119. * @param mesh The mesh to replace the default mesh of the gizmo
  108120. */
  108121. setCustomMesh(mesh: Mesh): void;
  108122. /**
  108123. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  108124. */
  108125. updateGizmoRotationToMatchAttachedMesh: boolean;
  108126. /**
  108127. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  108128. */
  108129. updateGizmoPositionToMatchAttachedMesh: boolean;
  108130. /**
  108131. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  108132. */
  108133. updateScale: boolean;
  108134. protected _interactionsEnabled: boolean;
  108135. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  108136. private _beforeRenderObserver;
  108137. private _tempVector;
  108138. /**
  108139. * Creates a gizmo
  108140. * @param gizmoLayer The utility layer the gizmo will be added to
  108141. */
  108142. constructor(
  108143. /** The utility layer the gizmo will be added to */
  108144. gizmoLayer?: UtilityLayerRenderer);
  108145. /**
  108146. * Updates the gizmo to match the attached mesh's position/rotation
  108147. */
  108148. protected _update(): void;
  108149. /**
  108150. * Disposes of the gizmo
  108151. */
  108152. dispose(): void;
  108153. }
  108154. }
  108155. declare module BABYLON {
  108156. /**
  108157. * Single plane drag gizmo
  108158. */
  108159. export class PlaneDragGizmo extends Gizmo {
  108160. /**
  108161. * Drag behavior responsible for the gizmos dragging interactions
  108162. */
  108163. dragBehavior: PointerDragBehavior;
  108164. private _pointerObserver;
  108165. /**
  108166. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  108167. */
  108168. snapDistance: number;
  108169. /**
  108170. * Event that fires each time the gizmo snaps to a new location.
  108171. * * snapDistance is the the change in distance
  108172. */
  108173. onSnapObservable: Observable<{
  108174. snapDistance: number;
  108175. }>;
  108176. private _plane;
  108177. private _coloredMaterial;
  108178. private _hoverMaterial;
  108179. private _isEnabled;
  108180. private _parent;
  108181. /** @hidden */
  108182. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  108183. /** @hidden */
  108184. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  108185. /**
  108186. * Creates a PlaneDragGizmo
  108187. * @param gizmoLayer The utility layer the gizmo will be added to
  108188. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  108189. * @param color The color of the gizmo
  108190. */
  108191. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  108192. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  108193. /**
  108194. * If the gizmo is enabled
  108195. */
  108196. isEnabled: boolean;
  108197. /**
  108198. * Disposes of the gizmo
  108199. */
  108200. dispose(): void;
  108201. }
  108202. }
  108203. declare module BABYLON {
  108204. /**
  108205. * Gizmo that enables dragging a mesh along 3 axis
  108206. */
  108207. export class PositionGizmo extends Gizmo {
  108208. /**
  108209. * Internal gizmo used for interactions on the x axis
  108210. */
  108211. xGizmo: AxisDragGizmo;
  108212. /**
  108213. * Internal gizmo used for interactions on the y axis
  108214. */
  108215. yGizmo: AxisDragGizmo;
  108216. /**
  108217. * Internal gizmo used for interactions on the z axis
  108218. */
  108219. zGizmo: AxisDragGizmo;
  108220. /**
  108221. * Internal gizmo used for interactions on the yz plane
  108222. */
  108223. xPlaneGizmo: PlaneDragGizmo;
  108224. /**
  108225. * Internal gizmo used for interactions on the xz plane
  108226. */
  108227. yPlaneGizmo: PlaneDragGizmo;
  108228. /**
  108229. * Internal gizmo used for interactions on the xy plane
  108230. */
  108231. zPlaneGizmo: PlaneDragGizmo;
  108232. /**
  108233. * private variables
  108234. */
  108235. private _meshAttached;
  108236. private _updateGizmoRotationToMatchAttachedMesh;
  108237. private _snapDistance;
  108238. private _scaleRatio;
  108239. /** Fires an event when any of it's sub gizmos are dragged */
  108240. onDragStartObservable: Observable<unknown>;
  108241. /** Fires an event when any of it's sub gizmos are released from dragging */
  108242. onDragEndObservable: Observable<unknown>;
  108243. /**
  108244. * If set to true, planar drag is enabled
  108245. */
  108246. private _planarGizmoEnabled;
  108247. attachedMesh: Nullable<AbstractMesh>;
  108248. /**
  108249. * Creates a PositionGizmo
  108250. * @param gizmoLayer The utility layer the gizmo will be added to
  108251. */
  108252. constructor(gizmoLayer?: UtilityLayerRenderer);
  108253. /**
  108254. * If the planar drag gizmo is enabled
  108255. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  108256. */
  108257. planarGizmoEnabled: boolean;
  108258. updateGizmoRotationToMatchAttachedMesh: boolean;
  108259. /**
  108260. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  108261. */
  108262. snapDistance: number;
  108263. /**
  108264. * Ratio for the scale of the gizmo (Default: 1)
  108265. */
  108266. scaleRatio: number;
  108267. /**
  108268. * Disposes of the gizmo
  108269. */
  108270. dispose(): void;
  108271. /**
  108272. * CustomMeshes are not supported by this gizmo
  108273. * @param mesh The mesh to replace the default mesh of the gizmo
  108274. */
  108275. setCustomMesh(mesh: Mesh): void;
  108276. }
  108277. }
  108278. declare module BABYLON {
  108279. /**
  108280. * Single axis drag gizmo
  108281. */
  108282. export class AxisDragGizmo extends Gizmo {
  108283. /**
  108284. * Drag behavior responsible for the gizmos dragging interactions
  108285. */
  108286. dragBehavior: PointerDragBehavior;
  108287. private _pointerObserver;
  108288. /**
  108289. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  108290. */
  108291. snapDistance: number;
  108292. /**
  108293. * Event that fires each time the gizmo snaps to a new location.
  108294. * * snapDistance is the the change in distance
  108295. */
  108296. onSnapObservable: Observable<{
  108297. snapDistance: number;
  108298. }>;
  108299. private _isEnabled;
  108300. private _parent;
  108301. private _arrow;
  108302. private _coloredMaterial;
  108303. private _hoverMaterial;
  108304. /** @hidden */
  108305. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  108306. /** @hidden */
  108307. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  108308. /**
  108309. * Creates an AxisDragGizmo
  108310. * @param gizmoLayer The utility layer the gizmo will be added to
  108311. * @param dragAxis The axis which the gizmo will be able to drag on
  108312. * @param color The color of the gizmo
  108313. */
  108314. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  108315. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  108316. /**
  108317. * If the gizmo is enabled
  108318. */
  108319. isEnabled: boolean;
  108320. /**
  108321. * Disposes of the gizmo
  108322. */
  108323. dispose(): void;
  108324. }
  108325. }
  108326. declare module BABYLON.Debug {
  108327. /**
  108328. * The Axes viewer will show 3 axes in a specific point in space
  108329. */
  108330. export class AxesViewer {
  108331. private _xAxis;
  108332. private _yAxis;
  108333. private _zAxis;
  108334. private _scaleLinesFactor;
  108335. private _instanced;
  108336. /**
  108337. * Gets the hosting scene
  108338. */
  108339. scene: Scene;
  108340. /**
  108341. * Gets or sets a number used to scale line length
  108342. */
  108343. scaleLines: number;
  108344. /** Gets the node hierarchy used to render x-axis */
  108345. readonly xAxis: TransformNode;
  108346. /** Gets the node hierarchy used to render y-axis */
  108347. readonly yAxis: TransformNode;
  108348. /** Gets the node hierarchy used to render z-axis */
  108349. readonly zAxis: TransformNode;
  108350. /**
  108351. * Creates a new AxesViewer
  108352. * @param scene defines the hosting scene
  108353. * @param scaleLines defines a number used to scale line length (1 by default)
  108354. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  108355. * @param xAxis defines the node hierarchy used to render the x-axis
  108356. * @param yAxis defines the node hierarchy used to render the y-axis
  108357. * @param zAxis defines the node hierarchy used to render the z-axis
  108358. */
  108359. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  108360. /**
  108361. * Force the viewer to update
  108362. * @param position defines the position of the viewer
  108363. * @param xaxis defines the x axis of the viewer
  108364. * @param yaxis defines the y axis of the viewer
  108365. * @param zaxis defines the z axis of the viewer
  108366. */
  108367. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  108368. /**
  108369. * Creates an instance of this axes viewer.
  108370. * @returns a new axes viewer with instanced meshes
  108371. */
  108372. createInstance(): AxesViewer;
  108373. /** Releases resources */
  108374. dispose(): void;
  108375. private static _SetRenderingGroupId;
  108376. }
  108377. }
  108378. declare module BABYLON.Debug {
  108379. /**
  108380. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  108381. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  108382. */
  108383. export class BoneAxesViewer extends AxesViewer {
  108384. /**
  108385. * Gets or sets the target mesh where to display the axes viewer
  108386. */
  108387. mesh: Nullable<Mesh>;
  108388. /**
  108389. * Gets or sets the target bone where to display the axes viewer
  108390. */
  108391. bone: Nullable<Bone>;
  108392. /** Gets current position */
  108393. pos: Vector3;
  108394. /** Gets direction of X axis */
  108395. xaxis: Vector3;
  108396. /** Gets direction of Y axis */
  108397. yaxis: Vector3;
  108398. /** Gets direction of Z axis */
  108399. zaxis: Vector3;
  108400. /**
  108401. * Creates a new BoneAxesViewer
  108402. * @param scene defines the hosting scene
  108403. * @param bone defines the target bone
  108404. * @param mesh defines the target mesh
  108405. * @param scaleLines defines a scaling factor for line length (1 by default)
  108406. */
  108407. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  108408. /**
  108409. * Force the viewer to update
  108410. */
  108411. update(): void;
  108412. /** Releases resources */
  108413. dispose(): void;
  108414. }
  108415. }
  108416. declare module BABYLON {
  108417. /**
  108418. * Interface used to define scene explorer extensibility option
  108419. */
  108420. export interface IExplorerExtensibilityOption {
  108421. /**
  108422. * Define the option label
  108423. */
  108424. label: string;
  108425. /**
  108426. * Defines the action to execute on click
  108427. */
  108428. action: (entity: any) => void;
  108429. }
  108430. /**
  108431. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  108432. */
  108433. export interface IExplorerExtensibilityGroup {
  108434. /**
  108435. * Defines a predicate to test if a given type mut be extended
  108436. */
  108437. predicate: (entity: any) => boolean;
  108438. /**
  108439. * Gets the list of options added to a type
  108440. */
  108441. entries: IExplorerExtensibilityOption[];
  108442. }
  108443. /**
  108444. * Interface used to define the options to use to create the Inspector
  108445. */
  108446. export interface IInspectorOptions {
  108447. /**
  108448. * Display in overlay mode (default: false)
  108449. */
  108450. overlay?: boolean;
  108451. /**
  108452. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  108453. */
  108454. globalRoot?: HTMLElement;
  108455. /**
  108456. * Display the Scene explorer
  108457. */
  108458. showExplorer?: boolean;
  108459. /**
  108460. * Display the property inspector
  108461. */
  108462. showInspector?: boolean;
  108463. /**
  108464. * Display in embed mode (both panes on the right)
  108465. */
  108466. embedMode?: boolean;
  108467. /**
  108468. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  108469. */
  108470. handleResize?: boolean;
  108471. /**
  108472. * Allow the panes to popup (default: true)
  108473. */
  108474. enablePopup?: boolean;
  108475. /**
  108476. * Allow the panes to be closed by users (default: true)
  108477. */
  108478. enableClose?: boolean;
  108479. /**
  108480. * Optional list of extensibility entries
  108481. */
  108482. explorerExtensibility?: IExplorerExtensibilityGroup[];
  108483. /**
  108484. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  108485. */
  108486. inspectorURL?: string;
  108487. }
  108488. interface Scene {
  108489. /**
  108490. * @hidden
  108491. * Backing field
  108492. */
  108493. _debugLayer: DebugLayer;
  108494. /**
  108495. * Gets the debug layer (aka Inspector) associated with the scene
  108496. * @see http://doc.babylonjs.com/features/playground_debuglayer
  108497. */
  108498. debugLayer: DebugLayer;
  108499. }
  108500. /**
  108501. * The debug layer (aka Inspector) is the go to tool in order to better understand
  108502. * what is happening in your scene
  108503. * @see http://doc.babylonjs.com/features/playground_debuglayer
  108504. */
  108505. export class DebugLayer {
  108506. /**
  108507. * Define the url to get the inspector script from.
  108508. * By default it uses the babylonjs CDN.
  108509. * @ignoreNaming
  108510. */
  108511. static InspectorURL: string;
  108512. private _scene;
  108513. private BJSINSPECTOR;
  108514. private _onPropertyChangedObservable?;
  108515. /**
  108516. * Observable triggered when a property is changed through the inspector.
  108517. */
  108518. readonly onPropertyChangedObservable: any;
  108519. /**
  108520. * Instantiates a new debug layer.
  108521. * The debug layer (aka Inspector) is the go to tool in order to better understand
  108522. * what is happening in your scene
  108523. * @see http://doc.babylonjs.com/features/playground_debuglayer
  108524. * @param scene Defines the scene to inspect
  108525. */
  108526. constructor(scene: Scene);
  108527. /** Creates the inspector window. */
  108528. private _createInspector;
  108529. /**
  108530. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  108531. * @param entity defines the entity to select
  108532. * @param lineContainerTitle defines the specific block to highlight
  108533. */
  108534. select(entity: any, lineContainerTitle?: string): void;
  108535. /** Get the inspector from bundle or global */
  108536. private _getGlobalInspector;
  108537. /**
  108538. * Get if the inspector is visible or not.
  108539. * @returns true if visible otherwise, false
  108540. */
  108541. isVisible(): boolean;
  108542. /**
  108543. * Hide the inspector and close its window.
  108544. */
  108545. hide(): void;
  108546. /**
  108547. * Launch the debugLayer.
  108548. * @param config Define the configuration of the inspector
  108549. * @return a promise fulfilled when the debug layer is visible
  108550. */
  108551. show(config?: IInspectorOptions): Promise<DebugLayer>;
  108552. }
  108553. }
  108554. declare module BABYLON {
  108555. /**
  108556. * Class containing static functions to help procedurally build meshes
  108557. */
  108558. export class BoxBuilder {
  108559. /**
  108560. * Creates a box mesh
  108561. * * The parameter `size` sets the size (float) of each box side (default 1)
  108562. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  108563. * * 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)
  108564. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  108565. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  108566. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  108567. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  108568. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  108569. * @param name defines the name of the mesh
  108570. * @param options defines the options used to create the mesh
  108571. * @param scene defines the hosting scene
  108572. * @returns the box mesh
  108573. */
  108574. static CreateBox(name: string, options: {
  108575. size?: number;
  108576. width?: number;
  108577. height?: number;
  108578. depth?: number;
  108579. faceUV?: Vector4[];
  108580. faceColors?: Color4[];
  108581. sideOrientation?: number;
  108582. frontUVs?: Vector4;
  108583. backUVs?: Vector4;
  108584. wrap?: boolean;
  108585. topBaseAt?: number;
  108586. bottomBaseAt?: number;
  108587. updatable?: boolean;
  108588. }, scene?: Nullable<Scene>): Mesh;
  108589. }
  108590. }
  108591. declare module BABYLON {
  108592. /**
  108593. * Class containing static functions to help procedurally build meshes
  108594. */
  108595. export class SphereBuilder {
  108596. /**
  108597. * Creates a sphere mesh
  108598. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  108599. * * 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`)
  108600. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  108601. * * 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
  108602. * * 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)
  108603. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  108604. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  108605. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  108606. * @param name defines the name of the mesh
  108607. * @param options defines the options used to create the mesh
  108608. * @param scene defines the hosting scene
  108609. * @returns the sphere mesh
  108610. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  108611. */
  108612. static CreateSphere(name: string, options: {
  108613. segments?: number;
  108614. diameter?: number;
  108615. diameterX?: number;
  108616. diameterY?: number;
  108617. diameterZ?: number;
  108618. arc?: number;
  108619. slice?: number;
  108620. sideOrientation?: number;
  108621. frontUVs?: Vector4;
  108622. backUVs?: Vector4;
  108623. updatable?: boolean;
  108624. }, scene?: Nullable<Scene>): Mesh;
  108625. }
  108626. }
  108627. declare module BABYLON.Debug {
  108628. /**
  108629. * Used to show the physics impostor around the specific mesh
  108630. */
  108631. export class PhysicsViewer {
  108632. /** @hidden */
  108633. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  108634. /** @hidden */
  108635. protected _meshes: Array<Nullable<AbstractMesh>>;
  108636. /** @hidden */
  108637. protected _scene: Nullable<Scene>;
  108638. /** @hidden */
  108639. protected _numMeshes: number;
  108640. /** @hidden */
  108641. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  108642. private _renderFunction;
  108643. private _utilityLayer;
  108644. private _debugBoxMesh;
  108645. private _debugSphereMesh;
  108646. private _debugCylinderMesh;
  108647. private _debugMaterial;
  108648. private _debugMeshMeshes;
  108649. /**
  108650. * Creates a new PhysicsViewer
  108651. * @param scene defines the hosting scene
  108652. */
  108653. constructor(scene: Scene);
  108654. /** @hidden */
  108655. protected _updateDebugMeshes(): void;
  108656. /**
  108657. * Renders a specified physic impostor
  108658. * @param impostor defines the impostor to render
  108659. * @param targetMesh defines the mesh represented by the impostor
  108660. * @returns the new debug mesh used to render the impostor
  108661. */
  108662. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  108663. /**
  108664. * Hides a specified physic impostor
  108665. * @param impostor defines the impostor to hide
  108666. */
  108667. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  108668. private _getDebugMaterial;
  108669. private _getDebugBoxMesh;
  108670. private _getDebugSphereMesh;
  108671. private _getDebugCylinderMesh;
  108672. private _getDebugMeshMesh;
  108673. private _getDebugMesh;
  108674. /** Releases all resources */
  108675. dispose(): void;
  108676. }
  108677. }
  108678. declare module BABYLON {
  108679. /**
  108680. * Class containing static functions to help procedurally build meshes
  108681. */
  108682. export class LinesBuilder {
  108683. /**
  108684. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  108685. * * 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
  108686. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  108687. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  108688. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  108689. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  108690. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  108691. * * 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
  108692. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  108693. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  108694. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  108695. * @param name defines the name of the new line system
  108696. * @param options defines the options used to create the line system
  108697. * @param scene defines the hosting scene
  108698. * @returns a new line system mesh
  108699. */
  108700. static CreateLineSystem(name: string, options: {
  108701. lines: Vector3[][];
  108702. updatable?: boolean;
  108703. instance?: Nullable<LinesMesh>;
  108704. colors?: Nullable<Color4[][]>;
  108705. useVertexAlpha?: boolean;
  108706. }, scene: Nullable<Scene>): LinesMesh;
  108707. /**
  108708. * Creates a line mesh
  108709. * 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
  108710. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  108711. * * The parameter `points` is an array successive Vector3
  108712. * * 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
  108713. * * The optional parameter `colors` is an array of successive Color4, one per line point
  108714. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  108715. * * When updating an instance, remember that only point positions can change, not the number of points
  108716. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  108717. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  108718. * @param name defines the name of the new line system
  108719. * @param options defines the options used to create the line system
  108720. * @param scene defines the hosting scene
  108721. * @returns a new line mesh
  108722. */
  108723. static CreateLines(name: string, options: {
  108724. points: Vector3[];
  108725. updatable?: boolean;
  108726. instance?: Nullable<LinesMesh>;
  108727. colors?: Color4[];
  108728. useVertexAlpha?: boolean;
  108729. }, scene?: Nullable<Scene>): LinesMesh;
  108730. /**
  108731. * Creates a dashed line mesh
  108732. * * 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
  108733. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  108734. * * The parameter `points` is an array successive Vector3
  108735. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  108736. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  108737. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  108738. * * 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
  108739. * * When updating an instance, remember that only point positions can change, not the number of points
  108740. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  108741. * @param name defines the name of the mesh
  108742. * @param options defines the options used to create the mesh
  108743. * @param scene defines the hosting scene
  108744. * @returns the dashed line mesh
  108745. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  108746. */
  108747. static CreateDashedLines(name: string, options: {
  108748. points: Vector3[];
  108749. dashSize?: number;
  108750. gapSize?: number;
  108751. dashNb?: number;
  108752. updatable?: boolean;
  108753. instance?: LinesMesh;
  108754. }, scene?: Nullable<Scene>): LinesMesh;
  108755. }
  108756. }
  108757. declare module BABYLON {
  108758. /**
  108759. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  108760. * in order to better appreciate the issue one might have.
  108761. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  108762. */
  108763. export class RayHelper {
  108764. /**
  108765. * Defines the ray we are currently tryin to visualize.
  108766. */
  108767. ray: Nullable<Ray>;
  108768. private _renderPoints;
  108769. private _renderLine;
  108770. private _renderFunction;
  108771. private _scene;
  108772. private _updateToMeshFunction;
  108773. private _attachedToMesh;
  108774. private _meshSpaceDirection;
  108775. private _meshSpaceOrigin;
  108776. /**
  108777. * Helper function to create a colored helper in a scene in one line.
  108778. * @param ray Defines the ray we are currently tryin to visualize
  108779. * @param scene Defines the scene the ray is used in
  108780. * @param color Defines the color we want to see the ray in
  108781. * @returns The newly created ray helper.
  108782. */
  108783. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  108784. /**
  108785. * Instantiate a new ray helper.
  108786. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  108787. * in order to better appreciate the issue one might have.
  108788. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  108789. * @param ray Defines the ray we are currently tryin to visualize
  108790. */
  108791. constructor(ray: Ray);
  108792. /**
  108793. * Shows the ray we are willing to debug.
  108794. * @param scene Defines the scene the ray needs to be rendered in
  108795. * @param color Defines the color the ray needs to be rendered in
  108796. */
  108797. show(scene: Scene, color?: Color3): void;
  108798. /**
  108799. * Hides the ray we are debugging.
  108800. */
  108801. hide(): void;
  108802. private _render;
  108803. /**
  108804. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  108805. * @param mesh Defines the mesh we want the helper attached to
  108806. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  108807. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  108808. * @param length Defines the length of the ray
  108809. */
  108810. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  108811. /**
  108812. * Detach the ray helper from the mesh it has previously been attached to.
  108813. */
  108814. detachFromMesh(): void;
  108815. private _updateToMesh;
  108816. /**
  108817. * Dispose the helper and release its associated resources.
  108818. */
  108819. dispose(): void;
  108820. }
  108821. }
  108822. declare module BABYLON.Debug {
  108823. /**
  108824. * Class used to render a debug view of a given skeleton
  108825. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  108826. */
  108827. export class SkeletonViewer {
  108828. /** defines the skeleton to render */
  108829. skeleton: Skeleton;
  108830. /** defines the mesh attached to the skeleton */
  108831. mesh: AbstractMesh;
  108832. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  108833. autoUpdateBonesMatrices: boolean;
  108834. /** defines the rendering group id to use with the viewer */
  108835. renderingGroupId: number;
  108836. /** Gets or sets the color used to render the skeleton */
  108837. color: Color3;
  108838. private _scene;
  108839. private _debugLines;
  108840. private _debugMesh;
  108841. private _isEnabled;
  108842. private _renderFunction;
  108843. private _utilityLayer;
  108844. /**
  108845. * Returns the mesh used to render the bones
  108846. */
  108847. readonly debugMesh: Nullable<LinesMesh>;
  108848. /**
  108849. * Creates a new SkeletonViewer
  108850. * @param skeleton defines the skeleton to render
  108851. * @param mesh defines the mesh attached to the skeleton
  108852. * @param scene defines the hosting scene
  108853. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  108854. * @param renderingGroupId defines the rendering group id to use with the viewer
  108855. */
  108856. constructor(
  108857. /** defines the skeleton to render */
  108858. skeleton: Skeleton,
  108859. /** defines the mesh attached to the skeleton */
  108860. mesh: AbstractMesh, scene: Scene,
  108861. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  108862. autoUpdateBonesMatrices?: boolean,
  108863. /** defines the rendering group id to use with the viewer */
  108864. renderingGroupId?: number);
  108865. /** Gets or sets a boolean indicating if the viewer is enabled */
  108866. isEnabled: boolean;
  108867. private _getBonePosition;
  108868. private _getLinesForBonesWithLength;
  108869. private _getLinesForBonesNoLength;
  108870. /** Update the viewer to sync with current skeleton state */
  108871. update(): void;
  108872. /** Release associated resources */
  108873. dispose(): void;
  108874. }
  108875. }
  108876. declare module BABYLON {
  108877. /**
  108878. * Options to create the null engine
  108879. */
  108880. export class NullEngineOptions {
  108881. /**
  108882. * Render width (Default: 512)
  108883. */
  108884. renderWidth: number;
  108885. /**
  108886. * Render height (Default: 256)
  108887. */
  108888. renderHeight: number;
  108889. /**
  108890. * Texture size (Default: 512)
  108891. */
  108892. textureSize: number;
  108893. /**
  108894. * If delta time between frames should be constant
  108895. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  108896. */
  108897. deterministicLockstep: boolean;
  108898. /**
  108899. * Maximum about of steps between frames (Default: 4)
  108900. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  108901. */
  108902. lockstepMaxSteps: number;
  108903. }
  108904. /**
  108905. * The null engine class provides support for headless version of babylon.js.
  108906. * This can be used in server side scenario or for testing purposes
  108907. */
  108908. export class NullEngine extends Engine {
  108909. private _options;
  108910. /**
  108911. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  108912. */
  108913. isDeterministicLockStep(): boolean;
  108914. /** @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep */
  108915. getLockstepMaxSteps(): number;
  108916. /**
  108917. * Sets hardware scaling, used to save performance if needed
  108918. * @see https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  108919. */
  108920. getHardwareScalingLevel(): number;
  108921. constructor(options?: NullEngineOptions);
  108922. createVertexBuffer(vertices: FloatArray): DataBuffer;
  108923. createIndexBuffer(indices: IndicesArray): DataBuffer;
  108924. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  108925. getRenderWidth(useScreen?: boolean): number;
  108926. getRenderHeight(useScreen?: boolean): number;
  108927. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  108928. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  108929. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  108930. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  108931. bindSamplers(effect: Effect): void;
  108932. enableEffect(effect: Effect): void;
  108933. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  108934. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  108935. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  108936. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  108937. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  108938. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  108939. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  108940. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  108941. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  108942. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  108943. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  108944. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  108945. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  108946. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  108947. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  108948. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  108949. setFloat(uniform: WebGLUniformLocation, value: number): void;
  108950. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  108951. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  108952. setBool(uniform: WebGLUniformLocation, bool: number): void;
  108953. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  108954. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  108955. bindBuffers(vertexBuffers: {
  108956. [key: string]: VertexBuffer;
  108957. }, indexBuffer: DataBuffer, effect: Effect): void;
  108958. wipeCaches(bruteForce?: boolean): void;
  108959. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  108960. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  108961. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  108962. /** @hidden */
  108963. _createTexture(): WebGLTexture;
  108964. /** @hidden */
  108965. _releaseTexture(texture: InternalTexture): void;
  108966. 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;
  108967. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  108968. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  108969. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  108970. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  108971. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  108972. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  108973. areAllEffectsReady(): boolean;
  108974. /**
  108975. * @hidden
  108976. * Get the current error code of the webGL context
  108977. * @returns the error code
  108978. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  108979. */
  108980. getError(): number;
  108981. /** @hidden */
  108982. _getUnpackAlignement(): number;
  108983. /** @hidden */
  108984. _unpackFlipY(value: boolean): void;
  108985. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  108986. /**
  108987. * Updates a dynamic vertex buffer.
  108988. * @param vertexBuffer the vertex buffer to update
  108989. * @param data the data used to update the vertex buffer
  108990. * @param byteOffset the byte offset of the data (optional)
  108991. * @param byteLength the byte length of the data (optional)
  108992. */
  108993. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  108994. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  108995. /** @hidden */
  108996. _bindTexture(channel: number, texture: InternalTexture): void;
  108997. protected _deleteBuffer(buffer: WebGLBuffer): void;
  108998. releaseEffects(): void;
  108999. displayLoadingUI(): void;
  109000. hideLoadingUI(): void;
  109001. /** @hidden */
  109002. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  109003. /** @hidden */
  109004. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  109005. /** @hidden */
  109006. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  109007. /** @hidden */
  109008. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  109009. }
  109010. }
  109011. declare module BABYLON {
  109012. /** @hidden */
  109013. export class _OcclusionDataStorage {
  109014. /** @hidden */
  109015. occlusionInternalRetryCounter: number;
  109016. /** @hidden */
  109017. isOcclusionQueryInProgress: boolean;
  109018. /** @hidden */
  109019. isOccluded: boolean;
  109020. /** @hidden */
  109021. occlusionRetryCount: number;
  109022. /** @hidden */
  109023. occlusionType: number;
  109024. /** @hidden */
  109025. occlusionQueryAlgorithmType: number;
  109026. }
  109027. interface Engine {
  109028. /**
  109029. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  109030. * @return the new query
  109031. */
  109032. createQuery(): WebGLQuery;
  109033. /**
  109034. * Delete and release a webGL query
  109035. * @param query defines the query to delete
  109036. * @return the current engine
  109037. */
  109038. deleteQuery(query: WebGLQuery): Engine;
  109039. /**
  109040. * Check if a given query has resolved and got its value
  109041. * @param query defines the query to check
  109042. * @returns true if the query got its value
  109043. */
  109044. isQueryResultAvailable(query: WebGLQuery): boolean;
  109045. /**
  109046. * Gets the value of a given query
  109047. * @param query defines the query to check
  109048. * @returns the value of the query
  109049. */
  109050. getQueryResult(query: WebGLQuery): number;
  109051. /**
  109052. * Initiates an occlusion query
  109053. * @param algorithmType defines the algorithm to use
  109054. * @param query defines the query to use
  109055. * @returns the current engine
  109056. * @see http://doc.babylonjs.com/features/occlusionquery
  109057. */
  109058. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  109059. /**
  109060. * Ends an occlusion query
  109061. * @see http://doc.babylonjs.com/features/occlusionquery
  109062. * @param algorithmType defines the algorithm to use
  109063. * @returns the current engine
  109064. */
  109065. endOcclusionQuery(algorithmType: number): Engine;
  109066. /**
  109067. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  109068. * Please note that only one query can be issued at a time
  109069. * @returns a time token used to track the time span
  109070. */
  109071. startTimeQuery(): Nullable<_TimeToken>;
  109072. /**
  109073. * Ends a time query
  109074. * @param token defines the token used to measure the time span
  109075. * @returns the time spent (in ns)
  109076. */
  109077. endTimeQuery(token: _TimeToken): int;
  109078. /** @hidden */
  109079. _currentNonTimestampToken: Nullable<_TimeToken>;
  109080. /** @hidden */
  109081. _createTimeQuery(): WebGLQuery;
  109082. /** @hidden */
  109083. _deleteTimeQuery(query: WebGLQuery): void;
  109084. /** @hidden */
  109085. _getGlAlgorithmType(algorithmType: number): number;
  109086. /** @hidden */
  109087. _getTimeQueryResult(query: WebGLQuery): any;
  109088. /** @hidden */
  109089. _getTimeQueryAvailability(query: WebGLQuery): any;
  109090. }
  109091. interface AbstractMesh {
  109092. /**
  109093. * Backing filed
  109094. * @hidden
  109095. */
  109096. __occlusionDataStorage: _OcclusionDataStorage;
  109097. /**
  109098. * Access property
  109099. * @hidden
  109100. */
  109101. _occlusionDataStorage: _OcclusionDataStorage;
  109102. /**
  109103. * 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.
  109104. * The default value is -1 which means don't break the query and wait till the result
  109105. * @see http://doc.babylonjs.com/features/occlusionquery
  109106. */
  109107. occlusionRetryCount: number;
  109108. /**
  109109. * 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:
  109110. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  109111. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  109112. * * 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.
  109113. * @see http://doc.babylonjs.com/features/occlusionquery
  109114. */
  109115. occlusionType: number;
  109116. /**
  109117. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  109118. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  109119. * * 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.
  109120. * @see http://doc.babylonjs.com/features/occlusionquery
  109121. */
  109122. occlusionQueryAlgorithmType: number;
  109123. /**
  109124. * 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
  109125. * @see http://doc.babylonjs.com/features/occlusionquery
  109126. */
  109127. isOccluded: boolean;
  109128. /**
  109129. * Flag to check the progress status of the query
  109130. * @see http://doc.babylonjs.com/features/occlusionquery
  109131. */
  109132. isOcclusionQueryInProgress: boolean;
  109133. }
  109134. }
  109135. declare module BABYLON {
  109136. /** @hidden */
  109137. export var _forceTransformFeedbackToBundle: boolean;
  109138. interface Engine {
  109139. /**
  109140. * Creates a webGL transform feedback object
  109141. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  109142. * @returns the webGL transform feedback object
  109143. */
  109144. createTransformFeedback(): WebGLTransformFeedback;
  109145. /**
  109146. * Delete a webGL transform feedback object
  109147. * @param value defines the webGL transform feedback object to delete
  109148. */
  109149. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  109150. /**
  109151. * Bind a webGL transform feedback object to the webgl context
  109152. * @param value defines the webGL transform feedback object to bind
  109153. */
  109154. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  109155. /**
  109156. * Begins a transform feedback operation
  109157. * @param usePoints defines if points or triangles must be used
  109158. */
  109159. beginTransformFeedback(usePoints: boolean): void;
  109160. /**
  109161. * Ends a transform feedback operation
  109162. */
  109163. endTransformFeedback(): void;
  109164. /**
  109165. * Specify the varyings to use with transform feedback
  109166. * @param program defines the associated webGL program
  109167. * @param value defines the list of strings representing the varying names
  109168. */
  109169. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  109170. /**
  109171. * Bind a webGL buffer for a transform feedback operation
  109172. * @param value defines the webGL buffer to bind
  109173. */
  109174. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  109175. }
  109176. }
  109177. declare module BABYLON {
  109178. /**
  109179. * Creation options of the multi render target texture.
  109180. */
  109181. export interface IMultiRenderTargetOptions {
  109182. /**
  109183. * Define if the texture needs to create mip maps after render.
  109184. */
  109185. generateMipMaps?: boolean;
  109186. /**
  109187. * Define the types of all the draw buffers we want to create
  109188. */
  109189. types?: number[];
  109190. /**
  109191. * Define the sampling modes of all the draw buffers we want to create
  109192. */
  109193. samplingModes?: number[];
  109194. /**
  109195. * Define if a depth buffer is required
  109196. */
  109197. generateDepthBuffer?: boolean;
  109198. /**
  109199. * Define if a stencil buffer is required
  109200. */
  109201. generateStencilBuffer?: boolean;
  109202. /**
  109203. * Define if a depth texture is required instead of a depth buffer
  109204. */
  109205. generateDepthTexture?: boolean;
  109206. /**
  109207. * Define the number of desired draw buffers
  109208. */
  109209. textureCount?: number;
  109210. /**
  109211. * Define if aspect ratio should be adapted to the texture or stay the scene one
  109212. */
  109213. doNotChangeAspectRatio?: boolean;
  109214. /**
  109215. * Define the default type of the buffers we are creating
  109216. */
  109217. defaultType?: number;
  109218. }
  109219. /**
  109220. * A multi render target, like a render target provides the ability to render to a texture.
  109221. * Unlike the render target, it can render to several draw buffers in one draw.
  109222. * This is specially interesting in deferred rendering or for any effects requiring more than
  109223. * just one color from a single pass.
  109224. */
  109225. export class MultiRenderTarget extends RenderTargetTexture {
  109226. private _internalTextures;
  109227. private _textures;
  109228. private _multiRenderTargetOptions;
  109229. /**
  109230. * Get if draw buffers are currently supported by the used hardware and browser.
  109231. */
  109232. readonly isSupported: boolean;
  109233. /**
  109234. * Get the list of textures generated by the multi render target.
  109235. */
  109236. readonly textures: Texture[];
  109237. /**
  109238. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  109239. */
  109240. readonly depthTexture: Texture;
  109241. /**
  109242. * Set the wrapping mode on U of all the textures we are rendering to.
  109243. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  109244. */
  109245. wrapU: number;
  109246. /**
  109247. * Set the wrapping mode on V of all the textures we are rendering to.
  109248. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  109249. */
  109250. wrapV: number;
  109251. /**
  109252. * Instantiate a new multi render target texture.
  109253. * A multi render target, like a render target provides the ability to render to a texture.
  109254. * Unlike the render target, it can render to several draw buffers in one draw.
  109255. * This is specially interesting in deferred rendering or for any effects requiring more than
  109256. * just one color from a single pass.
  109257. * @param name Define the name of the texture
  109258. * @param size Define the size of the buffers to render to
  109259. * @param count Define the number of target we are rendering into
  109260. * @param scene Define the scene the texture belongs to
  109261. * @param options Define the options used to create the multi render target
  109262. */
  109263. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  109264. /** @hidden */
  109265. _rebuild(): void;
  109266. private _createInternalTextures;
  109267. private _createTextures;
  109268. /**
  109269. * Define the number of samples used if MSAA is enabled.
  109270. */
  109271. samples: number;
  109272. /**
  109273. * Resize all the textures in the multi render target.
  109274. * Be carrefull as it will recreate all the data in the new texture.
  109275. * @param size Define the new size
  109276. */
  109277. resize(size: any): void;
  109278. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  109279. /**
  109280. * Dispose the render targets and their associated resources
  109281. */
  109282. dispose(): void;
  109283. /**
  109284. * Release all the underlying texture used as draw buffers.
  109285. */
  109286. releaseInternalTextures(): void;
  109287. }
  109288. }
  109289. declare module BABYLON {
  109290. interface Engine {
  109291. /**
  109292. * Unbind a list of render target textures from the webGL context
  109293. * This is used only when drawBuffer extension or webGL2 are active
  109294. * @param textures defines the render target textures to unbind
  109295. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  109296. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  109297. */
  109298. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  109299. /**
  109300. * Create a multi render target texture
  109301. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  109302. * @param size defines the size of the texture
  109303. * @param options defines the creation options
  109304. * @returns the cube texture as an InternalTexture
  109305. */
  109306. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  109307. /**
  109308. * Update the sample count for a given multiple render target texture
  109309. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  109310. * @param textures defines the textures to update
  109311. * @param samples defines the sample count to set
  109312. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  109313. */
  109314. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  109315. }
  109316. }
  109317. declare module BABYLON {
  109318. /** @hidden */
  109319. export var rgbdEncodePixelShader: {
  109320. name: string;
  109321. shader: string;
  109322. };
  109323. }
  109324. declare module BABYLON {
  109325. /** @hidden */
  109326. export var rgbdDecodePixelShader: {
  109327. name: string;
  109328. shader: string;
  109329. };
  109330. }
  109331. declare module BABYLON {
  109332. /**
  109333. * Raw texture data and descriptor sufficient for WebGL texture upload
  109334. */
  109335. export interface EnvironmentTextureInfo {
  109336. /**
  109337. * Version of the environment map
  109338. */
  109339. version: number;
  109340. /**
  109341. * Width of image
  109342. */
  109343. width: number;
  109344. /**
  109345. * Irradiance information stored in the file.
  109346. */
  109347. irradiance: any;
  109348. /**
  109349. * Specular information stored in the file.
  109350. */
  109351. specular: any;
  109352. }
  109353. /**
  109354. * Defines One Image in the file. It requires only the position in the file
  109355. * as well as the length.
  109356. */
  109357. interface BufferImageData {
  109358. /**
  109359. * Length of the image data.
  109360. */
  109361. length: number;
  109362. /**
  109363. * Position of the data from the null terminator delimiting the end of the JSON.
  109364. */
  109365. position: number;
  109366. }
  109367. /**
  109368. * Defines the specular data enclosed in the file.
  109369. * This corresponds to the version 1 of the data.
  109370. */
  109371. export interface EnvironmentTextureSpecularInfoV1 {
  109372. /**
  109373. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  109374. */
  109375. specularDataPosition?: number;
  109376. /**
  109377. * This contains all the images data needed to reconstruct the cubemap.
  109378. */
  109379. mipmaps: Array<BufferImageData>;
  109380. /**
  109381. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  109382. */
  109383. lodGenerationScale: number;
  109384. }
  109385. /**
  109386. * Sets of helpers addressing the serialization and deserialization of environment texture
  109387. * stored in a BabylonJS env file.
  109388. * Those files are usually stored as .env files.
  109389. */
  109390. export class EnvironmentTextureTools {
  109391. /**
  109392. * Magic number identifying the env file.
  109393. */
  109394. private static _MagicBytes;
  109395. /**
  109396. * Gets the environment info from an env file.
  109397. * @param data The array buffer containing the .env bytes.
  109398. * @returns the environment file info (the json header) if successfully parsed.
  109399. */
  109400. static GetEnvInfo(data: ArrayBuffer): Nullable<EnvironmentTextureInfo>;
  109401. /**
  109402. * Creates an environment texture from a loaded cube texture.
  109403. * @param texture defines the cube texture to convert in env file
  109404. * @return a promise containing the environment data if succesfull.
  109405. */
  109406. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  109407. /**
  109408. * Creates a JSON representation of the spherical data.
  109409. * @param texture defines the texture containing the polynomials
  109410. * @return the JSON representation of the spherical info
  109411. */
  109412. private static _CreateEnvTextureIrradiance;
  109413. /**
  109414. * Creates the ArrayBufferViews used for initializing environment texture image data.
  109415. * @param arrayBuffer the underlying ArrayBuffer to which the views refer
  109416. * @param info parameters that determine what views will be created for accessing the underlying buffer
  109417. * @return the views described by info providing access to the underlying buffer
  109418. */
  109419. static CreateImageDataArrayBufferViews(arrayBuffer: any, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  109420. /**
  109421. * Uploads the texture info contained in the env file to the GPU.
  109422. * @param texture defines the internal texture to upload to
  109423. * @param arrayBuffer defines the buffer cotaining the data to load
  109424. * @param info defines the texture info retrieved through the GetEnvInfo method
  109425. * @returns a promise
  109426. */
  109427. static UploadEnvLevelsAsync(texture: InternalTexture, arrayBuffer: any, info: EnvironmentTextureInfo): Promise<void>;
  109428. /**
  109429. * Uploads the levels of image data to the GPU.
  109430. * @param texture defines the internal texture to upload to
  109431. * @param imageData defines the array buffer views of image data [mipmap][face]
  109432. * @returns a promise
  109433. */
  109434. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  109435. /**
  109436. * Uploads spherical polynomials information to the texture.
  109437. * @param texture defines the texture we are trying to upload the information to
  109438. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  109439. */
  109440. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  109441. /** @hidden */
  109442. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  109443. }
  109444. }
  109445. declare module BABYLON {
  109446. /**
  109447. * Contains position and normal vectors for a vertex
  109448. */
  109449. export class PositionNormalVertex {
  109450. /** the position of the vertex (defaut: 0,0,0) */
  109451. position: Vector3;
  109452. /** the normal of the vertex (defaut: 0,1,0) */
  109453. normal: Vector3;
  109454. /**
  109455. * Creates a PositionNormalVertex
  109456. * @param position the position of the vertex (defaut: 0,0,0)
  109457. * @param normal the normal of the vertex (defaut: 0,1,0)
  109458. */
  109459. constructor(
  109460. /** the position of the vertex (defaut: 0,0,0) */
  109461. position?: Vector3,
  109462. /** the normal of the vertex (defaut: 0,1,0) */
  109463. normal?: Vector3);
  109464. /**
  109465. * Clones the PositionNormalVertex
  109466. * @returns the cloned PositionNormalVertex
  109467. */
  109468. clone(): PositionNormalVertex;
  109469. }
  109470. /**
  109471. * Contains position, normal and uv vectors for a vertex
  109472. */
  109473. export class PositionNormalTextureVertex {
  109474. /** the position of the vertex (defaut: 0,0,0) */
  109475. position: Vector3;
  109476. /** the normal of the vertex (defaut: 0,1,0) */
  109477. normal: Vector3;
  109478. /** the uv of the vertex (default: 0,0) */
  109479. uv: Vector2;
  109480. /**
  109481. * Creates a PositionNormalTextureVertex
  109482. * @param position the position of the vertex (defaut: 0,0,0)
  109483. * @param normal the normal of the vertex (defaut: 0,1,0)
  109484. * @param uv the uv of the vertex (default: 0,0)
  109485. */
  109486. constructor(
  109487. /** the position of the vertex (defaut: 0,0,0) */
  109488. position?: Vector3,
  109489. /** the normal of the vertex (defaut: 0,1,0) */
  109490. normal?: Vector3,
  109491. /** the uv of the vertex (default: 0,0) */
  109492. uv?: Vector2);
  109493. /**
  109494. * Clones the PositionNormalTextureVertex
  109495. * @returns the cloned PositionNormalTextureVertex
  109496. */
  109497. clone(): PositionNormalTextureVertex;
  109498. }
  109499. }
  109500. declare module BABYLON {
  109501. /** @hidden */
  109502. export class NativeShaderProcessor extends WebGL2ShaderProcessor {
  109503. private _genericAttributeLocation;
  109504. private _varyingLocationCount;
  109505. private _varyingLocationMap;
  109506. private _replacements;
  109507. private _textureCount;
  109508. private _uniforms;
  109509. lineProcessor(line: string): string;
  109510. attributeProcessor(attribute: string): string;
  109511. varyingProcessor(varying: string, isFragment: boolean): string;
  109512. uniformProcessor(uniform: string): string;
  109513. preProcessor(code: string, defines: string[], isFragment: boolean): string;
  109514. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  109515. }
  109516. }
  109517. declare module BABYLON {
  109518. /**
  109519. * Container for accessors for natively-stored mesh data buffers.
  109520. */
  109521. class NativeDataBuffer extends DataBuffer {
  109522. /**
  109523. * Accessor value used to identify/retrieve a natively-stored index buffer.
  109524. */
  109525. nativeIndexBuffer?: any;
  109526. /**
  109527. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  109528. */
  109529. nativeVertexBuffer?: any;
  109530. }
  109531. /** @hidden */
  109532. export class NativeEngine extends Engine {
  109533. private readonly _native;
  109534. getHardwareScalingLevel(): number;
  109535. constructor();
  109536. /**
  109537. * Can be used to override the current requestAnimationFrame requester.
  109538. * @hidden
  109539. */
  109540. protected _queueNewFrame(bindedRenderFunction: any, requester: any): number;
  109541. clear(color: Color4, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  109542. createIndexBuffer(indices: IndicesArray): NativeDataBuffer;
  109543. createVertexBuffer(data: DataArray): NativeDataBuffer;
  109544. recordVertexArrayObject(vertexBuffers: {
  109545. [key: string]: VertexBuffer;
  109546. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  109547. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  109548. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  109549. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  109550. /**
  109551. * Draw a list of indexed primitives
  109552. * @param fillMode defines the primitive to use
  109553. * @param indexStart defines the starting index
  109554. * @param indexCount defines the number of index to draw
  109555. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  109556. */
  109557. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  109558. /**
  109559. * Draw a list of unindexed primitives
  109560. * @param fillMode defines the primitive to use
  109561. * @param verticesStart defines the index of first vertex to draw
  109562. * @param verticesCount defines the count of vertices to draw
  109563. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  109564. */
  109565. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  109566. createPipelineContext(): IPipelineContext;
  109567. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  109568. /** @hidden */
  109569. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  109570. /** @hidden */
  109571. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  109572. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  109573. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  109574. protected _setProgram(program: WebGLProgram): void;
  109575. _releaseEffect(effect: Effect): void;
  109576. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  109577. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  109578. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  109579. bindSamplers(effect: Effect): void;
  109580. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  109581. getRenderWidth(useScreen?: boolean): number;
  109582. getRenderHeight(useScreen?: boolean): number;
  109583. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  109584. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  109585. /**
  109586. * Set the z offset to apply to current rendering
  109587. * @param value defines the offset to apply
  109588. */
  109589. setZOffset(value: number): void;
  109590. /**
  109591. * Gets the current value of the zOffset
  109592. * @returns the current zOffset state
  109593. */
  109594. getZOffset(): number;
  109595. /**
  109596. * Enable or disable depth buffering
  109597. * @param enable defines the state to set
  109598. */
  109599. setDepthBuffer(enable: boolean): void;
  109600. /**
  109601. * Gets a boolean indicating if depth writing is enabled
  109602. * @returns the current depth writing state
  109603. */
  109604. getDepthWrite(): boolean;
  109605. /**
  109606. * Enable or disable depth writing
  109607. * @param enable defines the state to set
  109608. */
  109609. setDepthWrite(enable: boolean): void;
  109610. /**
  109611. * Enable or disable color writing
  109612. * @param enable defines the state to set
  109613. */
  109614. setColorWrite(enable: boolean): void;
  109615. /**
  109616. * Gets a boolean indicating if color writing is enabled
  109617. * @returns the current color writing state
  109618. */
  109619. getColorWrite(): boolean;
  109620. /**
  109621. * Sets alpha constants used by some alpha blending modes
  109622. * @param r defines the red component
  109623. * @param g defines the green component
  109624. * @param b defines the blue component
  109625. * @param a defines the alpha component
  109626. */
  109627. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  109628. /**
  109629. * Sets the current alpha mode
  109630. * @param mode defines the mode to use (one of the BABYLON.Engine.ALPHA_XXX)
  109631. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  109632. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  109633. */
  109634. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  109635. /**
  109636. * Gets the current alpha mode
  109637. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  109638. * @returns the current alpha mode
  109639. */
  109640. getAlphaMode(): number;
  109641. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  109642. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  109643. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  109644. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  109645. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  109646. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  109647. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  109648. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  109649. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  109650. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  109651. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  109652. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  109653. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  109654. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  109655. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  109656. setFloat(uniform: WebGLUniformLocation, value: number): void;
  109657. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  109658. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  109659. setBool(uniform: WebGLUniformLocation, bool: number): void;
  109660. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  109661. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  109662. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  109663. wipeCaches(bruteForce?: boolean): void;
  109664. _createTexture(): WebGLTexture;
  109665. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  109666. /**
  109667. * Usually called from BABYLON.Texture.ts.
  109668. * Passed information to create a WebGLTexture
  109669. * @param urlArg defines a value which contains one of the following:
  109670. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  109671. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  109672. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  109673. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  109674. * @param invertY when true, image is flipped when loaded. You probably want true. Ignored for compressed textures. Must be flipped in the file
  109675. * @param scene needed for loading to the correct scene
  109676. * @param samplingMode mode with should be used sample / access the texture (Default: BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  109677. * @param onLoad optional callback to be called upon successful completion
  109678. * @param onError optional callback to be called upon failure
  109679. * @param buffer a source of a file previously fetched as either a base64 string, an ArrayBuffer (compressed or image format), or a Blob
  109680. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  109681. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  109682. * @param forcedExtension defines the extension to use to pick the right loader
  109683. * @returns a InternalTexture for assignment back into BABYLON.Texture
  109684. */
  109685. 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;
  109686. /**
  109687. * Creates a cube texture
  109688. * @param rootUrl defines the url where the files to load is located
  109689. * @param scene defines the current scene
  109690. * @param files defines the list of files to load (1 per face)
  109691. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  109692. * @param onLoad defines an optional callback raised when the texture is loaded
  109693. * @param onError defines an optional callback raised if there is an issue to load the texture
  109694. * @param format defines the format of the data
  109695. * @param forcedExtension defines the extension to use to pick the right loader
  109696. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  109697. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  109698. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  109699. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  109700. * @returns the cube texture as an InternalTexture
  109701. */
  109702. 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;
  109703. private _getSamplingFilter;
  109704. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  109705. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  109706. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  109707. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  109708. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  109709. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  109710. /**
  109711. * Updates a dynamic vertex buffer.
  109712. * @param vertexBuffer the vertex buffer to update
  109713. * @param data the data used to update the vertex buffer
  109714. * @param byteOffset the byte offset of the data (optional)
  109715. * @param byteLength the byte length of the data (optional)
  109716. */
  109717. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  109718. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  109719. private _updateAnisotropicLevel;
  109720. private _getAddressMode;
  109721. /** @hidden */
  109722. _bindTexture(channel: number, texture: InternalTexture): void;
  109723. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  109724. releaseEffects(): void;
  109725. /** @hidden */
  109726. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  109727. /** @hidden */
  109728. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  109729. /** @hidden */
  109730. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  109731. /** @hidden */
  109732. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  109733. }
  109734. }
  109735. declare module BABYLON {
  109736. /**
  109737. * Gather the list of clipboard event types as constants.
  109738. */
  109739. export class ClipboardEventTypes {
  109740. /**
  109741. * The clipboard event is fired when a copy command is active (pressed).
  109742. */
  109743. static readonly COPY: number;
  109744. /**
  109745. * The clipboard event is fired when a cut command is active (pressed).
  109746. */
  109747. static readonly CUT: number;
  109748. /**
  109749. * The clipboard event is fired when a paste command is active (pressed).
  109750. */
  109751. static readonly PASTE: number;
  109752. }
  109753. /**
  109754. * This class is used to store clipboard related info for the onClipboardObservable event.
  109755. */
  109756. export class ClipboardInfo {
  109757. /**
  109758. * Defines the type of event (BABYLON.ClipboardEventTypes)
  109759. */
  109760. type: number;
  109761. /**
  109762. * Defines the related dom event
  109763. */
  109764. event: ClipboardEvent;
  109765. /**
  109766. *Creates an instance of ClipboardInfo.
  109767. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  109768. * @param event Defines the related dom event
  109769. */
  109770. constructor(
  109771. /**
  109772. * Defines the type of event (BABYLON.ClipboardEventTypes)
  109773. */
  109774. type: number,
  109775. /**
  109776. * Defines the related dom event
  109777. */
  109778. event: ClipboardEvent);
  109779. /**
  109780. * Get the clipboard event's type from the keycode.
  109781. * @param keyCode Defines the keyCode for the current keyboard event.
  109782. * @return {number}
  109783. */
  109784. static GetTypeFromCharacter(keyCode: number): number;
  109785. }
  109786. }
  109787. declare module BABYLON {
  109788. /**
  109789. * Google Daydream controller
  109790. */
  109791. export class DaydreamController extends WebVRController {
  109792. /**
  109793. * Base Url for the controller model.
  109794. */
  109795. static MODEL_BASE_URL: string;
  109796. /**
  109797. * File name for the controller model.
  109798. */
  109799. static MODEL_FILENAME: string;
  109800. /**
  109801. * Gamepad Id prefix used to identify Daydream Controller.
  109802. */
  109803. static readonly GAMEPAD_ID_PREFIX: string;
  109804. /**
  109805. * Creates a new DaydreamController from a gamepad
  109806. * @param vrGamepad the gamepad that the controller should be created from
  109807. */
  109808. constructor(vrGamepad: any);
  109809. /**
  109810. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  109811. * @param scene scene in which to add meshes
  109812. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  109813. */
  109814. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  109815. /**
  109816. * Called once for each button that changed state since the last frame
  109817. * @param buttonIdx Which button index changed
  109818. * @param state New state of the button
  109819. * @param changes Which properties on the state changed since last frame
  109820. */
  109821. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  109822. }
  109823. }
  109824. declare module BABYLON {
  109825. /**
  109826. * Gear VR Controller
  109827. */
  109828. export class GearVRController extends WebVRController {
  109829. /**
  109830. * Base Url for the controller model.
  109831. */
  109832. static MODEL_BASE_URL: string;
  109833. /**
  109834. * File name for the controller model.
  109835. */
  109836. static MODEL_FILENAME: string;
  109837. /**
  109838. * Gamepad Id prefix used to identify this controller.
  109839. */
  109840. static readonly GAMEPAD_ID_PREFIX: string;
  109841. private readonly _buttonIndexToObservableNameMap;
  109842. /**
  109843. * Creates a new GearVRController from a gamepad
  109844. * @param vrGamepad the gamepad that the controller should be created from
  109845. */
  109846. constructor(vrGamepad: any);
  109847. /**
  109848. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  109849. * @param scene scene in which to add meshes
  109850. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  109851. */
  109852. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  109853. /**
  109854. * Called once for each button that changed state since the last frame
  109855. * @param buttonIdx Which button index changed
  109856. * @param state New state of the button
  109857. * @param changes Which properties on the state changed since last frame
  109858. */
  109859. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  109860. }
  109861. }
  109862. declare module BABYLON {
  109863. /**
  109864. * Class containing static functions to help procedurally build meshes
  109865. */
  109866. export class PolyhedronBuilder {
  109867. /**
  109868. * Creates a polyhedron mesh
  109869. * * 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
  109870. * * The parameter `size` (positive float, default 1) sets the polygon size
  109871. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  109872. * * 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`
  109873. * * 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
  109874. * * 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)`)
  109875. * * 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
  109876. * * 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
  109877. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  109878. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  109879. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  109880. * @param name defines the name of the mesh
  109881. * @param options defines the options used to create the mesh
  109882. * @param scene defines the hosting scene
  109883. * @returns the polyhedron mesh
  109884. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  109885. */
  109886. static CreatePolyhedron(name: string, options: {
  109887. type?: number;
  109888. size?: number;
  109889. sizeX?: number;
  109890. sizeY?: number;
  109891. sizeZ?: number;
  109892. custom?: any;
  109893. faceUV?: Vector4[];
  109894. faceColors?: Color4[];
  109895. flat?: boolean;
  109896. updatable?: boolean;
  109897. sideOrientation?: number;
  109898. frontUVs?: Vector4;
  109899. backUVs?: Vector4;
  109900. }, scene?: Nullable<Scene>): Mesh;
  109901. }
  109902. }
  109903. declare module BABYLON {
  109904. /**
  109905. * Gizmo that enables scaling a mesh along 3 axis
  109906. */
  109907. export class ScaleGizmo extends Gizmo {
  109908. /**
  109909. * Internal gizmo used for interactions on the x axis
  109910. */
  109911. xGizmo: AxisScaleGizmo;
  109912. /**
  109913. * Internal gizmo used for interactions on the y axis
  109914. */
  109915. yGizmo: AxisScaleGizmo;
  109916. /**
  109917. * Internal gizmo used for interactions on the z axis
  109918. */
  109919. zGizmo: AxisScaleGizmo;
  109920. /**
  109921. * Internal gizmo used to scale all axis equally
  109922. */
  109923. uniformScaleGizmo: AxisScaleGizmo;
  109924. private _meshAttached;
  109925. private _updateGizmoRotationToMatchAttachedMesh;
  109926. private _snapDistance;
  109927. private _scaleRatio;
  109928. private _uniformScalingMesh;
  109929. private _octahedron;
  109930. /** Fires an event when any of it's sub gizmos are dragged */
  109931. onDragStartObservable: Observable<unknown>;
  109932. /** Fires an event when any of it's sub gizmos are released from dragging */
  109933. onDragEndObservable: Observable<unknown>;
  109934. attachedMesh: Nullable<AbstractMesh>;
  109935. /**
  109936. * Creates a ScaleGizmo
  109937. * @param gizmoLayer The utility layer the gizmo will be added to
  109938. */
  109939. constructor(gizmoLayer?: UtilityLayerRenderer);
  109940. updateGizmoRotationToMatchAttachedMesh: boolean;
  109941. /**
  109942. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  109943. */
  109944. snapDistance: number;
  109945. /**
  109946. * Ratio for the scale of the gizmo (Default: 1)
  109947. */
  109948. scaleRatio: number;
  109949. /**
  109950. * Disposes of the gizmo
  109951. */
  109952. dispose(): void;
  109953. }
  109954. }
  109955. declare module BABYLON {
  109956. /**
  109957. * Single axis scale gizmo
  109958. */
  109959. export class AxisScaleGizmo extends Gizmo {
  109960. /**
  109961. * Drag behavior responsible for the gizmos dragging interactions
  109962. */
  109963. dragBehavior: PointerDragBehavior;
  109964. private _pointerObserver;
  109965. /**
  109966. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  109967. */
  109968. snapDistance: number;
  109969. /**
  109970. * Event that fires each time the gizmo snaps to a new location.
  109971. * * snapDistance is the the change in distance
  109972. */
  109973. onSnapObservable: Observable<{
  109974. snapDistance: number;
  109975. }>;
  109976. /**
  109977. * If the scaling operation should be done on all axis (default: false)
  109978. */
  109979. uniformScaling: boolean;
  109980. private _isEnabled;
  109981. private _parent;
  109982. private _arrow;
  109983. private _coloredMaterial;
  109984. private _hoverMaterial;
  109985. /**
  109986. * Creates an AxisScaleGizmo
  109987. * @param gizmoLayer The utility layer the gizmo will be added to
  109988. * @param dragAxis The axis which the gizmo will be able to scale on
  109989. * @param color The color of the gizmo
  109990. */
  109991. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>);
  109992. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  109993. /**
  109994. * If the gizmo is enabled
  109995. */
  109996. isEnabled: boolean;
  109997. /**
  109998. * Disposes of the gizmo
  109999. */
  110000. dispose(): void;
  110001. /**
  110002. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  110003. * @param mesh The mesh to replace the default mesh of the gizmo
  110004. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  110005. */
  110006. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  110007. }
  110008. }
  110009. declare module BABYLON {
  110010. /**
  110011. * Bounding box gizmo
  110012. */
  110013. export class BoundingBoxGizmo extends Gizmo {
  110014. private _lineBoundingBox;
  110015. private _rotateSpheresParent;
  110016. private _scaleBoxesParent;
  110017. private _boundingDimensions;
  110018. private _renderObserver;
  110019. private _pointerObserver;
  110020. private _scaleDragSpeed;
  110021. private _tmpQuaternion;
  110022. private _tmpVector;
  110023. private _tmpRotationMatrix;
  110024. /**
  110025. * 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)
  110026. */
  110027. ignoreChildren: boolean;
  110028. /**
  110029. * 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)
  110030. */
  110031. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  110032. /**
  110033. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  110034. */
  110035. rotationSphereSize: number;
  110036. /**
  110037. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  110038. */
  110039. scaleBoxSize: number;
  110040. /**
  110041. * 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)
  110042. */
  110043. fixedDragMeshScreenSize: boolean;
  110044. /**
  110045. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  110046. */
  110047. fixedDragMeshScreenSizeDistanceFactor: number;
  110048. /**
  110049. * Fired when a rotation sphere or scale box is dragged
  110050. */
  110051. onDragStartObservable: Observable<{}>;
  110052. /**
  110053. * Fired when a scale box is dragged
  110054. */
  110055. onScaleBoxDragObservable: Observable<{}>;
  110056. /**
  110057. * Fired when a scale box drag is ended
  110058. */
  110059. onScaleBoxDragEndObservable: Observable<{}>;
  110060. /**
  110061. * Fired when a rotation sphere is dragged
  110062. */
  110063. onRotationSphereDragObservable: Observable<{}>;
  110064. /**
  110065. * Fired when a rotation sphere drag is ended
  110066. */
  110067. onRotationSphereDragEndObservable: Observable<{}>;
  110068. /**
  110069. * 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)
  110070. */
  110071. scalePivot: Nullable<Vector3>;
  110072. /**
  110073. * Mesh used as a pivot to rotate the attached mesh
  110074. */
  110075. private _anchorMesh;
  110076. private _existingMeshScale;
  110077. private _dragMesh;
  110078. private pointerDragBehavior;
  110079. private coloredMaterial;
  110080. private hoverColoredMaterial;
  110081. /**
  110082. * Sets the color of the bounding box gizmo
  110083. * @param color the color to set
  110084. */
  110085. setColor(color: Color3): void;
  110086. /**
  110087. * Creates an BoundingBoxGizmo
  110088. * @param gizmoLayer The utility layer the gizmo will be added to
  110089. * @param color The color of the gizmo
  110090. */
  110091. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  110092. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  110093. private _selectNode;
  110094. /**
  110095. * Updates the bounding box information for the Gizmo
  110096. */
  110097. updateBoundingBox(): void;
  110098. private _updateRotationSpheres;
  110099. private _updateScaleBoxes;
  110100. /**
  110101. * Enables rotation on the specified axis and disables rotation on the others
  110102. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  110103. */
  110104. setEnabledRotationAxis(axis: string): void;
  110105. /**
  110106. * Enables/disables scaling
  110107. * @param enable if scaling should be enabled
  110108. */
  110109. setEnabledScaling(enable: boolean): void;
  110110. private _updateDummy;
  110111. /**
  110112. * Enables a pointer drag behavior on the bounding box of the gizmo
  110113. */
  110114. enableDragBehavior(): void;
  110115. /**
  110116. * Disposes of the gizmo
  110117. */
  110118. dispose(): void;
  110119. /**
  110120. * 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)
  110121. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  110122. * @returns the bounding box mesh with the passed in mesh as a child
  110123. */
  110124. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  110125. /**
  110126. * CustomMeshes are not supported by this gizmo
  110127. * @param mesh The mesh to replace the default mesh of the gizmo
  110128. */
  110129. setCustomMesh(mesh: Mesh): void;
  110130. }
  110131. }
  110132. declare module BABYLON {
  110133. /**
  110134. * Single plane rotation gizmo
  110135. */
  110136. export class PlaneRotationGizmo extends Gizmo {
  110137. /**
  110138. * Drag behavior responsible for the gizmos dragging interactions
  110139. */
  110140. dragBehavior: PointerDragBehavior;
  110141. private _pointerObserver;
  110142. /**
  110143. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  110144. */
  110145. snapDistance: number;
  110146. /**
  110147. * Event that fires each time the gizmo snaps to a new location.
  110148. * * snapDistance is the the change in distance
  110149. */
  110150. onSnapObservable: Observable<{
  110151. snapDistance: number;
  110152. }>;
  110153. private _isEnabled;
  110154. private _parent;
  110155. /**
  110156. * Creates a PlaneRotationGizmo
  110157. * @param gizmoLayer The utility layer the gizmo will be added to
  110158. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  110159. * @param color The color of the gizmo
  110160. * @param tessellation Amount of tessellation to be used when creating rotation circles
  110161. * @param useEulerRotation Use and update Euler angle instead of quaternion
  110162. */
  110163. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean);
  110164. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  110165. /**
  110166. * If the gizmo is enabled
  110167. */
  110168. isEnabled: boolean;
  110169. /**
  110170. * Disposes of the gizmo
  110171. */
  110172. dispose(): void;
  110173. }
  110174. }
  110175. declare module BABYLON {
  110176. /**
  110177. * Gizmo that enables rotating a mesh along 3 axis
  110178. */
  110179. export class RotationGizmo extends Gizmo {
  110180. /**
  110181. * Internal gizmo used for interactions on the x axis
  110182. */
  110183. xGizmo: PlaneRotationGizmo;
  110184. /**
  110185. * Internal gizmo used for interactions on the y axis
  110186. */
  110187. yGizmo: PlaneRotationGizmo;
  110188. /**
  110189. * Internal gizmo used for interactions on the z axis
  110190. */
  110191. zGizmo: PlaneRotationGizmo;
  110192. /** Fires an event when any of it's sub gizmos are dragged */
  110193. onDragStartObservable: Observable<unknown>;
  110194. /** Fires an event when any of it's sub gizmos are released from dragging */
  110195. onDragEndObservable: Observable<unknown>;
  110196. private _meshAttached;
  110197. attachedMesh: Nullable<AbstractMesh>;
  110198. /**
  110199. * Creates a RotationGizmo
  110200. * @param gizmoLayer The utility layer the gizmo will be added to
  110201. * @param tessellation Amount of tessellation to be used when creating rotation circles
  110202. * @param useEulerRotation Use and update Euler angle instead of quaternion
  110203. */
  110204. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean);
  110205. updateGizmoRotationToMatchAttachedMesh: boolean;
  110206. /**
  110207. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  110208. */
  110209. snapDistance: number;
  110210. /**
  110211. * Ratio for the scale of the gizmo (Default: 1)
  110212. */
  110213. scaleRatio: number;
  110214. /**
  110215. * Disposes of the gizmo
  110216. */
  110217. dispose(): void;
  110218. /**
  110219. * CustomMeshes are not supported by this gizmo
  110220. * @param mesh The mesh to replace the default mesh of the gizmo
  110221. */
  110222. setCustomMesh(mesh: Mesh): void;
  110223. }
  110224. }
  110225. declare module BABYLON {
  110226. /**
  110227. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  110228. */
  110229. export class GizmoManager implements IDisposable {
  110230. private scene;
  110231. /**
  110232. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  110233. */
  110234. gizmos: {
  110235. positionGizmo: Nullable<PositionGizmo>;
  110236. rotationGizmo: Nullable<RotationGizmo>;
  110237. scaleGizmo: Nullable<ScaleGizmo>;
  110238. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  110239. };
  110240. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  110241. clearGizmoOnEmptyPointerEvent: boolean;
  110242. /** Fires an event when the manager is attached to a mesh */
  110243. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  110244. private _gizmosEnabled;
  110245. private _pointerObserver;
  110246. private _attachedMesh;
  110247. private _boundingBoxColor;
  110248. private _defaultUtilityLayer;
  110249. private _defaultKeepDepthUtilityLayer;
  110250. /**
  110251. * When bounding box gizmo is enabled, this can be used to track drag/end events
  110252. */
  110253. boundingBoxDragBehavior: SixDofDragBehavior;
  110254. /**
  110255. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  110256. */
  110257. attachableMeshes: Nullable<Array<AbstractMesh>>;
  110258. /**
  110259. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  110260. */
  110261. usePointerToAttachGizmos: boolean;
  110262. /**
  110263. * Utility layer that the bounding box gizmo belongs to
  110264. */
  110265. readonly keepDepthUtilityLayer: UtilityLayerRenderer;
  110266. /**
  110267. * Utility layer that all gizmos besides bounding box belong to
  110268. */
  110269. readonly utilityLayer: UtilityLayerRenderer;
  110270. /**
  110271. * Instatiates a gizmo manager
  110272. * @param scene the scene to overlay the gizmos on top of
  110273. */
  110274. constructor(scene: Scene);
  110275. /**
  110276. * Attaches a set of gizmos to the specified mesh
  110277. * @param mesh The mesh the gizmo's should be attached to
  110278. */
  110279. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  110280. /**
  110281. * If the position gizmo is enabled
  110282. */
  110283. positionGizmoEnabled: boolean;
  110284. /**
  110285. * If the rotation gizmo is enabled
  110286. */
  110287. rotationGizmoEnabled: boolean;
  110288. /**
  110289. * If the scale gizmo is enabled
  110290. */
  110291. scaleGizmoEnabled: boolean;
  110292. /**
  110293. * If the boundingBox gizmo is enabled
  110294. */
  110295. boundingBoxGizmoEnabled: boolean;
  110296. /**
  110297. * Disposes of the gizmo manager
  110298. */
  110299. dispose(): void;
  110300. }
  110301. }
  110302. declare module BABYLON {
  110303. /**
  110304. * A directional light is defined by a direction (what a surprise!).
  110305. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  110306. * 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.
  110307. * Documentation: https://doc.babylonjs.com/babylon101/lights
  110308. */
  110309. export class DirectionalLight extends ShadowLight {
  110310. private _shadowFrustumSize;
  110311. /**
  110312. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  110313. */
  110314. /**
  110315. * Specifies a fix frustum size for the shadow generation.
  110316. */
  110317. shadowFrustumSize: number;
  110318. private _shadowOrthoScale;
  110319. /**
  110320. * Gets the shadow projection scale against the optimal computed one.
  110321. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  110322. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  110323. */
  110324. /**
  110325. * Sets the shadow projection scale against the optimal computed one.
  110326. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  110327. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  110328. */
  110329. shadowOrthoScale: number;
  110330. /**
  110331. * Automatically compute the projection matrix to best fit (including all the casters)
  110332. * on each frame.
  110333. */
  110334. autoUpdateExtends: boolean;
  110335. private _orthoLeft;
  110336. private _orthoRight;
  110337. private _orthoTop;
  110338. private _orthoBottom;
  110339. /**
  110340. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  110341. * The directional light is emitted from everywhere in the given direction.
  110342. * It can cast shadows.
  110343. * Documentation : https://doc.babylonjs.com/babylon101/lights
  110344. * @param name The friendly name of the light
  110345. * @param direction The direction of the light
  110346. * @param scene The scene the light belongs to
  110347. */
  110348. constructor(name: string, direction: Vector3, scene: Scene);
  110349. /**
  110350. * Returns the string "DirectionalLight".
  110351. * @return The class name
  110352. */
  110353. getClassName(): string;
  110354. /**
  110355. * Returns the integer 1.
  110356. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  110357. */
  110358. getTypeID(): number;
  110359. /**
  110360. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  110361. * Returns the DirectionalLight Shadow projection matrix.
  110362. */
  110363. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  110364. /**
  110365. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  110366. * Returns the DirectionalLight Shadow projection matrix.
  110367. */
  110368. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  110369. /**
  110370. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  110371. * Returns the DirectionalLight Shadow projection matrix.
  110372. */
  110373. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  110374. protected _buildUniformLayout(): void;
  110375. /**
  110376. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  110377. * @param effect The effect to update
  110378. * @param lightIndex The index of the light in the effect to update
  110379. * @returns The directional light
  110380. */
  110381. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  110382. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  110383. /**
  110384. * Gets the minZ used for shadow according to both the scene and the light.
  110385. *
  110386. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  110387. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  110388. * @param activeCamera The camera we are returning the min for
  110389. * @returns the depth min z
  110390. */
  110391. getDepthMinZ(activeCamera: Camera): number;
  110392. /**
  110393. * Gets the maxZ used for shadow according to both the scene and the light.
  110394. *
  110395. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  110396. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  110397. * @param activeCamera The camera we are returning the max for
  110398. * @returns the depth max z
  110399. */
  110400. getDepthMaxZ(activeCamera: Camera): number;
  110401. /**
  110402. * Prepares the list of defines specific to the light type.
  110403. * @param defines the list of defines
  110404. * @param lightIndex defines the index of the light for the effect
  110405. */
  110406. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  110407. }
  110408. }
  110409. declare module BABYLON {
  110410. /**
  110411. * Class containing static functions to help procedurally build meshes
  110412. */
  110413. export class HemisphereBuilder {
  110414. /**
  110415. * Creates a hemisphere mesh
  110416. * @param name defines the name of the mesh
  110417. * @param options defines the options used to create the mesh
  110418. * @param scene defines the hosting scene
  110419. * @returns the hemisphere mesh
  110420. */
  110421. static CreateHemisphere(name: string, options: {
  110422. segments?: number;
  110423. diameter?: number;
  110424. sideOrientation?: number;
  110425. }, scene: any): Mesh;
  110426. }
  110427. }
  110428. declare module BABYLON {
  110429. /**
  110430. * A spot light is defined by a position, a direction, an angle, and an exponent.
  110431. * These values define a cone of light starting from the position, emitting toward the direction.
  110432. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  110433. * and the exponent defines the speed of the decay of the light with distance (reach).
  110434. * Documentation: https://doc.babylonjs.com/babylon101/lights
  110435. */
  110436. export class SpotLight extends ShadowLight {
  110437. private _angle;
  110438. private _innerAngle;
  110439. private _cosHalfAngle;
  110440. private _lightAngleScale;
  110441. private _lightAngleOffset;
  110442. /**
  110443. * Gets the cone angle of the spot light in Radians.
  110444. */
  110445. /**
  110446. * Sets the cone angle of the spot light in Radians.
  110447. */
  110448. angle: number;
  110449. /**
  110450. * Only used in gltf falloff mode, this defines the angle where
  110451. * the directional falloff will start before cutting at angle which could be seen
  110452. * as outer angle.
  110453. */
  110454. /**
  110455. * Only used in gltf falloff mode, this defines the angle where
  110456. * the directional falloff will start before cutting at angle which could be seen
  110457. * as outer angle.
  110458. */
  110459. innerAngle: number;
  110460. private _shadowAngleScale;
  110461. /**
  110462. * Allows scaling the angle of the light for shadow generation only.
  110463. */
  110464. /**
  110465. * Allows scaling the angle of the light for shadow generation only.
  110466. */
  110467. shadowAngleScale: number;
  110468. /**
  110469. * The light decay speed with the distance from the emission spot.
  110470. */
  110471. exponent: number;
  110472. private _projectionTextureMatrix;
  110473. /**
  110474. * Allows reading the projecton texture
  110475. */
  110476. readonly projectionTextureMatrix: Matrix;
  110477. protected _projectionTextureLightNear: number;
  110478. /**
  110479. * Gets the near clip of the Spotlight for texture projection.
  110480. */
  110481. /**
  110482. * Sets the near clip of the Spotlight for texture projection.
  110483. */
  110484. projectionTextureLightNear: number;
  110485. protected _projectionTextureLightFar: number;
  110486. /**
  110487. * Gets the far clip of the Spotlight for texture projection.
  110488. */
  110489. /**
  110490. * Sets the far clip of the Spotlight for texture projection.
  110491. */
  110492. projectionTextureLightFar: number;
  110493. protected _projectionTextureUpDirection: Vector3;
  110494. /**
  110495. * Gets the Up vector of the Spotlight for texture projection.
  110496. */
  110497. /**
  110498. * Sets the Up vector of the Spotlight for texture projection.
  110499. */
  110500. projectionTextureUpDirection: Vector3;
  110501. private _projectionTexture;
  110502. /**
  110503. * Gets the projection texture of the light.
  110504. */
  110505. /**
  110506. * Sets the projection texture of the light.
  110507. */
  110508. projectionTexture: Nullable<BaseTexture>;
  110509. private _projectionTextureViewLightDirty;
  110510. private _projectionTextureProjectionLightDirty;
  110511. private _projectionTextureDirty;
  110512. private _projectionTextureViewTargetVector;
  110513. private _projectionTextureViewLightMatrix;
  110514. private _projectionTextureProjectionLightMatrix;
  110515. private _projectionTextureScalingMatrix;
  110516. /**
  110517. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  110518. * It can cast shadows.
  110519. * Documentation : https://doc.babylonjs.com/babylon101/lights
  110520. * @param name The light friendly name
  110521. * @param position The position of the spot light in the scene
  110522. * @param direction The direction of the light in the scene
  110523. * @param angle The cone angle of the light in Radians
  110524. * @param exponent The light decay speed with the distance from the emission spot
  110525. * @param scene The scene the lights belongs to
  110526. */
  110527. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  110528. /**
  110529. * Returns the string "SpotLight".
  110530. * @returns the class name
  110531. */
  110532. getClassName(): string;
  110533. /**
  110534. * Returns the integer 2.
  110535. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  110536. */
  110537. getTypeID(): number;
  110538. /**
  110539. * Overrides the direction setter to recompute the projection texture view light Matrix.
  110540. */
  110541. protected _setDirection(value: Vector3): void;
  110542. /**
  110543. * Overrides the position setter to recompute the projection texture view light Matrix.
  110544. */
  110545. protected _setPosition(value: Vector3): void;
  110546. /**
  110547. * 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.
  110548. * Returns the SpotLight.
  110549. */
  110550. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  110551. protected _computeProjectionTextureViewLightMatrix(): void;
  110552. protected _computeProjectionTextureProjectionLightMatrix(): void;
  110553. /**
  110554. * Main function for light texture projection matrix computing.
  110555. */
  110556. protected _computeProjectionTextureMatrix(): void;
  110557. protected _buildUniformLayout(): void;
  110558. private _computeAngleValues;
  110559. /**
  110560. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  110561. * @param effect The effect to update
  110562. * @param lightIndex The index of the light in the effect to update
  110563. * @returns The spot light
  110564. */
  110565. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  110566. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  110567. /**
  110568. * Disposes the light and the associated resources.
  110569. */
  110570. dispose(): void;
  110571. /**
  110572. * Prepares the list of defines specific to the light type.
  110573. * @param defines the list of defines
  110574. * @param lightIndex defines the index of the light for the effect
  110575. */
  110576. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  110577. }
  110578. }
  110579. declare module BABYLON {
  110580. /**
  110581. * Gizmo that enables viewing a light
  110582. */
  110583. export class LightGizmo extends Gizmo {
  110584. private _lightMesh;
  110585. private _material;
  110586. private cachedPosition;
  110587. private cachedForward;
  110588. /**
  110589. * Creates a LightGizmo
  110590. * @param gizmoLayer The utility layer the gizmo will be added to
  110591. */
  110592. constructor(gizmoLayer?: UtilityLayerRenderer);
  110593. private _light;
  110594. /**
  110595. * The light that the gizmo is attached to
  110596. */
  110597. light: Nullable<Light>;
  110598. /**
  110599. * Gets the material used to render the light gizmo
  110600. */
  110601. readonly material: StandardMaterial;
  110602. /**
  110603. * @hidden
  110604. * Updates the gizmo to match the attached mesh's position/rotation
  110605. */
  110606. protected _update(): void;
  110607. private static _Scale;
  110608. /**
  110609. * Creates the lines for a light mesh
  110610. */
  110611. private static _createLightLines;
  110612. /**
  110613. * Disposes of the light gizmo
  110614. */
  110615. dispose(): void;
  110616. private static _CreateHemisphericLightMesh;
  110617. private static _CreatePointLightMesh;
  110618. private static _CreateSpotLightMesh;
  110619. private static _CreateDirectionalLightMesh;
  110620. }
  110621. }
  110622. declare module BABYLON {
  110623. /** @hidden */
  110624. export var backgroundFragmentDeclaration: {
  110625. name: string;
  110626. shader: string;
  110627. };
  110628. }
  110629. declare module BABYLON {
  110630. /** @hidden */
  110631. export var backgroundUboDeclaration: {
  110632. name: string;
  110633. shader: string;
  110634. };
  110635. }
  110636. declare module BABYLON {
  110637. /** @hidden */
  110638. export var backgroundPixelShader: {
  110639. name: string;
  110640. shader: string;
  110641. };
  110642. }
  110643. declare module BABYLON {
  110644. /** @hidden */
  110645. export var backgroundVertexDeclaration: {
  110646. name: string;
  110647. shader: string;
  110648. };
  110649. }
  110650. declare module BABYLON {
  110651. /** @hidden */
  110652. export var backgroundVertexShader: {
  110653. name: string;
  110654. shader: string;
  110655. };
  110656. }
  110657. declare module BABYLON {
  110658. /**
  110659. * Background material used to create an efficient environement around your scene.
  110660. */
  110661. export class BackgroundMaterial extends PushMaterial {
  110662. /**
  110663. * Standard reflectance value at parallel view angle.
  110664. */
  110665. static StandardReflectance0: number;
  110666. /**
  110667. * Standard reflectance value at grazing angle.
  110668. */
  110669. static StandardReflectance90: number;
  110670. protected _primaryColor: Color3;
  110671. /**
  110672. * Key light Color (multiply against the environement texture)
  110673. */
  110674. primaryColor: Color3;
  110675. protected __perceptualColor: Nullable<Color3>;
  110676. /**
  110677. * Experimental Internal Use Only.
  110678. *
  110679. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  110680. * This acts as a helper to set the primary color to a more "human friendly" value.
  110681. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  110682. * output color as close as possible from the chosen value.
  110683. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  110684. * part of lighting setup.)
  110685. */
  110686. _perceptualColor: Nullable<Color3>;
  110687. protected _primaryColorShadowLevel: float;
  110688. /**
  110689. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  110690. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  110691. */
  110692. primaryColorShadowLevel: float;
  110693. protected _primaryColorHighlightLevel: float;
  110694. /**
  110695. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  110696. * The primary color is used at the level chosen to define what the white area would look.
  110697. */
  110698. primaryColorHighlightLevel: float;
  110699. protected _reflectionTexture: Nullable<BaseTexture>;
  110700. /**
  110701. * Reflection Texture used in the material.
  110702. * Should be author in a specific way for the best result (refer to the documentation).
  110703. */
  110704. reflectionTexture: Nullable<BaseTexture>;
  110705. protected _reflectionBlur: float;
  110706. /**
  110707. * Reflection Texture level of blur.
  110708. *
  110709. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  110710. * texture twice.
  110711. */
  110712. reflectionBlur: float;
  110713. protected _diffuseTexture: Nullable<BaseTexture>;
  110714. /**
  110715. * Diffuse Texture used in the material.
  110716. * Should be author in a specific way for the best result (refer to the documentation).
  110717. */
  110718. diffuseTexture: Nullable<BaseTexture>;
  110719. protected _shadowLights: Nullable<IShadowLight[]>;
  110720. /**
  110721. * Specify the list of lights casting shadow on the material.
  110722. * All scene shadow lights will be included if null.
  110723. */
  110724. shadowLights: Nullable<IShadowLight[]>;
  110725. protected _shadowLevel: float;
  110726. /**
  110727. * Helps adjusting the shadow to a softer level if required.
  110728. * 0 means black shadows and 1 means no shadows.
  110729. */
  110730. shadowLevel: float;
  110731. protected _sceneCenter: Vector3;
  110732. /**
  110733. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  110734. * It is usually zero but might be interesting to modify according to your setup.
  110735. */
  110736. sceneCenter: Vector3;
  110737. protected _opacityFresnel: boolean;
  110738. /**
  110739. * This helps specifying that the material is falling off to the sky box at grazing angle.
  110740. * This helps ensuring a nice transition when the camera goes under the ground.
  110741. */
  110742. opacityFresnel: boolean;
  110743. protected _reflectionFresnel: boolean;
  110744. /**
  110745. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  110746. * This helps adding a mirror texture on the ground.
  110747. */
  110748. reflectionFresnel: boolean;
  110749. protected _reflectionFalloffDistance: number;
  110750. /**
  110751. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  110752. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  110753. */
  110754. reflectionFalloffDistance: number;
  110755. protected _reflectionAmount: number;
  110756. /**
  110757. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  110758. */
  110759. reflectionAmount: number;
  110760. protected _reflectionReflectance0: number;
  110761. /**
  110762. * This specifies the weight of the reflection at grazing angle.
  110763. */
  110764. reflectionReflectance0: number;
  110765. protected _reflectionReflectance90: number;
  110766. /**
  110767. * This specifies the weight of the reflection at a perpendicular point of view.
  110768. */
  110769. reflectionReflectance90: number;
  110770. /**
  110771. * Sets the reflection reflectance fresnel values according to the default standard
  110772. * empirically know to work well :-)
  110773. */
  110774. reflectionStandardFresnelWeight: number;
  110775. protected _useRGBColor: boolean;
  110776. /**
  110777. * Helps to directly use the maps channels instead of their level.
  110778. */
  110779. useRGBColor: boolean;
  110780. protected _enableNoise: boolean;
  110781. /**
  110782. * This helps reducing the banding effect that could occur on the background.
  110783. */
  110784. enableNoise: boolean;
  110785. /**
  110786. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  110787. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  110788. * Recommended to be keep at 1.0 except for special cases.
  110789. */
  110790. fovMultiplier: number;
  110791. private _fovMultiplier;
  110792. /**
  110793. * Enable the FOV adjustment feature controlled by fovMultiplier.
  110794. */
  110795. useEquirectangularFOV: boolean;
  110796. private _maxSimultaneousLights;
  110797. /**
  110798. * Number of Simultaneous lights allowed on the material.
  110799. */
  110800. maxSimultaneousLights: int;
  110801. /**
  110802. * Default configuration related to image processing available in the Background Material.
  110803. */
  110804. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  110805. /**
  110806. * Keep track of the image processing observer to allow dispose and replace.
  110807. */
  110808. private _imageProcessingObserver;
  110809. /**
  110810. * Attaches a new image processing configuration to the PBR Material.
  110811. * @param configuration (if null the scene configuration will be use)
  110812. */
  110813. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  110814. /**
  110815. * Gets the image processing configuration used either in this material.
  110816. */
  110817. /**
  110818. * Sets the Default image processing configuration used either in the this material.
  110819. *
  110820. * If sets to null, the scene one is in use.
  110821. */
  110822. imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  110823. /**
  110824. * Gets wether the color curves effect is enabled.
  110825. */
  110826. /**
  110827. * Sets wether the color curves effect is enabled.
  110828. */
  110829. cameraColorCurvesEnabled: boolean;
  110830. /**
  110831. * Gets wether the color grading effect is enabled.
  110832. */
  110833. /**
  110834. * Gets wether the color grading effect is enabled.
  110835. */
  110836. cameraColorGradingEnabled: boolean;
  110837. /**
  110838. * Gets wether tonemapping is enabled or not.
  110839. */
  110840. /**
  110841. * Sets wether tonemapping is enabled or not
  110842. */
  110843. cameraToneMappingEnabled: boolean;
  110844. /**
  110845. * The camera exposure used on this material.
  110846. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  110847. * This corresponds to a photographic exposure.
  110848. */
  110849. /**
  110850. * The camera exposure used on this material.
  110851. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  110852. * This corresponds to a photographic exposure.
  110853. */
  110854. cameraExposure: float;
  110855. /**
  110856. * Gets The camera contrast used on this material.
  110857. */
  110858. /**
  110859. * Sets The camera contrast used on this material.
  110860. */
  110861. cameraContrast: float;
  110862. /**
  110863. * Gets the Color Grading 2D Lookup Texture.
  110864. */
  110865. /**
  110866. * Sets the Color Grading 2D Lookup Texture.
  110867. */
  110868. cameraColorGradingTexture: Nullable<BaseTexture>;
  110869. /**
  110870. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  110871. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  110872. * 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;
  110873. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  110874. */
  110875. /**
  110876. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  110877. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  110878. * 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;
  110879. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  110880. */
  110881. cameraColorCurves: Nullable<ColorCurves>;
  110882. /**
  110883. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  110884. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  110885. */
  110886. switchToBGR: boolean;
  110887. private _renderTargets;
  110888. private _reflectionControls;
  110889. private _white;
  110890. private _primaryShadowColor;
  110891. private _primaryHighlightColor;
  110892. /**
  110893. * Instantiates a Background Material in the given scene
  110894. * @param name The friendly name of the material
  110895. * @param scene The scene to add the material to
  110896. */
  110897. constructor(name: string, scene: Scene);
  110898. /**
  110899. * Gets a boolean indicating that current material needs to register RTT
  110900. */
  110901. readonly hasRenderTargetTextures: boolean;
  110902. /**
  110903. * The entire material has been created in order to prevent overdraw.
  110904. * @returns false
  110905. */
  110906. needAlphaTesting(): boolean;
  110907. /**
  110908. * The entire material has been created in order to prevent overdraw.
  110909. * @returns true if blending is enable
  110910. */
  110911. needAlphaBlending(): boolean;
  110912. /**
  110913. * Checks wether the material is ready to be rendered for a given mesh.
  110914. * @param mesh The mesh to render
  110915. * @param subMesh The submesh to check against
  110916. * @param useInstances Specify wether or not the material is used with instances
  110917. * @returns true if all the dependencies are ready (Textures, Effects...)
  110918. */
  110919. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  110920. /**
  110921. * Compute the primary color according to the chosen perceptual color.
  110922. */
  110923. private _computePrimaryColorFromPerceptualColor;
  110924. /**
  110925. * Compute the highlights and shadow colors according to their chosen levels.
  110926. */
  110927. private _computePrimaryColors;
  110928. /**
  110929. * Build the uniform buffer used in the material.
  110930. */
  110931. buildUniformLayout(): void;
  110932. /**
  110933. * Unbind the material.
  110934. */
  110935. unbind(): void;
  110936. /**
  110937. * Bind only the world matrix to the material.
  110938. * @param world The world matrix to bind.
  110939. */
  110940. bindOnlyWorldMatrix(world: Matrix): void;
  110941. /**
  110942. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  110943. * @param world The world matrix to bind.
  110944. * @param subMesh The submesh to bind for.
  110945. */
  110946. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  110947. /**
  110948. * Checks to see if a texture is used in the material.
  110949. * @param texture - Base texture to use.
  110950. * @returns - Boolean specifying if a texture is used in the material.
  110951. */
  110952. hasTexture(texture: BaseTexture): boolean;
  110953. /**
  110954. * Dispose the material.
  110955. * @param forceDisposeEffect Force disposal of the associated effect.
  110956. * @param forceDisposeTextures Force disposal of the associated textures.
  110957. */
  110958. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  110959. /**
  110960. * Clones the material.
  110961. * @param name The cloned name.
  110962. * @returns The cloned material.
  110963. */
  110964. clone(name: string): BackgroundMaterial;
  110965. /**
  110966. * Serializes the current material to its JSON representation.
  110967. * @returns The JSON representation.
  110968. */
  110969. serialize(): any;
  110970. /**
  110971. * Gets the class name of the material
  110972. * @returns "BackgroundMaterial"
  110973. */
  110974. getClassName(): string;
  110975. /**
  110976. * Parse a JSON input to create back a background material.
  110977. * @param source The JSON data to parse
  110978. * @param scene The scene to create the parsed material in
  110979. * @param rootUrl The root url of the assets the material depends upon
  110980. * @returns the instantiated BackgroundMaterial.
  110981. */
  110982. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  110983. }
  110984. }
  110985. declare module BABYLON {
  110986. /**
  110987. * Represents the different options available during the creation of
  110988. * a Environment helper.
  110989. *
  110990. * This can control the default ground, skybox and image processing setup of your scene.
  110991. */
  110992. export interface IEnvironmentHelperOptions {
  110993. /**
  110994. * Specifies wether or not to create a ground.
  110995. * True by default.
  110996. */
  110997. createGround: boolean;
  110998. /**
  110999. * Specifies the ground size.
  111000. * 15 by default.
  111001. */
  111002. groundSize: number;
  111003. /**
  111004. * The texture used on the ground for the main color.
  111005. * Comes from the BabylonJS CDN by default.
  111006. *
  111007. * Remarks: Can be either a texture or a url.
  111008. */
  111009. groundTexture: string | BaseTexture;
  111010. /**
  111011. * The color mixed in the ground texture by default.
  111012. * BabylonJS clearColor by default.
  111013. */
  111014. groundColor: Color3;
  111015. /**
  111016. * Specifies the ground opacity.
  111017. * 1 by default.
  111018. */
  111019. groundOpacity: number;
  111020. /**
  111021. * Enables the ground to receive shadows.
  111022. * True by default.
  111023. */
  111024. enableGroundShadow: boolean;
  111025. /**
  111026. * Helps preventing the shadow to be fully black on the ground.
  111027. * 0.5 by default.
  111028. */
  111029. groundShadowLevel: number;
  111030. /**
  111031. * Creates a mirror texture attach to the ground.
  111032. * false by default.
  111033. */
  111034. enableGroundMirror: boolean;
  111035. /**
  111036. * Specifies the ground mirror size ratio.
  111037. * 0.3 by default as the default kernel is 64.
  111038. */
  111039. groundMirrorSizeRatio: number;
  111040. /**
  111041. * Specifies the ground mirror blur kernel size.
  111042. * 64 by default.
  111043. */
  111044. groundMirrorBlurKernel: number;
  111045. /**
  111046. * Specifies the ground mirror visibility amount.
  111047. * 1 by default
  111048. */
  111049. groundMirrorAmount: number;
  111050. /**
  111051. * Specifies the ground mirror reflectance weight.
  111052. * This uses the standard weight of the background material to setup the fresnel effect
  111053. * of the mirror.
  111054. * 1 by default.
  111055. */
  111056. groundMirrorFresnelWeight: number;
  111057. /**
  111058. * Specifies the ground mirror Falloff distance.
  111059. * This can helps reducing the size of the reflection.
  111060. * 0 by Default.
  111061. */
  111062. groundMirrorFallOffDistance: number;
  111063. /**
  111064. * Specifies the ground mirror texture type.
  111065. * Unsigned Int by Default.
  111066. */
  111067. groundMirrorTextureType: number;
  111068. /**
  111069. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  111070. * the shown objects.
  111071. */
  111072. groundYBias: number;
  111073. /**
  111074. * Specifies wether or not to create a skybox.
  111075. * True by default.
  111076. */
  111077. createSkybox: boolean;
  111078. /**
  111079. * Specifies the skybox size.
  111080. * 20 by default.
  111081. */
  111082. skyboxSize: number;
  111083. /**
  111084. * The texture used on the skybox for the main color.
  111085. * Comes from the BabylonJS CDN by default.
  111086. *
  111087. * Remarks: Can be either a texture or a url.
  111088. */
  111089. skyboxTexture: string | BaseTexture;
  111090. /**
  111091. * The color mixed in the skybox texture by default.
  111092. * BabylonJS clearColor by default.
  111093. */
  111094. skyboxColor: Color3;
  111095. /**
  111096. * The background rotation around the Y axis of the scene.
  111097. * This helps aligning the key lights of your scene with the background.
  111098. * 0 by default.
  111099. */
  111100. backgroundYRotation: number;
  111101. /**
  111102. * Compute automatically the size of the elements to best fit with the scene.
  111103. */
  111104. sizeAuto: boolean;
  111105. /**
  111106. * Default position of the rootMesh if autoSize is not true.
  111107. */
  111108. rootPosition: Vector3;
  111109. /**
  111110. * Sets up the image processing in the scene.
  111111. * true by default.
  111112. */
  111113. setupImageProcessing: boolean;
  111114. /**
  111115. * The texture used as your environment texture in the scene.
  111116. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  111117. *
  111118. * Remarks: Can be either a texture or a url.
  111119. */
  111120. environmentTexture: string | BaseTexture;
  111121. /**
  111122. * The value of the exposure to apply to the scene.
  111123. * 0.6 by default if setupImageProcessing is true.
  111124. */
  111125. cameraExposure: number;
  111126. /**
  111127. * The value of the contrast to apply to the scene.
  111128. * 1.6 by default if setupImageProcessing is true.
  111129. */
  111130. cameraContrast: number;
  111131. /**
  111132. * Specifies wether or not tonemapping should be enabled in the scene.
  111133. * true by default if setupImageProcessing is true.
  111134. */
  111135. toneMappingEnabled: boolean;
  111136. }
  111137. /**
  111138. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  111139. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  111140. * It also helps with the default setup of your imageProcessing configuration.
  111141. */
  111142. export class EnvironmentHelper {
  111143. /**
  111144. * Default ground texture URL.
  111145. */
  111146. private static _groundTextureCDNUrl;
  111147. /**
  111148. * Default skybox texture URL.
  111149. */
  111150. private static _skyboxTextureCDNUrl;
  111151. /**
  111152. * Default environment texture URL.
  111153. */
  111154. private static _environmentTextureCDNUrl;
  111155. /**
  111156. * Creates the default options for the helper.
  111157. */
  111158. private static _getDefaultOptions;
  111159. private _rootMesh;
  111160. /**
  111161. * Gets the root mesh created by the helper.
  111162. */
  111163. readonly rootMesh: Mesh;
  111164. private _skybox;
  111165. /**
  111166. * Gets the skybox created by the helper.
  111167. */
  111168. readonly skybox: Nullable<Mesh>;
  111169. private _skyboxTexture;
  111170. /**
  111171. * Gets the skybox texture created by the helper.
  111172. */
  111173. readonly skyboxTexture: Nullable<BaseTexture>;
  111174. private _skyboxMaterial;
  111175. /**
  111176. * Gets the skybox material created by the helper.
  111177. */
  111178. readonly skyboxMaterial: Nullable<BackgroundMaterial>;
  111179. private _ground;
  111180. /**
  111181. * Gets the ground mesh created by the helper.
  111182. */
  111183. readonly ground: Nullable<Mesh>;
  111184. private _groundTexture;
  111185. /**
  111186. * Gets the ground texture created by the helper.
  111187. */
  111188. readonly groundTexture: Nullable<BaseTexture>;
  111189. private _groundMirror;
  111190. /**
  111191. * Gets the ground mirror created by the helper.
  111192. */
  111193. readonly groundMirror: Nullable<MirrorTexture>;
  111194. /**
  111195. * Gets the ground mirror render list to helps pushing the meshes
  111196. * you wish in the ground reflection.
  111197. */
  111198. readonly groundMirrorRenderList: Nullable<AbstractMesh[]>;
  111199. private _groundMaterial;
  111200. /**
  111201. * Gets the ground material created by the helper.
  111202. */
  111203. readonly groundMaterial: Nullable<BackgroundMaterial>;
  111204. /**
  111205. * Stores the creation options.
  111206. */
  111207. private readonly _scene;
  111208. private _options;
  111209. /**
  111210. * This observable will be notified with any error during the creation of the environment,
  111211. * mainly texture creation errors.
  111212. */
  111213. onErrorObservable: Observable<{
  111214. message?: string;
  111215. exception?: any;
  111216. }>;
  111217. /**
  111218. * constructor
  111219. * @param options Defines the options we want to customize the helper
  111220. * @param scene The scene to add the material to
  111221. */
  111222. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  111223. /**
  111224. * Updates the background according to the new options
  111225. * @param options
  111226. */
  111227. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  111228. /**
  111229. * Sets the primary color of all the available elements.
  111230. * @param color the main color to affect to the ground and the background
  111231. */
  111232. setMainColor(color: Color3): void;
  111233. /**
  111234. * Setup the image processing according to the specified options.
  111235. */
  111236. private _setupImageProcessing;
  111237. /**
  111238. * Setup the environment texture according to the specified options.
  111239. */
  111240. private _setupEnvironmentTexture;
  111241. /**
  111242. * Setup the background according to the specified options.
  111243. */
  111244. private _setupBackground;
  111245. /**
  111246. * Get the scene sizes according to the setup.
  111247. */
  111248. private _getSceneSize;
  111249. /**
  111250. * Setup the ground according to the specified options.
  111251. */
  111252. private _setupGround;
  111253. /**
  111254. * Setup the ground material according to the specified options.
  111255. */
  111256. private _setupGroundMaterial;
  111257. /**
  111258. * Setup the ground diffuse texture according to the specified options.
  111259. */
  111260. private _setupGroundDiffuseTexture;
  111261. /**
  111262. * Setup the ground mirror texture according to the specified options.
  111263. */
  111264. private _setupGroundMirrorTexture;
  111265. /**
  111266. * Setup the ground to receive the mirror texture.
  111267. */
  111268. private _setupMirrorInGroundMaterial;
  111269. /**
  111270. * Setup the skybox according to the specified options.
  111271. */
  111272. private _setupSkybox;
  111273. /**
  111274. * Setup the skybox material according to the specified options.
  111275. */
  111276. private _setupSkyboxMaterial;
  111277. /**
  111278. * Setup the skybox reflection texture according to the specified options.
  111279. */
  111280. private _setupSkyboxReflectionTexture;
  111281. private _errorHandler;
  111282. /**
  111283. * Dispose all the elements created by the Helper.
  111284. */
  111285. dispose(): void;
  111286. }
  111287. }
  111288. declare module BABYLON {
  111289. /**
  111290. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  111291. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  111292. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  111293. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  111294. */
  111295. export class PhotoDome extends TransformNode {
  111296. /**
  111297. * Define the image as a Monoscopic panoramic 360 image.
  111298. */
  111299. static readonly MODE_MONOSCOPIC: number;
  111300. /**
  111301. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  111302. */
  111303. static readonly MODE_TOPBOTTOM: number;
  111304. /**
  111305. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  111306. */
  111307. static readonly MODE_SIDEBYSIDE: number;
  111308. private _useDirectMapping;
  111309. /**
  111310. * The texture being displayed on the sphere
  111311. */
  111312. protected _photoTexture: Texture;
  111313. /**
  111314. * Gets or sets the texture being displayed on the sphere
  111315. */
  111316. photoTexture: Texture;
  111317. /**
  111318. * Observable raised when an error occured while loading the 360 image
  111319. */
  111320. onLoadErrorObservable: Observable<string>;
  111321. /**
  111322. * The skybox material
  111323. */
  111324. protected _material: BackgroundMaterial;
  111325. /**
  111326. * The surface used for the skybox
  111327. */
  111328. protected _mesh: Mesh;
  111329. /**
  111330. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  111331. * Also see the options.resolution property.
  111332. */
  111333. fovMultiplier: number;
  111334. private _imageMode;
  111335. /**
  111336. * Gets or set the current video mode for the video. It can be:
  111337. * * PhotoDome.MODE_MONOSCOPIC : Define the image as a Monoscopic panoramic 360 image.
  111338. * * PhotoDome.MODE_TOPBOTTOM : Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  111339. * * PhotoDome.MODE_SIDEBYSIDE : Define the image as a Stereoscopic Side by Side panoramic 360 image.
  111340. */
  111341. imageMode: number;
  111342. /**
  111343. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  111344. * @param name Element's name, child elements will append suffixes for their own names.
  111345. * @param urlsOfPhoto defines the url of the photo to display
  111346. * @param options defines an object containing optional or exposed sub element properties
  111347. * @param onError defines a callback called when an error occured while loading the texture
  111348. */
  111349. constructor(name: string, urlOfPhoto: string, options: {
  111350. resolution?: number;
  111351. size?: number;
  111352. useDirectMapping?: boolean;
  111353. faceForward?: boolean;
  111354. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  111355. private _onBeforeCameraRenderObserver;
  111356. private _changeImageMode;
  111357. /**
  111358. * Releases resources associated with this node.
  111359. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  111360. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  111361. */
  111362. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  111363. }
  111364. }
  111365. declare module BABYLON {
  111366. /**
  111367. * Class used to host texture specific utilities
  111368. */
  111369. export class BRDFTextureTools {
  111370. /**
  111371. * Expand the BRDF Texture from RGBD to Half Float if necessary.
  111372. * @param texture the texture to expand.
  111373. */
  111374. private static _ExpandDefaultBRDFTexture;
  111375. /**
  111376. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  111377. * @param scene defines the hosting scene
  111378. * @returns the environment BRDF texture
  111379. */
  111380. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  111381. private static _environmentBRDFBase64Texture;
  111382. }
  111383. }
  111384. declare module BABYLON {
  111385. /**
  111386. * @hidden
  111387. */
  111388. export interface IMaterialClearCoatDefines {
  111389. CLEARCOAT: boolean;
  111390. CLEARCOAT_DEFAULTIOR: boolean;
  111391. CLEARCOAT_TEXTURE: boolean;
  111392. CLEARCOAT_TEXTUREDIRECTUV: number;
  111393. CLEARCOAT_BUMP: boolean;
  111394. CLEARCOAT_BUMPDIRECTUV: number;
  111395. CLEARCOAT_TINT: boolean;
  111396. CLEARCOAT_TINT_TEXTURE: boolean;
  111397. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  111398. /** @hidden */
  111399. _areTexturesDirty: boolean;
  111400. }
  111401. /**
  111402. * Define the code related to the clear coat parameters of the pbr material.
  111403. */
  111404. export class PBRClearCoatConfiguration {
  111405. /**
  111406. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  111407. * The default fits with a polyurethane material.
  111408. */
  111409. private static readonly _DefaultIndexOfRefraction;
  111410. private _isEnabled;
  111411. /**
  111412. * Defines if the clear coat is enabled in the material.
  111413. */
  111414. isEnabled: boolean;
  111415. /**
  111416. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  111417. */
  111418. intensity: number;
  111419. /**
  111420. * Defines the clear coat layer roughness.
  111421. */
  111422. roughness: number;
  111423. private _indexOfRefraction;
  111424. /**
  111425. * Defines the index of refraction of the clear coat.
  111426. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  111427. * The default fits with a polyurethane material.
  111428. * Changing the default value is more performance intensive.
  111429. */
  111430. indexOfRefraction: number;
  111431. private _texture;
  111432. /**
  111433. * Stores the clear coat values in a texture.
  111434. */
  111435. texture: Nullable<BaseTexture>;
  111436. private _bumpTexture;
  111437. /**
  111438. * Define the clear coat specific bump texture.
  111439. */
  111440. bumpTexture: Nullable<BaseTexture>;
  111441. private _isTintEnabled;
  111442. /**
  111443. * Defines if the clear coat tint is enabled in the material.
  111444. */
  111445. isTintEnabled: boolean;
  111446. /**
  111447. * Defines the clear coat tint of the material.
  111448. * This is only use if tint is enabled
  111449. */
  111450. tintColor: Color3;
  111451. /**
  111452. * Defines the distance at which the tint color should be found in the
  111453. * clear coat media.
  111454. * This is only use if tint is enabled
  111455. */
  111456. tintColorAtDistance: number;
  111457. /**
  111458. * Defines the clear coat layer thickness.
  111459. * This is only use if tint is enabled
  111460. */
  111461. tintThickness: number;
  111462. private _tintTexture;
  111463. /**
  111464. * Stores the clear tint values in a texture.
  111465. * rgb is tint
  111466. * a is a thickness factor
  111467. */
  111468. tintTexture: Nullable<BaseTexture>;
  111469. /** @hidden */
  111470. private _internalMarkAllSubMeshesAsTexturesDirty;
  111471. /** @hidden */
  111472. _markAllSubMeshesAsTexturesDirty(): void;
  111473. /**
  111474. * Instantiate a new istance of clear coat configuration.
  111475. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  111476. */
  111477. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  111478. /**
  111479. * Gets wehter the submesh is ready to be used or not.
  111480. * @param defines the list of "defines" to update.
  111481. * @param scene defines the scene the material belongs to.
  111482. * @param engine defines the engine the material belongs to.
  111483. * @param disableBumpMap defines wether the material disables bump or not.
  111484. * @returns - boolean indicating that the submesh is ready or not.
  111485. */
  111486. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  111487. /**
  111488. * Checks to see if a texture is used in the material.
  111489. * @param defines the list of "defines" to update.
  111490. * @param scene defines the scene to the material belongs to.
  111491. */
  111492. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  111493. /**
  111494. * Binds the material data.
  111495. * @param uniformBuffer defines the Uniform buffer to fill in.
  111496. * @param scene defines the scene the material belongs to.
  111497. * @param engine defines the engine the material belongs to.
  111498. * @param disableBumpMap defines wether the material disables bump or not.
  111499. * @param isFrozen defines wether the material is frozen or not.
  111500. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  111501. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  111502. */
  111503. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  111504. /**
  111505. * Checks to see if a texture is used in the material.
  111506. * @param texture - Base texture to use.
  111507. * @returns - Boolean specifying if a texture is used in the material.
  111508. */
  111509. hasTexture(texture: BaseTexture): boolean;
  111510. /**
  111511. * Returns an array of the actively used textures.
  111512. * @param activeTextures Array of BaseTextures
  111513. */
  111514. getActiveTextures(activeTextures: BaseTexture[]): void;
  111515. /**
  111516. * Returns the animatable textures.
  111517. * @param animatables Array of animatable textures.
  111518. */
  111519. getAnimatables(animatables: IAnimatable[]): void;
  111520. /**
  111521. * Disposes the resources of the material.
  111522. * @param forceDisposeTextures - Forces the disposal of all textures.
  111523. */
  111524. dispose(forceDisposeTextures?: boolean): void;
  111525. /**
  111526. * Get the current class name of the texture useful for serialization or dynamic coding.
  111527. * @returns "PBRClearCoatConfiguration"
  111528. */
  111529. getClassName(): string;
  111530. /**
  111531. * Add fallbacks to the effect fallbacks list.
  111532. * @param defines defines the Base texture to use.
  111533. * @param fallbacks defines the current fallback list.
  111534. * @param currentRank defines the current fallback rank.
  111535. * @returns the new fallback rank.
  111536. */
  111537. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  111538. /**
  111539. * Add the required uniforms to the current list.
  111540. * @param uniforms defines the current uniform list.
  111541. */
  111542. static AddUniforms(uniforms: string[]): void;
  111543. /**
  111544. * Add the required samplers to the current list.
  111545. * @param samplers defines the current sampler list.
  111546. */
  111547. static AddSamplers(samplers: string[]): void;
  111548. /**
  111549. * Add the required uniforms to the current buffer.
  111550. * @param uniformBuffer defines the current uniform buffer.
  111551. */
  111552. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  111553. /**
  111554. * Makes a duplicate of the current configuration into another one.
  111555. * @param clearCoatConfiguration define the config where to copy the info
  111556. */
  111557. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  111558. /**
  111559. * Serializes this clear coat configuration.
  111560. * @returns - An object with the serialized config.
  111561. */
  111562. serialize(): any;
  111563. /**
  111564. * Parses a anisotropy Configuration from a serialized object.
  111565. * @param source - Serialized object.
  111566. * @param scene Defines the scene we are parsing for
  111567. * @param rootUrl Defines the rootUrl to load from
  111568. */
  111569. parse(source: any, scene: Scene, rootUrl: string): void;
  111570. }
  111571. }
  111572. declare module BABYLON {
  111573. /**
  111574. * @hidden
  111575. */
  111576. export interface IMaterialAnisotropicDefines {
  111577. ANISOTROPIC: boolean;
  111578. ANISOTROPIC_TEXTURE: boolean;
  111579. ANISOTROPIC_TEXTUREDIRECTUV: number;
  111580. MAINUV1: boolean;
  111581. _areTexturesDirty: boolean;
  111582. _needUVs: boolean;
  111583. }
  111584. /**
  111585. * Define the code related to the anisotropic parameters of the pbr material.
  111586. */
  111587. export class PBRAnisotropicConfiguration {
  111588. private _isEnabled;
  111589. /**
  111590. * Defines if the anisotropy is enabled in the material.
  111591. */
  111592. isEnabled: boolean;
  111593. /**
  111594. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  111595. */
  111596. intensity: number;
  111597. /**
  111598. * Defines if the effect is along the tangents, bitangents or in between.
  111599. * By default, the effect is "strectching" the highlights along the tangents.
  111600. */
  111601. direction: Vector2;
  111602. private _texture;
  111603. /**
  111604. * Stores the anisotropy values in a texture.
  111605. * rg is direction (like normal from -1 to 1)
  111606. * b is a intensity
  111607. */
  111608. texture: Nullable<BaseTexture>;
  111609. /** @hidden */
  111610. private _internalMarkAllSubMeshesAsTexturesDirty;
  111611. /** @hidden */
  111612. _markAllSubMeshesAsTexturesDirty(): void;
  111613. /**
  111614. * Instantiate a new istance of anisotropy configuration.
  111615. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  111616. */
  111617. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  111618. /**
  111619. * Specifies that the submesh is ready to be used.
  111620. * @param defines the list of "defines" to update.
  111621. * @param scene defines the scene the material belongs to.
  111622. * @returns - boolean indicating that the submesh is ready or not.
  111623. */
  111624. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  111625. /**
  111626. * Checks to see if a texture is used in the material.
  111627. * @param defines the list of "defines" to update.
  111628. * @param mesh the mesh we are preparing the defines for.
  111629. * @param scene defines the scene the material belongs to.
  111630. */
  111631. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  111632. /**
  111633. * Binds the material data.
  111634. * @param uniformBuffer defines the Uniform buffer to fill in.
  111635. * @param scene defines the scene the material belongs to.
  111636. * @param isFrozen defines wether the material is frozen or not.
  111637. */
  111638. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  111639. /**
  111640. * Checks to see if a texture is used in the material.
  111641. * @param texture - Base texture to use.
  111642. * @returns - Boolean specifying if a texture is used in the material.
  111643. */
  111644. hasTexture(texture: BaseTexture): boolean;
  111645. /**
  111646. * Returns an array of the actively used textures.
  111647. * @param activeTextures Array of BaseTextures
  111648. */
  111649. getActiveTextures(activeTextures: BaseTexture[]): void;
  111650. /**
  111651. * Returns the animatable textures.
  111652. * @param animatables Array of animatable textures.
  111653. */
  111654. getAnimatables(animatables: IAnimatable[]): void;
  111655. /**
  111656. * Disposes the resources of the material.
  111657. * @param forceDisposeTextures - Forces the disposal of all textures.
  111658. */
  111659. dispose(forceDisposeTextures?: boolean): void;
  111660. /**
  111661. * Get the current class name of the texture useful for serialization or dynamic coding.
  111662. * @returns "PBRAnisotropicConfiguration"
  111663. */
  111664. getClassName(): string;
  111665. /**
  111666. * Add fallbacks to the effect fallbacks list.
  111667. * @param defines defines the Base texture to use.
  111668. * @param fallbacks defines the current fallback list.
  111669. * @param currentRank defines the current fallback rank.
  111670. * @returns the new fallback rank.
  111671. */
  111672. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  111673. /**
  111674. * Add the required uniforms to the current list.
  111675. * @param uniforms defines the current uniform list.
  111676. */
  111677. static AddUniforms(uniforms: string[]): void;
  111678. /**
  111679. * Add the required uniforms to the current buffer.
  111680. * @param uniformBuffer defines the current uniform buffer.
  111681. */
  111682. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  111683. /**
  111684. * Add the required samplers to the current list.
  111685. * @param samplers defines the current sampler list.
  111686. */
  111687. static AddSamplers(samplers: string[]): void;
  111688. /**
  111689. * Makes a duplicate of the current configuration into another one.
  111690. * @param anisotropicConfiguration define the config where to copy the info
  111691. */
  111692. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  111693. /**
  111694. * Serializes this anisotropy configuration.
  111695. * @returns - An object with the serialized config.
  111696. */
  111697. serialize(): any;
  111698. /**
  111699. * Parses a anisotropy Configuration from a serialized object.
  111700. * @param source - Serialized object.
  111701. * @param scene Defines the scene we are parsing for
  111702. * @param rootUrl Defines the rootUrl to load from
  111703. */
  111704. parse(source: any, scene: Scene, rootUrl: string): void;
  111705. }
  111706. }
  111707. declare module BABYLON {
  111708. /**
  111709. * @hidden
  111710. */
  111711. export interface IMaterialBRDFDefines {
  111712. BRDF_V_HEIGHT_CORRELATED: boolean;
  111713. MS_BRDF_ENERGY_CONSERVATION: boolean;
  111714. SPHERICAL_HARMONICS: boolean;
  111715. /** @hidden */
  111716. _areMiscDirty: boolean;
  111717. }
  111718. /**
  111719. * Define the code related to the BRDF parameters of the pbr material.
  111720. */
  111721. export class PBRBRDFConfiguration {
  111722. /**
  111723. * Default value used for the energy conservation.
  111724. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  111725. */
  111726. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  111727. /**
  111728. * Default value used for the Smith Visibility Height Correlated mode.
  111729. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  111730. */
  111731. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  111732. /**
  111733. * Default value used for the IBL diffuse part.
  111734. * This can help switching back to the polynomials mode globally which is a tiny bit
  111735. * less GPU intensive at the drawback of a lower quality.
  111736. */
  111737. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  111738. private _useEnergyConservation;
  111739. /**
  111740. * Defines if the material uses energy conservation.
  111741. */
  111742. useEnergyConservation: boolean;
  111743. private _useSmithVisibilityHeightCorrelated;
  111744. /**
  111745. * LEGACY Mode set to false
  111746. * Defines if the material uses height smith correlated visibility term.
  111747. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  111748. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  111749. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  111750. * Not relying on height correlated will also disable energy conservation.
  111751. */
  111752. useSmithVisibilityHeightCorrelated: boolean;
  111753. private _useSphericalHarmonics;
  111754. /**
  111755. * LEGACY Mode set to false
  111756. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  111757. * diffuse part of the IBL.
  111758. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  111759. * to the ground truth.
  111760. */
  111761. useSphericalHarmonics: boolean;
  111762. /** @hidden */
  111763. private _internalMarkAllSubMeshesAsMiscDirty;
  111764. /** @hidden */
  111765. _markAllSubMeshesAsMiscDirty(): void;
  111766. /**
  111767. * Instantiate a new istance of clear coat configuration.
  111768. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  111769. */
  111770. constructor(markAllSubMeshesAsMiscDirty: () => void);
  111771. /**
  111772. * Checks to see if a texture is used in the material.
  111773. * @param defines the list of "defines" to update.
  111774. */
  111775. prepareDefines(defines: IMaterialBRDFDefines): void;
  111776. /**
  111777. * Get the current class name of the texture useful for serialization or dynamic coding.
  111778. * @returns "PBRClearCoatConfiguration"
  111779. */
  111780. getClassName(): string;
  111781. /**
  111782. * Makes a duplicate of the current configuration into another one.
  111783. * @param brdfConfiguration define the config where to copy the info
  111784. */
  111785. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  111786. /**
  111787. * Serializes this BRDF configuration.
  111788. * @returns - An object with the serialized config.
  111789. */
  111790. serialize(): any;
  111791. /**
  111792. * Parses a anisotropy Configuration from a serialized object.
  111793. * @param source - Serialized object.
  111794. * @param scene Defines the scene we are parsing for
  111795. * @param rootUrl Defines the rootUrl to load from
  111796. */
  111797. parse(source: any, scene: Scene, rootUrl: string): void;
  111798. }
  111799. }
  111800. declare module BABYLON {
  111801. /**
  111802. * @hidden
  111803. */
  111804. export interface IMaterialSheenDefines {
  111805. SHEEN: boolean;
  111806. SHEEN_TEXTURE: boolean;
  111807. SHEEN_TEXTUREDIRECTUV: number;
  111808. SHEEN_LINKWITHALBEDO: boolean;
  111809. /** @hidden */
  111810. _areTexturesDirty: boolean;
  111811. }
  111812. /**
  111813. * Define the code related to the Sheen parameters of the pbr material.
  111814. */
  111815. export class PBRSheenConfiguration {
  111816. private _isEnabled;
  111817. /**
  111818. * Defines if the material uses sheen.
  111819. */
  111820. isEnabled: boolean;
  111821. private _linkSheenWithAlbedo;
  111822. /**
  111823. * Defines if the sheen is linked to the sheen color.
  111824. */
  111825. linkSheenWithAlbedo: boolean;
  111826. /**
  111827. * Defines the sheen intensity.
  111828. */
  111829. intensity: number;
  111830. /**
  111831. * Defines the sheen color.
  111832. */
  111833. color: Color3;
  111834. private _texture;
  111835. /**
  111836. * Stores the sheen tint values in a texture.
  111837. * rgb is tint
  111838. * a is a intensity
  111839. */
  111840. texture: Nullable<BaseTexture>;
  111841. /** @hidden */
  111842. private _internalMarkAllSubMeshesAsTexturesDirty;
  111843. /** @hidden */
  111844. _markAllSubMeshesAsTexturesDirty(): void;
  111845. /**
  111846. * Instantiate a new istance of clear coat configuration.
  111847. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  111848. */
  111849. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  111850. /**
  111851. * Specifies that the submesh is ready to be used.
  111852. * @param defines the list of "defines" to update.
  111853. * @param scene defines the scene the material belongs to.
  111854. * @returns - boolean indicating that the submesh is ready or not.
  111855. */
  111856. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  111857. /**
  111858. * Checks to see if a texture is used in the material.
  111859. * @param defines the list of "defines" to update.
  111860. * @param scene defines the scene the material belongs to.
  111861. */
  111862. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  111863. /**
  111864. * Binds the material data.
  111865. * @param uniformBuffer defines the Uniform buffer to fill in.
  111866. * @param scene defines the scene the material belongs to.
  111867. * @param isFrozen defines wether the material is frozen or not.
  111868. */
  111869. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  111870. /**
  111871. * Checks to see if a texture is used in the material.
  111872. * @param texture - Base texture to use.
  111873. * @returns - Boolean specifying if a texture is used in the material.
  111874. */
  111875. hasTexture(texture: BaseTexture): boolean;
  111876. /**
  111877. * Returns an array of the actively used textures.
  111878. * @param activeTextures Array of BaseTextures
  111879. */
  111880. getActiveTextures(activeTextures: BaseTexture[]): void;
  111881. /**
  111882. * Returns the animatable textures.
  111883. * @param animatables Array of animatable textures.
  111884. */
  111885. getAnimatables(animatables: IAnimatable[]): void;
  111886. /**
  111887. * Disposes the resources of the material.
  111888. * @param forceDisposeTextures - Forces the disposal of all textures.
  111889. */
  111890. dispose(forceDisposeTextures?: boolean): void;
  111891. /**
  111892. * Get the current class name of the texture useful for serialization or dynamic coding.
  111893. * @returns "PBRSheenConfiguration"
  111894. */
  111895. getClassName(): string;
  111896. /**
  111897. * Add fallbacks to the effect fallbacks list.
  111898. * @param defines defines the Base texture to use.
  111899. * @param fallbacks defines the current fallback list.
  111900. * @param currentRank defines the current fallback rank.
  111901. * @returns the new fallback rank.
  111902. */
  111903. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  111904. /**
  111905. * Add the required uniforms to the current list.
  111906. * @param uniforms defines the current uniform list.
  111907. */
  111908. static AddUniforms(uniforms: string[]): void;
  111909. /**
  111910. * Add the required uniforms to the current buffer.
  111911. * @param uniformBuffer defines the current uniform buffer.
  111912. */
  111913. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  111914. /**
  111915. * Add the required samplers to the current list.
  111916. * @param samplers defines the current sampler list.
  111917. */
  111918. static AddSamplers(samplers: string[]): void;
  111919. /**
  111920. * Makes a duplicate of the current configuration into another one.
  111921. * @param sheenConfiguration define the config where to copy the info
  111922. */
  111923. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  111924. /**
  111925. * Serializes this BRDF configuration.
  111926. * @returns - An object with the serialized config.
  111927. */
  111928. serialize(): any;
  111929. /**
  111930. * Parses a anisotropy Configuration from a serialized object.
  111931. * @param source - Serialized object.
  111932. * @param scene Defines the scene we are parsing for
  111933. * @param rootUrl Defines the rootUrl to load from
  111934. */
  111935. parse(source: any, scene: Scene, rootUrl: string): void;
  111936. }
  111937. }
  111938. declare module BABYLON {
  111939. /**
  111940. * @hidden
  111941. */
  111942. export interface IMaterialSubSurfaceDefines {
  111943. SUBSURFACE: boolean;
  111944. SS_REFRACTION: boolean;
  111945. SS_TRANSLUCENCY: boolean;
  111946. SS_SCATERRING: boolean;
  111947. SS_THICKNESSANDMASK_TEXTURE: boolean;
  111948. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  111949. SS_REFRACTIONMAP_3D: boolean;
  111950. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  111951. SS_LODINREFRACTIONALPHA: boolean;
  111952. SS_GAMMAREFRACTION: boolean;
  111953. SS_RGBDREFRACTION: boolean;
  111954. SS_LINEARSPECULARREFRACTION: boolean;
  111955. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  111956. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  111957. /** @hidden */
  111958. _areTexturesDirty: boolean;
  111959. }
  111960. /**
  111961. * Define the code related to the sub surface parameters of the pbr material.
  111962. */
  111963. export class PBRSubSurfaceConfiguration {
  111964. private _isRefractionEnabled;
  111965. /**
  111966. * Defines if the refraction is enabled in the material.
  111967. */
  111968. isRefractionEnabled: boolean;
  111969. private _isTranslucencyEnabled;
  111970. /**
  111971. * Defines if the translucency is enabled in the material.
  111972. */
  111973. isTranslucencyEnabled: boolean;
  111974. private _isScatteringEnabled;
  111975. /**
  111976. * Defines the refraction intensity of the material.
  111977. * The refraction when enabled replaces the Diffuse part of the material.
  111978. * The intensity helps transitionning between diffuse and refraction.
  111979. */
  111980. refractionIntensity: number;
  111981. /**
  111982. * Defines the translucency intensity of the material.
  111983. * When translucency has been enabled, this defines how much of the "translucency"
  111984. * is addded to the diffuse part of the material.
  111985. */
  111986. translucencyIntensity: number;
  111987. /**
  111988. * Defines the scattering intensity of the material.
  111989. * When scattering has been enabled, this defines how much of the "scattered light"
  111990. * is addded to the diffuse part of the material.
  111991. */
  111992. scatteringIntensity: number;
  111993. private _thicknessTexture;
  111994. /**
  111995. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  111996. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  111997. * 0 would mean minimumThickness
  111998. * 1 would mean maximumThickness
  111999. * The other channels might be use as a mask to vary the different effects intensity.
  112000. */
  112001. thicknessTexture: Nullable<BaseTexture>;
  112002. private _refractionTexture;
  112003. /**
  112004. * Defines the texture to use for refraction.
  112005. */
  112006. refractionTexture: Nullable<BaseTexture>;
  112007. private _indexOfRefraction;
  112008. /**
  112009. * Defines the index of refraction used in the material.
  112010. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  112011. */
  112012. indexOfRefraction: number;
  112013. private _invertRefractionY;
  112014. /**
  112015. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  112016. */
  112017. invertRefractionY: boolean;
  112018. private _linkRefractionWithTransparency;
  112019. /**
  112020. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  112021. * Materials half opaque for instance using refraction could benefit from this control.
  112022. */
  112023. linkRefractionWithTransparency: boolean;
  112024. /**
  112025. * Defines the minimum thickness stored in the thickness map.
  112026. * If no thickness map is defined, this value will be used to simulate thickness.
  112027. */
  112028. minimumThickness: number;
  112029. /**
  112030. * Defines the maximum thickness stored in the thickness map.
  112031. */
  112032. maximumThickness: number;
  112033. /**
  112034. * Defines the volume tint of the material.
  112035. * This is used for both translucency and scattering.
  112036. */
  112037. tintColor: Color3;
  112038. /**
  112039. * Defines the distance at which the tint color should be found in the media.
  112040. * This is used for refraction only.
  112041. */
  112042. tintColorAtDistance: number;
  112043. /**
  112044. * Defines how far each channel transmit through the media.
  112045. * It is defined as a color to simplify it selection.
  112046. */
  112047. diffusionDistance: Color3;
  112048. private _useMaskFromThicknessTexture;
  112049. /**
  112050. * Stores the intensity of the different subsurface effects in the thickness texture.
  112051. * * the green channel is the translucency intensity.
  112052. * * the blue channel is the scattering intensity.
  112053. * * the alpha channel is the refraction intensity.
  112054. */
  112055. useMaskFromThicknessTexture: boolean;
  112056. /** @hidden */
  112057. private _internalMarkAllSubMeshesAsTexturesDirty;
  112058. /** @hidden */
  112059. _markAllSubMeshesAsTexturesDirty(): void;
  112060. /**
  112061. * Instantiate a new istance of sub surface configuration.
  112062. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  112063. */
  112064. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  112065. /**
  112066. * Gets wehter the submesh is ready to be used or not.
  112067. * @param defines the list of "defines" to update.
  112068. * @param scene defines the scene the material belongs to.
  112069. * @returns - boolean indicating that the submesh is ready or not.
  112070. */
  112071. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  112072. /**
  112073. * Checks to see if a texture is used in the material.
  112074. * @param defines the list of "defines" to update.
  112075. * @param scene defines the scene to the material belongs to.
  112076. */
  112077. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  112078. /**
  112079. * Binds the material data.
  112080. * @param uniformBuffer defines the Uniform buffer to fill in.
  112081. * @param scene defines the scene the material belongs to.
  112082. * @param engine defines the engine the material belongs to.
  112083. * @param isFrozen defines wether the material is frozen or not.
  112084. * @param lodBasedMicrosurface defines wether the material relies on lod based microsurface or not.
  112085. */
  112086. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean): void;
  112087. /**
  112088. * Unbinds the material from the mesh.
  112089. * @param activeEffect defines the effect that should be unbound from.
  112090. * @returns true if unbound, otherwise false
  112091. */
  112092. unbind(activeEffect: Effect): boolean;
  112093. /**
  112094. * Returns the texture used for refraction or null if none is used.
  112095. * @param scene defines the scene the material belongs to.
  112096. * @returns - Refraction texture if present. If no refraction texture and refraction
  112097. * is linked with transparency, returns environment texture. Otherwise, returns null.
  112098. */
  112099. private _getRefractionTexture;
  112100. /**
  112101. * Returns true if alpha blending should be disabled.
  112102. */
  112103. readonly disableAlphaBlending: boolean;
  112104. /**
  112105. * Fills the list of render target textures.
  112106. * @param renderTargets the list of render targets to update
  112107. */
  112108. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  112109. /**
  112110. * Checks to see if a texture is used in the material.
  112111. * @param texture - Base texture to use.
  112112. * @returns - Boolean specifying if a texture is used in the material.
  112113. */
  112114. hasTexture(texture: BaseTexture): boolean;
  112115. /**
  112116. * Gets a boolean indicating that current material needs to register RTT
  112117. * @returns true if this uses a render target otherwise false.
  112118. */
  112119. hasRenderTargetTextures(): boolean;
  112120. /**
  112121. * Returns an array of the actively used textures.
  112122. * @param activeTextures Array of BaseTextures
  112123. */
  112124. getActiveTextures(activeTextures: BaseTexture[]): void;
  112125. /**
  112126. * Returns the animatable textures.
  112127. * @param animatables Array of animatable textures.
  112128. */
  112129. getAnimatables(animatables: IAnimatable[]): void;
  112130. /**
  112131. * Disposes the resources of the material.
  112132. * @param forceDisposeTextures - Forces the disposal of all textures.
  112133. */
  112134. dispose(forceDisposeTextures?: boolean): void;
  112135. /**
  112136. * Get the current class name of the texture useful for serialization or dynamic coding.
  112137. * @returns "PBRSubSurfaceConfiguration"
  112138. */
  112139. getClassName(): string;
  112140. /**
  112141. * Add fallbacks to the effect fallbacks list.
  112142. * @param defines defines the Base texture to use.
  112143. * @param fallbacks defines the current fallback list.
  112144. * @param currentRank defines the current fallback rank.
  112145. * @returns the new fallback rank.
  112146. */
  112147. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  112148. /**
  112149. * Add the required uniforms to the current list.
  112150. * @param uniforms defines the current uniform list.
  112151. */
  112152. static AddUniforms(uniforms: string[]): void;
  112153. /**
  112154. * Add the required samplers to the current list.
  112155. * @param samplers defines the current sampler list.
  112156. */
  112157. static AddSamplers(samplers: string[]): void;
  112158. /**
  112159. * Add the required uniforms to the current buffer.
  112160. * @param uniformBuffer defines the current uniform buffer.
  112161. */
  112162. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  112163. /**
  112164. * Makes a duplicate of the current configuration into another one.
  112165. * @param configuration define the config where to copy the info
  112166. */
  112167. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  112168. /**
  112169. * Serializes this Sub Surface configuration.
  112170. * @returns - An object with the serialized config.
  112171. */
  112172. serialize(): any;
  112173. /**
  112174. * Parses a anisotropy Configuration from a serialized object.
  112175. * @param source - Serialized object.
  112176. * @param scene Defines the scene we are parsing for
  112177. * @param rootUrl Defines the rootUrl to load from
  112178. */
  112179. parse(source: any, scene: Scene, rootUrl: string): void;
  112180. }
  112181. }
  112182. declare module BABYLON {
  112183. /** @hidden */
  112184. export var pbrFragmentDeclaration: {
  112185. name: string;
  112186. shader: string;
  112187. };
  112188. }
  112189. declare module BABYLON {
  112190. /** @hidden */
  112191. export var pbrUboDeclaration: {
  112192. name: string;
  112193. shader: string;
  112194. };
  112195. }
  112196. declare module BABYLON {
  112197. /** @hidden */
  112198. export var pbrFragmentExtraDeclaration: {
  112199. name: string;
  112200. shader: string;
  112201. };
  112202. }
  112203. declare module BABYLON {
  112204. /** @hidden */
  112205. export var pbrFragmentSamplersDeclaration: {
  112206. name: string;
  112207. shader: string;
  112208. };
  112209. }
  112210. declare module BABYLON {
  112211. /** @hidden */
  112212. export var pbrHelperFunctions: {
  112213. name: string;
  112214. shader: string;
  112215. };
  112216. }
  112217. declare module BABYLON {
  112218. /** @hidden */
  112219. export var harmonicsFunctions: {
  112220. name: string;
  112221. shader: string;
  112222. };
  112223. }
  112224. declare module BABYLON {
  112225. /** @hidden */
  112226. export var pbrDirectLightingSetupFunctions: {
  112227. name: string;
  112228. shader: string;
  112229. };
  112230. }
  112231. declare module BABYLON {
  112232. /** @hidden */
  112233. export var pbrDirectLightingFalloffFunctions: {
  112234. name: string;
  112235. shader: string;
  112236. };
  112237. }
  112238. declare module BABYLON {
  112239. /** @hidden */
  112240. export var pbrBRDFFunctions: {
  112241. name: string;
  112242. shader: string;
  112243. };
  112244. }
  112245. declare module BABYLON {
  112246. /** @hidden */
  112247. export var pbrDirectLightingFunctions: {
  112248. name: string;
  112249. shader: string;
  112250. };
  112251. }
  112252. declare module BABYLON {
  112253. /** @hidden */
  112254. export var pbrIBLFunctions: {
  112255. name: string;
  112256. shader: string;
  112257. };
  112258. }
  112259. declare module BABYLON {
  112260. /** @hidden */
  112261. export var pbrDebug: {
  112262. name: string;
  112263. shader: string;
  112264. };
  112265. }
  112266. declare module BABYLON {
  112267. /** @hidden */
  112268. export var pbrPixelShader: {
  112269. name: string;
  112270. shader: string;
  112271. };
  112272. }
  112273. declare module BABYLON {
  112274. /** @hidden */
  112275. export var pbrVertexDeclaration: {
  112276. name: string;
  112277. shader: string;
  112278. };
  112279. }
  112280. declare module BABYLON {
  112281. /** @hidden */
  112282. export var pbrVertexShader: {
  112283. name: string;
  112284. shader: string;
  112285. };
  112286. }
  112287. declare module BABYLON {
  112288. /**
  112289. * Manages the defines for the PBR Material.
  112290. * @hidden
  112291. */
  112292. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines {
  112293. PBR: boolean;
  112294. MAINUV1: boolean;
  112295. MAINUV2: boolean;
  112296. UV1: boolean;
  112297. UV2: boolean;
  112298. ALBEDO: boolean;
  112299. ALBEDODIRECTUV: number;
  112300. VERTEXCOLOR: boolean;
  112301. AMBIENT: boolean;
  112302. AMBIENTDIRECTUV: number;
  112303. AMBIENTINGRAYSCALE: boolean;
  112304. OPACITY: boolean;
  112305. VERTEXALPHA: boolean;
  112306. OPACITYDIRECTUV: number;
  112307. OPACITYRGB: boolean;
  112308. ALPHATEST: boolean;
  112309. DEPTHPREPASS: boolean;
  112310. ALPHABLEND: boolean;
  112311. ALPHAFROMALBEDO: boolean;
  112312. ALPHATESTVALUE: string;
  112313. SPECULAROVERALPHA: boolean;
  112314. RADIANCEOVERALPHA: boolean;
  112315. ALPHAFRESNEL: boolean;
  112316. LINEARALPHAFRESNEL: boolean;
  112317. PREMULTIPLYALPHA: boolean;
  112318. EMISSIVE: boolean;
  112319. EMISSIVEDIRECTUV: number;
  112320. REFLECTIVITY: boolean;
  112321. REFLECTIVITYDIRECTUV: number;
  112322. SPECULARTERM: boolean;
  112323. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  112324. MICROSURFACEAUTOMATIC: boolean;
  112325. LODBASEDMICROSFURACE: boolean;
  112326. MICROSURFACEMAP: boolean;
  112327. MICROSURFACEMAPDIRECTUV: number;
  112328. METALLICWORKFLOW: boolean;
  112329. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  112330. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  112331. METALLNESSSTOREINMETALMAPBLUE: boolean;
  112332. AOSTOREINMETALMAPRED: boolean;
  112333. ENVIRONMENTBRDF: boolean;
  112334. ENVIRONMENTBRDF_RGBD: boolean;
  112335. NORMAL: boolean;
  112336. TANGENT: boolean;
  112337. BUMP: boolean;
  112338. BUMPDIRECTUV: number;
  112339. OBJECTSPACE_NORMALMAP: boolean;
  112340. PARALLAX: boolean;
  112341. PARALLAXOCCLUSION: boolean;
  112342. NORMALXYSCALE: boolean;
  112343. LIGHTMAP: boolean;
  112344. LIGHTMAPDIRECTUV: number;
  112345. USELIGHTMAPASSHADOWMAP: boolean;
  112346. GAMMALIGHTMAP: boolean;
  112347. REFLECTION: boolean;
  112348. REFLECTIONMAP_3D: boolean;
  112349. REFLECTIONMAP_SPHERICAL: boolean;
  112350. REFLECTIONMAP_PLANAR: boolean;
  112351. REFLECTIONMAP_CUBIC: boolean;
  112352. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  112353. REFLECTIONMAP_PROJECTION: boolean;
  112354. REFLECTIONMAP_SKYBOX: boolean;
  112355. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  112356. REFLECTIONMAP_EXPLICIT: boolean;
  112357. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  112358. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  112359. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  112360. INVERTCUBICMAP: boolean;
  112361. USESPHERICALFROMREFLECTIONMAP: boolean;
  112362. USEIRRADIANCEMAP: boolean;
  112363. SPHERICAL_HARMONICS: boolean;
  112364. USESPHERICALINVERTEX: boolean;
  112365. REFLECTIONMAP_OPPOSITEZ: boolean;
  112366. LODINREFLECTIONALPHA: boolean;
  112367. GAMMAREFLECTION: boolean;
  112368. RGBDREFLECTION: boolean;
  112369. LINEARSPECULARREFLECTION: boolean;
  112370. RADIANCEOCCLUSION: boolean;
  112371. HORIZONOCCLUSION: boolean;
  112372. INSTANCES: boolean;
  112373. NUM_BONE_INFLUENCERS: number;
  112374. BonesPerMesh: number;
  112375. BONETEXTURE: boolean;
  112376. NONUNIFORMSCALING: boolean;
  112377. MORPHTARGETS: boolean;
  112378. MORPHTARGETS_NORMAL: boolean;
  112379. MORPHTARGETS_TANGENT: boolean;
  112380. MORPHTARGETS_UV: boolean;
  112381. NUM_MORPH_INFLUENCERS: number;
  112382. IMAGEPROCESSING: boolean;
  112383. VIGNETTE: boolean;
  112384. VIGNETTEBLENDMODEMULTIPLY: boolean;
  112385. VIGNETTEBLENDMODEOPAQUE: boolean;
  112386. TONEMAPPING: boolean;
  112387. TONEMAPPING_ACES: boolean;
  112388. CONTRAST: boolean;
  112389. COLORCURVES: boolean;
  112390. COLORGRADING: boolean;
  112391. COLORGRADING3D: boolean;
  112392. SAMPLER3DGREENDEPTH: boolean;
  112393. SAMPLER3DBGRMAP: boolean;
  112394. IMAGEPROCESSINGPOSTPROCESS: boolean;
  112395. EXPOSURE: boolean;
  112396. MULTIVIEW: boolean;
  112397. USEPHYSICALLIGHTFALLOFF: boolean;
  112398. USEGLTFLIGHTFALLOFF: boolean;
  112399. TWOSIDEDLIGHTING: boolean;
  112400. SHADOWFLOAT: boolean;
  112401. CLIPPLANE: boolean;
  112402. CLIPPLANE2: boolean;
  112403. CLIPPLANE3: boolean;
  112404. CLIPPLANE4: boolean;
  112405. POINTSIZE: boolean;
  112406. FOG: boolean;
  112407. LOGARITHMICDEPTH: boolean;
  112408. FORCENORMALFORWARD: boolean;
  112409. SPECULARAA: boolean;
  112410. CLEARCOAT: boolean;
  112411. CLEARCOAT_DEFAULTIOR: boolean;
  112412. CLEARCOAT_TEXTURE: boolean;
  112413. CLEARCOAT_TEXTUREDIRECTUV: number;
  112414. CLEARCOAT_BUMP: boolean;
  112415. CLEARCOAT_BUMPDIRECTUV: number;
  112416. CLEARCOAT_TINT: boolean;
  112417. CLEARCOAT_TINT_TEXTURE: boolean;
  112418. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  112419. ANISOTROPIC: boolean;
  112420. ANISOTROPIC_TEXTURE: boolean;
  112421. ANISOTROPIC_TEXTUREDIRECTUV: number;
  112422. BRDF_V_HEIGHT_CORRELATED: boolean;
  112423. MS_BRDF_ENERGY_CONSERVATION: boolean;
  112424. SHEEN: boolean;
  112425. SHEEN_TEXTURE: boolean;
  112426. SHEEN_TEXTUREDIRECTUV: number;
  112427. SHEEN_LINKWITHALBEDO: boolean;
  112428. SUBSURFACE: boolean;
  112429. SS_REFRACTION: boolean;
  112430. SS_TRANSLUCENCY: boolean;
  112431. SS_SCATERRING: boolean;
  112432. SS_THICKNESSANDMASK_TEXTURE: boolean;
  112433. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  112434. SS_REFRACTIONMAP_3D: boolean;
  112435. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  112436. SS_LODINREFRACTIONALPHA: boolean;
  112437. SS_GAMMAREFRACTION: boolean;
  112438. SS_RGBDREFRACTION: boolean;
  112439. SS_LINEARSPECULARREFRACTION: boolean;
  112440. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  112441. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  112442. UNLIT: boolean;
  112443. DEBUGMODE: number;
  112444. /**
  112445. * Initializes the PBR Material defines.
  112446. */
  112447. constructor();
  112448. /**
  112449. * Resets the PBR Material defines.
  112450. */
  112451. reset(): void;
  112452. }
  112453. /**
  112454. * The Physically based material base class of BJS.
  112455. *
  112456. * This offers the main features of a standard PBR material.
  112457. * For more information, please refer to the documentation :
  112458. * https://doc.babylonjs.com/how_to/physically_based_rendering
  112459. */
  112460. export abstract class PBRBaseMaterial extends PushMaterial {
  112461. /**
  112462. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  112463. */
  112464. static readonly PBRMATERIAL_OPAQUE: number;
  112465. /**
  112466. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  112467. */
  112468. static readonly PBRMATERIAL_ALPHATEST: number;
  112469. /**
  112470. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  112471. */
  112472. static readonly PBRMATERIAL_ALPHABLEND: number;
  112473. /**
  112474. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  112475. * They are also discarded below the alpha cutoff threshold to improve performances.
  112476. */
  112477. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  112478. /**
  112479. * Defines the default value of how much AO map is occluding the analytical lights
  112480. * (point spot...).
  112481. */
  112482. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  112483. /**
  112484. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  112485. */
  112486. static readonly LIGHTFALLOFF_PHYSICAL: number;
  112487. /**
  112488. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  112489. * to enhance interoperability with other engines.
  112490. */
  112491. static readonly LIGHTFALLOFF_GLTF: number;
  112492. /**
  112493. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  112494. * to enhance interoperability with other materials.
  112495. */
  112496. static readonly LIGHTFALLOFF_STANDARD: number;
  112497. /**
  112498. * Intensity of the direct lights e.g. the four lights available in your scene.
  112499. * This impacts both the direct diffuse and specular highlights.
  112500. */
  112501. protected _directIntensity: number;
  112502. /**
  112503. * Intensity of the emissive part of the material.
  112504. * This helps controlling the emissive effect without modifying the emissive color.
  112505. */
  112506. protected _emissiveIntensity: number;
  112507. /**
  112508. * Intensity of the environment e.g. how much the environment will light the object
  112509. * either through harmonics for rough material or through the refelction for shiny ones.
  112510. */
  112511. protected _environmentIntensity: number;
  112512. /**
  112513. * This is a special control allowing the reduction of the specular highlights coming from the
  112514. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  112515. */
  112516. protected _specularIntensity: number;
  112517. /**
  112518. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  112519. */
  112520. private _lightingInfos;
  112521. /**
  112522. * Debug Control allowing disabling the bump map on this material.
  112523. */
  112524. protected _disableBumpMap: boolean;
  112525. /**
  112526. * AKA Diffuse Texture in standard nomenclature.
  112527. */
  112528. protected _albedoTexture: Nullable<BaseTexture>;
  112529. /**
  112530. * AKA Occlusion Texture in other nomenclature.
  112531. */
  112532. protected _ambientTexture: Nullable<BaseTexture>;
  112533. /**
  112534. * AKA Occlusion Texture Intensity in other nomenclature.
  112535. */
  112536. protected _ambientTextureStrength: number;
  112537. /**
  112538. * Defines how much the AO map is occluding the analytical lights (point spot...).
  112539. * 1 means it completely occludes it
  112540. * 0 mean it has no impact
  112541. */
  112542. protected _ambientTextureImpactOnAnalyticalLights: number;
  112543. /**
  112544. * Stores the alpha values in a texture.
  112545. */
  112546. protected _opacityTexture: Nullable<BaseTexture>;
  112547. /**
  112548. * Stores the reflection values in a texture.
  112549. */
  112550. protected _reflectionTexture: Nullable<BaseTexture>;
  112551. /**
  112552. * Stores the emissive values in a texture.
  112553. */
  112554. protected _emissiveTexture: Nullable<BaseTexture>;
  112555. /**
  112556. * AKA Specular texture in other nomenclature.
  112557. */
  112558. protected _reflectivityTexture: Nullable<BaseTexture>;
  112559. /**
  112560. * Used to switch from specular/glossiness to metallic/roughness workflow.
  112561. */
  112562. protected _metallicTexture: Nullable<BaseTexture>;
  112563. /**
  112564. * Specifies the metallic scalar of the metallic/roughness workflow.
  112565. * Can also be used to scale the metalness values of the metallic texture.
  112566. */
  112567. protected _metallic: Nullable<number>;
  112568. /**
  112569. * Specifies the roughness scalar of the metallic/roughness workflow.
  112570. * Can also be used to scale the roughness values of the metallic texture.
  112571. */
  112572. protected _roughness: Nullable<number>;
  112573. /**
  112574. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  112575. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  112576. */
  112577. protected _microSurfaceTexture: Nullable<BaseTexture>;
  112578. /**
  112579. * Stores surface normal data used to displace a mesh in a texture.
  112580. */
  112581. protected _bumpTexture: Nullable<BaseTexture>;
  112582. /**
  112583. * Stores the pre-calculated light information of a mesh in a texture.
  112584. */
  112585. protected _lightmapTexture: Nullable<BaseTexture>;
  112586. /**
  112587. * The color of a material in ambient lighting.
  112588. */
  112589. protected _ambientColor: Color3;
  112590. /**
  112591. * AKA Diffuse Color in other nomenclature.
  112592. */
  112593. protected _albedoColor: Color3;
  112594. /**
  112595. * AKA Specular Color in other nomenclature.
  112596. */
  112597. protected _reflectivityColor: Color3;
  112598. /**
  112599. * The color applied when light is reflected from a material.
  112600. */
  112601. protected _reflectionColor: Color3;
  112602. /**
  112603. * The color applied when light is emitted from a material.
  112604. */
  112605. protected _emissiveColor: Color3;
  112606. /**
  112607. * AKA Glossiness in other nomenclature.
  112608. */
  112609. protected _microSurface: number;
  112610. /**
  112611. * Specifies that the material will use the light map as a show map.
  112612. */
  112613. protected _useLightmapAsShadowmap: boolean;
  112614. /**
  112615. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  112616. * makes the reflect vector face the model (under horizon).
  112617. */
  112618. protected _useHorizonOcclusion: boolean;
  112619. /**
  112620. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  112621. * too much the area relying on ambient texture to define their ambient occlusion.
  112622. */
  112623. protected _useRadianceOcclusion: boolean;
  112624. /**
  112625. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  112626. */
  112627. protected _useAlphaFromAlbedoTexture: boolean;
  112628. /**
  112629. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  112630. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  112631. */
  112632. protected _useSpecularOverAlpha: boolean;
  112633. /**
  112634. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  112635. */
  112636. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  112637. /**
  112638. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  112639. */
  112640. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  112641. /**
  112642. * Specifies if the metallic texture contains the roughness information in its green channel.
  112643. */
  112644. protected _useRoughnessFromMetallicTextureGreen: boolean;
  112645. /**
  112646. * Specifies if the metallic texture contains the metallness information in its blue channel.
  112647. */
  112648. protected _useMetallnessFromMetallicTextureBlue: boolean;
  112649. /**
  112650. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  112651. */
  112652. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  112653. /**
  112654. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  112655. */
  112656. protected _useAmbientInGrayScale: boolean;
  112657. /**
  112658. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  112659. * The material will try to infer what glossiness each pixel should be.
  112660. */
  112661. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  112662. /**
  112663. * Defines the falloff type used in this material.
  112664. * It by default is Physical.
  112665. */
  112666. protected _lightFalloff: number;
  112667. /**
  112668. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  112669. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  112670. */
  112671. protected _useRadianceOverAlpha: boolean;
  112672. /**
  112673. * Allows using an object space normal map (instead of tangent space).
  112674. */
  112675. protected _useObjectSpaceNormalMap: boolean;
  112676. /**
  112677. * Allows using the bump map in parallax mode.
  112678. */
  112679. protected _useParallax: boolean;
  112680. /**
  112681. * Allows using the bump map in parallax occlusion mode.
  112682. */
  112683. protected _useParallaxOcclusion: boolean;
  112684. /**
  112685. * Controls the scale bias of the parallax mode.
  112686. */
  112687. protected _parallaxScaleBias: number;
  112688. /**
  112689. * If sets to true, disables all the lights affecting the material.
  112690. */
  112691. protected _disableLighting: boolean;
  112692. /**
  112693. * Number of Simultaneous lights allowed on the material.
  112694. */
  112695. protected _maxSimultaneousLights: number;
  112696. /**
  112697. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  112698. */
  112699. protected _invertNormalMapX: boolean;
  112700. /**
  112701. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  112702. */
  112703. protected _invertNormalMapY: boolean;
  112704. /**
  112705. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  112706. */
  112707. protected _twoSidedLighting: boolean;
  112708. /**
  112709. * Defines the alpha limits in alpha test mode.
  112710. */
  112711. protected _alphaCutOff: number;
  112712. /**
  112713. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  112714. */
  112715. protected _forceAlphaTest: boolean;
  112716. /**
  112717. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  112718. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  112719. */
  112720. protected _useAlphaFresnel: boolean;
  112721. /**
  112722. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  112723. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  112724. */
  112725. protected _useLinearAlphaFresnel: boolean;
  112726. /**
  112727. * The transparency mode of the material.
  112728. */
  112729. protected _transparencyMode: Nullable<number>;
  112730. /**
  112731. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  112732. * from cos thetav and roughness:
  112733. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  112734. */
  112735. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  112736. /**
  112737. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  112738. */
  112739. protected _forceIrradianceInFragment: boolean;
  112740. /**
  112741. * Force normal to face away from face.
  112742. */
  112743. protected _forceNormalForward: boolean;
  112744. /**
  112745. * Enables specular anti aliasing in the PBR shader.
  112746. * It will both interacts on the Geometry for analytical and IBL lighting.
  112747. * It also prefilter the roughness map based on the bump values.
  112748. */
  112749. protected _enableSpecularAntiAliasing: boolean;
  112750. /**
  112751. * Default configuration related to image processing available in the PBR Material.
  112752. */
  112753. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  112754. /**
  112755. * Keep track of the image processing observer to allow dispose and replace.
  112756. */
  112757. private _imageProcessingObserver;
  112758. /**
  112759. * Attaches a new image processing configuration to the PBR Material.
  112760. * @param configuration
  112761. */
  112762. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  112763. /**
  112764. * Stores the available render targets.
  112765. */
  112766. private _renderTargets;
  112767. /**
  112768. * Sets the global ambient color for the material used in lighting calculations.
  112769. */
  112770. private _globalAmbientColor;
  112771. /**
  112772. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  112773. */
  112774. private _useLogarithmicDepth;
  112775. /**
  112776. * If set to true, no lighting calculations will be applied.
  112777. */
  112778. private _unlit;
  112779. private _debugMode;
  112780. /**
  112781. * @hidden
  112782. * This is reserved for the inspector.
  112783. * Defines the material debug mode.
  112784. * It helps seeing only some components of the material while troubleshooting.
  112785. */
  112786. debugMode: number;
  112787. /**
  112788. * @hidden
  112789. * This is reserved for the inspector.
  112790. * Specify from where on screen the debug mode should start.
  112791. * The value goes from -1 (full screen) to 1 (not visible)
  112792. * It helps with side by side comparison against the final render
  112793. * This defaults to -1
  112794. */
  112795. private debugLimit;
  112796. /**
  112797. * @hidden
  112798. * This is reserved for the inspector.
  112799. * As the default viewing range might not be enough (if the ambient is really small for instance)
  112800. * You can use the factor to better multiply the final value.
  112801. */
  112802. private debugFactor;
  112803. /**
  112804. * Defines the clear coat layer parameters for the material.
  112805. */
  112806. readonly clearCoat: PBRClearCoatConfiguration;
  112807. /**
  112808. * Defines the anisotropic parameters for the material.
  112809. */
  112810. readonly anisotropy: PBRAnisotropicConfiguration;
  112811. /**
  112812. * Defines the BRDF parameters for the material.
  112813. */
  112814. readonly brdf: PBRBRDFConfiguration;
  112815. /**
  112816. * Defines the Sheen parameters for the material.
  112817. */
  112818. readonly sheen: PBRSheenConfiguration;
  112819. /**
  112820. * Defines the SubSurface parameters for the material.
  112821. */
  112822. readonly subSurface: PBRSubSurfaceConfiguration;
  112823. /**
  112824. * Custom callback helping to override the default shader used in the material.
  112825. */
  112826. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: PBRMaterialDefines) => string;
  112827. protected _rebuildInParallel: boolean;
  112828. /**
  112829. * Instantiates a new PBRMaterial instance.
  112830. *
  112831. * @param name The material name
  112832. * @param scene The scene the material will be use in.
  112833. */
  112834. constructor(name: string, scene: Scene);
  112835. /**
  112836. * Gets a boolean indicating that current material needs to register RTT
  112837. */
  112838. readonly hasRenderTargetTextures: boolean;
  112839. /**
  112840. * Gets the name of the material class.
  112841. */
  112842. getClassName(): string;
  112843. /**
  112844. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  112845. */
  112846. /**
  112847. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  112848. */
  112849. useLogarithmicDepth: boolean;
  112850. /**
  112851. * Gets the current transparency mode.
  112852. */
  112853. /**
  112854. * Sets the transparency mode of the material.
  112855. *
  112856. * | Value | Type | Description |
  112857. * | ----- | ----------------------------------- | ----------- |
  112858. * | 0 | OPAQUE | |
  112859. * | 1 | ALPHATEST | |
  112860. * | 2 | ALPHABLEND | |
  112861. * | 3 | ALPHATESTANDBLEND | |
  112862. *
  112863. */
  112864. transparencyMode: Nullable<number>;
  112865. /**
  112866. * Returns true if alpha blending should be disabled.
  112867. */
  112868. private readonly _disableAlphaBlending;
  112869. /**
  112870. * Specifies whether or not this material should be rendered in alpha blend mode.
  112871. */
  112872. needAlphaBlending(): boolean;
  112873. /**
  112874. * Specifies if the mesh will require alpha blending.
  112875. * @param mesh - BJS mesh.
  112876. */
  112877. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  112878. /**
  112879. * Specifies whether or not this material should be rendered in alpha test mode.
  112880. */
  112881. needAlphaTesting(): boolean;
  112882. /**
  112883. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  112884. */
  112885. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  112886. /**
  112887. * Gets the texture used for the alpha test.
  112888. */
  112889. getAlphaTestTexture(): Nullable<BaseTexture>;
  112890. /**
  112891. * Specifies that the submesh is ready to be used.
  112892. * @param mesh - BJS mesh.
  112893. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  112894. * @param useInstances - Specifies that instances should be used.
  112895. * @returns - boolean indicating that the submesh is ready or not.
  112896. */
  112897. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  112898. /**
  112899. * Specifies if the material uses metallic roughness workflow.
  112900. * @returns boolean specifiying if the material uses metallic roughness workflow.
  112901. */
  112902. isMetallicWorkflow(): boolean;
  112903. private _prepareEffect;
  112904. private _prepareDefines;
  112905. /**
  112906. * Force shader compilation
  112907. */
  112908. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  112909. clipPlane: boolean;
  112910. }>): void;
  112911. /**
  112912. * Initializes the uniform buffer layout for the shader.
  112913. */
  112914. buildUniformLayout(): void;
  112915. /**
  112916. * Unbinds the material from the mesh
  112917. */
  112918. unbind(): void;
  112919. /**
  112920. * Binds the submesh data.
  112921. * @param world - The world matrix.
  112922. * @param mesh - The BJS mesh.
  112923. * @param subMesh - A submesh of the BJS mesh.
  112924. */
  112925. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  112926. /**
  112927. * Returns the animatable textures.
  112928. * @returns - Array of animatable textures.
  112929. */
  112930. getAnimatables(): IAnimatable[];
  112931. /**
  112932. * Returns the texture used for reflections.
  112933. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  112934. */
  112935. private _getReflectionTexture;
  112936. /**
  112937. * Returns an array of the actively used textures.
  112938. * @returns - Array of BaseTextures
  112939. */
  112940. getActiveTextures(): BaseTexture[];
  112941. /**
  112942. * Checks to see if a texture is used in the material.
  112943. * @param texture - Base texture to use.
  112944. * @returns - Boolean specifying if a texture is used in the material.
  112945. */
  112946. hasTexture(texture: BaseTexture): boolean;
  112947. /**
  112948. * Disposes the resources of the material.
  112949. * @param forceDisposeEffect - Forces the disposal of effects.
  112950. * @param forceDisposeTextures - Forces the disposal of all textures.
  112951. */
  112952. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  112953. }
  112954. }
  112955. declare module BABYLON {
  112956. /**
  112957. * The Physically based material of BJS.
  112958. *
  112959. * This offers the main features of a standard PBR material.
  112960. * For more information, please refer to the documentation :
  112961. * https://doc.babylonjs.com/how_to/physically_based_rendering
  112962. */
  112963. export class PBRMaterial extends PBRBaseMaterial {
  112964. /**
  112965. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  112966. */
  112967. static readonly PBRMATERIAL_OPAQUE: number;
  112968. /**
  112969. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  112970. */
  112971. static readonly PBRMATERIAL_ALPHATEST: number;
  112972. /**
  112973. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  112974. */
  112975. static readonly PBRMATERIAL_ALPHABLEND: number;
  112976. /**
  112977. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  112978. * They are also discarded below the alpha cutoff threshold to improve performances.
  112979. */
  112980. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  112981. /**
  112982. * Defines the default value of how much AO map is occluding the analytical lights
  112983. * (point spot...).
  112984. */
  112985. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  112986. /**
  112987. * Intensity of the direct lights e.g. the four lights available in your scene.
  112988. * This impacts both the direct diffuse and specular highlights.
  112989. */
  112990. directIntensity: number;
  112991. /**
  112992. * Intensity of the emissive part of the material.
  112993. * This helps controlling the emissive effect without modifying the emissive color.
  112994. */
  112995. emissiveIntensity: number;
  112996. /**
  112997. * Intensity of the environment e.g. how much the environment will light the object
  112998. * either through harmonics for rough material or through the refelction for shiny ones.
  112999. */
  113000. environmentIntensity: number;
  113001. /**
  113002. * This is a special control allowing the reduction of the specular highlights coming from the
  113003. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  113004. */
  113005. specularIntensity: number;
  113006. /**
  113007. * Debug Control allowing disabling the bump map on this material.
  113008. */
  113009. disableBumpMap: boolean;
  113010. /**
  113011. * AKA Diffuse Texture in standard nomenclature.
  113012. */
  113013. albedoTexture: BaseTexture;
  113014. /**
  113015. * AKA Occlusion Texture in other nomenclature.
  113016. */
  113017. ambientTexture: BaseTexture;
  113018. /**
  113019. * AKA Occlusion Texture Intensity in other nomenclature.
  113020. */
  113021. ambientTextureStrength: number;
  113022. /**
  113023. * Defines how much the AO map is occluding the analytical lights (point spot...).
  113024. * 1 means it completely occludes it
  113025. * 0 mean it has no impact
  113026. */
  113027. ambientTextureImpactOnAnalyticalLights: number;
  113028. /**
  113029. * Stores the alpha values in a texture.
  113030. */
  113031. opacityTexture: BaseTexture;
  113032. /**
  113033. * Stores the reflection values in a texture.
  113034. */
  113035. reflectionTexture: Nullable<BaseTexture>;
  113036. /**
  113037. * Stores the emissive values in a texture.
  113038. */
  113039. emissiveTexture: BaseTexture;
  113040. /**
  113041. * AKA Specular texture in other nomenclature.
  113042. */
  113043. reflectivityTexture: BaseTexture;
  113044. /**
  113045. * Used to switch from specular/glossiness to metallic/roughness workflow.
  113046. */
  113047. metallicTexture: BaseTexture;
  113048. /**
  113049. * Specifies the metallic scalar of the metallic/roughness workflow.
  113050. * Can also be used to scale the metalness values of the metallic texture.
  113051. */
  113052. metallic: Nullable<number>;
  113053. /**
  113054. * Specifies the roughness scalar of the metallic/roughness workflow.
  113055. * Can also be used to scale the roughness values of the metallic texture.
  113056. */
  113057. roughness: Nullable<number>;
  113058. /**
  113059. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  113060. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  113061. */
  113062. microSurfaceTexture: BaseTexture;
  113063. /**
  113064. * Stores surface normal data used to displace a mesh in a texture.
  113065. */
  113066. bumpTexture: BaseTexture;
  113067. /**
  113068. * Stores the pre-calculated light information of a mesh in a texture.
  113069. */
  113070. lightmapTexture: BaseTexture;
  113071. /**
  113072. * Stores the refracted light information in a texture.
  113073. */
  113074. refractionTexture: Nullable<BaseTexture>;
  113075. /**
  113076. * The color of a material in ambient lighting.
  113077. */
  113078. ambientColor: Color3;
  113079. /**
  113080. * AKA Diffuse Color in other nomenclature.
  113081. */
  113082. albedoColor: Color3;
  113083. /**
  113084. * AKA Specular Color in other nomenclature.
  113085. */
  113086. reflectivityColor: Color3;
  113087. /**
  113088. * The color reflected from the material.
  113089. */
  113090. reflectionColor: Color3;
  113091. /**
  113092. * The color emitted from the material.
  113093. */
  113094. emissiveColor: Color3;
  113095. /**
  113096. * AKA Glossiness in other nomenclature.
  113097. */
  113098. microSurface: number;
  113099. /**
  113100. * source material index of refraction (IOR)' / 'destination material IOR.
  113101. */
  113102. indexOfRefraction: number;
  113103. /**
  113104. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  113105. */
  113106. invertRefractionY: boolean;
  113107. /**
  113108. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  113109. * Materials half opaque for instance using refraction could benefit from this control.
  113110. */
  113111. linkRefractionWithTransparency: boolean;
  113112. /**
  113113. * If true, the light map contains occlusion information instead of lighting info.
  113114. */
  113115. useLightmapAsShadowmap: boolean;
  113116. /**
  113117. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  113118. */
  113119. useAlphaFromAlbedoTexture: boolean;
  113120. /**
  113121. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  113122. */
  113123. forceAlphaTest: boolean;
  113124. /**
  113125. * Defines the alpha limits in alpha test mode.
  113126. */
  113127. alphaCutOff: number;
  113128. /**
  113129. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  113130. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  113131. */
  113132. useSpecularOverAlpha: boolean;
  113133. /**
  113134. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  113135. */
  113136. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  113137. /**
  113138. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  113139. */
  113140. useRoughnessFromMetallicTextureAlpha: boolean;
  113141. /**
  113142. * Specifies if the metallic texture contains the roughness information in its green channel.
  113143. */
  113144. useRoughnessFromMetallicTextureGreen: boolean;
  113145. /**
  113146. * Specifies if the metallic texture contains the metallness information in its blue channel.
  113147. */
  113148. useMetallnessFromMetallicTextureBlue: boolean;
  113149. /**
  113150. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  113151. */
  113152. useAmbientOcclusionFromMetallicTextureRed: boolean;
  113153. /**
  113154. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  113155. */
  113156. useAmbientInGrayScale: boolean;
  113157. /**
  113158. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  113159. * The material will try to infer what glossiness each pixel should be.
  113160. */
  113161. useAutoMicroSurfaceFromReflectivityMap: boolean;
  113162. /**
  113163. * BJS is using an harcoded light falloff based on a manually sets up range.
  113164. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  113165. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  113166. */
  113167. /**
  113168. * BJS is using an harcoded light falloff based on a manually sets up range.
  113169. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  113170. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  113171. */
  113172. usePhysicalLightFalloff: boolean;
  113173. /**
  113174. * In order to support the falloff compatibility with gltf, a special mode has been added
  113175. * to reproduce the gltf light falloff.
  113176. */
  113177. /**
  113178. * In order to support the falloff compatibility with gltf, a special mode has been added
  113179. * to reproduce the gltf light falloff.
  113180. */
  113181. useGLTFLightFalloff: boolean;
  113182. /**
  113183. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  113184. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  113185. */
  113186. useRadianceOverAlpha: boolean;
  113187. /**
  113188. * Allows using an object space normal map (instead of tangent space).
  113189. */
  113190. useObjectSpaceNormalMap: boolean;
  113191. /**
  113192. * Allows using the bump map in parallax mode.
  113193. */
  113194. useParallax: boolean;
  113195. /**
  113196. * Allows using the bump map in parallax occlusion mode.
  113197. */
  113198. useParallaxOcclusion: boolean;
  113199. /**
  113200. * Controls the scale bias of the parallax mode.
  113201. */
  113202. parallaxScaleBias: number;
  113203. /**
  113204. * If sets to true, disables all the lights affecting the material.
  113205. */
  113206. disableLighting: boolean;
  113207. /**
  113208. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  113209. */
  113210. forceIrradianceInFragment: boolean;
  113211. /**
  113212. * Number of Simultaneous lights allowed on the material.
  113213. */
  113214. maxSimultaneousLights: number;
  113215. /**
  113216. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  113217. */
  113218. invertNormalMapX: boolean;
  113219. /**
  113220. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  113221. */
  113222. invertNormalMapY: boolean;
  113223. /**
  113224. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  113225. */
  113226. twoSidedLighting: boolean;
  113227. /**
  113228. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  113229. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  113230. */
  113231. useAlphaFresnel: boolean;
  113232. /**
  113233. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  113234. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  113235. */
  113236. useLinearAlphaFresnel: boolean;
  113237. /**
  113238. * Let user defines the brdf lookup texture used for IBL.
  113239. * A default 8bit version is embedded but you could point at :
  113240. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  113241. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  113242. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  113243. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  113244. */
  113245. environmentBRDFTexture: Nullable<BaseTexture>;
  113246. /**
  113247. * Force normal to face away from face.
  113248. */
  113249. forceNormalForward: boolean;
  113250. /**
  113251. * Enables specular anti aliasing in the PBR shader.
  113252. * It will both interacts on the Geometry for analytical and IBL lighting.
  113253. * It also prefilter the roughness map based on the bump values.
  113254. */
  113255. enableSpecularAntiAliasing: boolean;
  113256. /**
  113257. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  113258. * makes the reflect vector face the model (under horizon).
  113259. */
  113260. useHorizonOcclusion: boolean;
  113261. /**
  113262. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  113263. * too much the area relying on ambient texture to define their ambient occlusion.
  113264. */
  113265. useRadianceOcclusion: boolean;
  113266. /**
  113267. * If set to true, no lighting calculations will be applied.
  113268. */
  113269. unlit: boolean;
  113270. /**
  113271. * Gets the image processing configuration used either in this material.
  113272. */
  113273. /**
  113274. * Sets the Default image processing configuration used either in the this material.
  113275. *
  113276. * If sets to null, the scene one is in use.
  113277. */
  113278. imageProcessingConfiguration: ImageProcessingConfiguration;
  113279. /**
  113280. * Gets wether the color curves effect is enabled.
  113281. */
  113282. /**
  113283. * Sets wether the color curves effect is enabled.
  113284. */
  113285. cameraColorCurvesEnabled: boolean;
  113286. /**
  113287. * Gets wether the color grading effect is enabled.
  113288. */
  113289. /**
  113290. * Gets wether the color grading effect is enabled.
  113291. */
  113292. cameraColorGradingEnabled: boolean;
  113293. /**
  113294. * Gets wether tonemapping is enabled or not.
  113295. */
  113296. /**
  113297. * Sets wether tonemapping is enabled or not
  113298. */
  113299. cameraToneMappingEnabled: boolean;
  113300. /**
  113301. * The camera exposure used on this material.
  113302. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  113303. * This corresponds to a photographic exposure.
  113304. */
  113305. /**
  113306. * The camera exposure used on this material.
  113307. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  113308. * This corresponds to a photographic exposure.
  113309. */
  113310. cameraExposure: number;
  113311. /**
  113312. * Gets The camera contrast used on this material.
  113313. */
  113314. /**
  113315. * Sets The camera contrast used on this material.
  113316. */
  113317. cameraContrast: number;
  113318. /**
  113319. * Gets the Color Grading 2D Lookup Texture.
  113320. */
  113321. /**
  113322. * Sets the Color Grading 2D Lookup Texture.
  113323. */
  113324. cameraColorGradingTexture: Nullable<BaseTexture>;
  113325. /**
  113326. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  113327. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  113328. * 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;
  113329. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  113330. */
  113331. /**
  113332. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  113333. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  113334. * 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;
  113335. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  113336. */
  113337. cameraColorCurves: Nullable<ColorCurves>;
  113338. /**
  113339. * Instantiates a new PBRMaterial instance.
  113340. *
  113341. * @param name The material name
  113342. * @param scene The scene the material will be use in.
  113343. */
  113344. constructor(name: string, scene: Scene);
  113345. /**
  113346. * Returns the name of this material class.
  113347. */
  113348. getClassName(): string;
  113349. /**
  113350. * Makes a duplicate of the current material.
  113351. * @param name - name to use for the new material.
  113352. */
  113353. clone(name: string): PBRMaterial;
  113354. /**
  113355. * Serializes this PBR Material.
  113356. * @returns - An object with the serialized material.
  113357. */
  113358. serialize(): any;
  113359. /**
  113360. * Parses a PBR Material from a serialized object.
  113361. * @param source - Serialized object.
  113362. * @param scene - BJS scene instance.
  113363. * @param rootUrl - url for the scene object
  113364. * @returns - PBRMaterial
  113365. */
  113366. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  113367. }
  113368. }
  113369. declare module BABYLON {
  113370. /**
  113371. * Direct draw surface info
  113372. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  113373. */
  113374. export interface DDSInfo {
  113375. /**
  113376. * Width of the texture
  113377. */
  113378. width: number;
  113379. /**
  113380. * Width of the texture
  113381. */
  113382. height: number;
  113383. /**
  113384. * Number of Mipmaps for the texture
  113385. * @see https://en.wikipedia.org/wiki/Mipmap
  113386. */
  113387. mipmapCount: number;
  113388. /**
  113389. * If the textures format is a known fourCC format
  113390. * @see https://www.fourcc.org/
  113391. */
  113392. isFourCC: boolean;
  113393. /**
  113394. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  113395. */
  113396. isRGB: boolean;
  113397. /**
  113398. * If the texture is a lumincance format
  113399. */
  113400. isLuminance: boolean;
  113401. /**
  113402. * If this is a cube texture
  113403. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  113404. */
  113405. isCube: boolean;
  113406. /**
  113407. * If the texture is a compressed format eg. FOURCC_DXT1
  113408. */
  113409. isCompressed: boolean;
  113410. /**
  113411. * The dxgiFormat of the texture
  113412. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  113413. */
  113414. dxgiFormat: number;
  113415. /**
  113416. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  113417. */
  113418. textureType: number;
  113419. /**
  113420. * Sphericle polynomial created for the dds texture
  113421. */
  113422. sphericalPolynomial?: SphericalPolynomial;
  113423. }
  113424. /**
  113425. * Class used to provide DDS decompression tools
  113426. */
  113427. export class DDSTools {
  113428. /**
  113429. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  113430. */
  113431. static StoreLODInAlphaChannel: boolean;
  113432. /**
  113433. * Gets DDS information from an array buffer
  113434. * @param arrayBuffer defines the array buffer to read data from
  113435. * @returns the DDS information
  113436. */
  113437. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  113438. private static _FloatView;
  113439. private static _Int32View;
  113440. private static _ToHalfFloat;
  113441. private static _FromHalfFloat;
  113442. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  113443. private static _GetHalfFloatRGBAArrayBuffer;
  113444. private static _GetFloatRGBAArrayBuffer;
  113445. private static _GetFloatAsUIntRGBAArrayBuffer;
  113446. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  113447. private static _GetRGBAArrayBuffer;
  113448. private static _ExtractLongWordOrder;
  113449. private static _GetRGBArrayBuffer;
  113450. private static _GetLuminanceArrayBuffer;
  113451. /**
  113452. * Uploads DDS Levels to a Babylon Texture
  113453. * @hidden
  113454. */
  113455. static UploadDDSLevels(engine: Engine, texture: InternalTexture, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  113456. }
  113457. interface Engine {
  113458. /**
  113459. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  113460. * @param rootUrl defines the url where the file to load is located
  113461. * @param scene defines the current scene
  113462. * @param lodScale defines scale to apply to the mip map selection
  113463. * @param lodOffset defines offset to apply to the mip map selection
  113464. * @param onLoad defines an optional callback raised when the texture is loaded
  113465. * @param onError defines an optional callback raised if there is an issue to load the texture
  113466. * @param format defines the format of the data
  113467. * @param forcedExtension defines the extension to use to pick the right loader
  113468. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  113469. * @returns the cube texture as an InternalTexture
  113470. */
  113471. 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;
  113472. }
  113473. }
  113474. declare module BABYLON {
  113475. /**
  113476. * Implementation of the DDS Texture Loader.
  113477. * @hidden
  113478. */
  113479. export class _DDSTextureLoader implements IInternalTextureLoader {
  113480. /**
  113481. * Defines wether the loader supports cascade loading the different faces.
  113482. */
  113483. readonly supportCascades: boolean;
  113484. /**
  113485. * This returns if the loader support the current file information.
  113486. * @param extension defines the file extension of the file being loaded
  113487. * @param textureFormatInUse defines the current compressed format in use iun the engine
  113488. * @param fallback defines the fallback internal texture if any
  113489. * @param isBase64 defines whether the texture is encoded as a base64
  113490. * @param isBuffer defines whether the texture data are stored as a buffer
  113491. * @returns true if the loader can load the specified file
  113492. */
  113493. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  113494. /**
  113495. * Transform the url before loading if required.
  113496. * @param rootUrl the url of the texture
  113497. * @param textureFormatInUse defines the current compressed format in use iun the engine
  113498. * @returns the transformed texture
  113499. */
  113500. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  113501. /**
  113502. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  113503. * @param rootUrl the url of the texture
  113504. * @param textureFormatInUse defines the current compressed format in use iun the engine
  113505. * @returns the fallback texture
  113506. */
  113507. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  113508. /**
  113509. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  113510. * @param data contains the texture data
  113511. * @param texture defines the BabylonJS internal texture
  113512. * @param createPolynomials will be true if polynomials have been requested
  113513. * @param onLoad defines the callback to trigger once the texture is ready
  113514. * @param onError defines the callback to trigger in case of error
  113515. */
  113516. loadCubeData(imgs: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  113517. /**
  113518. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  113519. * @param data contains the texture data
  113520. * @param texture defines the BabylonJS internal texture
  113521. * @param callback defines the method to call once ready to upload
  113522. */
  113523. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  113524. }
  113525. }
  113526. declare module BABYLON {
  113527. /**
  113528. * Implementation of the ENV Texture Loader.
  113529. * @hidden
  113530. */
  113531. export class _ENVTextureLoader implements IInternalTextureLoader {
  113532. /**
  113533. * Defines wether the loader supports cascade loading the different faces.
  113534. */
  113535. readonly supportCascades: boolean;
  113536. /**
  113537. * This returns if the loader support the current file information.
  113538. * @param extension defines the file extension of the file being loaded
  113539. * @param textureFormatInUse defines the current compressed format in use iun the engine
  113540. * @param fallback defines the fallback internal texture if any
  113541. * @param isBase64 defines whether the texture is encoded as a base64
  113542. * @param isBuffer defines whether the texture data are stored as a buffer
  113543. * @returns true if the loader can load the specified file
  113544. */
  113545. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  113546. /**
  113547. * Transform the url before loading if required.
  113548. * @param rootUrl the url of the texture
  113549. * @param textureFormatInUse defines the current compressed format in use iun the engine
  113550. * @returns the transformed texture
  113551. */
  113552. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  113553. /**
  113554. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  113555. * @param rootUrl the url of the texture
  113556. * @param textureFormatInUse defines the current compressed format in use iun the engine
  113557. * @returns the fallback texture
  113558. */
  113559. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  113560. /**
  113561. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  113562. * @param data contains the texture data
  113563. * @param texture defines the BabylonJS internal texture
  113564. * @param createPolynomials will be true if polynomials have been requested
  113565. * @param onLoad defines the callback to trigger once the texture is ready
  113566. * @param onError defines the callback to trigger in case of error
  113567. */
  113568. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  113569. /**
  113570. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  113571. * @param data contains the texture data
  113572. * @param texture defines the BabylonJS internal texture
  113573. * @param callback defines the method to call once ready to upload
  113574. */
  113575. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  113576. }
  113577. }
  113578. declare module BABYLON {
  113579. /**
  113580. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  113581. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  113582. */
  113583. export class KhronosTextureContainer {
  113584. /** contents of the KTX container file */
  113585. arrayBuffer: any;
  113586. private static HEADER_LEN;
  113587. private static COMPRESSED_2D;
  113588. private static COMPRESSED_3D;
  113589. private static TEX_2D;
  113590. private static TEX_3D;
  113591. /**
  113592. * Gets the openGL type
  113593. */
  113594. glType: number;
  113595. /**
  113596. * Gets the openGL type size
  113597. */
  113598. glTypeSize: number;
  113599. /**
  113600. * Gets the openGL format
  113601. */
  113602. glFormat: number;
  113603. /**
  113604. * Gets the openGL internal format
  113605. */
  113606. glInternalFormat: number;
  113607. /**
  113608. * Gets the base internal format
  113609. */
  113610. glBaseInternalFormat: number;
  113611. /**
  113612. * Gets image width in pixel
  113613. */
  113614. pixelWidth: number;
  113615. /**
  113616. * Gets image height in pixel
  113617. */
  113618. pixelHeight: number;
  113619. /**
  113620. * Gets image depth in pixels
  113621. */
  113622. pixelDepth: number;
  113623. /**
  113624. * Gets the number of array elements
  113625. */
  113626. numberOfArrayElements: number;
  113627. /**
  113628. * Gets the number of faces
  113629. */
  113630. numberOfFaces: number;
  113631. /**
  113632. * Gets the number of mipmap levels
  113633. */
  113634. numberOfMipmapLevels: number;
  113635. /**
  113636. * Gets the bytes of key value data
  113637. */
  113638. bytesOfKeyValueData: number;
  113639. /**
  113640. * Gets the load type
  113641. */
  113642. loadType: number;
  113643. /**
  113644. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  113645. */
  113646. isInvalid: boolean;
  113647. /**
  113648. * Creates a new KhronosTextureContainer
  113649. * @param arrayBuffer contents of the KTX container file
  113650. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  113651. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  113652. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  113653. */
  113654. constructor(
  113655. /** contents of the KTX container file */
  113656. arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  113657. /**
  113658. * Uploads KTX content to a Babylon Texture.
  113659. * It is assumed that the texture has already been created & is currently bound
  113660. * @hidden
  113661. */
  113662. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  113663. private _upload2DCompressedLevels;
  113664. }
  113665. }
  113666. declare module BABYLON {
  113667. /**
  113668. * Implementation of the KTX Texture Loader.
  113669. * @hidden
  113670. */
  113671. export class _KTXTextureLoader implements IInternalTextureLoader {
  113672. /**
  113673. * Defines wether the loader supports cascade loading the different faces.
  113674. */
  113675. readonly supportCascades: boolean;
  113676. /**
  113677. * This returns if the loader support the current file information.
  113678. * @param extension defines the file extension of the file being loaded
  113679. * @param textureFormatInUse defines the current compressed format in use iun the engine
  113680. * @param fallback defines the fallback internal texture if any
  113681. * @param isBase64 defines whether the texture is encoded as a base64
  113682. * @param isBuffer defines whether the texture data are stored as a buffer
  113683. * @returns true if the loader can load the specified file
  113684. */
  113685. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  113686. /**
  113687. * Transform the url before loading if required.
  113688. * @param rootUrl the url of the texture
  113689. * @param textureFormatInUse defines the current compressed format in use iun the engine
  113690. * @returns the transformed texture
  113691. */
  113692. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  113693. /**
  113694. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  113695. * @param rootUrl the url of the texture
  113696. * @param textureFormatInUse defines the current compressed format in use iun the engine
  113697. * @returns the fallback texture
  113698. */
  113699. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  113700. /**
  113701. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  113702. * @param data contains the texture data
  113703. * @param texture defines the BabylonJS internal texture
  113704. * @param createPolynomials will be true if polynomials have been requested
  113705. * @param onLoad defines the callback to trigger once the texture is ready
  113706. * @param onError defines the callback to trigger in case of error
  113707. */
  113708. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  113709. /**
  113710. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  113711. * @param data contains the texture data
  113712. * @param texture defines the BabylonJS internal texture
  113713. * @param callback defines the method to call once ready to upload
  113714. */
  113715. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  113716. }
  113717. }
  113718. declare module BABYLON {
  113719. /**
  113720. * Options for the default xr helper
  113721. */
  113722. export class WebXRDefaultExperienceOptions {
  113723. /**
  113724. * Floor meshes that should be used for teleporting
  113725. */
  113726. floorMeshes: Array<AbstractMesh>;
  113727. }
  113728. /**
  113729. * Default experience which provides a similar setup to the previous webVRExperience
  113730. */
  113731. export class WebXRDefaultExperience {
  113732. /**
  113733. * Base experience
  113734. */
  113735. baseExperience: WebXRExperienceHelper;
  113736. /**
  113737. * Input experience extension
  113738. */
  113739. input: WebXRInput;
  113740. /**
  113741. * Loads the controller models
  113742. */
  113743. controllerModelLoader: WebXRControllerModelLoader;
  113744. /**
  113745. * Enables laser pointer and selection
  113746. */
  113747. pointerSelection: WebXRControllerPointerSelection;
  113748. /**
  113749. * Enables teleportation
  113750. */
  113751. teleportation: WebXRControllerTeleportation;
  113752. /**
  113753. * Enables ui for enetering/exiting xr
  113754. */
  113755. enterExitUI: WebXREnterExitUI;
  113756. /**
  113757. * Default output canvas xr should render to
  113758. */
  113759. outputCanvas: WebXRManagedOutputCanvas;
  113760. /**
  113761. * Creates the default xr experience
  113762. * @param scene scene
  113763. * @param options options for basic configuration
  113764. * @returns resulting WebXRDefaultExperience
  113765. */
  113766. static CreateAsync(scene: Scene, options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  113767. private constructor();
  113768. /**
  113769. * DIsposes of the experience helper
  113770. */
  113771. dispose(): void;
  113772. }
  113773. }
  113774. declare module BABYLON {
  113775. /** @hidden */
  113776. export var _forceSceneHelpersToBundle: boolean;
  113777. interface Scene {
  113778. /**
  113779. * Creates a default light for the scene.
  113780. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  113781. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  113782. */
  113783. createDefaultLight(replace?: boolean): void;
  113784. /**
  113785. * Creates a default camera for the scene.
  113786. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  113787. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  113788. * @param replace has default false, when true replaces the active camera in the scene
  113789. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  113790. */
  113791. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  113792. /**
  113793. * Creates a default camera and a default light.
  113794. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  113795. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  113796. * @param replace has the default false, when true replaces the active camera/light in the scene
  113797. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  113798. */
  113799. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  113800. /**
  113801. * Creates a new sky box
  113802. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  113803. * @param environmentTexture defines the texture to use as environment texture
  113804. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  113805. * @param scale defines the overall scale of the skybox
  113806. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  113807. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  113808. * @returns a new mesh holding the sky box
  113809. */
  113810. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  113811. /**
  113812. * Creates a new environment
  113813. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  113814. * @param options defines the options you can use to configure the environment
  113815. * @returns the new EnvironmentHelper
  113816. */
  113817. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  113818. /**
  113819. * Creates a new VREXperienceHelper
  113820. * @see http://doc.babylonjs.com/how_to/webvr_helper
  113821. * @param webVROptions defines the options used to create the new VREXperienceHelper
  113822. * @returns a new VREXperienceHelper
  113823. */
  113824. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  113825. /**
  113826. * Creates a new WebXRDefaultExperience
  113827. * @see http://doc.babylonjs.com/how_to/webxr
  113828. * @param options experience options
  113829. * @returns a promise for a new WebXRDefaultExperience
  113830. */
  113831. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  113832. }
  113833. }
  113834. declare module BABYLON {
  113835. /**
  113836. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  113837. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  113838. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  113839. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  113840. */
  113841. export class VideoDome extends TransformNode {
  113842. /**
  113843. * Define the video source as a Monoscopic panoramic 360 video.
  113844. */
  113845. static readonly MODE_MONOSCOPIC: number;
  113846. /**
  113847. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  113848. */
  113849. static readonly MODE_TOPBOTTOM: number;
  113850. /**
  113851. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  113852. */
  113853. static readonly MODE_SIDEBYSIDE: number;
  113854. private _halfDome;
  113855. private _useDirectMapping;
  113856. /**
  113857. * The video texture being displayed on the sphere
  113858. */
  113859. protected _videoTexture: VideoTexture;
  113860. /**
  113861. * Gets the video texture being displayed on the sphere
  113862. */
  113863. readonly videoTexture: VideoTexture;
  113864. /**
  113865. * The skybox material
  113866. */
  113867. protected _material: BackgroundMaterial;
  113868. /**
  113869. * The surface used for the skybox
  113870. */
  113871. protected _mesh: Mesh;
  113872. /**
  113873. * A mesh that will be used to mask the back of the video dome in case it is a 180 degree movie.
  113874. */
  113875. private _halfDomeMask;
  113876. /**
  113877. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  113878. * Also see the options.resolution property.
  113879. */
  113880. fovMultiplier: number;
  113881. private _videoMode;
  113882. /**
  113883. * Gets or set the current video mode for the video. It can be:
  113884. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  113885. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  113886. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  113887. */
  113888. videoMode: number;
  113889. /**
  113890. * Is the video a 180 degrees video (half dome) or 360 video (full dome)
  113891. *
  113892. */
  113893. /**
  113894. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  113895. */
  113896. halfDome: boolean;
  113897. /**
  113898. * Oberserver used in Stereoscopic VR Mode.
  113899. */
  113900. private _onBeforeCameraRenderObserver;
  113901. /**
  113902. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  113903. * @param name Element's name, child elements will append suffixes for their own names.
  113904. * @param urlsOrVideo defines the url(s) or the video element to use
  113905. * @param options An object containing optional or exposed sub element properties
  113906. */
  113907. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  113908. resolution?: number;
  113909. clickToPlay?: boolean;
  113910. autoPlay?: boolean;
  113911. loop?: boolean;
  113912. size?: number;
  113913. poster?: string;
  113914. faceForward?: boolean;
  113915. useDirectMapping?: boolean;
  113916. halfDomeMode?: boolean;
  113917. }, scene: Scene);
  113918. private _changeVideoMode;
  113919. /**
  113920. * Releases resources associated with this node.
  113921. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  113922. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  113923. */
  113924. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  113925. }
  113926. }
  113927. declare module BABYLON {
  113928. /**
  113929. * This class can be used to get instrumentation data from a Babylon engine
  113930. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  113931. */
  113932. export class EngineInstrumentation implements IDisposable {
  113933. /**
  113934. * Define the instrumented engine.
  113935. */
  113936. engine: Engine;
  113937. private _captureGPUFrameTime;
  113938. private _gpuFrameTimeToken;
  113939. private _gpuFrameTime;
  113940. private _captureShaderCompilationTime;
  113941. private _shaderCompilationTime;
  113942. private _onBeginFrameObserver;
  113943. private _onEndFrameObserver;
  113944. private _onBeforeShaderCompilationObserver;
  113945. private _onAfterShaderCompilationObserver;
  113946. /**
  113947. * Gets the perf counter used for GPU frame time
  113948. */
  113949. readonly gpuFrameTimeCounter: PerfCounter;
  113950. /**
  113951. * Gets the GPU frame time capture status
  113952. */
  113953. /**
  113954. * Enable or disable the GPU frame time capture
  113955. */
  113956. captureGPUFrameTime: boolean;
  113957. /**
  113958. * Gets the perf counter used for shader compilation time
  113959. */
  113960. readonly shaderCompilationTimeCounter: PerfCounter;
  113961. /**
  113962. * Gets the shader compilation time capture status
  113963. */
  113964. /**
  113965. * Enable or disable the shader compilation time capture
  113966. */
  113967. captureShaderCompilationTime: boolean;
  113968. /**
  113969. * Instantiates a new engine instrumentation.
  113970. * This class can be used to get instrumentation data from a Babylon engine
  113971. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  113972. * @param engine Defines the engine to instrument
  113973. */
  113974. constructor(
  113975. /**
  113976. * Define the instrumented engine.
  113977. */
  113978. engine: Engine);
  113979. /**
  113980. * Dispose and release associated resources.
  113981. */
  113982. dispose(): void;
  113983. }
  113984. }
  113985. declare module BABYLON {
  113986. /**
  113987. * This class can be used to get instrumentation data from a Babylon engine
  113988. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  113989. */
  113990. export class SceneInstrumentation implements IDisposable {
  113991. /**
  113992. * Defines the scene to instrument
  113993. */
  113994. scene: Scene;
  113995. private _captureActiveMeshesEvaluationTime;
  113996. private _activeMeshesEvaluationTime;
  113997. private _captureRenderTargetsRenderTime;
  113998. private _renderTargetsRenderTime;
  113999. private _captureFrameTime;
  114000. private _frameTime;
  114001. private _captureRenderTime;
  114002. private _renderTime;
  114003. private _captureInterFrameTime;
  114004. private _interFrameTime;
  114005. private _captureParticlesRenderTime;
  114006. private _particlesRenderTime;
  114007. private _captureSpritesRenderTime;
  114008. private _spritesRenderTime;
  114009. private _capturePhysicsTime;
  114010. private _physicsTime;
  114011. private _captureAnimationsTime;
  114012. private _animationsTime;
  114013. private _captureCameraRenderTime;
  114014. private _cameraRenderTime;
  114015. private _onBeforeActiveMeshesEvaluationObserver;
  114016. private _onAfterActiveMeshesEvaluationObserver;
  114017. private _onBeforeRenderTargetsRenderObserver;
  114018. private _onAfterRenderTargetsRenderObserver;
  114019. private _onAfterRenderObserver;
  114020. private _onBeforeDrawPhaseObserver;
  114021. private _onAfterDrawPhaseObserver;
  114022. private _onBeforeAnimationsObserver;
  114023. private _onBeforeParticlesRenderingObserver;
  114024. private _onAfterParticlesRenderingObserver;
  114025. private _onBeforeSpritesRenderingObserver;
  114026. private _onAfterSpritesRenderingObserver;
  114027. private _onBeforePhysicsObserver;
  114028. private _onAfterPhysicsObserver;
  114029. private _onAfterAnimationsObserver;
  114030. private _onBeforeCameraRenderObserver;
  114031. private _onAfterCameraRenderObserver;
  114032. /**
  114033. * Gets the perf counter used for active meshes evaluation time
  114034. */
  114035. readonly activeMeshesEvaluationTimeCounter: PerfCounter;
  114036. /**
  114037. * Gets the active meshes evaluation time capture status
  114038. */
  114039. /**
  114040. * Enable or disable the active meshes evaluation time capture
  114041. */
  114042. captureActiveMeshesEvaluationTime: boolean;
  114043. /**
  114044. * Gets the perf counter used for render targets render time
  114045. */
  114046. readonly renderTargetsRenderTimeCounter: PerfCounter;
  114047. /**
  114048. * Gets the render targets render time capture status
  114049. */
  114050. /**
  114051. * Enable or disable the render targets render time capture
  114052. */
  114053. captureRenderTargetsRenderTime: boolean;
  114054. /**
  114055. * Gets the perf counter used for particles render time
  114056. */
  114057. readonly particlesRenderTimeCounter: PerfCounter;
  114058. /**
  114059. * Gets the particles render time capture status
  114060. */
  114061. /**
  114062. * Enable or disable the particles render time capture
  114063. */
  114064. captureParticlesRenderTime: boolean;
  114065. /**
  114066. * Gets the perf counter used for sprites render time
  114067. */
  114068. readonly spritesRenderTimeCounter: PerfCounter;
  114069. /**
  114070. * Gets the sprites render time capture status
  114071. */
  114072. /**
  114073. * Enable or disable the sprites render time capture
  114074. */
  114075. captureSpritesRenderTime: boolean;
  114076. /**
  114077. * Gets the perf counter used for physics time
  114078. */
  114079. readonly physicsTimeCounter: PerfCounter;
  114080. /**
  114081. * Gets the physics time capture status
  114082. */
  114083. /**
  114084. * Enable or disable the physics time capture
  114085. */
  114086. capturePhysicsTime: boolean;
  114087. /**
  114088. * Gets the perf counter used for animations time
  114089. */
  114090. readonly animationsTimeCounter: PerfCounter;
  114091. /**
  114092. * Gets the animations time capture status
  114093. */
  114094. /**
  114095. * Enable or disable the animations time capture
  114096. */
  114097. captureAnimationsTime: boolean;
  114098. /**
  114099. * Gets the perf counter used for frame time capture
  114100. */
  114101. readonly frameTimeCounter: PerfCounter;
  114102. /**
  114103. * Gets the frame time capture status
  114104. */
  114105. /**
  114106. * Enable or disable the frame time capture
  114107. */
  114108. captureFrameTime: boolean;
  114109. /**
  114110. * Gets the perf counter used for inter-frames time capture
  114111. */
  114112. readonly interFrameTimeCounter: PerfCounter;
  114113. /**
  114114. * Gets the inter-frames time capture status
  114115. */
  114116. /**
  114117. * Enable or disable the inter-frames time capture
  114118. */
  114119. captureInterFrameTime: boolean;
  114120. /**
  114121. * Gets the perf counter used for render time capture
  114122. */
  114123. readonly renderTimeCounter: PerfCounter;
  114124. /**
  114125. * Gets the render time capture status
  114126. */
  114127. /**
  114128. * Enable or disable the render time capture
  114129. */
  114130. captureRenderTime: boolean;
  114131. /**
  114132. * Gets the perf counter used for camera render time capture
  114133. */
  114134. readonly cameraRenderTimeCounter: PerfCounter;
  114135. /**
  114136. * Gets the camera render time capture status
  114137. */
  114138. /**
  114139. * Enable or disable the camera render time capture
  114140. */
  114141. captureCameraRenderTime: boolean;
  114142. /**
  114143. * Gets the perf counter used for draw calls
  114144. */
  114145. readonly drawCallsCounter: PerfCounter;
  114146. /**
  114147. * Instantiates a new scene instrumentation.
  114148. * This class can be used to get instrumentation data from a Babylon engine
  114149. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  114150. * @param scene Defines the scene to instrument
  114151. */
  114152. constructor(
  114153. /**
  114154. * Defines the scene to instrument
  114155. */
  114156. scene: Scene);
  114157. /**
  114158. * Dispose and release associated resources.
  114159. */
  114160. dispose(): void;
  114161. }
  114162. }
  114163. declare module BABYLON {
  114164. /** @hidden */
  114165. export var glowMapGenerationPixelShader: {
  114166. name: string;
  114167. shader: string;
  114168. };
  114169. }
  114170. declare module BABYLON {
  114171. /** @hidden */
  114172. export var glowMapGenerationVertexShader: {
  114173. name: string;
  114174. shader: string;
  114175. };
  114176. }
  114177. declare module BABYLON {
  114178. /**
  114179. * Effect layer options. This helps customizing the behaviour
  114180. * of the effect layer.
  114181. */
  114182. export interface IEffectLayerOptions {
  114183. /**
  114184. * Multiplication factor apply to the canvas size to compute the render target size
  114185. * used to generated the objects (the smaller the faster).
  114186. */
  114187. mainTextureRatio: number;
  114188. /**
  114189. * Enforces a fixed size texture to ensure effect stability across devices.
  114190. */
  114191. mainTextureFixedSize?: number;
  114192. /**
  114193. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  114194. */
  114195. alphaBlendingMode: number;
  114196. /**
  114197. * The camera attached to the layer.
  114198. */
  114199. camera: Nullable<Camera>;
  114200. /**
  114201. * The rendering group to draw the layer in.
  114202. */
  114203. renderingGroupId: number;
  114204. }
  114205. /**
  114206. * The effect layer Helps adding post process effect blended with the main pass.
  114207. *
  114208. * This can be for instance use to generate glow or higlight effects on the scene.
  114209. *
  114210. * The effect layer class can not be used directly and is intented to inherited from to be
  114211. * customized per effects.
  114212. */
  114213. export abstract class EffectLayer {
  114214. private _vertexBuffers;
  114215. private _indexBuffer;
  114216. private _cachedDefines;
  114217. private _effectLayerMapGenerationEffect;
  114218. private _effectLayerOptions;
  114219. private _mergeEffect;
  114220. protected _scene: Scene;
  114221. protected _engine: Engine;
  114222. protected _maxSize: number;
  114223. protected _mainTextureDesiredSize: ISize;
  114224. protected _mainTexture: RenderTargetTexture;
  114225. protected _shouldRender: boolean;
  114226. protected _postProcesses: PostProcess[];
  114227. protected _textures: BaseTexture[];
  114228. protected _emissiveTextureAndColor: {
  114229. texture: Nullable<BaseTexture>;
  114230. color: Color4;
  114231. };
  114232. /**
  114233. * The name of the layer
  114234. */
  114235. name: string;
  114236. /**
  114237. * The clear color of the texture used to generate the glow map.
  114238. */
  114239. neutralColor: Color4;
  114240. /**
  114241. * Specifies wether the highlight layer is enabled or not.
  114242. */
  114243. isEnabled: boolean;
  114244. /**
  114245. * Gets the camera attached to the layer.
  114246. */
  114247. readonly camera: Nullable<Camera>;
  114248. /**
  114249. * Gets the rendering group id the layer should render in.
  114250. */
  114251. renderingGroupId: number;
  114252. /**
  114253. * An event triggered when the effect layer has been disposed.
  114254. */
  114255. onDisposeObservable: Observable<EffectLayer>;
  114256. /**
  114257. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  114258. */
  114259. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  114260. /**
  114261. * An event triggered when the generated texture is being merged in the scene.
  114262. */
  114263. onBeforeComposeObservable: Observable<EffectLayer>;
  114264. /**
  114265. * An event triggered when the generated texture has been merged in the scene.
  114266. */
  114267. onAfterComposeObservable: Observable<EffectLayer>;
  114268. /**
  114269. * An event triggered when the efffect layer changes its size.
  114270. */
  114271. onSizeChangedObservable: Observable<EffectLayer>;
  114272. /** @hidden */
  114273. static _SceneComponentInitialization: (scene: Scene) => void;
  114274. /**
  114275. * Instantiates a new effect Layer and references it in the scene.
  114276. * @param name The name of the layer
  114277. * @param scene The scene to use the layer in
  114278. */
  114279. constructor(
  114280. /** The Friendly of the effect in the scene */
  114281. name: string, scene: Scene);
  114282. /**
  114283. * Get the effect name of the layer.
  114284. * @return The effect name
  114285. */
  114286. abstract getEffectName(): string;
  114287. /**
  114288. * Checks for the readiness of the element composing the layer.
  114289. * @param subMesh the mesh to check for
  114290. * @param useInstances specify wether or not to use instances to render the mesh
  114291. * @return true if ready otherwise, false
  114292. */
  114293. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  114294. /**
  114295. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  114296. * @returns true if the effect requires stencil during the main canvas render pass.
  114297. */
  114298. abstract needStencil(): boolean;
  114299. /**
  114300. * Create the merge effect. This is the shader use to blit the information back
  114301. * to the main canvas at the end of the scene rendering.
  114302. * @returns The effect containing the shader used to merge the effect on the main canvas
  114303. */
  114304. protected abstract _createMergeEffect(): Effect;
  114305. /**
  114306. * Creates the render target textures and post processes used in the effect layer.
  114307. */
  114308. protected abstract _createTextureAndPostProcesses(): void;
  114309. /**
  114310. * Implementation specific of rendering the generating effect on the main canvas.
  114311. * @param effect The effect used to render through
  114312. */
  114313. protected abstract _internalRender(effect: Effect): void;
  114314. /**
  114315. * Sets the required values for both the emissive texture and and the main color.
  114316. */
  114317. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  114318. /**
  114319. * Free any resources and references associated to a mesh.
  114320. * Internal use
  114321. * @param mesh The mesh to free.
  114322. */
  114323. abstract _disposeMesh(mesh: Mesh): void;
  114324. /**
  114325. * Serializes this layer (Glow or Highlight for example)
  114326. * @returns a serialized layer object
  114327. */
  114328. abstract serialize?(): any;
  114329. /**
  114330. * Initializes the effect layer with the required options.
  114331. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  114332. */
  114333. protected _init(options: Partial<IEffectLayerOptions>): void;
  114334. /**
  114335. * Generates the index buffer of the full screen quad blending to the main canvas.
  114336. */
  114337. private _generateIndexBuffer;
  114338. /**
  114339. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  114340. */
  114341. private _generateVertexBuffer;
  114342. /**
  114343. * Sets the main texture desired size which is the closest power of two
  114344. * of the engine canvas size.
  114345. */
  114346. private _setMainTextureSize;
  114347. /**
  114348. * Creates the main texture for the effect layer.
  114349. */
  114350. protected _createMainTexture(): void;
  114351. /**
  114352. * Adds specific effects defines.
  114353. * @param defines The defines to add specifics to.
  114354. */
  114355. protected _addCustomEffectDefines(defines: string[]): void;
  114356. /**
  114357. * Checks for the readiness of the element composing the layer.
  114358. * @param subMesh the mesh to check for
  114359. * @param useInstances specify wether or not to use instances to render the mesh
  114360. * @param emissiveTexture the associated emissive texture used to generate the glow
  114361. * @return true if ready otherwise, false
  114362. */
  114363. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  114364. /**
  114365. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  114366. */
  114367. render(): void;
  114368. /**
  114369. * Determine if a given mesh will be used in the current effect.
  114370. * @param mesh mesh to test
  114371. * @returns true if the mesh will be used
  114372. */
  114373. hasMesh(mesh: AbstractMesh): boolean;
  114374. /**
  114375. * Returns true if the layer contains information to display, otherwise false.
  114376. * @returns true if the glow layer should be rendered
  114377. */
  114378. shouldRender(): boolean;
  114379. /**
  114380. * Returns true if the mesh should render, otherwise false.
  114381. * @param mesh The mesh to render
  114382. * @returns true if it should render otherwise false
  114383. */
  114384. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  114385. /**
  114386. * Returns true if the mesh can be rendered, otherwise false.
  114387. * @param mesh The mesh to render
  114388. * @param material The material used on the mesh
  114389. * @returns true if it can be rendered otherwise false
  114390. */
  114391. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  114392. /**
  114393. * Returns true if the mesh should render, otherwise false.
  114394. * @param mesh The mesh to render
  114395. * @returns true if it should render otherwise false
  114396. */
  114397. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  114398. /**
  114399. * Renders the submesh passed in parameter to the generation map.
  114400. */
  114401. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  114402. /**
  114403. * Rebuild the required buffers.
  114404. * @hidden Internal use only.
  114405. */
  114406. _rebuild(): void;
  114407. /**
  114408. * Dispose only the render target textures and post process.
  114409. */
  114410. private _disposeTextureAndPostProcesses;
  114411. /**
  114412. * Dispose the highlight layer and free resources.
  114413. */
  114414. dispose(): void;
  114415. /**
  114416. * Gets the class name of the effect layer
  114417. * @returns the string with the class name of the effect layer
  114418. */
  114419. getClassName(): string;
  114420. /**
  114421. * Creates an effect layer from parsed effect layer data
  114422. * @param parsedEffectLayer defines effect layer data
  114423. * @param scene defines the current scene
  114424. * @param rootUrl defines the root URL containing the effect layer information
  114425. * @returns a parsed effect Layer
  114426. */
  114427. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  114428. }
  114429. }
  114430. declare module BABYLON {
  114431. interface AbstractScene {
  114432. /**
  114433. * The list of effect layers (highlights/glow) added to the scene
  114434. * @see http://doc.babylonjs.com/how_to/highlight_layer
  114435. * @see http://doc.babylonjs.com/how_to/glow_layer
  114436. */
  114437. effectLayers: Array<EffectLayer>;
  114438. /**
  114439. * Removes the given effect layer from this scene.
  114440. * @param toRemove defines the effect layer to remove
  114441. * @returns the index of the removed effect layer
  114442. */
  114443. removeEffectLayer(toRemove: EffectLayer): number;
  114444. /**
  114445. * Adds the given effect layer to this scene
  114446. * @param newEffectLayer defines the effect layer to add
  114447. */
  114448. addEffectLayer(newEffectLayer: EffectLayer): void;
  114449. }
  114450. /**
  114451. * Defines the layer scene component responsible to manage any effect layers
  114452. * in a given scene.
  114453. */
  114454. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  114455. /**
  114456. * The component name helpfull to identify the component in the list of scene components.
  114457. */
  114458. readonly name: string;
  114459. /**
  114460. * The scene the component belongs to.
  114461. */
  114462. scene: Scene;
  114463. private _engine;
  114464. private _renderEffects;
  114465. private _needStencil;
  114466. private _previousStencilState;
  114467. /**
  114468. * Creates a new instance of the component for the given scene
  114469. * @param scene Defines the scene to register the component in
  114470. */
  114471. constructor(scene: Scene);
  114472. /**
  114473. * Registers the component in a given scene
  114474. */
  114475. register(): void;
  114476. /**
  114477. * Rebuilds the elements related to this component in case of
  114478. * context lost for instance.
  114479. */
  114480. rebuild(): void;
  114481. /**
  114482. * Serializes the component data to the specified json object
  114483. * @param serializationObject The object to serialize to
  114484. */
  114485. serialize(serializationObject: any): void;
  114486. /**
  114487. * Adds all the elements from the container to the scene
  114488. * @param container the container holding the elements
  114489. */
  114490. addFromContainer(container: AbstractScene): void;
  114491. /**
  114492. * Removes all the elements in the container from the scene
  114493. * @param container contains the elements to remove
  114494. * @param dispose if the removed element should be disposed (default: false)
  114495. */
  114496. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  114497. /**
  114498. * Disposes the component and the associated ressources.
  114499. */
  114500. dispose(): void;
  114501. private _isReadyForMesh;
  114502. private _renderMainTexture;
  114503. private _setStencil;
  114504. private _setStencilBack;
  114505. private _draw;
  114506. private _drawCamera;
  114507. private _drawRenderingGroup;
  114508. }
  114509. }
  114510. declare module BABYLON {
  114511. /** @hidden */
  114512. export var glowMapMergePixelShader: {
  114513. name: string;
  114514. shader: string;
  114515. };
  114516. }
  114517. declare module BABYLON {
  114518. /** @hidden */
  114519. export var glowMapMergeVertexShader: {
  114520. name: string;
  114521. shader: string;
  114522. };
  114523. }
  114524. declare module BABYLON {
  114525. interface AbstractScene {
  114526. /**
  114527. * Return a the first highlight layer of the scene with a given name.
  114528. * @param name The name of the highlight layer to look for.
  114529. * @return The highlight layer if found otherwise null.
  114530. */
  114531. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  114532. }
  114533. /**
  114534. * Glow layer options. This helps customizing the behaviour
  114535. * of the glow layer.
  114536. */
  114537. export interface IGlowLayerOptions {
  114538. /**
  114539. * Multiplication factor apply to the canvas size to compute the render target size
  114540. * used to generated the glowing objects (the smaller the faster).
  114541. */
  114542. mainTextureRatio: number;
  114543. /**
  114544. * Enforces a fixed size texture to ensure resize independant blur.
  114545. */
  114546. mainTextureFixedSize?: number;
  114547. /**
  114548. * How big is the kernel of the blur texture.
  114549. */
  114550. blurKernelSize: number;
  114551. /**
  114552. * The camera attached to the layer.
  114553. */
  114554. camera: Nullable<Camera>;
  114555. /**
  114556. * Enable MSAA by chosing the number of samples.
  114557. */
  114558. mainTextureSamples?: number;
  114559. /**
  114560. * The rendering group to draw the layer in.
  114561. */
  114562. renderingGroupId: number;
  114563. }
  114564. /**
  114565. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  114566. *
  114567. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  114568. * glowy meshes to your scene.
  114569. *
  114570. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  114571. */
  114572. export class GlowLayer extends EffectLayer {
  114573. /**
  114574. * Effect Name of the layer.
  114575. */
  114576. static readonly EffectName: string;
  114577. /**
  114578. * The default blur kernel size used for the glow.
  114579. */
  114580. static DefaultBlurKernelSize: number;
  114581. /**
  114582. * The default texture size ratio used for the glow.
  114583. */
  114584. static DefaultTextureRatio: number;
  114585. /**
  114586. * Sets the kernel size of the blur.
  114587. */
  114588. /**
  114589. * Gets the kernel size of the blur.
  114590. */
  114591. blurKernelSize: number;
  114592. /**
  114593. * Sets the glow intensity.
  114594. */
  114595. /**
  114596. * Gets the glow intensity.
  114597. */
  114598. intensity: number;
  114599. private _options;
  114600. private _intensity;
  114601. private _horizontalBlurPostprocess1;
  114602. private _verticalBlurPostprocess1;
  114603. private _horizontalBlurPostprocess2;
  114604. private _verticalBlurPostprocess2;
  114605. private _blurTexture1;
  114606. private _blurTexture2;
  114607. private _postProcesses1;
  114608. private _postProcesses2;
  114609. private _includedOnlyMeshes;
  114610. private _excludedMeshes;
  114611. /**
  114612. * Callback used to let the user override the color selection on a per mesh basis
  114613. */
  114614. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  114615. /**
  114616. * Callback used to let the user override the texture selection on a per mesh basis
  114617. */
  114618. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  114619. /**
  114620. * Instantiates a new glow Layer and references it to the scene.
  114621. * @param name The name of the layer
  114622. * @param scene The scene to use the layer in
  114623. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  114624. */
  114625. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  114626. /**
  114627. * Get the effect name of the layer.
  114628. * @return The effect name
  114629. */
  114630. getEffectName(): string;
  114631. /**
  114632. * Create the merge effect. This is the shader use to blit the information back
  114633. * to the main canvas at the end of the scene rendering.
  114634. */
  114635. protected _createMergeEffect(): Effect;
  114636. /**
  114637. * Creates the render target textures and post processes used in the glow layer.
  114638. */
  114639. protected _createTextureAndPostProcesses(): void;
  114640. /**
  114641. * Checks for the readiness of the element composing the layer.
  114642. * @param subMesh the mesh to check for
  114643. * @param useInstances specify wether or not to use instances to render the mesh
  114644. * @param emissiveTexture the associated emissive texture used to generate the glow
  114645. * @return true if ready otherwise, false
  114646. */
  114647. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  114648. /**
  114649. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  114650. */
  114651. needStencil(): boolean;
  114652. /**
  114653. * Returns true if the mesh can be rendered, otherwise false.
  114654. * @param mesh The mesh to render
  114655. * @param material The material used on the mesh
  114656. * @returns true if it can be rendered otherwise false
  114657. */
  114658. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  114659. /**
  114660. * Implementation specific of rendering the generating effect on the main canvas.
  114661. * @param effect The effect used to render through
  114662. */
  114663. protected _internalRender(effect: Effect): void;
  114664. /**
  114665. * Sets the required values for both the emissive texture and and the main color.
  114666. */
  114667. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  114668. /**
  114669. * Returns true if the mesh should render, otherwise false.
  114670. * @param mesh The mesh to render
  114671. * @returns true if it should render otherwise false
  114672. */
  114673. protected _shouldRenderMesh(mesh: Mesh): boolean;
  114674. /**
  114675. * Adds specific effects defines.
  114676. * @param defines The defines to add specifics to.
  114677. */
  114678. protected _addCustomEffectDefines(defines: string[]): void;
  114679. /**
  114680. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  114681. * @param mesh The mesh to exclude from the glow layer
  114682. */
  114683. addExcludedMesh(mesh: Mesh): void;
  114684. /**
  114685. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  114686. * @param mesh The mesh to remove
  114687. */
  114688. removeExcludedMesh(mesh: Mesh): void;
  114689. /**
  114690. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  114691. * @param mesh The mesh to include in the glow layer
  114692. */
  114693. addIncludedOnlyMesh(mesh: Mesh): void;
  114694. /**
  114695. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  114696. * @param mesh The mesh to remove
  114697. */
  114698. removeIncludedOnlyMesh(mesh: Mesh): void;
  114699. /**
  114700. * Determine if a given mesh will be used in the glow layer
  114701. * @param mesh The mesh to test
  114702. * @returns true if the mesh will be highlighted by the current glow layer
  114703. */
  114704. hasMesh(mesh: AbstractMesh): boolean;
  114705. /**
  114706. * Free any resources and references associated to a mesh.
  114707. * Internal use
  114708. * @param mesh The mesh to free.
  114709. * @hidden
  114710. */
  114711. _disposeMesh(mesh: Mesh): void;
  114712. /**
  114713. * Gets the class name of the effect layer
  114714. * @returns the string with the class name of the effect layer
  114715. */
  114716. getClassName(): string;
  114717. /**
  114718. * Serializes this glow layer
  114719. * @returns a serialized glow layer object
  114720. */
  114721. serialize(): any;
  114722. /**
  114723. * Creates a Glow Layer from parsed glow layer data
  114724. * @param parsedGlowLayer defines glow layer data
  114725. * @param scene defines the current scene
  114726. * @param rootUrl defines the root URL containing the glow layer information
  114727. * @returns a parsed Glow Layer
  114728. */
  114729. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  114730. }
  114731. }
  114732. declare module BABYLON {
  114733. /** @hidden */
  114734. export var glowBlurPostProcessPixelShader: {
  114735. name: string;
  114736. shader: string;
  114737. };
  114738. }
  114739. declare module BABYLON {
  114740. interface AbstractScene {
  114741. /**
  114742. * Return a the first highlight layer of the scene with a given name.
  114743. * @param name The name of the highlight layer to look for.
  114744. * @return The highlight layer if found otherwise null.
  114745. */
  114746. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  114747. }
  114748. /**
  114749. * Highlight layer options. This helps customizing the behaviour
  114750. * of the highlight layer.
  114751. */
  114752. export interface IHighlightLayerOptions {
  114753. /**
  114754. * Multiplication factor apply to the canvas size to compute the render target size
  114755. * used to generated the glowing objects (the smaller the faster).
  114756. */
  114757. mainTextureRatio: number;
  114758. /**
  114759. * Enforces a fixed size texture to ensure resize independant blur.
  114760. */
  114761. mainTextureFixedSize?: number;
  114762. /**
  114763. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  114764. * of the picture to blur (the smaller the faster).
  114765. */
  114766. blurTextureSizeRatio: number;
  114767. /**
  114768. * How big in texel of the blur texture is the vertical blur.
  114769. */
  114770. blurVerticalSize: number;
  114771. /**
  114772. * How big in texel of the blur texture is the horizontal blur.
  114773. */
  114774. blurHorizontalSize: number;
  114775. /**
  114776. * Alpha blending mode used to apply the blur. Default is combine.
  114777. */
  114778. alphaBlendingMode: number;
  114779. /**
  114780. * The camera attached to the layer.
  114781. */
  114782. camera: Nullable<Camera>;
  114783. /**
  114784. * Should we display highlight as a solid stroke?
  114785. */
  114786. isStroke?: boolean;
  114787. /**
  114788. * The rendering group to draw the layer in.
  114789. */
  114790. renderingGroupId: number;
  114791. }
  114792. /**
  114793. * The highlight layer Helps adding a glow effect around a mesh.
  114794. *
  114795. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  114796. * glowy meshes to your scene.
  114797. *
  114798. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  114799. */
  114800. export class HighlightLayer extends EffectLayer {
  114801. name: string;
  114802. /**
  114803. * Effect Name of the highlight layer.
  114804. */
  114805. static readonly EffectName: string;
  114806. /**
  114807. * The neutral color used during the preparation of the glow effect.
  114808. * This is black by default as the blend operation is a blend operation.
  114809. */
  114810. static NeutralColor: Color4;
  114811. /**
  114812. * Stencil value used for glowing meshes.
  114813. */
  114814. static GlowingMeshStencilReference: number;
  114815. /**
  114816. * Stencil value used for the other meshes in the scene.
  114817. */
  114818. static NormalMeshStencilReference: number;
  114819. /**
  114820. * Specifies whether or not the inner glow is ACTIVE in the layer.
  114821. */
  114822. innerGlow: boolean;
  114823. /**
  114824. * Specifies whether or not the outer glow is ACTIVE in the layer.
  114825. */
  114826. outerGlow: boolean;
  114827. /**
  114828. * Specifies the horizontal size of the blur.
  114829. */
  114830. /**
  114831. * Gets the horizontal size of the blur.
  114832. */
  114833. blurHorizontalSize: number;
  114834. /**
  114835. * Specifies the vertical size of the blur.
  114836. */
  114837. /**
  114838. * Gets the vertical size of the blur.
  114839. */
  114840. blurVerticalSize: number;
  114841. /**
  114842. * An event triggered when the highlight layer is being blurred.
  114843. */
  114844. onBeforeBlurObservable: Observable<HighlightLayer>;
  114845. /**
  114846. * An event triggered when the highlight layer has been blurred.
  114847. */
  114848. onAfterBlurObservable: Observable<HighlightLayer>;
  114849. private _instanceGlowingMeshStencilReference;
  114850. private _options;
  114851. private _downSamplePostprocess;
  114852. private _horizontalBlurPostprocess;
  114853. private _verticalBlurPostprocess;
  114854. private _blurTexture;
  114855. private _meshes;
  114856. private _excludedMeshes;
  114857. /**
  114858. * Instantiates a new highlight Layer and references it to the scene..
  114859. * @param name The name of the layer
  114860. * @param scene The scene to use the layer in
  114861. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  114862. */
  114863. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  114864. /**
  114865. * Get the effect name of the layer.
  114866. * @return The effect name
  114867. */
  114868. getEffectName(): string;
  114869. /**
  114870. * Create the merge effect. This is the shader use to blit the information back
  114871. * to the main canvas at the end of the scene rendering.
  114872. */
  114873. protected _createMergeEffect(): Effect;
  114874. /**
  114875. * Creates the render target textures and post processes used in the highlight layer.
  114876. */
  114877. protected _createTextureAndPostProcesses(): void;
  114878. /**
  114879. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  114880. */
  114881. needStencil(): boolean;
  114882. /**
  114883. * Checks for the readiness of the element composing the layer.
  114884. * @param subMesh the mesh to check for
  114885. * @param useInstances specify wether or not to use instances to render the mesh
  114886. * @param emissiveTexture the associated emissive texture used to generate the glow
  114887. * @return true if ready otherwise, false
  114888. */
  114889. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  114890. /**
  114891. * Implementation specific of rendering the generating effect on the main canvas.
  114892. * @param effect The effect used to render through
  114893. */
  114894. protected _internalRender(effect: Effect): void;
  114895. /**
  114896. * Returns true if the layer contains information to display, otherwise false.
  114897. */
  114898. shouldRender(): boolean;
  114899. /**
  114900. * Returns true if the mesh should render, otherwise false.
  114901. * @param mesh The mesh to render
  114902. * @returns true if it should render otherwise false
  114903. */
  114904. protected _shouldRenderMesh(mesh: Mesh): boolean;
  114905. /**
  114906. * Sets the required values for both the emissive texture and and the main color.
  114907. */
  114908. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  114909. /**
  114910. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  114911. * @param mesh The mesh to exclude from the highlight layer
  114912. */
  114913. addExcludedMesh(mesh: Mesh): void;
  114914. /**
  114915. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  114916. * @param mesh The mesh to highlight
  114917. */
  114918. removeExcludedMesh(mesh: Mesh): void;
  114919. /**
  114920. * Determine if a given mesh will be highlighted by the current HighlightLayer
  114921. * @param mesh mesh to test
  114922. * @returns true if the mesh will be highlighted by the current HighlightLayer
  114923. */
  114924. hasMesh(mesh: AbstractMesh): boolean;
  114925. /**
  114926. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  114927. * @param mesh The mesh to highlight
  114928. * @param color The color of the highlight
  114929. * @param glowEmissiveOnly Extract the glow from the emissive texture
  114930. */
  114931. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  114932. /**
  114933. * Remove a mesh from the highlight layer in order to make it stop glowing.
  114934. * @param mesh The mesh to highlight
  114935. */
  114936. removeMesh(mesh: Mesh): void;
  114937. /**
  114938. * Force the stencil to the normal expected value for none glowing parts
  114939. */
  114940. private _defaultStencilReference;
  114941. /**
  114942. * Free any resources and references associated to a mesh.
  114943. * Internal use
  114944. * @param mesh The mesh to free.
  114945. * @hidden
  114946. */
  114947. _disposeMesh(mesh: Mesh): void;
  114948. /**
  114949. * Dispose the highlight layer and free resources.
  114950. */
  114951. dispose(): void;
  114952. /**
  114953. * Gets the class name of the effect layer
  114954. * @returns the string with the class name of the effect layer
  114955. */
  114956. getClassName(): string;
  114957. /**
  114958. * Serializes this Highlight layer
  114959. * @returns a serialized Highlight layer object
  114960. */
  114961. serialize(): any;
  114962. /**
  114963. * Creates a Highlight layer from parsed Highlight layer data
  114964. * @param parsedHightlightLayer defines the Highlight layer data
  114965. * @param scene defines the current scene
  114966. * @param rootUrl defines the root URL containing the Highlight layer information
  114967. * @returns a parsed Highlight layer
  114968. */
  114969. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  114970. }
  114971. }
  114972. declare module BABYLON {
  114973. interface AbstractScene {
  114974. /**
  114975. * The list of layers (background and foreground) of the scene
  114976. */
  114977. layers: Array<Layer>;
  114978. }
  114979. /**
  114980. * Defines the layer scene component responsible to manage any layers
  114981. * in a given scene.
  114982. */
  114983. export class LayerSceneComponent implements ISceneComponent {
  114984. /**
  114985. * The component name helpfull to identify the component in the list of scene components.
  114986. */
  114987. readonly name: string;
  114988. /**
  114989. * The scene the component belongs to.
  114990. */
  114991. scene: Scene;
  114992. private _engine;
  114993. /**
  114994. * Creates a new instance of the component for the given scene
  114995. * @param scene Defines the scene to register the component in
  114996. */
  114997. constructor(scene: Scene);
  114998. /**
  114999. * Registers the component in a given scene
  115000. */
  115001. register(): void;
  115002. /**
  115003. * Rebuilds the elements related to this component in case of
  115004. * context lost for instance.
  115005. */
  115006. rebuild(): void;
  115007. /**
  115008. * Disposes the component and the associated ressources.
  115009. */
  115010. dispose(): void;
  115011. private _draw;
  115012. private _drawCameraPredicate;
  115013. private _drawCameraBackground;
  115014. private _drawCameraForeground;
  115015. private _drawRenderTargetPredicate;
  115016. private _drawRenderTargetBackground;
  115017. private _drawRenderTargetForeground;
  115018. /**
  115019. * Adds all the elements from the container to the scene
  115020. * @param container the container holding the elements
  115021. */
  115022. addFromContainer(container: AbstractScene): void;
  115023. /**
  115024. * Removes all the elements in the container from the scene
  115025. * @param container contains the elements to remove
  115026. * @param dispose if the removed element should be disposed (default: false)
  115027. */
  115028. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  115029. }
  115030. }
  115031. declare module BABYLON {
  115032. /** @hidden */
  115033. export var layerPixelShader: {
  115034. name: string;
  115035. shader: string;
  115036. };
  115037. }
  115038. declare module BABYLON {
  115039. /** @hidden */
  115040. export var layerVertexShader: {
  115041. name: string;
  115042. shader: string;
  115043. };
  115044. }
  115045. declare module BABYLON {
  115046. /**
  115047. * This represents a full screen 2d layer.
  115048. * This can be useful to display a picture in the background of your scene for instance.
  115049. * @see https://www.babylonjs-playground.com/#08A2BS#1
  115050. */
  115051. export class Layer {
  115052. /**
  115053. * Define the name of the layer.
  115054. */
  115055. name: string;
  115056. /**
  115057. * Define the texture the layer should display.
  115058. */
  115059. texture: Nullable<Texture>;
  115060. /**
  115061. * Is the layer in background or foreground.
  115062. */
  115063. isBackground: boolean;
  115064. /**
  115065. * Define the color of the layer (instead of texture).
  115066. */
  115067. color: Color4;
  115068. /**
  115069. * Define the scale of the layer in order to zoom in out of the texture.
  115070. */
  115071. scale: Vector2;
  115072. /**
  115073. * Define an offset for the layer in order to shift the texture.
  115074. */
  115075. offset: Vector2;
  115076. /**
  115077. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  115078. */
  115079. alphaBlendingMode: number;
  115080. /**
  115081. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  115082. * Alpha test will not mix with the background color in case of transparency.
  115083. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  115084. */
  115085. alphaTest: boolean;
  115086. /**
  115087. * Define a mask to restrict the layer to only some of the scene cameras.
  115088. */
  115089. layerMask: number;
  115090. /**
  115091. * Define the list of render target the layer is visible into.
  115092. */
  115093. renderTargetTextures: RenderTargetTexture[];
  115094. /**
  115095. * Define if the layer is only used in renderTarget or if it also
  115096. * renders in the main frame buffer of the canvas.
  115097. */
  115098. renderOnlyInRenderTargetTextures: boolean;
  115099. private _scene;
  115100. private _vertexBuffers;
  115101. private _indexBuffer;
  115102. private _effect;
  115103. private _alphaTestEffect;
  115104. /**
  115105. * An event triggered when the layer is disposed.
  115106. */
  115107. onDisposeObservable: Observable<Layer>;
  115108. private _onDisposeObserver;
  115109. /**
  115110. * Back compatibility with callback before the onDisposeObservable existed.
  115111. * The set callback will be triggered when the layer has been disposed.
  115112. */
  115113. onDispose: () => void;
  115114. /**
  115115. * An event triggered before rendering the scene
  115116. */
  115117. onBeforeRenderObservable: Observable<Layer>;
  115118. private _onBeforeRenderObserver;
  115119. /**
  115120. * Back compatibility with callback before the onBeforeRenderObservable existed.
  115121. * The set callback will be triggered just before rendering the layer.
  115122. */
  115123. onBeforeRender: () => void;
  115124. /**
  115125. * An event triggered after rendering the scene
  115126. */
  115127. onAfterRenderObservable: Observable<Layer>;
  115128. private _onAfterRenderObserver;
  115129. /**
  115130. * Back compatibility with callback before the onAfterRenderObservable existed.
  115131. * The set callback will be triggered just after rendering the layer.
  115132. */
  115133. onAfterRender: () => void;
  115134. /**
  115135. * Instantiates a new layer.
  115136. * This represents a full screen 2d layer.
  115137. * This can be useful to display a picture in the background of your scene for instance.
  115138. * @see https://www.babylonjs-playground.com/#08A2BS#1
  115139. * @param name Define the name of the layer in the scene
  115140. * @param imgUrl Define the url of the texture to display in the layer
  115141. * @param scene Define the scene the layer belongs to
  115142. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  115143. * @param color Defines a color for the layer
  115144. */
  115145. constructor(
  115146. /**
  115147. * Define the name of the layer.
  115148. */
  115149. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  115150. private _createIndexBuffer;
  115151. /** @hidden */
  115152. _rebuild(): void;
  115153. /**
  115154. * Renders the layer in the scene.
  115155. */
  115156. render(): void;
  115157. /**
  115158. * Disposes and releases the associated ressources.
  115159. */
  115160. dispose(): void;
  115161. }
  115162. }
  115163. declare module BABYLON {
  115164. /** @hidden */
  115165. export var lensFlarePixelShader: {
  115166. name: string;
  115167. shader: string;
  115168. };
  115169. }
  115170. declare module BABYLON {
  115171. /** @hidden */
  115172. export var lensFlareVertexShader: {
  115173. name: string;
  115174. shader: string;
  115175. };
  115176. }
  115177. declare module BABYLON {
  115178. /**
  115179. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  115180. * It is usually composed of several `lensFlare`.
  115181. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  115182. */
  115183. export class LensFlareSystem {
  115184. /**
  115185. * Define the name of the lens flare system
  115186. */
  115187. name: string;
  115188. /**
  115189. * List of lens flares used in this system.
  115190. */
  115191. lensFlares: LensFlare[];
  115192. /**
  115193. * Define a limit from the border the lens flare can be visible.
  115194. */
  115195. borderLimit: number;
  115196. /**
  115197. * Define a viewport border we do not want to see the lens flare in.
  115198. */
  115199. viewportBorder: number;
  115200. /**
  115201. * Define a predicate which could limit the list of meshes able to occlude the effect.
  115202. */
  115203. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  115204. /**
  115205. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  115206. */
  115207. layerMask: number;
  115208. /**
  115209. * Define the id of the lens flare system in the scene.
  115210. * (equal to name by default)
  115211. */
  115212. id: string;
  115213. private _scene;
  115214. private _emitter;
  115215. private _vertexBuffers;
  115216. private _indexBuffer;
  115217. private _effect;
  115218. private _positionX;
  115219. private _positionY;
  115220. private _isEnabled;
  115221. /** @hidden */
  115222. static _SceneComponentInitialization: (scene: Scene) => void;
  115223. /**
  115224. * Instantiates a lens flare system.
  115225. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  115226. * It is usually composed of several `lensFlare`.
  115227. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  115228. * @param name Define the name of the lens flare system in the scene
  115229. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  115230. * @param scene Define the scene the lens flare system belongs to
  115231. */
  115232. constructor(
  115233. /**
  115234. * Define the name of the lens flare system
  115235. */
  115236. name: string, emitter: any, scene: Scene);
  115237. /**
  115238. * Define if the lens flare system is enabled.
  115239. */
  115240. isEnabled: boolean;
  115241. /**
  115242. * Get the scene the effects belongs to.
  115243. * @returns the scene holding the lens flare system
  115244. */
  115245. getScene(): Scene;
  115246. /**
  115247. * Get the emitter of the lens flare system.
  115248. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  115249. * @returns the emitter of the lens flare system
  115250. */
  115251. getEmitter(): any;
  115252. /**
  115253. * Set the emitter of the lens flare system.
  115254. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  115255. * @param newEmitter Define the new emitter of the system
  115256. */
  115257. setEmitter(newEmitter: any): void;
  115258. /**
  115259. * Get the lens flare system emitter position.
  115260. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  115261. * @returns the position
  115262. */
  115263. getEmitterPosition(): Vector3;
  115264. /**
  115265. * @hidden
  115266. */
  115267. computeEffectivePosition(globalViewport: Viewport): boolean;
  115268. /** @hidden */
  115269. _isVisible(): boolean;
  115270. /**
  115271. * @hidden
  115272. */
  115273. render(): boolean;
  115274. /**
  115275. * Dispose and release the lens flare with its associated resources.
  115276. */
  115277. dispose(): void;
  115278. /**
  115279. * Parse a lens flare system from a JSON repressentation
  115280. * @param parsedLensFlareSystem Define the JSON to parse
  115281. * @param scene Define the scene the parsed system should be instantiated in
  115282. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  115283. * @returns the parsed system
  115284. */
  115285. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  115286. /**
  115287. * Serialize the current Lens Flare System into a JSON representation.
  115288. * @returns the serialized JSON
  115289. */
  115290. serialize(): any;
  115291. }
  115292. }
  115293. declare module BABYLON {
  115294. /**
  115295. * This represents one of the lens effect in a `lensFlareSystem`.
  115296. * It controls one of the indiviual texture used in the effect.
  115297. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  115298. */
  115299. export class LensFlare {
  115300. /**
  115301. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  115302. */
  115303. size: number;
  115304. /**
  115305. * 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.
  115306. */
  115307. position: number;
  115308. /**
  115309. * Define the lens color.
  115310. */
  115311. color: Color3;
  115312. /**
  115313. * Define the lens texture.
  115314. */
  115315. texture: Nullable<Texture>;
  115316. /**
  115317. * Define the alpha mode to render this particular lens.
  115318. */
  115319. alphaMode: number;
  115320. private _system;
  115321. /**
  115322. * Creates a new Lens Flare.
  115323. * This represents one of the lens effect in a `lensFlareSystem`.
  115324. * It controls one of the indiviual texture used in the effect.
  115325. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  115326. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  115327. * @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.
  115328. * @param color Define the lens color
  115329. * @param imgUrl Define the lens texture url
  115330. * @param system Define the `lensFlareSystem` this flare is part of
  115331. * @returns The newly created Lens Flare
  115332. */
  115333. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  115334. /**
  115335. * Instantiates a new Lens Flare.
  115336. * This represents one of the lens effect in a `lensFlareSystem`.
  115337. * It controls one of the indiviual texture used in the effect.
  115338. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  115339. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  115340. * @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.
  115341. * @param color Define the lens color
  115342. * @param imgUrl Define the lens texture url
  115343. * @param system Define the `lensFlareSystem` this flare is part of
  115344. */
  115345. constructor(
  115346. /**
  115347. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  115348. */
  115349. size: number,
  115350. /**
  115351. * 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.
  115352. */
  115353. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  115354. /**
  115355. * Dispose and release the lens flare with its associated resources.
  115356. */
  115357. dispose(): void;
  115358. }
  115359. }
  115360. declare module BABYLON {
  115361. interface AbstractScene {
  115362. /**
  115363. * The list of lens flare system added to the scene
  115364. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  115365. */
  115366. lensFlareSystems: Array<LensFlareSystem>;
  115367. /**
  115368. * Removes the given lens flare system from this scene.
  115369. * @param toRemove The lens flare system to remove
  115370. * @returns The index of the removed lens flare system
  115371. */
  115372. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  115373. /**
  115374. * Adds the given lens flare system to this scene
  115375. * @param newLensFlareSystem The lens flare system to add
  115376. */
  115377. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  115378. /**
  115379. * Gets a lens flare system using its name
  115380. * @param name defines the name to look for
  115381. * @returns the lens flare system or null if not found
  115382. */
  115383. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  115384. /**
  115385. * Gets a lens flare system using its id
  115386. * @param id defines the id to look for
  115387. * @returns the lens flare system or null if not found
  115388. */
  115389. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  115390. }
  115391. /**
  115392. * Defines the lens flare scene component responsible to manage any lens flares
  115393. * in a given scene.
  115394. */
  115395. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  115396. /**
  115397. * The component name helpfull to identify the component in the list of scene components.
  115398. */
  115399. readonly name: string;
  115400. /**
  115401. * The scene the component belongs to.
  115402. */
  115403. scene: Scene;
  115404. /**
  115405. * Creates a new instance of the component for the given scene
  115406. * @param scene Defines the scene to register the component in
  115407. */
  115408. constructor(scene: Scene);
  115409. /**
  115410. * Registers the component in a given scene
  115411. */
  115412. register(): void;
  115413. /**
  115414. * Rebuilds the elements related to this component in case of
  115415. * context lost for instance.
  115416. */
  115417. rebuild(): void;
  115418. /**
  115419. * Adds all the elements from the container to the scene
  115420. * @param container the container holding the elements
  115421. */
  115422. addFromContainer(container: AbstractScene): void;
  115423. /**
  115424. * Removes all the elements in the container from the scene
  115425. * @param container contains the elements to remove
  115426. * @param dispose if the removed element should be disposed (default: false)
  115427. */
  115428. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  115429. /**
  115430. * Serializes the component data to the specified json object
  115431. * @param serializationObject The object to serialize to
  115432. */
  115433. serialize(serializationObject: any): void;
  115434. /**
  115435. * Disposes the component and the associated ressources.
  115436. */
  115437. dispose(): void;
  115438. private _draw;
  115439. }
  115440. }
  115441. declare module BABYLON {
  115442. /**
  115443. * Defines the shadow generator component responsible to manage any shadow generators
  115444. * in a given scene.
  115445. */
  115446. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  115447. /**
  115448. * The component name helpfull to identify the component in the list of scene components.
  115449. */
  115450. readonly name: string;
  115451. /**
  115452. * The scene the component belongs to.
  115453. */
  115454. scene: Scene;
  115455. /**
  115456. * Creates a new instance of the component for the given scene
  115457. * @param scene Defines the scene to register the component in
  115458. */
  115459. constructor(scene: Scene);
  115460. /**
  115461. * Registers the component in a given scene
  115462. */
  115463. register(): void;
  115464. /**
  115465. * Rebuilds the elements related to this component in case of
  115466. * context lost for instance.
  115467. */
  115468. rebuild(): void;
  115469. /**
  115470. * Serializes the component data to the specified json object
  115471. * @param serializationObject The object to serialize to
  115472. */
  115473. serialize(serializationObject: any): void;
  115474. /**
  115475. * Adds all the elements from the container to the scene
  115476. * @param container the container holding the elements
  115477. */
  115478. addFromContainer(container: AbstractScene): void;
  115479. /**
  115480. * Removes all the elements in the container from the scene
  115481. * @param container contains the elements to remove
  115482. * @param dispose if the removed element should be disposed (default: false)
  115483. */
  115484. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  115485. /**
  115486. * Rebuilds the elements related to this component in case of
  115487. * context lost for instance.
  115488. */
  115489. dispose(): void;
  115490. private _gatherRenderTargets;
  115491. }
  115492. }
  115493. declare module BABYLON {
  115494. /**
  115495. * A point light is a light defined by an unique point in world space.
  115496. * The light is emitted in every direction from this point.
  115497. * A good example of a point light is a standard light bulb.
  115498. * Documentation: https://doc.babylonjs.com/babylon101/lights
  115499. */
  115500. export class PointLight extends ShadowLight {
  115501. private _shadowAngle;
  115502. /**
  115503. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  115504. * This specifies what angle the shadow will use to be created.
  115505. *
  115506. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  115507. */
  115508. /**
  115509. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  115510. * This specifies what angle the shadow will use to be created.
  115511. *
  115512. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  115513. */
  115514. shadowAngle: number;
  115515. /**
  115516. * Gets the direction if it has been set.
  115517. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  115518. */
  115519. /**
  115520. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  115521. */
  115522. direction: Vector3;
  115523. /**
  115524. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  115525. * A PointLight emits the light in every direction.
  115526. * It can cast shadows.
  115527. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  115528. * ```javascript
  115529. * var pointLight = new PointLight("pl", camera.position, scene);
  115530. * ```
  115531. * Documentation : https://doc.babylonjs.com/babylon101/lights
  115532. * @param name The light friendly name
  115533. * @param position The position of the point light in the scene
  115534. * @param scene The scene the lights belongs to
  115535. */
  115536. constructor(name: string, position: Vector3, scene: Scene);
  115537. /**
  115538. * Returns the string "PointLight"
  115539. * @returns the class name
  115540. */
  115541. getClassName(): string;
  115542. /**
  115543. * Returns the integer 0.
  115544. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  115545. */
  115546. getTypeID(): number;
  115547. /**
  115548. * Specifies wether or not the shadowmap should be a cube texture.
  115549. * @returns true if the shadowmap needs to be a cube texture.
  115550. */
  115551. needCube(): boolean;
  115552. /**
  115553. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  115554. * @param faceIndex The index of the face we are computed the direction to generate shadow
  115555. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  115556. */
  115557. getShadowDirection(faceIndex?: number): Vector3;
  115558. /**
  115559. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  115560. * - fov = PI / 2
  115561. * - aspect ratio : 1.0
  115562. * - z-near and far equal to the active camera minZ and maxZ.
  115563. * Returns the PointLight.
  115564. */
  115565. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  115566. protected _buildUniformLayout(): void;
  115567. /**
  115568. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  115569. * @param effect The effect to update
  115570. * @param lightIndex The index of the light in the effect to update
  115571. * @returns The point light
  115572. */
  115573. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  115574. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  115575. /**
  115576. * Prepares the list of defines specific to the light type.
  115577. * @param defines the list of defines
  115578. * @param lightIndex defines the index of the light for the effect
  115579. */
  115580. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  115581. }
  115582. }
  115583. declare module BABYLON {
  115584. /**
  115585. * Header information of HDR texture files.
  115586. */
  115587. export interface HDRInfo {
  115588. /**
  115589. * The height of the texture in pixels.
  115590. */
  115591. height: number;
  115592. /**
  115593. * The width of the texture in pixels.
  115594. */
  115595. width: number;
  115596. /**
  115597. * The index of the beginning of the data in the binary file.
  115598. */
  115599. dataPosition: number;
  115600. }
  115601. /**
  115602. * This groups tools to convert HDR texture to native colors array.
  115603. */
  115604. export class HDRTools {
  115605. private static Ldexp;
  115606. private static Rgbe2float;
  115607. private static readStringLine;
  115608. /**
  115609. * Reads header information from an RGBE texture stored in a native array.
  115610. * More information on this format are available here:
  115611. * https://en.wikipedia.org/wiki/RGBE_image_format
  115612. *
  115613. * @param uint8array The binary file stored in native array.
  115614. * @return The header information.
  115615. */
  115616. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  115617. /**
  115618. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  115619. * This RGBE texture needs to store the information as a panorama.
  115620. *
  115621. * More information on this format are available here:
  115622. * https://en.wikipedia.org/wiki/RGBE_image_format
  115623. *
  115624. * @param buffer The binary file stored in an array buffer.
  115625. * @param size The expected size of the extracted cubemap.
  115626. * @return The Cube Map information.
  115627. */
  115628. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  115629. /**
  115630. * Returns the pixels data extracted from an RGBE texture.
  115631. * This pixels will be stored left to right up to down in the R G B order in one array.
  115632. *
  115633. * More information on this format are available here:
  115634. * https://en.wikipedia.org/wiki/RGBE_image_format
  115635. *
  115636. * @param uint8array The binary file stored in an array buffer.
  115637. * @param hdrInfo The header information of the file.
  115638. * @return The pixels data in RGB right to left up to down order.
  115639. */
  115640. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  115641. private static RGBE_ReadPixels_RLE;
  115642. }
  115643. }
  115644. declare module BABYLON {
  115645. /**
  115646. * This represents a texture coming from an HDR input.
  115647. *
  115648. * The only supported format is currently panorama picture stored in RGBE format.
  115649. * Example of such files can be found on HDRLib: http://hdrlib.com/
  115650. */
  115651. export class HDRCubeTexture extends BaseTexture {
  115652. private static _facesMapping;
  115653. private _generateHarmonics;
  115654. private _noMipmap;
  115655. private _textureMatrix;
  115656. private _size;
  115657. private _onLoad;
  115658. private _onError;
  115659. /**
  115660. * The texture URL.
  115661. */
  115662. url: string;
  115663. /**
  115664. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  115665. */
  115666. coordinatesMode: number;
  115667. protected _isBlocking: boolean;
  115668. /**
  115669. * Sets wether or not the texture is blocking during loading.
  115670. */
  115671. /**
  115672. * Gets wether or not the texture is blocking during loading.
  115673. */
  115674. isBlocking: boolean;
  115675. protected _rotationY: number;
  115676. /**
  115677. * Sets texture matrix rotation angle around Y axis in radians.
  115678. */
  115679. /**
  115680. * Gets texture matrix rotation angle around Y axis radians.
  115681. */
  115682. rotationY: number;
  115683. /**
  115684. * Gets or sets the center of the bounding box associated with the cube texture
  115685. * It must define where the camera used to render the texture was set
  115686. */
  115687. boundingBoxPosition: Vector3;
  115688. private _boundingBoxSize;
  115689. /**
  115690. * Gets or sets the size of the bounding box associated with the cube texture
  115691. * When defined, the cubemap will switch to local mode
  115692. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  115693. * @example https://www.babylonjs-playground.com/#RNASML
  115694. */
  115695. boundingBoxSize: Vector3;
  115696. /**
  115697. * Instantiates an HDRTexture from the following parameters.
  115698. *
  115699. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  115700. * @param scene The scene the texture will be used in
  115701. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  115702. * @param noMipmap Forces to not generate the mipmap if true
  115703. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  115704. * @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)
  115705. * @param reserved Reserved flag for internal use.
  115706. */
  115707. 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>);
  115708. /**
  115709. * Get the current class name of the texture useful for serialization or dynamic coding.
  115710. * @returns "HDRCubeTexture"
  115711. */
  115712. getClassName(): string;
  115713. /**
  115714. * Occurs when the file is raw .hdr file.
  115715. */
  115716. private loadTexture;
  115717. clone(): HDRCubeTexture;
  115718. delayLoad(): void;
  115719. /**
  115720. * Get the texture reflection matrix used to rotate/transform the reflection.
  115721. * @returns the reflection matrix
  115722. */
  115723. getReflectionTextureMatrix(): Matrix;
  115724. /**
  115725. * Set the texture reflection matrix used to rotate/transform the reflection.
  115726. * @param value Define the reflection matrix to set
  115727. */
  115728. setReflectionTextureMatrix(value: Matrix): void;
  115729. /**
  115730. * Parses a JSON representation of an HDR Texture in order to create the texture
  115731. * @param parsedTexture Define the JSON representation
  115732. * @param scene Define the scene the texture should be created in
  115733. * @param rootUrl Define the root url in case we need to load relative dependencies
  115734. * @returns the newly created texture after parsing
  115735. */
  115736. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  115737. serialize(): any;
  115738. }
  115739. }
  115740. declare module BABYLON {
  115741. /**
  115742. * Class used to control physics engine
  115743. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  115744. */
  115745. export class PhysicsEngine implements IPhysicsEngine {
  115746. private _physicsPlugin;
  115747. /**
  115748. * Global value used to control the smallest number supported by the simulation
  115749. */
  115750. static Epsilon: number;
  115751. private _impostors;
  115752. private _joints;
  115753. /**
  115754. * Gets the gravity vector used by the simulation
  115755. */
  115756. gravity: Vector3;
  115757. /**
  115758. * Factory used to create the default physics plugin.
  115759. * @returns The default physics plugin
  115760. */
  115761. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  115762. /**
  115763. * Creates a new Physics Engine
  115764. * @param gravity defines the gravity vector used by the simulation
  115765. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  115766. */
  115767. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  115768. /**
  115769. * Sets the gravity vector used by the simulation
  115770. * @param gravity defines the gravity vector to use
  115771. */
  115772. setGravity(gravity: Vector3): void;
  115773. /**
  115774. * Set the time step of the physics engine.
  115775. * Default is 1/60.
  115776. * To slow it down, enter 1/600 for example.
  115777. * To speed it up, 1/30
  115778. * @param newTimeStep defines the new timestep to apply to this world.
  115779. */
  115780. setTimeStep(newTimeStep?: number): void;
  115781. /**
  115782. * Get the time step of the physics engine.
  115783. * @returns the current time step
  115784. */
  115785. getTimeStep(): number;
  115786. /**
  115787. * Release all resources
  115788. */
  115789. dispose(): void;
  115790. /**
  115791. * Gets the name of the current physics plugin
  115792. * @returns the name of the plugin
  115793. */
  115794. getPhysicsPluginName(): string;
  115795. /**
  115796. * Adding a new impostor for the impostor tracking.
  115797. * This will be done by the impostor itself.
  115798. * @param impostor the impostor to add
  115799. */
  115800. addImpostor(impostor: PhysicsImpostor): void;
  115801. /**
  115802. * Remove an impostor from the engine.
  115803. * This impostor and its mesh will not longer be updated by the physics engine.
  115804. * @param impostor the impostor to remove
  115805. */
  115806. removeImpostor(impostor: PhysicsImpostor): void;
  115807. /**
  115808. * Add a joint to the physics engine
  115809. * @param mainImpostor defines the main impostor to which the joint is added.
  115810. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  115811. * @param joint defines the joint that will connect both impostors.
  115812. */
  115813. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  115814. /**
  115815. * Removes a joint from the simulation
  115816. * @param mainImpostor defines the impostor used with the joint
  115817. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  115818. * @param joint defines the joint to remove
  115819. */
  115820. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  115821. /**
  115822. * Called by the scene. No need to call it.
  115823. * @param delta defines the timespam between frames
  115824. */
  115825. _step(delta: number): void;
  115826. /**
  115827. * Gets the current plugin used to run the simulation
  115828. * @returns current plugin
  115829. */
  115830. getPhysicsPlugin(): IPhysicsEnginePlugin;
  115831. /**
  115832. * Gets the list of physic impostors
  115833. * @returns an array of PhysicsImpostor
  115834. */
  115835. getImpostors(): Array<PhysicsImpostor>;
  115836. /**
  115837. * Gets the impostor for a physics enabled object
  115838. * @param object defines the object impersonated by the impostor
  115839. * @returns the PhysicsImpostor or null if not found
  115840. */
  115841. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  115842. /**
  115843. * Gets the impostor for a physics body object
  115844. * @param body defines physics body used by the impostor
  115845. * @returns the PhysicsImpostor or null if not found
  115846. */
  115847. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  115848. /**
  115849. * Does a raycast in the physics world
  115850. * @param from when should the ray start?
  115851. * @param to when should the ray end?
  115852. * @returns PhysicsRaycastResult
  115853. */
  115854. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  115855. }
  115856. }
  115857. declare module BABYLON {
  115858. /** @hidden */
  115859. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  115860. private _useDeltaForWorldStep;
  115861. world: any;
  115862. name: string;
  115863. private _physicsMaterials;
  115864. private _fixedTimeStep;
  115865. private _cannonRaycastResult;
  115866. private _raycastResult;
  115867. private _physicsBodysToRemoveAfterStep;
  115868. BJSCANNON: any;
  115869. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  115870. setGravity(gravity: Vector3): void;
  115871. setTimeStep(timeStep: number): void;
  115872. getTimeStep(): number;
  115873. executeStep(delta: number): void;
  115874. private _removeMarkedPhysicsBodiesFromWorld;
  115875. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  115876. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  115877. generatePhysicsBody(impostor: PhysicsImpostor): void;
  115878. private _processChildMeshes;
  115879. removePhysicsBody(impostor: PhysicsImpostor): void;
  115880. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  115881. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  115882. private _addMaterial;
  115883. private _checkWithEpsilon;
  115884. private _createShape;
  115885. private _createHeightmap;
  115886. private _minus90X;
  115887. private _plus90X;
  115888. private _tmpPosition;
  115889. private _tmpDeltaPosition;
  115890. private _tmpUnityRotation;
  115891. private _updatePhysicsBodyTransformation;
  115892. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  115893. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  115894. isSupported(): boolean;
  115895. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  115896. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  115897. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  115898. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  115899. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  115900. getBodyMass(impostor: PhysicsImpostor): number;
  115901. getBodyFriction(impostor: PhysicsImpostor): number;
  115902. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  115903. getBodyRestitution(impostor: PhysicsImpostor): number;
  115904. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  115905. sleepBody(impostor: PhysicsImpostor): void;
  115906. wakeUpBody(impostor: PhysicsImpostor): void;
  115907. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  115908. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  115909. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  115910. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  115911. getRadius(impostor: PhysicsImpostor): number;
  115912. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  115913. dispose(): void;
  115914. private _extendNamespace;
  115915. /**
  115916. * Does a raycast in the physics world
  115917. * @param from when should the ray start?
  115918. * @param to when should the ray end?
  115919. * @returns PhysicsRaycastResult
  115920. */
  115921. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  115922. }
  115923. }
  115924. declare module BABYLON {
  115925. /** @hidden */
  115926. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  115927. world: any;
  115928. name: string;
  115929. BJSOIMO: any;
  115930. private _raycastResult;
  115931. constructor(iterations?: number, oimoInjection?: any);
  115932. setGravity(gravity: Vector3): void;
  115933. setTimeStep(timeStep: number): void;
  115934. getTimeStep(): number;
  115935. private _tmpImpostorsArray;
  115936. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  115937. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  115938. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  115939. generatePhysicsBody(impostor: PhysicsImpostor): void;
  115940. private _tmpPositionVector;
  115941. removePhysicsBody(impostor: PhysicsImpostor): void;
  115942. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  115943. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  115944. isSupported(): boolean;
  115945. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  115946. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  115947. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  115948. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  115949. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  115950. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  115951. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  115952. getBodyMass(impostor: PhysicsImpostor): number;
  115953. getBodyFriction(impostor: PhysicsImpostor): number;
  115954. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  115955. getBodyRestitution(impostor: PhysicsImpostor): number;
  115956. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  115957. sleepBody(impostor: PhysicsImpostor): void;
  115958. wakeUpBody(impostor: PhysicsImpostor): void;
  115959. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  115960. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  115961. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  115962. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  115963. getRadius(impostor: PhysicsImpostor): number;
  115964. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  115965. dispose(): void;
  115966. /**
  115967. * Does a raycast in the physics world
  115968. * @param from when should the ray start?
  115969. * @param to when should the ray end?
  115970. * @returns PhysicsRaycastResult
  115971. */
  115972. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  115973. }
  115974. }
  115975. declare module BABYLON {
  115976. /**
  115977. * Class containing static functions to help procedurally build meshes
  115978. */
  115979. export class RibbonBuilder {
  115980. /**
  115981. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  115982. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  115983. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  115984. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  115985. * * 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
  115986. * * 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
  115987. * * 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
  115988. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  115989. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  115990. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  115991. * * 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
  115992. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  115993. * * 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
  115994. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  115995. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  115996. * @param name defines the name of the mesh
  115997. * @param options defines the options used to create the mesh
  115998. * @param scene defines the hosting scene
  115999. * @returns the ribbon mesh
  116000. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  116001. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  116002. */
  116003. static CreateRibbon(name: string, options: {
  116004. pathArray: Vector3[][];
  116005. closeArray?: boolean;
  116006. closePath?: boolean;
  116007. offset?: number;
  116008. updatable?: boolean;
  116009. sideOrientation?: number;
  116010. frontUVs?: Vector4;
  116011. backUVs?: Vector4;
  116012. instance?: Mesh;
  116013. invertUV?: boolean;
  116014. uvs?: Vector2[];
  116015. colors?: Color4[];
  116016. }, scene?: Nullable<Scene>): Mesh;
  116017. }
  116018. }
  116019. declare module BABYLON {
  116020. /**
  116021. * Class containing static functions to help procedurally build meshes
  116022. */
  116023. export class ShapeBuilder {
  116024. /**
  116025. * 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.
  116026. * * 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.
  116027. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  116028. * * 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.
  116029. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  116030. * * 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
  116031. * * 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
  116032. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  116033. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  116034. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  116035. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  116036. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  116037. * @param name defines the name of the mesh
  116038. * @param options defines the options used to create the mesh
  116039. * @param scene defines the hosting scene
  116040. * @returns the extruded shape mesh
  116041. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  116042. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  116043. */
  116044. static ExtrudeShape(name: string, options: {
  116045. shape: Vector3[];
  116046. path: Vector3[];
  116047. scale?: number;
  116048. rotation?: number;
  116049. cap?: number;
  116050. updatable?: boolean;
  116051. sideOrientation?: number;
  116052. frontUVs?: Vector4;
  116053. backUVs?: Vector4;
  116054. instance?: Mesh;
  116055. invertUV?: boolean;
  116056. }, scene?: Nullable<Scene>): Mesh;
  116057. /**
  116058. * Creates an custom extruded shape mesh.
  116059. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  116060. * * 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.
  116061. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  116062. * * 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
  116063. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  116064. * * 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
  116065. * * It must returns a float value that will be the scale value applied to the shape on each path point
  116066. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  116067. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  116068. * * 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
  116069. * * 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
  116070. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  116071. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  116072. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  116073. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  116074. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  116075. * @param name defines the name of the mesh
  116076. * @param options defines the options used to create the mesh
  116077. * @param scene defines the hosting scene
  116078. * @returns the custom extruded shape mesh
  116079. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  116080. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  116081. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  116082. */
  116083. static ExtrudeShapeCustom(name: string, options: {
  116084. shape: Vector3[];
  116085. path: Vector3[];
  116086. scaleFunction?: any;
  116087. rotationFunction?: any;
  116088. ribbonCloseArray?: boolean;
  116089. ribbonClosePath?: boolean;
  116090. cap?: number;
  116091. updatable?: boolean;
  116092. sideOrientation?: number;
  116093. frontUVs?: Vector4;
  116094. backUVs?: Vector4;
  116095. instance?: Mesh;
  116096. invertUV?: boolean;
  116097. }, scene?: Nullable<Scene>): Mesh;
  116098. private static _ExtrudeShapeGeneric;
  116099. }
  116100. }
  116101. declare module BABYLON {
  116102. /**
  116103. * AmmoJS Physics plugin
  116104. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  116105. * @see https://github.com/kripken/ammo.js/
  116106. */
  116107. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  116108. private _useDeltaForWorldStep;
  116109. /**
  116110. * Reference to the Ammo library
  116111. */
  116112. bjsAMMO: any;
  116113. /**
  116114. * Created ammoJS world which physics bodies are added to
  116115. */
  116116. world: any;
  116117. /**
  116118. * Name of the plugin
  116119. */
  116120. name: string;
  116121. private _timeStep;
  116122. private _fixedTimeStep;
  116123. private _maxSteps;
  116124. private _tmpQuaternion;
  116125. private _tmpAmmoTransform;
  116126. private _tmpAmmoQuaternion;
  116127. private _tmpAmmoConcreteContactResultCallback;
  116128. private _collisionConfiguration;
  116129. private _dispatcher;
  116130. private _overlappingPairCache;
  116131. private _solver;
  116132. private _softBodySolver;
  116133. private _tmpAmmoVectorA;
  116134. private _tmpAmmoVectorB;
  116135. private _tmpAmmoVectorC;
  116136. private _tmpAmmoVectorD;
  116137. private _tmpContactCallbackResult;
  116138. private _tmpAmmoVectorRCA;
  116139. private _tmpAmmoVectorRCB;
  116140. private _raycastResult;
  116141. private static readonly DISABLE_COLLISION_FLAG;
  116142. private static readonly KINEMATIC_FLAG;
  116143. private static readonly DISABLE_DEACTIVATION_FLAG;
  116144. /**
  116145. * Initializes the ammoJS plugin
  116146. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  116147. * @param ammoInjection can be used to inject your own ammo reference
  116148. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  116149. */
  116150. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  116151. /**
  116152. * Sets the gravity of the physics world (m/(s^2))
  116153. * @param gravity Gravity to set
  116154. */
  116155. setGravity(gravity: Vector3): void;
  116156. /**
  116157. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  116158. * @param timeStep timestep to use in seconds
  116159. */
  116160. setTimeStep(timeStep: number): void;
  116161. /**
  116162. * 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)
  116163. * @param fixedTimeStep fixedTimeStep to use in seconds
  116164. */
  116165. setFixedTimeStep(fixedTimeStep: number): void;
  116166. /**
  116167. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  116168. * @param maxSteps the maximum number of steps by the physics engine per frame
  116169. */
  116170. setMaxSteps(maxSteps: number): void;
  116171. /**
  116172. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  116173. * @returns the current timestep in seconds
  116174. */
  116175. getTimeStep(): number;
  116176. private _isImpostorInContact;
  116177. private _isImpostorPairInContact;
  116178. private _stepSimulation;
  116179. /**
  116180. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  116181. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  116182. * After the step the babylon meshes are set to the position of the physics imposters
  116183. * @param delta amount of time to step forward
  116184. * @param impostors array of imposters to update before/after the step
  116185. */
  116186. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  116187. /**
  116188. * Update babylon mesh to match physics world object
  116189. * @param impostor imposter to match
  116190. */
  116191. private _afterSoftStep;
  116192. /**
  116193. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  116194. * @param impostor imposter to match
  116195. */
  116196. private _ropeStep;
  116197. /**
  116198. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  116199. * @param impostor imposter to match
  116200. */
  116201. private _softbodyOrClothStep;
  116202. private _tmpVector;
  116203. private _tmpMatrix;
  116204. /**
  116205. * Applies an impulse on the imposter
  116206. * @param impostor imposter to apply impulse to
  116207. * @param force amount of force to be applied to the imposter
  116208. * @param contactPoint the location to apply the impulse on the imposter
  116209. */
  116210. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  116211. /**
  116212. * Applies a force on the imposter
  116213. * @param impostor imposter to apply force
  116214. * @param force amount of force to be applied to the imposter
  116215. * @param contactPoint the location to apply the force on the imposter
  116216. */
  116217. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  116218. /**
  116219. * Creates a physics body using the plugin
  116220. * @param impostor the imposter to create the physics body on
  116221. */
  116222. generatePhysicsBody(impostor: PhysicsImpostor): void;
  116223. /**
  116224. * Removes the physics body from the imposter and disposes of the body's memory
  116225. * @param impostor imposter to remove the physics body from
  116226. */
  116227. removePhysicsBody(impostor: PhysicsImpostor): void;
  116228. /**
  116229. * Generates a joint
  116230. * @param impostorJoint the imposter joint to create the joint with
  116231. */
  116232. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  116233. /**
  116234. * Removes a joint
  116235. * @param impostorJoint the imposter joint to remove the joint from
  116236. */
  116237. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  116238. private _addMeshVerts;
  116239. /**
  116240. * Initialise the soft body vertices to match its object's (mesh) vertices
  116241. * Softbody vertices (nodes) are in world space and to match this
  116242. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  116243. * @param impostor to create the softbody for
  116244. */
  116245. private _softVertexData;
  116246. /**
  116247. * Create an impostor's soft body
  116248. * @param impostor to create the softbody for
  116249. */
  116250. private _createSoftbody;
  116251. /**
  116252. * Create cloth for an impostor
  116253. * @param impostor to create the softbody for
  116254. */
  116255. private _createCloth;
  116256. /**
  116257. * Create rope for an impostor
  116258. * @param impostor to create the softbody for
  116259. */
  116260. private _createRope;
  116261. private _addHullVerts;
  116262. private _createShape;
  116263. /**
  116264. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  116265. * @param impostor imposter containing the physics body and babylon object
  116266. */
  116267. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  116268. /**
  116269. * Sets the babylon object's position/rotation from the physics body's position/rotation
  116270. * @param impostor imposter containing the physics body and babylon object
  116271. * @param newPosition new position
  116272. * @param newRotation new rotation
  116273. */
  116274. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  116275. /**
  116276. * If this plugin is supported
  116277. * @returns true if its supported
  116278. */
  116279. isSupported(): boolean;
  116280. /**
  116281. * Sets the linear velocity of the physics body
  116282. * @param impostor imposter to set the velocity on
  116283. * @param velocity velocity to set
  116284. */
  116285. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  116286. /**
  116287. * Sets the angular velocity of the physics body
  116288. * @param impostor imposter to set the velocity on
  116289. * @param velocity velocity to set
  116290. */
  116291. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  116292. /**
  116293. * gets the linear velocity
  116294. * @param impostor imposter to get linear velocity from
  116295. * @returns linear velocity
  116296. */
  116297. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  116298. /**
  116299. * gets the angular velocity
  116300. * @param impostor imposter to get angular velocity from
  116301. * @returns angular velocity
  116302. */
  116303. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  116304. /**
  116305. * Sets the mass of physics body
  116306. * @param impostor imposter to set the mass on
  116307. * @param mass mass to set
  116308. */
  116309. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  116310. /**
  116311. * Gets the mass of the physics body
  116312. * @param impostor imposter to get the mass from
  116313. * @returns mass
  116314. */
  116315. getBodyMass(impostor: PhysicsImpostor): number;
  116316. /**
  116317. * Gets friction of the impostor
  116318. * @param impostor impostor to get friction from
  116319. * @returns friction value
  116320. */
  116321. getBodyFriction(impostor: PhysicsImpostor): number;
  116322. /**
  116323. * Sets friction of the impostor
  116324. * @param impostor impostor to set friction on
  116325. * @param friction friction value
  116326. */
  116327. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  116328. /**
  116329. * Gets restitution of the impostor
  116330. * @param impostor impostor to get restitution from
  116331. * @returns restitution value
  116332. */
  116333. getBodyRestitution(impostor: PhysicsImpostor): number;
  116334. /**
  116335. * Sets resitution of the impostor
  116336. * @param impostor impostor to set resitution on
  116337. * @param restitution resitution value
  116338. */
  116339. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  116340. /**
  116341. * Gets pressure inside the impostor
  116342. * @param impostor impostor to get pressure from
  116343. * @returns pressure value
  116344. */
  116345. getBodyPressure(impostor: PhysicsImpostor): number;
  116346. /**
  116347. * Sets pressure inside a soft body impostor
  116348. * Cloth and rope must remain 0 pressure
  116349. * @param impostor impostor to set pressure on
  116350. * @param pressure pressure value
  116351. */
  116352. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  116353. /**
  116354. * Gets stiffness of the impostor
  116355. * @param impostor impostor to get stiffness from
  116356. * @returns pressure value
  116357. */
  116358. getBodyStiffness(impostor: PhysicsImpostor): number;
  116359. /**
  116360. * Sets stiffness of the impostor
  116361. * @param impostor impostor to set stiffness on
  116362. * @param stiffness stiffness value from 0 to 1
  116363. */
  116364. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  116365. /**
  116366. * Gets velocityIterations of the impostor
  116367. * @param impostor impostor to get velocity iterations from
  116368. * @returns velocityIterations value
  116369. */
  116370. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  116371. /**
  116372. * Sets velocityIterations of the impostor
  116373. * @param impostor impostor to set velocity iterations on
  116374. * @param velocityIterations velocityIterations value
  116375. */
  116376. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  116377. /**
  116378. * Gets positionIterations of the impostor
  116379. * @param impostor impostor to get position iterations from
  116380. * @returns positionIterations value
  116381. */
  116382. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  116383. /**
  116384. * Sets positionIterations of the impostor
  116385. * @param impostor impostor to set position on
  116386. * @param positionIterations positionIterations value
  116387. */
  116388. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  116389. /**
  116390. * Append an anchor to a cloth object
  116391. * @param impostor is the cloth impostor to add anchor to
  116392. * @param otherImpostor is the rigid impostor to anchor to
  116393. * @param width ratio across width from 0 to 1
  116394. * @param height ratio up height from 0 to 1
  116395. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  116396. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  116397. */
  116398. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  116399. /**
  116400. * Append an hook to a rope object
  116401. * @param impostor is the rope impostor to add hook to
  116402. * @param otherImpostor is the rigid impostor to hook to
  116403. * @param length ratio along the rope from 0 to 1
  116404. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  116405. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  116406. */
  116407. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  116408. /**
  116409. * Sleeps the physics body and stops it from being active
  116410. * @param impostor impostor to sleep
  116411. */
  116412. sleepBody(impostor: PhysicsImpostor): void;
  116413. /**
  116414. * Activates the physics body
  116415. * @param impostor impostor to activate
  116416. */
  116417. wakeUpBody(impostor: PhysicsImpostor): void;
  116418. /**
  116419. * Updates the distance parameters of the joint
  116420. * @param joint joint to update
  116421. * @param maxDistance maximum distance of the joint
  116422. * @param minDistance minimum distance of the joint
  116423. */
  116424. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  116425. /**
  116426. * Sets a motor on the joint
  116427. * @param joint joint to set motor on
  116428. * @param speed speed of the motor
  116429. * @param maxForce maximum force of the motor
  116430. * @param motorIndex index of the motor
  116431. */
  116432. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  116433. /**
  116434. * Sets the motors limit
  116435. * @param joint joint to set limit on
  116436. * @param upperLimit upper limit
  116437. * @param lowerLimit lower limit
  116438. */
  116439. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  116440. /**
  116441. * Syncs the position and rotation of a mesh with the impostor
  116442. * @param mesh mesh to sync
  116443. * @param impostor impostor to update the mesh with
  116444. */
  116445. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  116446. /**
  116447. * Gets the radius of the impostor
  116448. * @param impostor impostor to get radius from
  116449. * @returns the radius
  116450. */
  116451. getRadius(impostor: PhysicsImpostor): number;
  116452. /**
  116453. * Gets the box size of the impostor
  116454. * @param impostor impostor to get box size from
  116455. * @param result the resulting box size
  116456. */
  116457. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  116458. /**
  116459. * Disposes of the impostor
  116460. */
  116461. dispose(): void;
  116462. /**
  116463. * Does a raycast in the physics world
  116464. * @param from when should the ray start?
  116465. * @param to when should the ray end?
  116466. * @returns PhysicsRaycastResult
  116467. */
  116468. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  116469. }
  116470. }
  116471. declare module BABYLON {
  116472. interface AbstractScene {
  116473. /**
  116474. * The list of reflection probes added to the scene
  116475. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  116476. */
  116477. reflectionProbes: Array<ReflectionProbe>;
  116478. /**
  116479. * Removes the given reflection probe from this scene.
  116480. * @param toRemove The reflection probe to remove
  116481. * @returns The index of the removed reflection probe
  116482. */
  116483. removeReflectionProbe(toRemove: ReflectionProbe): number;
  116484. /**
  116485. * Adds the given reflection probe to this scene.
  116486. * @param newReflectionProbe The reflection probe to add
  116487. */
  116488. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  116489. }
  116490. /**
  116491. * Class used to generate realtime reflection / refraction cube textures
  116492. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  116493. */
  116494. export class ReflectionProbe {
  116495. /** defines the name of the probe */
  116496. name: string;
  116497. private _scene;
  116498. private _renderTargetTexture;
  116499. private _projectionMatrix;
  116500. private _viewMatrix;
  116501. private _target;
  116502. private _add;
  116503. private _attachedMesh;
  116504. private _invertYAxis;
  116505. /** Gets or sets probe position (center of the cube map) */
  116506. position: Vector3;
  116507. /**
  116508. * Creates a new reflection probe
  116509. * @param name defines the name of the probe
  116510. * @param size defines the texture resolution (for each face)
  116511. * @param scene defines the hosting scene
  116512. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  116513. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  116514. */
  116515. constructor(
  116516. /** defines the name of the probe */
  116517. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  116518. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  116519. samples: number;
  116520. /** Gets or sets the refresh rate to use (on every frame by default) */
  116521. refreshRate: number;
  116522. /**
  116523. * Gets the hosting scene
  116524. * @returns a Scene
  116525. */
  116526. getScene(): Scene;
  116527. /** Gets the internal CubeTexture used to render to */
  116528. readonly cubeTexture: RenderTargetTexture;
  116529. /** Gets the list of meshes to render */
  116530. readonly renderList: Nullable<AbstractMesh[]>;
  116531. /**
  116532. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  116533. * @param mesh defines the mesh to attach to
  116534. */
  116535. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  116536. /**
  116537. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  116538. * @param renderingGroupId The rendering group id corresponding to its index
  116539. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  116540. */
  116541. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  116542. /**
  116543. * Clean all associated resources
  116544. */
  116545. dispose(): void;
  116546. /**
  116547. * Converts the reflection probe information to a readable string for debug purpose.
  116548. * @param fullDetails Supports for multiple levels of logging within scene loading
  116549. * @returns the human readable reflection probe info
  116550. */
  116551. toString(fullDetails?: boolean): string;
  116552. /**
  116553. * Get the class name of the relfection probe.
  116554. * @returns "ReflectionProbe"
  116555. */
  116556. getClassName(): string;
  116557. /**
  116558. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  116559. * @returns The JSON representation of the texture
  116560. */
  116561. serialize(): any;
  116562. /**
  116563. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  116564. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  116565. * @param scene Define the scene the parsed reflection probe should be instantiated in
  116566. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  116567. * @returns The parsed reflection probe if successful
  116568. */
  116569. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  116570. }
  116571. }
  116572. declare module BABYLON {
  116573. /** @hidden */
  116574. export var _BabylonLoaderRegistered: boolean;
  116575. }
  116576. declare module BABYLON {
  116577. /**
  116578. * The Physically based simple base material of BJS.
  116579. *
  116580. * This enables better naming and convention enforcements on top of the pbrMaterial.
  116581. * It is used as the base class for both the specGloss and metalRough conventions.
  116582. */
  116583. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  116584. /**
  116585. * Number of Simultaneous lights allowed on the material.
  116586. */
  116587. maxSimultaneousLights: number;
  116588. /**
  116589. * If sets to true, disables all the lights affecting the material.
  116590. */
  116591. disableLighting: boolean;
  116592. /**
  116593. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  116594. */
  116595. environmentTexture: BaseTexture;
  116596. /**
  116597. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  116598. */
  116599. invertNormalMapX: boolean;
  116600. /**
  116601. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  116602. */
  116603. invertNormalMapY: boolean;
  116604. /**
  116605. * Normal map used in the model.
  116606. */
  116607. normalTexture: BaseTexture;
  116608. /**
  116609. * Emissivie color used to self-illuminate the model.
  116610. */
  116611. emissiveColor: Color3;
  116612. /**
  116613. * Emissivie texture used to self-illuminate the model.
  116614. */
  116615. emissiveTexture: BaseTexture;
  116616. /**
  116617. * Occlusion Channel Strenght.
  116618. */
  116619. occlusionStrength: number;
  116620. /**
  116621. * Occlusion Texture of the material (adding extra occlusion effects).
  116622. */
  116623. occlusionTexture: BaseTexture;
  116624. /**
  116625. * Defines the alpha limits in alpha test mode.
  116626. */
  116627. alphaCutOff: number;
  116628. /**
  116629. * Gets the current double sided mode.
  116630. */
  116631. /**
  116632. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  116633. */
  116634. doubleSided: boolean;
  116635. /**
  116636. * Stores the pre-calculated light information of a mesh in a texture.
  116637. */
  116638. lightmapTexture: BaseTexture;
  116639. /**
  116640. * If true, the light map contains occlusion information instead of lighting info.
  116641. */
  116642. useLightmapAsShadowmap: boolean;
  116643. /**
  116644. * Instantiates a new PBRMaterial instance.
  116645. *
  116646. * @param name The material name
  116647. * @param scene The scene the material will be use in.
  116648. */
  116649. constructor(name: string, scene: Scene);
  116650. getClassName(): string;
  116651. }
  116652. }
  116653. declare module BABYLON {
  116654. /**
  116655. * The PBR material of BJS following the metal roughness convention.
  116656. *
  116657. * This fits to the PBR convention in the GLTF definition:
  116658. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  116659. */
  116660. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  116661. /**
  116662. * The base color has two different interpretations depending on the value of metalness.
  116663. * When the material is a metal, the base color is the specific measured reflectance value
  116664. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  116665. * of the material.
  116666. */
  116667. baseColor: Color3;
  116668. /**
  116669. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  116670. * well as opacity information in the alpha channel.
  116671. */
  116672. baseTexture: BaseTexture;
  116673. /**
  116674. * Specifies the metallic scalar value of the material.
  116675. * Can also be used to scale the metalness values of the metallic texture.
  116676. */
  116677. metallic: number;
  116678. /**
  116679. * Specifies the roughness scalar value of the material.
  116680. * Can also be used to scale the roughness values of the metallic texture.
  116681. */
  116682. roughness: number;
  116683. /**
  116684. * Texture containing both the metallic value in the B channel and the
  116685. * roughness value in the G channel to keep better precision.
  116686. */
  116687. metallicRoughnessTexture: BaseTexture;
  116688. /**
  116689. * Instantiates a new PBRMetalRoughnessMaterial instance.
  116690. *
  116691. * @param name The material name
  116692. * @param scene The scene the material will be use in.
  116693. */
  116694. constructor(name: string, scene: Scene);
  116695. /**
  116696. * Return the currrent class name of the material.
  116697. */
  116698. getClassName(): string;
  116699. /**
  116700. * Makes a duplicate of the current material.
  116701. * @param name - name to use for the new material.
  116702. */
  116703. clone(name: string): PBRMetallicRoughnessMaterial;
  116704. /**
  116705. * Serialize the material to a parsable JSON object.
  116706. */
  116707. serialize(): any;
  116708. /**
  116709. * Parses a JSON object correponding to the serialize function.
  116710. */
  116711. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  116712. }
  116713. }
  116714. declare module BABYLON {
  116715. /**
  116716. * The PBR material of BJS following the specular glossiness convention.
  116717. *
  116718. * This fits to the PBR convention in the GLTF definition:
  116719. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  116720. */
  116721. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  116722. /**
  116723. * Specifies the diffuse color of the material.
  116724. */
  116725. diffuseColor: Color3;
  116726. /**
  116727. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  116728. * channel.
  116729. */
  116730. diffuseTexture: BaseTexture;
  116731. /**
  116732. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  116733. */
  116734. specularColor: Color3;
  116735. /**
  116736. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  116737. */
  116738. glossiness: number;
  116739. /**
  116740. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  116741. */
  116742. specularGlossinessTexture: BaseTexture;
  116743. /**
  116744. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  116745. *
  116746. * @param name The material name
  116747. * @param scene The scene the material will be use in.
  116748. */
  116749. constructor(name: string, scene: Scene);
  116750. /**
  116751. * Return the currrent class name of the material.
  116752. */
  116753. getClassName(): string;
  116754. /**
  116755. * Makes a duplicate of the current material.
  116756. * @param name - name to use for the new material.
  116757. */
  116758. clone(name: string): PBRSpecularGlossinessMaterial;
  116759. /**
  116760. * Serialize the material to a parsable JSON object.
  116761. */
  116762. serialize(): any;
  116763. /**
  116764. * Parses a JSON object correponding to the serialize function.
  116765. */
  116766. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  116767. }
  116768. }
  116769. declare module BABYLON {
  116770. /**
  116771. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  116772. * It can help converting any input color in a desired output one. This can then be used to create effects
  116773. * from sepia, black and white to sixties or futuristic rendering...
  116774. *
  116775. * The only supported format is currently 3dl.
  116776. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  116777. */
  116778. export class ColorGradingTexture extends BaseTexture {
  116779. /**
  116780. * The current texture matrix. (will always be identity in color grading texture)
  116781. */
  116782. private _textureMatrix;
  116783. /**
  116784. * The texture URL.
  116785. */
  116786. url: string;
  116787. /**
  116788. * Empty line regex stored for GC.
  116789. */
  116790. private static _noneEmptyLineRegex;
  116791. private _engine;
  116792. /**
  116793. * Instantiates a ColorGradingTexture from the following parameters.
  116794. *
  116795. * @param url The location of the color gradind data (currently only supporting 3dl)
  116796. * @param scene The scene the texture will be used in
  116797. */
  116798. constructor(url: string, scene: Scene);
  116799. /**
  116800. * Returns the texture matrix used in most of the material.
  116801. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  116802. */
  116803. getTextureMatrix(): Matrix;
  116804. /**
  116805. * Occurs when the file being loaded is a .3dl LUT file.
  116806. */
  116807. private load3dlTexture;
  116808. /**
  116809. * Starts the loading process of the texture.
  116810. */
  116811. private loadTexture;
  116812. /**
  116813. * Clones the color gradind texture.
  116814. */
  116815. clone(): ColorGradingTexture;
  116816. /**
  116817. * Called during delayed load for textures.
  116818. */
  116819. delayLoad(): void;
  116820. /**
  116821. * Parses a color grading texture serialized by Babylon.
  116822. * @param parsedTexture The texture information being parsedTexture
  116823. * @param scene The scene to load the texture in
  116824. * @param rootUrl The root url of the data assets to load
  116825. * @return A color gradind texture
  116826. */
  116827. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  116828. /**
  116829. * Serializes the LUT texture to json format.
  116830. */
  116831. serialize(): any;
  116832. }
  116833. }
  116834. declare module BABYLON {
  116835. /**
  116836. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  116837. */
  116838. export class EquiRectangularCubeTexture extends BaseTexture {
  116839. /** The six faces of the cube. */
  116840. private static _FacesMapping;
  116841. private _noMipmap;
  116842. private _onLoad;
  116843. private _onError;
  116844. /** The size of the cubemap. */
  116845. private _size;
  116846. /** The buffer of the image. */
  116847. private _buffer;
  116848. /** The width of the input image. */
  116849. private _width;
  116850. /** The height of the input image. */
  116851. private _height;
  116852. /** The URL to the image. */
  116853. url: string;
  116854. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  116855. coordinatesMode: number;
  116856. /**
  116857. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  116858. * @param url The location of the image
  116859. * @param scene The scene the texture will be used in
  116860. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  116861. * @param noMipmap Forces to not generate the mipmap if true
  116862. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  116863. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  116864. * @param onLoad — defines a callback called when texture is loaded
  116865. * @param onError — defines a callback called if there is an error
  116866. */
  116867. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  116868. /**
  116869. * Load the image data, by putting the image on a canvas and extracting its buffer.
  116870. */
  116871. private loadImage;
  116872. /**
  116873. * Convert the image buffer into a cubemap and create a CubeTexture.
  116874. */
  116875. private loadTexture;
  116876. /**
  116877. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  116878. * @param buffer The ArrayBuffer that should be converted.
  116879. * @returns The buffer as Float32Array.
  116880. */
  116881. private getFloat32ArrayFromArrayBuffer;
  116882. /**
  116883. * Get the current class name of the texture useful for serialization or dynamic coding.
  116884. * @returns "EquiRectangularCubeTexture"
  116885. */
  116886. getClassName(): string;
  116887. /**
  116888. * Create a clone of the current EquiRectangularCubeTexture and return it.
  116889. * @returns A clone of the current EquiRectangularCubeTexture.
  116890. */
  116891. clone(): EquiRectangularCubeTexture;
  116892. }
  116893. }
  116894. declare module BABYLON {
  116895. /**
  116896. * Based on jsTGALoader - Javascript loader for TGA file
  116897. * By Vincent Thibault
  116898. * @see http://blog.robrowser.com/javascript-tga-loader.html
  116899. */
  116900. export class TGATools {
  116901. private static _TYPE_INDEXED;
  116902. private static _TYPE_RGB;
  116903. private static _TYPE_GREY;
  116904. private static _TYPE_RLE_INDEXED;
  116905. private static _TYPE_RLE_RGB;
  116906. private static _TYPE_RLE_GREY;
  116907. private static _ORIGIN_MASK;
  116908. private static _ORIGIN_SHIFT;
  116909. private static _ORIGIN_BL;
  116910. private static _ORIGIN_BR;
  116911. private static _ORIGIN_UL;
  116912. private static _ORIGIN_UR;
  116913. /**
  116914. * Gets the header of a TGA file
  116915. * @param data defines the TGA data
  116916. * @returns the header
  116917. */
  116918. static GetTGAHeader(data: Uint8Array): any;
  116919. /**
  116920. * Uploads TGA content to a Babylon Texture
  116921. * @hidden
  116922. */
  116923. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  116924. /** @hidden */
  116925. 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;
  116926. /** @hidden */
  116927. 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;
  116928. /** @hidden */
  116929. 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;
  116930. /** @hidden */
  116931. 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;
  116932. /** @hidden */
  116933. 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;
  116934. /** @hidden */
  116935. 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;
  116936. }
  116937. }
  116938. declare module BABYLON {
  116939. /**
  116940. * Implementation of the TGA Texture Loader.
  116941. * @hidden
  116942. */
  116943. export class _TGATextureLoader implements IInternalTextureLoader {
  116944. /**
  116945. * Defines wether the loader supports cascade loading the different faces.
  116946. */
  116947. readonly supportCascades: boolean;
  116948. /**
  116949. * This returns if the loader support the current file information.
  116950. * @param extension defines the file extension of the file being loaded
  116951. * @param textureFormatInUse defines the current compressed format in use iun the engine
  116952. * @param fallback defines the fallback internal texture if any
  116953. * @param isBase64 defines whether the texture is encoded as a base64
  116954. * @param isBuffer defines whether the texture data are stored as a buffer
  116955. * @returns true if the loader can load the specified file
  116956. */
  116957. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  116958. /**
  116959. * Transform the url before loading if required.
  116960. * @param rootUrl the url of the texture
  116961. * @param textureFormatInUse defines the current compressed format in use iun the engine
  116962. * @returns the transformed texture
  116963. */
  116964. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  116965. /**
  116966. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  116967. * @param rootUrl the url of the texture
  116968. * @param textureFormatInUse defines the current compressed format in use iun the engine
  116969. * @returns the fallback texture
  116970. */
  116971. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  116972. /**
  116973. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  116974. * @param data contains the texture data
  116975. * @param texture defines the BabylonJS internal texture
  116976. * @param createPolynomials will be true if polynomials have been requested
  116977. * @param onLoad defines the callback to trigger once the texture is ready
  116978. * @param onError defines the callback to trigger in case of error
  116979. */
  116980. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  116981. /**
  116982. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  116983. * @param data contains the texture data
  116984. * @param texture defines the BabylonJS internal texture
  116985. * @param callback defines the method to call once ready to upload
  116986. */
  116987. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  116988. }
  116989. }
  116990. declare module BABYLON {
  116991. /**
  116992. * Info about the .basis files
  116993. */
  116994. class BasisFileInfo {
  116995. /**
  116996. * If the file has alpha
  116997. */
  116998. hasAlpha: boolean;
  116999. /**
  117000. * Info about each image of the basis file
  117001. */
  117002. images: Array<{
  117003. levels: Array<{
  117004. width: number;
  117005. height: number;
  117006. transcodedPixels: ArrayBufferView;
  117007. }>;
  117008. }>;
  117009. }
  117010. /**
  117011. * Result of transcoding a basis file
  117012. */
  117013. class TranscodeResult {
  117014. /**
  117015. * Info about the .basis file
  117016. */
  117017. fileInfo: BasisFileInfo;
  117018. /**
  117019. * Format to use when loading the file
  117020. */
  117021. format: number;
  117022. }
  117023. /**
  117024. * Configuration options for the Basis transcoder
  117025. */
  117026. export class BasisTranscodeConfiguration {
  117027. /**
  117028. * Supported compression formats used to determine the supported output format of the transcoder
  117029. */
  117030. supportedCompressionFormats?: {
  117031. /**
  117032. * etc1 compression format
  117033. */
  117034. etc1?: boolean;
  117035. /**
  117036. * s3tc compression format
  117037. */
  117038. s3tc?: boolean;
  117039. /**
  117040. * pvrtc compression format
  117041. */
  117042. pvrtc?: boolean;
  117043. /**
  117044. * etc2 compression format
  117045. */
  117046. etc2?: boolean;
  117047. };
  117048. /**
  117049. * If mipmap levels should be loaded for transcoded images (Default: true)
  117050. */
  117051. loadMipmapLevels?: boolean;
  117052. /**
  117053. * Index of a single image to load (Default: all images)
  117054. */
  117055. loadSingleImage?: number;
  117056. }
  117057. /**
  117058. * Used to load .Basis files
  117059. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  117060. */
  117061. export class BasisTools {
  117062. private static _IgnoreSupportedFormats;
  117063. /**
  117064. * URL to use when loading the basis transcoder
  117065. */
  117066. static JSModuleURL: string;
  117067. /**
  117068. * URL to use when loading the wasm module for the transcoder
  117069. */
  117070. static WasmModuleURL: string;
  117071. /**
  117072. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  117073. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  117074. * @returns internal format corresponding to the Basis format
  117075. */
  117076. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  117077. private static _WorkerPromise;
  117078. private static _Worker;
  117079. private static _actionId;
  117080. private static _CreateWorkerAsync;
  117081. /**
  117082. * Transcodes a loaded image file to compressed pixel data
  117083. * @param imageData image data to transcode
  117084. * @param config configuration options for the transcoding
  117085. * @returns a promise resulting in the transcoded image
  117086. */
  117087. static TranscodeAsync(imageData: ArrayBuffer, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  117088. /**
  117089. * Loads a texture from the transcode result
  117090. * @param texture texture load to
  117091. * @param transcodeResult the result of transcoding the basis file to load from
  117092. */
  117093. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  117094. }
  117095. }
  117096. declare module BABYLON {
  117097. /**
  117098. * Loader for .basis file format
  117099. */
  117100. export class _BasisTextureLoader implements IInternalTextureLoader {
  117101. /**
  117102. * Defines whether the loader supports cascade loading the different faces.
  117103. */
  117104. readonly supportCascades: boolean;
  117105. /**
  117106. * This returns if the loader support the current file information.
  117107. * @param extension defines the file extension of the file being loaded
  117108. * @param textureFormatInUse defines the current compressed format in use iun the engine
  117109. * @param fallback defines the fallback internal texture if any
  117110. * @param isBase64 defines whether the texture is encoded as a base64
  117111. * @param isBuffer defines whether the texture data are stored as a buffer
  117112. * @returns true if the loader can load the specified file
  117113. */
  117114. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  117115. /**
  117116. * Transform the url before loading if required.
  117117. * @param rootUrl the url of the texture
  117118. * @param textureFormatInUse defines the current compressed format in use iun the engine
  117119. * @returns the transformed texture
  117120. */
  117121. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  117122. /**
  117123. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  117124. * @param rootUrl the url of the texture
  117125. * @param textureFormatInUse defines the current compressed format in use iun the engine
  117126. * @returns the fallback texture
  117127. */
  117128. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  117129. /**
  117130. * Uploads the cube texture data to the WebGl Texture. It has already been bound.
  117131. * @param data contains the texture data
  117132. * @param texture defines the BabylonJS internal texture
  117133. * @param createPolynomials will be true if polynomials have been requested
  117134. * @param onLoad defines the callback to trigger once the texture is ready
  117135. * @param onError defines the callback to trigger in case of error
  117136. */
  117137. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  117138. /**
  117139. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  117140. * @param data contains the texture data
  117141. * @param texture defines the BabylonJS internal texture
  117142. * @param callback defines the method to call once ready to upload
  117143. */
  117144. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  117145. }
  117146. }
  117147. declare module BABYLON {
  117148. /**
  117149. * 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.
  117150. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  117151. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  117152. */
  117153. export class CustomProceduralTexture extends ProceduralTexture {
  117154. private _animate;
  117155. private _time;
  117156. private _config;
  117157. private _texturePath;
  117158. /**
  117159. * Instantiates a new Custom Procedural Texture.
  117160. * 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.
  117161. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  117162. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  117163. * @param name Define the name of the texture
  117164. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  117165. * @param size Define the size of the texture to create
  117166. * @param scene Define the scene the texture belongs to
  117167. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  117168. * @param generateMipMaps Define if the texture should creates mip maps or not
  117169. */
  117170. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  117171. private _loadJson;
  117172. /**
  117173. * Is the texture ready to be used ? (rendered at least once)
  117174. * @returns true if ready, otherwise, false.
  117175. */
  117176. isReady(): boolean;
  117177. /**
  117178. * Render the texture to its associated render target.
  117179. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  117180. */
  117181. render(useCameraPostProcess?: boolean): void;
  117182. /**
  117183. * Update the list of dependant textures samplers in the shader.
  117184. */
  117185. updateTextures(): void;
  117186. /**
  117187. * Update the uniform values of the procedural texture in the shader.
  117188. */
  117189. updateShaderUniforms(): void;
  117190. /**
  117191. * Define if the texture animates or not.
  117192. */
  117193. animate: boolean;
  117194. }
  117195. }
  117196. declare module BABYLON {
  117197. /** @hidden */
  117198. export var noisePixelShader: {
  117199. name: string;
  117200. shader: string;
  117201. };
  117202. }
  117203. declare module BABYLON {
  117204. /**
  117205. * Class used to generate noise procedural textures
  117206. */
  117207. export class NoiseProceduralTexture extends ProceduralTexture {
  117208. private _time;
  117209. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  117210. brightness: number;
  117211. /** Defines the number of octaves to process */
  117212. octaves: number;
  117213. /** Defines the level of persistence (0.8 by default) */
  117214. persistence: number;
  117215. /** Gets or sets animation speed factor (default is 1) */
  117216. animationSpeedFactor: number;
  117217. /**
  117218. * Creates a new NoiseProceduralTexture
  117219. * @param name defines the name fo the texture
  117220. * @param size defines the size of the texture (default is 256)
  117221. * @param scene defines the hosting scene
  117222. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  117223. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  117224. */
  117225. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  117226. private _updateShaderUniforms;
  117227. protected _getDefines(): string;
  117228. /** Generate the current state of the procedural texture */
  117229. render(useCameraPostProcess?: boolean): void;
  117230. /**
  117231. * Serializes this noise procedural texture
  117232. * @returns a serialized noise procedural texture object
  117233. */
  117234. serialize(): any;
  117235. /**
  117236. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  117237. * @param parsedTexture defines parsed texture data
  117238. * @param scene defines the current scene
  117239. * @param rootUrl defines the root URL containing noise procedural texture information
  117240. * @returns a parsed NoiseProceduralTexture
  117241. */
  117242. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  117243. }
  117244. }
  117245. declare module BABYLON {
  117246. /**
  117247. * Raw cube texture where the raw buffers are passed in
  117248. */
  117249. export class RawCubeTexture extends CubeTexture {
  117250. /**
  117251. * Creates a cube texture where the raw buffers are passed in.
  117252. * @param scene defines the scene the texture is attached to
  117253. * @param data defines the array of data to use to create each face
  117254. * @param size defines the size of the textures
  117255. * @param format defines the format of the data
  117256. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  117257. * @param generateMipMaps defines if the engine should generate the mip levels
  117258. * @param invertY defines if data must be stored with Y axis inverted
  117259. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  117260. * @param compression defines the compression used (null by default)
  117261. */
  117262. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  117263. /**
  117264. * Updates the raw cube texture.
  117265. * @param data defines the data to store
  117266. * @param format defines the data format
  117267. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  117268. * @param invertY defines if data must be stored with Y axis inverted
  117269. * @param compression defines the compression used (null by default)
  117270. * @param level defines which level of the texture to update
  117271. */
  117272. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  117273. /**
  117274. * Updates a raw cube texture with RGBD encoded data.
  117275. * @param data defines the array of data [mipmap][face] to use to create each face
  117276. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  117277. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  117278. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  117279. * @returns a promsie that resolves when the operation is complete
  117280. */
  117281. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  117282. /**
  117283. * Clones the raw cube texture.
  117284. * @return a new cube texture
  117285. */
  117286. clone(): CubeTexture;
  117287. /** @hidden */
  117288. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  117289. }
  117290. }
  117291. declare module BABYLON {
  117292. /**
  117293. * Class used to store 3D textures containing user data
  117294. */
  117295. export class RawTexture3D extends Texture {
  117296. /** Gets or sets the texture format to use */
  117297. format: number;
  117298. private _engine;
  117299. /**
  117300. * Create a new RawTexture3D
  117301. * @param data defines the data of the texture
  117302. * @param width defines the width of the texture
  117303. * @param height defines the height of the texture
  117304. * @param depth defines the depth of the texture
  117305. * @param format defines the texture format to use
  117306. * @param scene defines the hosting scene
  117307. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  117308. * @param invertY defines if texture must be stored with Y axis inverted
  117309. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  117310. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  117311. */
  117312. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  117313. /** Gets or sets the texture format to use */
  117314. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  117315. /**
  117316. * Update the texture with new data
  117317. * @param data defines the data to store in the texture
  117318. */
  117319. update(data: ArrayBufferView): void;
  117320. }
  117321. }
  117322. declare module BABYLON {
  117323. /**
  117324. * Creates a refraction texture used by refraction channel of the standard material.
  117325. * It is like a mirror but to see through a material.
  117326. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  117327. */
  117328. export class RefractionTexture extends RenderTargetTexture {
  117329. /**
  117330. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  117331. * 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.
  117332. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  117333. */
  117334. refractionPlane: Plane;
  117335. /**
  117336. * Define how deep under the surface we should see.
  117337. */
  117338. depth: number;
  117339. /**
  117340. * Creates a refraction texture used by refraction channel of the standard material.
  117341. * It is like a mirror but to see through a material.
  117342. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  117343. * @param name Define the texture name
  117344. * @param size Define the size of the underlying texture
  117345. * @param scene Define the scene the refraction belongs to
  117346. * @param generateMipMaps Define if we need to generate mips level for the refraction
  117347. */
  117348. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  117349. /**
  117350. * Clone the refraction texture.
  117351. * @returns the cloned texture
  117352. */
  117353. clone(): RefractionTexture;
  117354. /**
  117355. * Serialize the texture to a JSON representation you could use in Parse later on
  117356. * @returns the serialized JSON representation
  117357. */
  117358. serialize(): any;
  117359. }
  117360. }
  117361. declare module BABYLON {
  117362. /**
  117363. * Defines the options related to the creation of an HtmlElementTexture
  117364. */
  117365. export interface IHtmlElementTextureOptions {
  117366. /**
  117367. * Defines wether mip maps should be created or not.
  117368. */
  117369. generateMipMaps?: boolean;
  117370. /**
  117371. * Defines the sampling mode of the texture.
  117372. */
  117373. samplingMode?: number;
  117374. /**
  117375. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  117376. */
  117377. engine: Nullable<Engine>;
  117378. /**
  117379. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  117380. */
  117381. scene: Nullable<Scene>;
  117382. }
  117383. /**
  117384. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  117385. * To be as efficient as possible depending on your constraints nothing aside the first upload
  117386. * is automatically managed.
  117387. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  117388. * in your application.
  117389. *
  117390. * As the update is not automatic, you need to call them manually.
  117391. */
  117392. export class HtmlElementTexture extends BaseTexture {
  117393. /**
  117394. * The texture URL.
  117395. */
  117396. element: HTMLVideoElement | HTMLCanvasElement;
  117397. private static readonly DefaultOptions;
  117398. private _textureMatrix;
  117399. private _engine;
  117400. private _isVideo;
  117401. private _generateMipMaps;
  117402. private _samplingMode;
  117403. /**
  117404. * Instantiates a HtmlElementTexture from the following parameters.
  117405. *
  117406. * @param name Defines the name of the texture
  117407. * @param element Defines the video or canvas the texture is filled with
  117408. * @param options Defines the other none mandatory texture creation options
  117409. */
  117410. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  117411. private _createInternalTexture;
  117412. /**
  117413. * Returns the texture matrix used in most of the material.
  117414. */
  117415. getTextureMatrix(): Matrix;
  117416. /**
  117417. * Updates the content of the texture.
  117418. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  117419. */
  117420. update(invertY?: Nullable<boolean>): void;
  117421. }
  117422. }
  117423. declare module BABYLON {
  117424. /**
  117425. * Enum used to define the target of a block
  117426. */
  117427. export enum NodeMaterialBlockTargets {
  117428. /** Vertex shader */
  117429. Vertex = 1,
  117430. /** Fragment shader */
  117431. Fragment = 2,
  117432. /** Neutral */
  117433. Neutral = 4,
  117434. /** Vertex and Fragment */
  117435. VertexAndFragment = 3
  117436. }
  117437. }
  117438. declare module BABYLON {
  117439. /**
  117440. * Defines the kind of connection point for node based material
  117441. */
  117442. export enum NodeMaterialBlockConnectionPointTypes {
  117443. /** Float */
  117444. Float = 1,
  117445. /** Int */
  117446. Int = 2,
  117447. /** Vector2 */
  117448. Vector2 = 4,
  117449. /** Vector3 */
  117450. Vector3 = 8,
  117451. /** Vector4 */
  117452. Vector4 = 16,
  117453. /** Color3 */
  117454. Color3 = 32,
  117455. /** Color4 */
  117456. Color4 = 64,
  117457. /** Matrix */
  117458. Matrix = 128,
  117459. /** Detect type based on connection */
  117460. AutoDetect = 1024,
  117461. /** Output type that will be defined by input type */
  117462. BasedOnInput = 2048
  117463. }
  117464. }
  117465. declare module BABYLON {
  117466. /**
  117467. * Root class for all node material optimizers
  117468. */
  117469. export class NodeMaterialOptimizer {
  117470. /**
  117471. * Function used to optimize a NodeMaterial graph
  117472. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  117473. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  117474. */
  117475. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  117476. }
  117477. }
  117478. declare module BABYLON {
  117479. /**
  117480. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  117481. */
  117482. export class TransformBlock extends NodeMaterialBlock {
  117483. /**
  117484. * Defines the value to use to complement W value to transform it to a Vector4
  117485. */
  117486. complementW: number;
  117487. /**
  117488. * Defines the value to use to complement z value to transform it to a Vector4
  117489. */
  117490. complementZ: number;
  117491. /**
  117492. * Creates a new TransformBlock
  117493. * @param name defines the block name
  117494. */
  117495. constructor(name: string);
  117496. /**
  117497. * Gets the current class name
  117498. * @returns the class name
  117499. */
  117500. getClassName(): string;
  117501. /**
  117502. * Gets the vector input
  117503. */
  117504. readonly vector: NodeMaterialConnectionPoint;
  117505. /**
  117506. * Gets the output component
  117507. */
  117508. readonly output: NodeMaterialConnectionPoint;
  117509. /**
  117510. * Gets the matrix transform input
  117511. */
  117512. readonly transform: NodeMaterialConnectionPoint;
  117513. protected _buildBlock(state: NodeMaterialBuildState): this;
  117514. serialize(): any;
  117515. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  117516. protected _dumpPropertiesCode(): string;
  117517. }
  117518. }
  117519. declare module BABYLON {
  117520. /**
  117521. * Block used to output the vertex position
  117522. */
  117523. export class VertexOutputBlock extends NodeMaterialBlock {
  117524. /**
  117525. * Creates a new VertexOutputBlock
  117526. * @param name defines the block name
  117527. */
  117528. constructor(name: string);
  117529. /**
  117530. * Gets the current class name
  117531. * @returns the class name
  117532. */
  117533. getClassName(): string;
  117534. /**
  117535. * Gets the vector input component
  117536. */
  117537. readonly vector: NodeMaterialConnectionPoint;
  117538. protected _buildBlock(state: NodeMaterialBuildState): this;
  117539. }
  117540. }
  117541. declare module BABYLON {
  117542. /**
  117543. * Block used to output the final color
  117544. */
  117545. export class FragmentOutputBlock extends NodeMaterialBlock {
  117546. /**
  117547. * Create a new FragmentOutputBlock
  117548. * @param name defines the block name
  117549. */
  117550. constructor(name: string);
  117551. /**
  117552. * Gets the current class name
  117553. * @returns the class name
  117554. */
  117555. getClassName(): string;
  117556. /**
  117557. * Gets the rgba input component
  117558. */
  117559. readonly rgba: NodeMaterialConnectionPoint;
  117560. /**
  117561. * Gets the rgb input component
  117562. */
  117563. readonly rgb: NodeMaterialConnectionPoint;
  117564. /**
  117565. * Gets the a input component
  117566. */
  117567. readonly a: NodeMaterialConnectionPoint;
  117568. protected _buildBlock(state: NodeMaterialBuildState): this;
  117569. }
  117570. }
  117571. declare module BABYLON {
  117572. /**
  117573. * Enum used to define system values e.g. values automatically provided by the system
  117574. */
  117575. export enum NodeMaterialSystemValues {
  117576. /** World */
  117577. World = 1,
  117578. /** View */
  117579. View = 2,
  117580. /** Projection */
  117581. Projection = 3,
  117582. /** ViewProjection */
  117583. ViewProjection = 4,
  117584. /** WorldView */
  117585. WorldView = 5,
  117586. /** WorldViewProjection */
  117587. WorldViewProjection = 6,
  117588. /** CameraPosition */
  117589. CameraPosition = 7,
  117590. /** Fog Color */
  117591. FogColor = 8
  117592. }
  117593. }
  117594. declare module BABYLON {
  117595. /**
  117596. * Block used to read a reflection texture from a sampler
  117597. */
  117598. export class ReflectionTextureBlock extends NodeMaterialBlock {
  117599. private _define3DName;
  117600. private _defineCubicName;
  117601. private _defineExplicitName;
  117602. private _defineProjectionName;
  117603. private _defineLocalCubicName;
  117604. private _defineSphericalName;
  117605. private _definePlanarName;
  117606. private _defineEquirectangularName;
  117607. private _defineMirroredEquirectangularFixedName;
  117608. private _defineEquirectangularFixedName;
  117609. private _defineSkyboxName;
  117610. private _cubeSamplerName;
  117611. private _2DSamplerName;
  117612. private _positionUVWName;
  117613. private _directionWName;
  117614. private _reflectionCoordsName;
  117615. private _reflection2DCoordsName;
  117616. private _reflectionColorName;
  117617. private _reflectionMatrixName;
  117618. /**
  117619. * Gets or sets the texture associated with the node
  117620. */
  117621. texture: Nullable<BaseTexture>;
  117622. /**
  117623. * Create a new TextureBlock
  117624. * @param name defines the block name
  117625. */
  117626. constructor(name: string);
  117627. /**
  117628. * Gets the current class name
  117629. * @returns the class name
  117630. */
  117631. getClassName(): string;
  117632. /**
  117633. * Gets the world position input component
  117634. */
  117635. readonly position: NodeMaterialConnectionPoint;
  117636. /**
  117637. * Gets the world position input component
  117638. */
  117639. readonly worldPosition: NodeMaterialConnectionPoint;
  117640. /**
  117641. * Gets the world normal input component
  117642. */
  117643. readonly worldNormal: NodeMaterialConnectionPoint;
  117644. /**
  117645. * Gets the world input component
  117646. */
  117647. readonly world: NodeMaterialConnectionPoint;
  117648. /**
  117649. * Gets the camera (or eye) position component
  117650. */
  117651. readonly cameraPosition: NodeMaterialConnectionPoint;
  117652. /**
  117653. * Gets the view input component
  117654. */
  117655. readonly view: NodeMaterialConnectionPoint;
  117656. /**
  117657. * Gets the rgb output component
  117658. */
  117659. readonly rgb: NodeMaterialConnectionPoint;
  117660. /**
  117661. * Gets the r output component
  117662. */
  117663. readonly r: NodeMaterialConnectionPoint;
  117664. /**
  117665. * Gets the g output component
  117666. */
  117667. readonly g: NodeMaterialConnectionPoint;
  117668. /**
  117669. * Gets the b output component
  117670. */
  117671. readonly b: NodeMaterialConnectionPoint;
  117672. autoConfigure(material: NodeMaterial): void;
  117673. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  117674. isReady(): boolean;
  117675. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  117676. private _injectVertexCode;
  117677. private _writeOutput;
  117678. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  117679. serialize(): any;
  117680. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  117681. }
  117682. }
  117683. declare module BABYLON {
  117684. /**
  117685. * Interface used to configure the node material editor
  117686. */
  117687. export interface INodeMaterialEditorOptions {
  117688. /** Define the URl to load node editor script */
  117689. editorURL?: string;
  117690. }
  117691. /** @hidden */
  117692. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  117693. /** BONES */
  117694. NUM_BONE_INFLUENCERS: number;
  117695. BonesPerMesh: number;
  117696. BONETEXTURE: boolean;
  117697. /** MORPH TARGETS */
  117698. MORPHTARGETS: boolean;
  117699. MORPHTARGETS_NORMAL: boolean;
  117700. MORPHTARGETS_TANGENT: boolean;
  117701. MORPHTARGETS_UV: boolean;
  117702. NUM_MORPH_INFLUENCERS: number;
  117703. /** IMAGE PROCESSING */
  117704. IMAGEPROCESSING: boolean;
  117705. VIGNETTE: boolean;
  117706. VIGNETTEBLENDMODEMULTIPLY: boolean;
  117707. VIGNETTEBLENDMODEOPAQUE: boolean;
  117708. TONEMAPPING: boolean;
  117709. TONEMAPPING_ACES: boolean;
  117710. CONTRAST: boolean;
  117711. EXPOSURE: boolean;
  117712. COLORCURVES: boolean;
  117713. COLORGRADING: boolean;
  117714. COLORGRADING3D: boolean;
  117715. SAMPLER3DGREENDEPTH: boolean;
  117716. SAMPLER3DBGRMAP: boolean;
  117717. IMAGEPROCESSINGPOSTPROCESS: boolean;
  117718. constructor();
  117719. setValue(name: string, value: boolean): void;
  117720. }
  117721. /**
  117722. * Class used to configure NodeMaterial
  117723. */
  117724. export interface INodeMaterialOptions {
  117725. /**
  117726. * Defines if blocks should emit comments
  117727. */
  117728. emitComments: boolean;
  117729. }
  117730. /**
  117731. * Class used to create a node based material built by assembling shader blocks
  117732. */
  117733. export class NodeMaterial extends PushMaterial {
  117734. private static _BuildIdGenerator;
  117735. private _options;
  117736. private _vertexCompilationState;
  117737. private _fragmentCompilationState;
  117738. private _sharedData;
  117739. private _buildId;
  117740. private _buildWasSuccessful;
  117741. private _cachedWorldViewMatrix;
  117742. private _cachedWorldViewProjectionMatrix;
  117743. private _optimizers;
  117744. private _animationFrame;
  117745. /** Define the URl to load node editor script */
  117746. static EditorURL: string;
  117747. private BJSNODEMATERIALEDITOR;
  117748. /** Get the inspector from bundle or global */
  117749. private _getGlobalNodeMaterialEditor;
  117750. /**
  117751. * 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)
  117752. */
  117753. ignoreAlpha: boolean;
  117754. /**
  117755. * Defines the maximum number of lights that can be used in the material
  117756. */
  117757. maxSimultaneousLights: number;
  117758. /**
  117759. * Observable raised when the material is built
  117760. */
  117761. onBuildObservable: Observable<NodeMaterial>;
  117762. /**
  117763. * Gets or sets the root nodes of the material vertex shader
  117764. */
  117765. _vertexOutputNodes: NodeMaterialBlock[];
  117766. /**
  117767. * Gets or sets the root nodes of the material fragment (pixel) shader
  117768. */
  117769. _fragmentOutputNodes: NodeMaterialBlock[];
  117770. /** Gets or sets options to control the node material overall behavior */
  117771. options: INodeMaterialOptions;
  117772. /**
  117773. * Default configuration related to image processing available in the standard Material.
  117774. */
  117775. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  117776. /**
  117777. * Gets the image processing configuration used either in this material.
  117778. */
  117779. /**
  117780. * Sets the Default image processing configuration used either in the this material.
  117781. *
  117782. * If sets to null, the scene one is in use.
  117783. */
  117784. imageProcessingConfiguration: ImageProcessingConfiguration;
  117785. /**
  117786. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  117787. */
  117788. attachedBlocks: NodeMaterialBlock[];
  117789. /**
  117790. * Create a new node based material
  117791. * @param name defines the material name
  117792. * @param scene defines the hosting scene
  117793. * @param options defines creation option
  117794. */
  117795. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  117796. /**
  117797. * Gets the current class name of the material e.g. "NodeMaterial"
  117798. * @returns the class name
  117799. */
  117800. getClassName(): string;
  117801. /**
  117802. * Keep track of the image processing observer to allow dispose and replace.
  117803. */
  117804. private _imageProcessingObserver;
  117805. /**
  117806. * Attaches a new image processing configuration to the Standard Material.
  117807. * @param configuration
  117808. */
  117809. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  117810. /**
  117811. * Get a block by its name
  117812. * @param name defines the name of the block to retrieve
  117813. * @returns the required block or null if not found
  117814. */
  117815. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  117816. /**
  117817. * Get a block by its name
  117818. * @param predicate defines the predicate used to find the good candidate
  117819. * @returns the required block or null if not found
  117820. */
  117821. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  117822. /**
  117823. * Get an input block by its name
  117824. * @param predicate defines the predicate used to find the good candidate
  117825. * @returns the required input block or null if not found
  117826. */
  117827. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  117828. /**
  117829. * Gets the list of input blocks attached to this material
  117830. * @returns an array of InputBlocks
  117831. */
  117832. getInputBlocks(): InputBlock[];
  117833. /**
  117834. * Adds a new optimizer to the list of optimizers
  117835. * @param optimizer defines the optimizers to add
  117836. * @returns the current material
  117837. */
  117838. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  117839. /**
  117840. * Remove an optimizer from the list of optimizers
  117841. * @param optimizer defines the optimizers to remove
  117842. * @returns the current material
  117843. */
  117844. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  117845. /**
  117846. * Add a new block to the list of output nodes
  117847. * @param node defines the node to add
  117848. * @returns the current material
  117849. */
  117850. addOutputNode(node: NodeMaterialBlock): this;
  117851. /**
  117852. * Remove a block from the list of root nodes
  117853. * @param node defines the node to remove
  117854. * @returns the current material
  117855. */
  117856. removeOutputNode(node: NodeMaterialBlock): this;
  117857. private _addVertexOutputNode;
  117858. private _removeVertexOutputNode;
  117859. private _addFragmentOutputNode;
  117860. private _removeFragmentOutputNode;
  117861. /**
  117862. * Specifies if the material will require alpha blending
  117863. * @returns a boolean specifying if alpha blending is needed
  117864. */
  117865. needAlphaBlending(): boolean;
  117866. /**
  117867. * Specifies if this material should be rendered in alpha test mode
  117868. * @returns a boolean specifying if an alpha test is needed.
  117869. */
  117870. needAlphaTesting(): boolean;
  117871. private _initializeBlock;
  117872. private _resetDualBlocks;
  117873. /**
  117874. * Build the material and generates the inner effect
  117875. * @param verbose defines if the build should log activity
  117876. */
  117877. build(verbose?: boolean): void;
  117878. /**
  117879. * Runs an otpimization phase to try to improve the shader code
  117880. */
  117881. optimize(): void;
  117882. private _prepareDefinesForAttributes;
  117883. /**
  117884. * Get if the submesh is ready to be used and all its information available.
  117885. * Child classes can use it to update shaders
  117886. * @param mesh defines the mesh to check
  117887. * @param subMesh defines which submesh to check
  117888. * @param useInstances specifies that instances should be used
  117889. * @returns a boolean indicating that the submesh is ready or not
  117890. */
  117891. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  117892. /**
  117893. * Get a string representing the shaders built by the current node graph
  117894. */
  117895. readonly compiledShaders: string;
  117896. /**
  117897. * Binds the world matrix to the material
  117898. * @param world defines the world transformation matrix
  117899. */
  117900. bindOnlyWorldMatrix(world: Matrix): void;
  117901. /**
  117902. * Binds the submesh to this material by preparing the effect and shader to draw
  117903. * @param world defines the world transformation matrix
  117904. * @param mesh defines the mesh containing the submesh
  117905. * @param subMesh defines the submesh to bind the material to
  117906. */
  117907. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  117908. /**
  117909. * Gets the active textures from the material
  117910. * @returns an array of textures
  117911. */
  117912. getActiveTextures(): BaseTexture[];
  117913. /**
  117914. * Gets the list of texture blocks
  117915. * @returns an array of texture blocks
  117916. */
  117917. getTextureBlocks(): (TextureBlock | ReflectionTextureBlock)[];
  117918. /**
  117919. * Specifies if the material uses a texture
  117920. * @param texture defines the texture to check against the material
  117921. * @returns a boolean specifying if the material uses the texture
  117922. */
  117923. hasTexture(texture: BaseTexture): boolean;
  117924. /**
  117925. * Disposes the material
  117926. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  117927. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  117928. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  117929. */
  117930. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  117931. /** Creates the node editor window. */
  117932. private _createNodeEditor;
  117933. /**
  117934. * Launch the node material editor
  117935. * @param config Define the configuration of the editor
  117936. * @return a promise fulfilled when the node editor is visible
  117937. */
  117938. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  117939. /**
  117940. * Clear the current material
  117941. */
  117942. clear(): void;
  117943. /**
  117944. * Clear the current material and set it to a default state
  117945. */
  117946. setToDefault(): void;
  117947. /**
  117948. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  117949. * @param url defines the url to load from
  117950. * @returns a promise that will fullfil when the material is fully loaded
  117951. */
  117952. loadAsync(url: string): Promise<unknown>;
  117953. private _gatherBlocks;
  117954. /**
  117955. * Generate a string containing the code declaration required to create an equivalent of this material
  117956. * @returns a string
  117957. */
  117958. generateCode(): string;
  117959. /**
  117960. * Serializes this material in a JSON representation
  117961. * @returns the serialized material object
  117962. */
  117963. serialize(): any;
  117964. private _restoreConnections;
  117965. /**
  117966. * Clear the current graph and load a new one from a serialization object
  117967. * @param source defines the JSON representation of the material
  117968. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  117969. */
  117970. loadFromSerialization(source: any, rootUrl?: string): void;
  117971. /**
  117972. * Creates a node material from parsed material data
  117973. * @param source defines the JSON representation of the material
  117974. * @param scene defines the hosting scene
  117975. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  117976. * @returns a new node material
  117977. */
  117978. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  117979. /**
  117980. * Creates a new node material set to default basic configuration
  117981. * @param name defines the name of the material
  117982. * @param scene defines the hosting scene
  117983. * @returns a new NodeMaterial
  117984. */
  117985. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  117986. }
  117987. }
  117988. declare module BABYLON {
  117989. /**
  117990. * Block used to read a texture from a sampler
  117991. */
  117992. export class TextureBlock extends NodeMaterialBlock {
  117993. private _defineName;
  117994. private _samplerName;
  117995. private _transformedUVName;
  117996. private _textureTransformName;
  117997. private _textureInfoName;
  117998. private _mainUVName;
  117999. private _mainUVDefineName;
  118000. /**
  118001. * Gets or sets the texture associated with the node
  118002. */
  118003. texture: Nullable<BaseTexture>;
  118004. /**
  118005. * Create a new TextureBlock
  118006. * @param name defines the block name
  118007. */
  118008. constructor(name: string);
  118009. /**
  118010. * Gets the current class name
  118011. * @returns the class name
  118012. */
  118013. getClassName(): string;
  118014. /**
  118015. * Gets the uv input component
  118016. */
  118017. readonly uv: NodeMaterialConnectionPoint;
  118018. /**
  118019. * Gets the rgba output component
  118020. */
  118021. readonly rgba: NodeMaterialConnectionPoint;
  118022. /**
  118023. * Gets the rgb output component
  118024. */
  118025. readonly rgb: NodeMaterialConnectionPoint;
  118026. /**
  118027. * Gets the r output component
  118028. */
  118029. readonly r: NodeMaterialConnectionPoint;
  118030. /**
  118031. * Gets the g output component
  118032. */
  118033. readonly g: NodeMaterialConnectionPoint;
  118034. /**
  118035. * Gets the b output component
  118036. */
  118037. readonly b: NodeMaterialConnectionPoint;
  118038. /**
  118039. * Gets the a output component
  118040. */
  118041. readonly a: NodeMaterialConnectionPoint;
  118042. readonly target: NodeMaterialBlockTargets;
  118043. autoConfigure(material: NodeMaterial): void;
  118044. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  118045. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  118046. isReady(): boolean;
  118047. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  118048. private readonly _isMixed;
  118049. private _injectVertexCode;
  118050. private _writeOutput;
  118051. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  118052. protected _dumpPropertiesCode(): string;
  118053. serialize(): any;
  118054. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  118055. }
  118056. }
  118057. declare module BABYLON {
  118058. /**
  118059. * Class used to store shared data between 2 NodeMaterialBuildState
  118060. */
  118061. export class NodeMaterialBuildStateSharedData {
  118062. /**
  118063. * Gets the list of emitted varyings
  118064. */
  118065. temps: string[];
  118066. /**
  118067. * Gets the list of emitted varyings
  118068. */
  118069. varyings: string[];
  118070. /**
  118071. * Gets the varying declaration string
  118072. */
  118073. varyingDeclaration: string;
  118074. /**
  118075. * Input blocks
  118076. */
  118077. inputBlocks: InputBlock[];
  118078. /**
  118079. * Input blocks
  118080. */
  118081. textureBlocks: (ReflectionTextureBlock | TextureBlock)[];
  118082. /**
  118083. * Bindable blocks (Blocks that need to set data to the effect)
  118084. */
  118085. bindableBlocks: NodeMaterialBlock[];
  118086. /**
  118087. * List of blocks that can provide a compilation fallback
  118088. */
  118089. blocksWithFallbacks: NodeMaterialBlock[];
  118090. /**
  118091. * List of blocks that can provide a define update
  118092. */
  118093. blocksWithDefines: NodeMaterialBlock[];
  118094. /**
  118095. * List of blocks that can provide a repeatable content
  118096. */
  118097. repeatableContentBlocks: NodeMaterialBlock[];
  118098. /**
  118099. * List of blocks that can provide a dynamic list of uniforms
  118100. */
  118101. dynamicUniformBlocks: NodeMaterialBlock[];
  118102. /**
  118103. * List of blocks that can block the isReady function for the material
  118104. */
  118105. blockingBlocks: NodeMaterialBlock[];
  118106. /**
  118107. * Gets the list of animated inputs
  118108. */
  118109. animatedInputs: InputBlock[];
  118110. /**
  118111. * Build Id used to avoid multiple recompilations
  118112. */
  118113. buildId: number;
  118114. /** List of emitted variables */
  118115. variableNames: {
  118116. [key: string]: number;
  118117. };
  118118. /** List of emitted defines */
  118119. defineNames: {
  118120. [key: string]: number;
  118121. };
  118122. /** Should emit comments? */
  118123. emitComments: boolean;
  118124. /** Emit build activity */
  118125. verbose: boolean;
  118126. /**
  118127. * Gets the compilation hints emitted at compilation time
  118128. */
  118129. hints: {
  118130. needWorldViewMatrix: boolean;
  118131. needWorldViewProjectionMatrix: boolean;
  118132. needAlphaBlending: boolean;
  118133. needAlphaTesting: boolean;
  118134. };
  118135. /**
  118136. * List of compilation checks
  118137. */
  118138. checks: {
  118139. emitVertex: boolean;
  118140. emitFragment: boolean;
  118141. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  118142. };
  118143. /** Creates a new shared data */
  118144. constructor();
  118145. /**
  118146. * Emits console errors and exceptions if there is a failing check
  118147. */
  118148. emitErrors(): void;
  118149. }
  118150. }
  118151. declare module BABYLON {
  118152. /**
  118153. * Class used to store node based material build state
  118154. */
  118155. export class NodeMaterialBuildState {
  118156. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  118157. supportUniformBuffers: boolean;
  118158. /**
  118159. * Gets the list of emitted attributes
  118160. */
  118161. attributes: string[];
  118162. /**
  118163. * Gets the list of emitted uniforms
  118164. */
  118165. uniforms: string[];
  118166. /**
  118167. * Gets the list of emitted uniform buffers
  118168. */
  118169. uniformBuffers: string[];
  118170. /**
  118171. * Gets the list of emitted samplers
  118172. */
  118173. samplers: string[];
  118174. /**
  118175. * Gets the list of emitted functions
  118176. */
  118177. functions: {
  118178. [key: string]: string;
  118179. };
  118180. /**
  118181. * Gets the target of the compilation state
  118182. */
  118183. target: NodeMaterialBlockTargets;
  118184. /**
  118185. * Gets the list of emitted counters
  118186. */
  118187. counters: {
  118188. [key: string]: number;
  118189. };
  118190. /**
  118191. * Shared data between multiple NodeMaterialBuildState instances
  118192. */
  118193. sharedData: NodeMaterialBuildStateSharedData;
  118194. /** @hidden */
  118195. _vertexState: NodeMaterialBuildState;
  118196. /** @hidden */
  118197. _attributeDeclaration: string;
  118198. /** @hidden */
  118199. _uniformDeclaration: string;
  118200. /** @hidden */
  118201. _samplerDeclaration: string;
  118202. /** @hidden */
  118203. _varyingTransfer: string;
  118204. private _repeatableContentAnchorIndex;
  118205. /** @hidden */
  118206. _builtCompilationString: string;
  118207. /**
  118208. * Gets the emitted compilation strings
  118209. */
  118210. compilationString: string;
  118211. /**
  118212. * Finalize the compilation strings
  118213. * @param state defines the current compilation state
  118214. */
  118215. finalize(state: NodeMaterialBuildState): void;
  118216. /** @hidden */
  118217. readonly _repeatableContentAnchor: string;
  118218. /** @hidden */
  118219. _getFreeVariableName(prefix: string): string;
  118220. /** @hidden */
  118221. _getFreeDefineName(prefix: string): string;
  118222. /** @hidden */
  118223. _excludeVariableName(name: string): void;
  118224. /** @hidden */
  118225. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  118226. /** @hidden */
  118227. _emitFunction(name: string, code: string, comments: string): void;
  118228. /** @hidden */
  118229. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  118230. replaceStrings?: {
  118231. search: RegExp;
  118232. replace: string;
  118233. }[];
  118234. repeatKey?: string;
  118235. }): string;
  118236. /** @hidden */
  118237. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  118238. repeatKey?: string;
  118239. removeAttributes?: boolean;
  118240. removeUniforms?: boolean;
  118241. removeVaryings?: boolean;
  118242. removeIfDef?: boolean;
  118243. replaceStrings?: {
  118244. search: RegExp;
  118245. replace: string;
  118246. }[];
  118247. }, storeKey?: string): void;
  118248. /** @hidden */
  118249. _registerTempVariable(name: string): boolean;
  118250. /** @hidden */
  118251. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  118252. /** @hidden */
  118253. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  118254. }
  118255. }
  118256. declare module BABYLON {
  118257. /**
  118258. * Defines a block that can be used inside a node based material
  118259. */
  118260. export class NodeMaterialBlock {
  118261. private _buildId;
  118262. private _buildTarget;
  118263. private _target;
  118264. private _isFinalMerger;
  118265. private _isInput;
  118266. /** @hidden */
  118267. _codeVariableName: string;
  118268. /** @hidden */
  118269. _inputs: NodeMaterialConnectionPoint[];
  118270. /** @hidden */
  118271. _outputs: NodeMaterialConnectionPoint[];
  118272. /** @hidden */
  118273. _preparationId: number;
  118274. /**
  118275. * Gets or sets the name of the block
  118276. */
  118277. name: string;
  118278. /**
  118279. * Gets or sets the unique id of the node
  118280. */
  118281. uniqueId: number;
  118282. /**
  118283. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  118284. */
  118285. readonly isFinalMerger: boolean;
  118286. /**
  118287. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  118288. */
  118289. readonly isInput: boolean;
  118290. /**
  118291. * Gets or sets the build Id
  118292. */
  118293. buildId: number;
  118294. /**
  118295. * Gets or sets the target of the block
  118296. */
  118297. target: NodeMaterialBlockTargets;
  118298. /**
  118299. * Gets the list of input points
  118300. */
  118301. readonly inputs: NodeMaterialConnectionPoint[];
  118302. /** Gets the list of output points */
  118303. readonly outputs: NodeMaterialConnectionPoint[];
  118304. /**
  118305. * Find an input by its name
  118306. * @param name defines the name of the input to look for
  118307. * @returns the input or null if not found
  118308. */
  118309. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  118310. /**
  118311. * Find an output by its name
  118312. * @param name defines the name of the outputto look for
  118313. * @returns the output or null if not found
  118314. */
  118315. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  118316. /**
  118317. * Creates a new NodeMaterialBlock
  118318. * @param name defines the block name
  118319. * @param target defines the target of that block (Vertex by default)
  118320. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  118321. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  118322. */
  118323. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  118324. /**
  118325. * Initialize the block and prepare the context for build
  118326. * @param state defines the state that will be used for the build
  118327. */
  118328. initialize(state: NodeMaterialBuildState): void;
  118329. /**
  118330. * Bind data to effect. Will only be called for blocks with isBindable === true
  118331. * @param effect defines the effect to bind data to
  118332. * @param nodeMaterial defines the hosting NodeMaterial
  118333. * @param mesh defines the mesh that will be rendered
  118334. */
  118335. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  118336. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  118337. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  118338. protected _writeFloat(value: number): string;
  118339. /**
  118340. * Gets the current class name e.g. "NodeMaterialBlock"
  118341. * @returns the class name
  118342. */
  118343. getClassName(): string;
  118344. /**
  118345. * Register a new input. Must be called inside a block constructor
  118346. * @param name defines the connection point name
  118347. * @param type defines the connection point type
  118348. * @param isOptional defines a boolean indicating that this input can be omitted
  118349. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  118350. * @returns the current block
  118351. */
  118352. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets): this;
  118353. /**
  118354. * Register a new output. Must be called inside a block constructor
  118355. * @param name defines the connection point name
  118356. * @param type defines the connection point type
  118357. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  118358. * @returns the current block
  118359. */
  118360. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets): this;
  118361. /**
  118362. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  118363. * @param forOutput defines an optional connection point to check compatibility with
  118364. * @returns the first available input or null
  118365. */
  118366. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  118367. /**
  118368. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  118369. * @param forBlock defines an optional block to check compatibility with
  118370. * @returns the first available input or null
  118371. */
  118372. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  118373. /**
  118374. * Gets the sibling of the given output
  118375. * @param current defines the current output
  118376. * @returns the next output in the list or null
  118377. */
  118378. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  118379. /**
  118380. * Connect current block with another block
  118381. * @param other defines the block to connect with
  118382. * @param options define the various options to help pick the right connections
  118383. * @returns the current block
  118384. */
  118385. connectTo(other: NodeMaterialBlock, options?: {
  118386. input?: string;
  118387. output?: string;
  118388. outputSwizzle?: string;
  118389. }): this | undefined;
  118390. protected _buildBlock(state: NodeMaterialBuildState): void;
  118391. /**
  118392. * Add uniforms, samplers and uniform buffers at compilation time
  118393. * @param state defines the state to update
  118394. * @param nodeMaterial defines the node material requesting the update
  118395. * @param defines defines the material defines to update
  118396. */
  118397. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  118398. /**
  118399. * Add potential fallbacks if shader compilation fails
  118400. * @param mesh defines the mesh to be rendered
  118401. * @param fallbacks defines the current prioritized list of fallbacks
  118402. */
  118403. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  118404. /**
  118405. * Update defines for shader compilation
  118406. * @param mesh defines the mesh to be rendered
  118407. * @param nodeMaterial defines the node material requesting the update
  118408. * @param defines defines the material defines to update
  118409. * @param useInstances specifies that instances should be used
  118410. */
  118411. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  118412. /**
  118413. * Initialize defines for shader compilation
  118414. * @param mesh defines the mesh to be rendered
  118415. * @param nodeMaterial defines the node material requesting the update
  118416. * @param defines defines the material defines to be prepared
  118417. * @param useInstances specifies that instances should be used
  118418. */
  118419. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  118420. /**
  118421. * Lets the block try to connect some inputs automatically
  118422. * @param material defines the hosting NodeMaterial
  118423. */
  118424. autoConfigure(material: NodeMaterial): void;
  118425. /**
  118426. * Function called when a block is declared as repeatable content generator
  118427. * @param vertexShaderState defines the current compilation state for the vertex shader
  118428. * @param fragmentShaderState defines the current compilation state for the fragment shader
  118429. * @param mesh defines the mesh to be rendered
  118430. * @param defines defines the material defines to update
  118431. */
  118432. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  118433. /**
  118434. * Checks if the block is ready
  118435. * @param mesh defines the mesh to be rendered
  118436. * @param nodeMaterial defines the node material requesting the update
  118437. * @param defines defines the material defines to update
  118438. * @param useInstances specifies that instances should be used
  118439. * @returns true if the block is ready
  118440. */
  118441. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  118442. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number): void;
  118443. private _processBuild;
  118444. /**
  118445. * Compile the current node and generate the shader code
  118446. * @param state defines the current compilation state (uniforms, samplers, current string)
  118447. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  118448. * @returns true if already built
  118449. */
  118450. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  118451. protected _inputRename(name: string): string;
  118452. protected _outputRename(name: string): string;
  118453. protected _dumpPropertiesCode(): string;
  118454. /** @hidden */
  118455. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  118456. /**
  118457. * Clone the current block to a new identical block
  118458. * @param scene defines the hosting scene
  118459. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  118460. * @returns a copy of the current block
  118461. */
  118462. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  118463. /**
  118464. * Serializes this block in a JSON representation
  118465. * @returns the serialized block object
  118466. */
  118467. serialize(): any;
  118468. /** @hidden */
  118469. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  118470. }
  118471. }
  118472. declare module BABYLON {
  118473. /**
  118474. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  118475. */
  118476. export enum NodeMaterialBlockConnectionPointMode {
  118477. /** Value is an uniform */
  118478. Uniform = 0,
  118479. /** Value is a mesh attribute */
  118480. Attribute = 1,
  118481. /** Value is a varying between vertex and fragment shaders */
  118482. Varying = 2,
  118483. /** Mode is undefined */
  118484. Undefined = 3
  118485. }
  118486. }
  118487. declare module BABYLON {
  118488. /**
  118489. * Enum defining the type of animations supported by InputBlock
  118490. */
  118491. export enum AnimatedInputBlockTypes {
  118492. /** No animation */
  118493. None = 0,
  118494. /** Time based animation. Will only work for floats */
  118495. Time = 1
  118496. }
  118497. }
  118498. declare module BABYLON {
  118499. /**
  118500. * Block used to expose an input value
  118501. */
  118502. export class InputBlock extends NodeMaterialBlock {
  118503. private _mode;
  118504. private _associatedVariableName;
  118505. private _storedValue;
  118506. private _valueCallback;
  118507. private _type;
  118508. private _animationType;
  118509. /** @hidden */
  118510. _systemValue: Nullable<NodeMaterialSystemValues>;
  118511. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  118512. visibleInInspector: boolean;
  118513. /**
  118514. * Gets or sets the connection point type (default is float)
  118515. */
  118516. readonly type: NodeMaterialBlockConnectionPointTypes;
  118517. /**
  118518. * Creates a new InputBlock
  118519. * @param name defines the block name
  118520. * @param target defines the target of that block (Vertex by default)
  118521. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  118522. */
  118523. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  118524. /**
  118525. * Gets the output component
  118526. */
  118527. readonly output: NodeMaterialConnectionPoint;
  118528. /**
  118529. * Set the source of this connection point to a vertex attribute
  118530. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  118531. * @returns the current connection point
  118532. */
  118533. setAsAttribute(attributeName?: string): InputBlock;
  118534. /**
  118535. * Set the source of this connection point to a system value
  118536. * @param value define the system value to use (world, view, etc...) or null to switch to manual value
  118537. * @returns the current connection point
  118538. */
  118539. setAsSystemValue(value: Nullable<NodeMaterialSystemValues>): InputBlock;
  118540. /**
  118541. * Gets or sets the value of that point.
  118542. * Please note that this value will be ignored if valueCallback is defined
  118543. */
  118544. value: any;
  118545. /**
  118546. * Gets or sets a callback used to get the value of that point.
  118547. * Please note that setting this value will force the connection point to ignore the value property
  118548. */
  118549. valueCallback: () => any;
  118550. /**
  118551. * Gets or sets the associated variable name in the shader
  118552. */
  118553. associatedVariableName: string;
  118554. /** Gets or sets the type of animation applied to the input */
  118555. animationType: AnimatedInputBlockTypes;
  118556. /**
  118557. * Gets a boolean indicating that this connection point not defined yet
  118558. */
  118559. readonly isUndefined: boolean;
  118560. /**
  118561. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  118562. * In this case the connection point name must be the name of the uniform to use.
  118563. * Can only be set on inputs
  118564. */
  118565. isUniform: boolean;
  118566. /**
  118567. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  118568. * In this case the connection point name must be the name of the attribute to use
  118569. * Can only be set on inputs
  118570. */
  118571. isAttribute: boolean;
  118572. /**
  118573. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  118574. * Can only be set on exit points
  118575. */
  118576. isVarying: boolean;
  118577. /**
  118578. * Gets a boolean indicating that the current connection point is a system value
  118579. */
  118580. readonly isSystemValue: boolean;
  118581. /**
  118582. * Gets or sets the current well known value or null if not defined as a system value
  118583. */
  118584. systemValue: Nullable<NodeMaterialSystemValues>;
  118585. /**
  118586. * Gets the current class name
  118587. * @returns the class name
  118588. */
  118589. getClassName(): string;
  118590. /**
  118591. * Animate the input if animationType !== None
  118592. * @param scene defines the rendering scene
  118593. */
  118594. animate(scene: Scene): void;
  118595. private _emitDefine;
  118596. /**
  118597. * Set the input block to its default value (based on its type)
  118598. */
  118599. setDefaultValue(): void;
  118600. protected _dumpPropertiesCode(): string;
  118601. private _emit;
  118602. /** @hidden */
  118603. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  118604. /** @hidden */
  118605. _transmit(effect: Effect, scene: Scene): void;
  118606. protected _buildBlock(state: NodeMaterialBuildState): void;
  118607. serialize(): any;
  118608. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  118609. }
  118610. }
  118611. declare module BABYLON {
  118612. /**
  118613. * Defines a connection point for a block
  118614. */
  118615. export class NodeMaterialConnectionPoint {
  118616. /** @hidden */
  118617. _ownerBlock: NodeMaterialBlock;
  118618. /** @hidden */
  118619. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  118620. private _endpoints;
  118621. private _associatedVariableName;
  118622. /** @hidden */
  118623. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  118624. /** @hidden */
  118625. _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  118626. private _type;
  118627. /** @hidden */
  118628. _enforceAssociatedVariableName: boolean;
  118629. /**
  118630. * Gets or sets the additional types supported byt this connection point
  118631. */
  118632. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  118633. /**
  118634. * Gets or sets the associated variable name in the shader
  118635. */
  118636. associatedVariableName: string;
  118637. /**
  118638. * Gets or sets the connection point type (default is float)
  118639. */
  118640. type: NodeMaterialBlockConnectionPointTypes;
  118641. /**
  118642. * Gets or sets the connection point name
  118643. */
  118644. name: string;
  118645. /**
  118646. * Gets or sets a boolean indicating that this connection point can be omitted
  118647. */
  118648. isOptional: boolean;
  118649. /**
  118650. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  118651. */
  118652. define: string;
  118653. /** Gets or sets the target of that connection point */
  118654. target: NodeMaterialBlockTargets;
  118655. /**
  118656. * Gets a boolean indicating that the current point is connected
  118657. */
  118658. readonly isConnected: boolean;
  118659. /**
  118660. * Gets a boolean indicating that the current point is connected to an input block
  118661. */
  118662. readonly isConnectedToInputBlock: boolean;
  118663. /**
  118664. * Gets a the connected input block (if any)
  118665. */
  118666. readonly connectInputBlock: Nullable<InputBlock>;
  118667. /** Get the other side of the connection (if any) */
  118668. readonly connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  118669. /** Get the block that owns this connection point */
  118670. readonly ownerBlock: NodeMaterialBlock;
  118671. /** Get the block connected on the other side of this connection (if any) */
  118672. readonly sourceBlock: Nullable<NodeMaterialBlock>;
  118673. /** Get the block connected on the endpoints of this connection (if any) */
  118674. readonly connectedBlocks: Array<NodeMaterialBlock>;
  118675. /** Gets the list of connected endpoints */
  118676. readonly endpoints: NodeMaterialConnectionPoint[];
  118677. /** Gets a boolean indicating if that output point is connected to at least one input */
  118678. readonly hasEndpoints: boolean;
  118679. /**
  118680. * Creates a new connection point
  118681. * @param name defines the connection point name
  118682. * @param ownerBlock defines the block hosting this connection point
  118683. */
  118684. constructor(name: string, ownerBlock: NodeMaterialBlock);
  118685. /**
  118686. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  118687. * @returns the class name
  118688. */
  118689. getClassName(): string;
  118690. /**
  118691. * Gets an boolean indicating if the current point can be connected to another point
  118692. * @param connectionPoint defines the other connection point
  118693. * @returns true if the connection is possible
  118694. */
  118695. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  118696. /**
  118697. * Connect this point to another connection point
  118698. * @param connectionPoint defines the other connection point
  118699. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  118700. * @returns the current connection point
  118701. */
  118702. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  118703. /**
  118704. * Disconnect this point from one of his endpoint
  118705. * @param endpoint defines the other connection point
  118706. * @returns the current connection point
  118707. */
  118708. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  118709. /**
  118710. * Serializes this point in a JSON representation
  118711. * @returns the serialized point object
  118712. */
  118713. serialize(): any;
  118714. }
  118715. }
  118716. declare module BABYLON {
  118717. /**
  118718. * Block used to add support for vertex skinning (bones)
  118719. */
  118720. export class BonesBlock extends NodeMaterialBlock {
  118721. /**
  118722. * Creates a new BonesBlock
  118723. * @param name defines the block name
  118724. */
  118725. constructor(name: string);
  118726. /**
  118727. * Initialize the block and prepare the context for build
  118728. * @param state defines the state that will be used for the build
  118729. */
  118730. initialize(state: NodeMaterialBuildState): void;
  118731. /**
  118732. * Gets the current class name
  118733. * @returns the class name
  118734. */
  118735. getClassName(): string;
  118736. /**
  118737. * Gets the matrix indices input component
  118738. */
  118739. readonly matricesIndices: NodeMaterialConnectionPoint;
  118740. /**
  118741. * Gets the matrix weights input component
  118742. */
  118743. readonly matricesWeights: NodeMaterialConnectionPoint;
  118744. /**
  118745. * Gets the extra matrix indices input component
  118746. */
  118747. readonly matricesIndicesExtra: NodeMaterialConnectionPoint;
  118748. /**
  118749. * Gets the extra matrix weights input component
  118750. */
  118751. readonly matricesWeightsExtra: NodeMaterialConnectionPoint;
  118752. /**
  118753. * Gets the world input component
  118754. */
  118755. readonly world: NodeMaterialConnectionPoint;
  118756. /**
  118757. * Gets the output component
  118758. */
  118759. readonly output: NodeMaterialConnectionPoint;
  118760. autoConfigure(material: NodeMaterial): void;
  118761. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  118762. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  118763. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  118764. protected _buildBlock(state: NodeMaterialBuildState): this;
  118765. }
  118766. }
  118767. declare module BABYLON {
  118768. /**
  118769. * Block used to add support for instances
  118770. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  118771. */
  118772. export class InstancesBlock extends NodeMaterialBlock {
  118773. /**
  118774. * Creates a new InstancesBlock
  118775. * @param name defines the block name
  118776. */
  118777. constructor(name: string);
  118778. /**
  118779. * Gets the current class name
  118780. * @returns the class name
  118781. */
  118782. getClassName(): string;
  118783. /**
  118784. * Gets the first world row input component
  118785. */
  118786. readonly world0: NodeMaterialConnectionPoint;
  118787. /**
  118788. * Gets the second world row input component
  118789. */
  118790. readonly world1: NodeMaterialConnectionPoint;
  118791. /**
  118792. * Gets the third world row input component
  118793. */
  118794. readonly world2: NodeMaterialConnectionPoint;
  118795. /**
  118796. * Gets the forth world row input component
  118797. */
  118798. readonly world3: NodeMaterialConnectionPoint;
  118799. /**
  118800. * Gets the world input component
  118801. */
  118802. readonly world: NodeMaterialConnectionPoint;
  118803. /**
  118804. * Gets the output component
  118805. */
  118806. readonly output: NodeMaterialConnectionPoint;
  118807. autoConfigure(material: NodeMaterial): void;
  118808. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  118809. protected _buildBlock(state: NodeMaterialBuildState): this;
  118810. }
  118811. }
  118812. declare module BABYLON {
  118813. /**
  118814. * Block used to add morph targets support to vertex shader
  118815. */
  118816. export class MorphTargetsBlock extends NodeMaterialBlock {
  118817. private _repeatableContentAnchor;
  118818. private _repeatebleContentGenerated;
  118819. /**
  118820. * Create a new MorphTargetsBlock
  118821. * @param name defines the block name
  118822. */
  118823. constructor(name: string);
  118824. /**
  118825. * Gets the current class name
  118826. * @returns the class name
  118827. */
  118828. getClassName(): string;
  118829. /**
  118830. * Gets the position input component
  118831. */
  118832. readonly position: NodeMaterialConnectionPoint;
  118833. /**
  118834. * Gets the normal input component
  118835. */
  118836. readonly normal: NodeMaterialConnectionPoint;
  118837. /**
  118838. * Gets the tangent input component
  118839. */
  118840. readonly tangent: NodeMaterialConnectionPoint;
  118841. /**
  118842. * Gets the tangent input component
  118843. */
  118844. readonly uv: NodeMaterialConnectionPoint;
  118845. /**
  118846. * Gets the position output component
  118847. */
  118848. readonly positionOutput: NodeMaterialConnectionPoint;
  118849. /**
  118850. * Gets the normal output component
  118851. */
  118852. readonly normalOutput: NodeMaterialConnectionPoint;
  118853. /**
  118854. * Gets the tangent output component
  118855. */
  118856. readonly tangentOutput: NodeMaterialConnectionPoint;
  118857. /**
  118858. * Gets the tangent output component
  118859. */
  118860. readonly uvOutput: NodeMaterialConnectionPoint;
  118861. initialize(state: NodeMaterialBuildState): void;
  118862. autoConfigure(material: NodeMaterial): void;
  118863. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  118864. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  118865. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  118866. protected _buildBlock(state: NodeMaterialBuildState): this;
  118867. }
  118868. }
  118869. declare module BABYLON {
  118870. /**
  118871. * Block used to get data information from a light
  118872. */
  118873. export class LightInformationBlock extends NodeMaterialBlock {
  118874. private _lightDataDefineName;
  118875. private _lightColorDefineName;
  118876. /**
  118877. * Gets or sets the light associated with this block
  118878. */
  118879. light: Nullable<Light>;
  118880. /**
  118881. * Creates a new LightInformationBlock
  118882. * @param name defines the block name
  118883. */
  118884. constructor(name: string);
  118885. /**
  118886. * Gets the current class name
  118887. * @returns the class name
  118888. */
  118889. getClassName(): string;
  118890. /**
  118891. * Gets the world position input component
  118892. */
  118893. readonly worldPosition: NodeMaterialConnectionPoint;
  118894. /**
  118895. * Gets the direction output component
  118896. */
  118897. readonly direction: NodeMaterialConnectionPoint;
  118898. /**
  118899. * Gets the direction output component
  118900. */
  118901. readonly color: NodeMaterialConnectionPoint;
  118902. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  118903. protected _buildBlock(state: NodeMaterialBuildState): this;
  118904. serialize(): any;
  118905. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  118906. }
  118907. }
  118908. declare module BABYLON {
  118909. /**
  118910. * Block used to add an alpha test in the fragment shader
  118911. */
  118912. export class AlphaTestBlock extends NodeMaterialBlock {
  118913. /**
  118914. * Gets or sets the alpha value where alpha testing happens
  118915. */
  118916. alphaCutOff: number;
  118917. /**
  118918. * Create a new AlphaTestBlock
  118919. * @param name defines the block name
  118920. */
  118921. constructor(name: string);
  118922. /**
  118923. * Gets the current class name
  118924. * @returns the class name
  118925. */
  118926. getClassName(): string;
  118927. /**
  118928. * Gets the color input component
  118929. */
  118930. readonly color: NodeMaterialConnectionPoint;
  118931. /**
  118932. * Gets the alpha input component
  118933. */
  118934. readonly alpha: NodeMaterialConnectionPoint;
  118935. protected _buildBlock(state: NodeMaterialBuildState): this;
  118936. protected _dumpPropertiesCode(): string;
  118937. serialize(): any;
  118938. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  118939. }
  118940. }
  118941. declare module BABYLON {
  118942. /**
  118943. * Block used to add image processing support to fragment shader
  118944. */
  118945. export class ImageProcessingBlock extends NodeMaterialBlock {
  118946. /**
  118947. * Create a new ImageProcessingBlock
  118948. * @param name defines the block name
  118949. */
  118950. constructor(name: string);
  118951. /**
  118952. * Gets the current class name
  118953. * @returns the class name
  118954. */
  118955. getClassName(): string;
  118956. /**
  118957. * Gets the color input component
  118958. */
  118959. readonly color: NodeMaterialConnectionPoint;
  118960. /**
  118961. * Gets the output component
  118962. */
  118963. readonly output: NodeMaterialConnectionPoint;
  118964. /**
  118965. * Initialize the block and prepare the context for build
  118966. * @param state defines the state that will be used for the build
  118967. */
  118968. initialize(state: NodeMaterialBuildState): void;
  118969. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  118970. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  118971. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  118972. protected _buildBlock(state: NodeMaterialBuildState): this;
  118973. }
  118974. }
  118975. declare module BABYLON {
  118976. /**
  118977. * Block used to add support for scene fog
  118978. */
  118979. export class FogBlock extends NodeMaterialBlock {
  118980. private _fogDistanceName;
  118981. private _fogParameters;
  118982. /**
  118983. * Create a new FogBlock
  118984. * @param name defines the block name
  118985. */
  118986. constructor(name: string);
  118987. /**
  118988. * Gets the current class name
  118989. * @returns the class name
  118990. */
  118991. getClassName(): string;
  118992. /**
  118993. * Gets the world position input component
  118994. */
  118995. readonly worldPosition: NodeMaterialConnectionPoint;
  118996. /**
  118997. * Gets the view input component
  118998. */
  118999. readonly view: NodeMaterialConnectionPoint;
  119000. /**
  119001. * Gets the color input component
  119002. */
  119003. readonly input: NodeMaterialConnectionPoint;
  119004. /**
  119005. * Gets the fog color input component
  119006. */
  119007. readonly fogColor: NodeMaterialConnectionPoint;
  119008. /**
  119009. * Gets the output component
  119010. */
  119011. readonly output: NodeMaterialConnectionPoint;
  119012. autoConfigure(material: NodeMaterial): void;
  119013. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  119014. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  119015. protected _buildBlock(state: NodeMaterialBuildState): this;
  119016. }
  119017. }
  119018. declare module BABYLON {
  119019. /**
  119020. * Block used to add light in the fragment shader
  119021. */
  119022. export class LightBlock extends NodeMaterialBlock {
  119023. private _lightId;
  119024. /**
  119025. * Gets or sets the light associated with this block
  119026. */
  119027. light: Nullable<Light>;
  119028. /**
  119029. * Create a new LightBlock
  119030. * @param name defines the block name
  119031. */
  119032. constructor(name: string);
  119033. /**
  119034. * Gets the current class name
  119035. * @returns the class name
  119036. */
  119037. getClassName(): string;
  119038. /**
  119039. * Gets the world position input component
  119040. */
  119041. readonly worldPosition: NodeMaterialConnectionPoint;
  119042. /**
  119043. * Gets the world normal input component
  119044. */
  119045. readonly worldNormal: NodeMaterialConnectionPoint;
  119046. /**
  119047. * Gets the camera (or eye) position component
  119048. */
  119049. readonly cameraPosition: NodeMaterialConnectionPoint;
  119050. /**
  119051. * Gets the diffuse output component
  119052. */
  119053. readonly diffuseOutput: NodeMaterialConnectionPoint;
  119054. /**
  119055. * Gets the specular output component
  119056. */
  119057. readonly specularOutput: NodeMaterialConnectionPoint;
  119058. autoConfigure(material: NodeMaterial): void;
  119059. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  119060. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  119061. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  119062. private _injectVertexCode;
  119063. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  119064. serialize(): any;
  119065. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  119066. }
  119067. }
  119068. declare module BABYLON {
  119069. /**
  119070. * Block used to multiply 2 values
  119071. */
  119072. export class MultiplyBlock extends NodeMaterialBlock {
  119073. /**
  119074. * Creates a new MultiplyBlock
  119075. * @param name defines the block name
  119076. */
  119077. constructor(name: string);
  119078. /**
  119079. * Gets the current class name
  119080. * @returns the class name
  119081. */
  119082. getClassName(): string;
  119083. /**
  119084. * Gets the left operand input component
  119085. */
  119086. readonly left: NodeMaterialConnectionPoint;
  119087. /**
  119088. * Gets the right operand input component
  119089. */
  119090. readonly right: NodeMaterialConnectionPoint;
  119091. /**
  119092. * Gets the output component
  119093. */
  119094. readonly output: NodeMaterialConnectionPoint;
  119095. protected _buildBlock(state: NodeMaterialBuildState): this;
  119096. }
  119097. }
  119098. declare module BABYLON {
  119099. /**
  119100. * Block used to add 2 vectors
  119101. */
  119102. export class AddBlock extends NodeMaterialBlock {
  119103. /**
  119104. * Creates a new AddBlock
  119105. * @param name defines the block name
  119106. */
  119107. constructor(name: string);
  119108. /**
  119109. * Gets the current class name
  119110. * @returns the class name
  119111. */
  119112. getClassName(): string;
  119113. /**
  119114. * Gets the left operand input component
  119115. */
  119116. readonly left: NodeMaterialConnectionPoint;
  119117. /**
  119118. * Gets the right operand input component
  119119. */
  119120. readonly right: NodeMaterialConnectionPoint;
  119121. /**
  119122. * Gets the output component
  119123. */
  119124. readonly output: NodeMaterialConnectionPoint;
  119125. protected _buildBlock(state: NodeMaterialBuildState): this;
  119126. }
  119127. }
  119128. declare module BABYLON {
  119129. /**
  119130. * Block used to scale a vector by a float
  119131. */
  119132. export class ScaleBlock extends NodeMaterialBlock {
  119133. /**
  119134. * Creates a new ScaleBlock
  119135. * @param name defines the block name
  119136. */
  119137. constructor(name: string);
  119138. /**
  119139. * Gets the current class name
  119140. * @returns the class name
  119141. */
  119142. getClassName(): string;
  119143. /**
  119144. * Gets the input component
  119145. */
  119146. readonly input: NodeMaterialConnectionPoint;
  119147. /**
  119148. * Gets the factor input component
  119149. */
  119150. readonly factor: NodeMaterialConnectionPoint;
  119151. /**
  119152. * Gets the output component
  119153. */
  119154. readonly output: NodeMaterialConnectionPoint;
  119155. protected _buildBlock(state: NodeMaterialBuildState): this;
  119156. }
  119157. }
  119158. declare module BABYLON {
  119159. /**
  119160. * Block used to clamp a float
  119161. */
  119162. export class ClampBlock extends NodeMaterialBlock {
  119163. /** Gets or sets the minimum range */
  119164. minimum: number;
  119165. /** Gets or sets the maximum range */
  119166. maximum: number;
  119167. /**
  119168. * Creates a new ClampBlock
  119169. * @param name defines the block name
  119170. */
  119171. constructor(name: string);
  119172. /**
  119173. * Gets the current class name
  119174. * @returns the class name
  119175. */
  119176. getClassName(): string;
  119177. /**
  119178. * Gets the value input component
  119179. */
  119180. readonly value: NodeMaterialConnectionPoint;
  119181. /**
  119182. * Gets the output component
  119183. */
  119184. readonly output: NodeMaterialConnectionPoint;
  119185. protected _buildBlock(state: NodeMaterialBuildState): this;
  119186. protected _dumpPropertiesCode(): string;
  119187. serialize(): any;
  119188. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  119189. }
  119190. }
  119191. declare module BABYLON {
  119192. /**
  119193. * Block used to apply a cross product between 2 vectors
  119194. */
  119195. export class CrossBlock extends NodeMaterialBlock {
  119196. /**
  119197. * Creates a new CrossBlock
  119198. * @param name defines the block name
  119199. */
  119200. constructor(name: string);
  119201. /**
  119202. * Gets the current class name
  119203. * @returns the class name
  119204. */
  119205. getClassName(): string;
  119206. /**
  119207. * Gets the left operand input component
  119208. */
  119209. readonly left: NodeMaterialConnectionPoint;
  119210. /**
  119211. * Gets the right operand input component
  119212. */
  119213. readonly right: NodeMaterialConnectionPoint;
  119214. /**
  119215. * Gets the output component
  119216. */
  119217. readonly output: NodeMaterialConnectionPoint;
  119218. protected _buildBlock(state: NodeMaterialBuildState): this;
  119219. }
  119220. }
  119221. declare module BABYLON {
  119222. /**
  119223. * Block used to apply a dot product between 2 vectors
  119224. */
  119225. export class DotBlock extends NodeMaterialBlock {
  119226. /**
  119227. * Creates a new DotBlock
  119228. * @param name defines the block name
  119229. */
  119230. constructor(name: string);
  119231. /**
  119232. * Gets the current class name
  119233. * @returns the class name
  119234. */
  119235. getClassName(): string;
  119236. /**
  119237. * Gets the left operand input component
  119238. */
  119239. readonly left: NodeMaterialConnectionPoint;
  119240. /**
  119241. * Gets the right operand input component
  119242. */
  119243. readonly right: NodeMaterialConnectionPoint;
  119244. /**
  119245. * Gets the output component
  119246. */
  119247. readonly output: NodeMaterialConnectionPoint;
  119248. protected _buildBlock(state: NodeMaterialBuildState): this;
  119249. }
  119250. }
  119251. declare module BABYLON {
  119252. /**
  119253. * Block used to remap a float from a range to a new one
  119254. */
  119255. export class RemapBlock extends NodeMaterialBlock {
  119256. /**
  119257. * Gets or sets the source range
  119258. */
  119259. sourceRange: Vector2;
  119260. /**
  119261. * Gets or sets the target range
  119262. */
  119263. targetRange: Vector2;
  119264. /**
  119265. * Creates a new RemapBlock
  119266. * @param name defines the block name
  119267. */
  119268. constructor(name: string);
  119269. /**
  119270. * Gets the current class name
  119271. * @returns the class name
  119272. */
  119273. getClassName(): string;
  119274. /**
  119275. * Gets the input component
  119276. */
  119277. readonly input: NodeMaterialConnectionPoint;
  119278. /**
  119279. * Gets the output component
  119280. */
  119281. readonly output: NodeMaterialConnectionPoint;
  119282. protected _buildBlock(state: NodeMaterialBuildState): this;
  119283. protected _dumpPropertiesCode(): string;
  119284. serialize(): any;
  119285. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  119286. }
  119287. }
  119288. declare module BABYLON {
  119289. /**
  119290. * Block used to normalize a vector
  119291. */
  119292. export class NormalizeBlock extends NodeMaterialBlock {
  119293. /**
  119294. * Creates a new NormalizeBlock
  119295. * @param name defines the block name
  119296. */
  119297. constructor(name: string);
  119298. /**
  119299. * Gets the current class name
  119300. * @returns the class name
  119301. */
  119302. getClassName(): string;
  119303. /**
  119304. * Gets the input component
  119305. */
  119306. readonly input: NodeMaterialConnectionPoint;
  119307. /**
  119308. * Gets the output component
  119309. */
  119310. readonly output: NodeMaterialConnectionPoint;
  119311. protected _buildBlock(state: NodeMaterialBuildState): this;
  119312. }
  119313. }
  119314. declare module BABYLON {
  119315. /**
  119316. * Operations supported by the Trigonometry block
  119317. */
  119318. export enum TrigonometryBlockOperations {
  119319. /** Cos */
  119320. Cos = 0,
  119321. /** Sin */
  119322. Sin = 1,
  119323. /** Abs */
  119324. Abs = 2,
  119325. /** Exp */
  119326. Exp = 3,
  119327. /** Exp2 */
  119328. Exp2 = 4,
  119329. /** Round */
  119330. Round = 5,
  119331. /** Floor */
  119332. Floor = 6,
  119333. /** Ceiling */
  119334. Ceiling = 7
  119335. }
  119336. /**
  119337. * Block used to apply trigonometry operation to floats
  119338. */
  119339. export class TrigonometryBlock extends NodeMaterialBlock {
  119340. /**
  119341. * Gets or sets the operation applied by the block
  119342. */
  119343. operation: TrigonometryBlockOperations;
  119344. /**
  119345. * Creates a new TrigonometryBlock
  119346. * @param name defines the block name
  119347. */
  119348. constructor(name: string);
  119349. /**
  119350. * Gets the current class name
  119351. * @returns the class name
  119352. */
  119353. getClassName(): string;
  119354. /**
  119355. * Gets the input component
  119356. */
  119357. readonly input: NodeMaterialConnectionPoint;
  119358. /**
  119359. * Gets the output component
  119360. */
  119361. readonly output: NodeMaterialConnectionPoint;
  119362. protected _buildBlock(state: NodeMaterialBuildState): this;
  119363. serialize(): any;
  119364. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  119365. }
  119366. }
  119367. declare module BABYLON {
  119368. /**
  119369. * Block used to create a Color3/4 out of individual inputs (one for each component)
  119370. */
  119371. export class ColorMergerBlock extends NodeMaterialBlock {
  119372. /**
  119373. * Create a new ColorMergerBlock
  119374. * @param name defines the block name
  119375. */
  119376. constructor(name: string);
  119377. /**
  119378. * Gets the current class name
  119379. * @returns the class name
  119380. */
  119381. getClassName(): string;
  119382. /**
  119383. * Gets the r component (input)
  119384. */
  119385. readonly r: NodeMaterialConnectionPoint;
  119386. /**
  119387. * Gets the g component (input)
  119388. */
  119389. readonly g: NodeMaterialConnectionPoint;
  119390. /**
  119391. * Gets the b component (input)
  119392. */
  119393. readonly b: NodeMaterialConnectionPoint;
  119394. /**
  119395. * Gets the a component (input)
  119396. */
  119397. readonly a: NodeMaterialConnectionPoint;
  119398. /**
  119399. * Gets the rgba component (output)
  119400. */
  119401. readonly rgba: NodeMaterialConnectionPoint;
  119402. /**
  119403. * Gets the rgb component (output)
  119404. */
  119405. readonly rgb: NodeMaterialConnectionPoint;
  119406. protected _buildBlock(state: NodeMaterialBuildState): this;
  119407. }
  119408. }
  119409. declare module BABYLON {
  119410. /**
  119411. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  119412. */
  119413. export class VectorMergerBlock extends NodeMaterialBlock {
  119414. /**
  119415. * Create a new VectorMergerBlock
  119416. * @param name defines the block name
  119417. */
  119418. constructor(name: string);
  119419. /**
  119420. * Gets the current class name
  119421. * @returns the class name
  119422. */
  119423. getClassName(): string;
  119424. /**
  119425. * Gets the x component (input)
  119426. */
  119427. readonly x: NodeMaterialConnectionPoint;
  119428. /**
  119429. * Gets the y component (input)
  119430. */
  119431. readonly y: NodeMaterialConnectionPoint;
  119432. /**
  119433. * Gets the z component (input)
  119434. */
  119435. readonly z: NodeMaterialConnectionPoint;
  119436. /**
  119437. * Gets the w component (input)
  119438. */
  119439. readonly w: NodeMaterialConnectionPoint;
  119440. /**
  119441. * Gets the xyzw component (output)
  119442. */
  119443. readonly xyzw: NodeMaterialConnectionPoint;
  119444. /**
  119445. * Gets the xyz component (output)
  119446. */
  119447. readonly xyz: NodeMaterialConnectionPoint;
  119448. /**
  119449. * Gets the xy component (output)
  119450. */
  119451. readonly xy: NodeMaterialConnectionPoint;
  119452. protected _buildBlock(state: NodeMaterialBuildState): this;
  119453. }
  119454. }
  119455. declare module BABYLON {
  119456. /**
  119457. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  119458. */
  119459. export class ColorSplitterBlock extends NodeMaterialBlock {
  119460. /**
  119461. * Create a new ColorSplitterBlock
  119462. * @param name defines the block name
  119463. */
  119464. constructor(name: string);
  119465. /**
  119466. * Gets the current class name
  119467. * @returns the class name
  119468. */
  119469. getClassName(): string;
  119470. /**
  119471. * Gets the rgba component (input)
  119472. */
  119473. readonly rgba: NodeMaterialConnectionPoint;
  119474. /**
  119475. * Gets the rgb component (input)
  119476. */
  119477. readonly rgbIn: NodeMaterialConnectionPoint;
  119478. /**
  119479. * Gets the rgb component (output)
  119480. */
  119481. readonly rgbOut: NodeMaterialConnectionPoint;
  119482. /**
  119483. * Gets the r component (output)
  119484. */
  119485. readonly r: NodeMaterialConnectionPoint;
  119486. /**
  119487. * Gets the g component (output)
  119488. */
  119489. readonly g: NodeMaterialConnectionPoint;
  119490. /**
  119491. * Gets the b component (output)
  119492. */
  119493. readonly b: NodeMaterialConnectionPoint;
  119494. /**
  119495. * Gets the a component (output)
  119496. */
  119497. readonly a: NodeMaterialConnectionPoint;
  119498. protected _inputRename(name: string): string;
  119499. protected _outputRename(name: string): string;
  119500. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  119501. }
  119502. }
  119503. declare module BABYLON {
  119504. /**
  119505. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  119506. */
  119507. export class VectorSplitterBlock extends NodeMaterialBlock {
  119508. /**
  119509. * Create a new VectorSplitterBlock
  119510. * @param name defines the block name
  119511. */
  119512. constructor(name: string);
  119513. /**
  119514. * Gets the current class name
  119515. * @returns the class name
  119516. */
  119517. getClassName(): string;
  119518. /**
  119519. * Gets the xyzw component (input)
  119520. */
  119521. readonly xyzw: NodeMaterialConnectionPoint;
  119522. /**
  119523. * Gets the xyz component (input)
  119524. */
  119525. readonly xyzIn: NodeMaterialConnectionPoint;
  119526. /**
  119527. * Gets the xy component (input)
  119528. */
  119529. readonly xyIn: NodeMaterialConnectionPoint;
  119530. /**
  119531. * Gets the xyz component (output)
  119532. */
  119533. readonly xyzOut: NodeMaterialConnectionPoint;
  119534. /**
  119535. * Gets the xy component (output)
  119536. */
  119537. readonly xyOut: NodeMaterialConnectionPoint;
  119538. /**
  119539. * Gets the x component (output)
  119540. */
  119541. readonly x: NodeMaterialConnectionPoint;
  119542. /**
  119543. * Gets the y component (output)
  119544. */
  119545. readonly y: NodeMaterialConnectionPoint;
  119546. /**
  119547. * Gets the z component (output)
  119548. */
  119549. readonly z: NodeMaterialConnectionPoint;
  119550. /**
  119551. * Gets the w component (output)
  119552. */
  119553. readonly w: NodeMaterialConnectionPoint;
  119554. protected _inputRename(name: string): string;
  119555. protected _outputRename(name: string): string;
  119556. protected _buildBlock(state: NodeMaterialBuildState): this;
  119557. }
  119558. }
  119559. declare module BABYLON {
  119560. /**
  119561. * Block used to lerp 2 values
  119562. */
  119563. export class LerpBlock extends NodeMaterialBlock {
  119564. /**
  119565. * Creates a new LerpBlock
  119566. * @param name defines the block name
  119567. */
  119568. constructor(name: string);
  119569. /**
  119570. * Gets the current class name
  119571. * @returns the class name
  119572. */
  119573. getClassName(): string;
  119574. /**
  119575. * Gets the left operand input component
  119576. */
  119577. readonly left: NodeMaterialConnectionPoint;
  119578. /**
  119579. * Gets the right operand input component
  119580. */
  119581. readonly right: NodeMaterialConnectionPoint;
  119582. /**
  119583. * Gets the gradient operand input component
  119584. */
  119585. readonly gradient: NodeMaterialConnectionPoint;
  119586. /**
  119587. * Gets the output component
  119588. */
  119589. readonly output: NodeMaterialConnectionPoint;
  119590. protected _buildBlock(state: NodeMaterialBuildState): this;
  119591. }
  119592. }
  119593. declare module BABYLON {
  119594. /**
  119595. * Block used to divide 2 vectors
  119596. */
  119597. export class DivideBlock extends NodeMaterialBlock {
  119598. /**
  119599. * Creates a new DivideBlock
  119600. * @param name defines the block name
  119601. */
  119602. constructor(name: string);
  119603. /**
  119604. * Gets the current class name
  119605. * @returns the class name
  119606. */
  119607. getClassName(): string;
  119608. /**
  119609. * Gets the left operand input component
  119610. */
  119611. readonly left: NodeMaterialConnectionPoint;
  119612. /**
  119613. * Gets the right operand input component
  119614. */
  119615. readonly right: NodeMaterialConnectionPoint;
  119616. /**
  119617. * Gets the output component
  119618. */
  119619. readonly output: NodeMaterialConnectionPoint;
  119620. protected _buildBlock(state: NodeMaterialBuildState): this;
  119621. }
  119622. }
  119623. declare module BABYLON {
  119624. /**
  119625. * Block used to subtract 2 vectors
  119626. */
  119627. export class SubtractBlock extends NodeMaterialBlock {
  119628. /**
  119629. * Creates a new SubtractBlock
  119630. * @param name defines the block name
  119631. */
  119632. constructor(name: string);
  119633. /**
  119634. * Gets the current class name
  119635. * @returns the class name
  119636. */
  119637. getClassName(): string;
  119638. /**
  119639. * Gets the left operand input component
  119640. */
  119641. readonly left: NodeMaterialConnectionPoint;
  119642. /**
  119643. * Gets the right operand input component
  119644. */
  119645. readonly right: NodeMaterialConnectionPoint;
  119646. /**
  119647. * Gets the output component
  119648. */
  119649. readonly output: NodeMaterialConnectionPoint;
  119650. protected _buildBlock(state: NodeMaterialBuildState): this;
  119651. }
  119652. }
  119653. declare module BABYLON {
  119654. /**
  119655. * Block used to step a value
  119656. */
  119657. export class StepBlock extends NodeMaterialBlock {
  119658. /**
  119659. * Creates a new AddBlock
  119660. * @param name defines the block name
  119661. */
  119662. constructor(name: string);
  119663. /**
  119664. * Gets the current class name
  119665. * @returns the class name
  119666. */
  119667. getClassName(): string;
  119668. /**
  119669. * Gets the value operand input component
  119670. */
  119671. readonly value: NodeMaterialConnectionPoint;
  119672. /**
  119673. * Gets the edge operand input component
  119674. */
  119675. readonly edge: NodeMaterialConnectionPoint;
  119676. /**
  119677. * Gets the output component
  119678. */
  119679. readonly output: NodeMaterialConnectionPoint;
  119680. protected _buildBlock(state: NodeMaterialBuildState): this;
  119681. }
  119682. }
  119683. declare module BABYLON {
  119684. /**
  119685. * Block used to get the opposite of a value
  119686. */
  119687. export class OppositeBlock extends NodeMaterialBlock {
  119688. /**
  119689. * Creates a new OppositeBlock
  119690. * @param name defines the block name
  119691. */
  119692. constructor(name: string);
  119693. /**
  119694. * Gets the current class name
  119695. * @returns the class name
  119696. */
  119697. getClassName(): string;
  119698. /**
  119699. * Gets the input component
  119700. */
  119701. readonly input: NodeMaterialConnectionPoint;
  119702. /**
  119703. * Gets the output component
  119704. */
  119705. readonly output: NodeMaterialConnectionPoint;
  119706. protected _buildBlock(state: NodeMaterialBuildState): this;
  119707. }
  119708. }
  119709. declare module BABYLON {
  119710. /**
  119711. * Block used to get the view direction
  119712. */
  119713. export class ViewDirectionBlock extends NodeMaterialBlock {
  119714. /**
  119715. * Creates a new ViewDirectionBlock
  119716. * @param name defines the block name
  119717. */
  119718. constructor(name: string);
  119719. /**
  119720. * Gets the current class name
  119721. * @returns the class name
  119722. */
  119723. getClassName(): string;
  119724. /**
  119725. * Gets the world position component
  119726. */
  119727. readonly worldPosition: NodeMaterialConnectionPoint;
  119728. /**
  119729. * Gets the camera position component
  119730. */
  119731. readonly cameraPosition: NodeMaterialConnectionPoint;
  119732. /**
  119733. * Gets the output component
  119734. */
  119735. readonly output: NodeMaterialConnectionPoint;
  119736. autoConfigure(material: NodeMaterial): void;
  119737. protected _buildBlock(state: NodeMaterialBuildState): this;
  119738. }
  119739. }
  119740. declare module BABYLON {
  119741. /**
  119742. * Block used to compute fresnel value
  119743. */
  119744. export class FresnelBlock extends NodeMaterialBlock {
  119745. /**
  119746. * Create a new FresnelBlock
  119747. * @param name defines the block name
  119748. */
  119749. constructor(name: string);
  119750. /**
  119751. * Gets the current class name
  119752. * @returns the class name
  119753. */
  119754. getClassName(): string;
  119755. /**
  119756. * Gets the world normal input component
  119757. */
  119758. readonly worldNormal: NodeMaterialConnectionPoint;
  119759. /**
  119760. * Gets the view direction input component
  119761. */
  119762. readonly viewDirection: NodeMaterialConnectionPoint;
  119763. /**
  119764. * Gets the bias input component
  119765. */
  119766. readonly bias: NodeMaterialConnectionPoint;
  119767. /**
  119768. * Gets the camera (or eye) position component
  119769. */
  119770. readonly power: NodeMaterialConnectionPoint;
  119771. /**
  119772. * Gets the fresnel output component
  119773. */
  119774. readonly fresnel: NodeMaterialConnectionPoint;
  119775. autoConfigure(material: NodeMaterial): void;
  119776. protected _buildBlock(state: NodeMaterialBuildState): this;
  119777. }
  119778. }
  119779. declare module BABYLON {
  119780. /**
  119781. * Block used to get the max of 2 values
  119782. */
  119783. export class MaxBlock extends NodeMaterialBlock {
  119784. /**
  119785. * Creates a new MaxBlock
  119786. * @param name defines the block name
  119787. */
  119788. constructor(name: string);
  119789. /**
  119790. * Gets the current class name
  119791. * @returns the class name
  119792. */
  119793. getClassName(): string;
  119794. /**
  119795. * Gets the left operand input component
  119796. */
  119797. readonly left: NodeMaterialConnectionPoint;
  119798. /**
  119799. * Gets the right operand input component
  119800. */
  119801. readonly right: NodeMaterialConnectionPoint;
  119802. /**
  119803. * Gets the output component
  119804. */
  119805. readonly output: NodeMaterialConnectionPoint;
  119806. protected _buildBlock(state: NodeMaterialBuildState): this;
  119807. }
  119808. }
  119809. declare module BABYLON {
  119810. /**
  119811. * Block used to get the min of 2 values
  119812. */
  119813. export class MinBlock extends NodeMaterialBlock {
  119814. /**
  119815. * Creates a new MinBlock
  119816. * @param name defines the block name
  119817. */
  119818. constructor(name: string);
  119819. /**
  119820. * Gets the current class name
  119821. * @returns the class name
  119822. */
  119823. getClassName(): string;
  119824. /**
  119825. * Gets the left operand input component
  119826. */
  119827. readonly left: NodeMaterialConnectionPoint;
  119828. /**
  119829. * Gets the right operand input component
  119830. */
  119831. readonly right: NodeMaterialConnectionPoint;
  119832. /**
  119833. * Gets the output component
  119834. */
  119835. readonly output: NodeMaterialConnectionPoint;
  119836. protected _buildBlock(state: NodeMaterialBuildState): this;
  119837. }
  119838. }
  119839. declare module BABYLON {
  119840. /**
  119841. * Effect Render Options
  119842. */
  119843. export interface IEffectRendererOptions {
  119844. /**
  119845. * Defines the vertices positions.
  119846. */
  119847. positions?: number[];
  119848. /**
  119849. * Defines the indices.
  119850. */
  119851. indices?: number[];
  119852. }
  119853. /**
  119854. * Helper class to render one or more effects
  119855. */
  119856. export class EffectRenderer {
  119857. private engine;
  119858. private static _DefaultOptions;
  119859. private _vertexBuffers;
  119860. private _indexBuffer;
  119861. private _ringBufferIndex;
  119862. private _ringScreenBuffer;
  119863. private _fullscreenViewport;
  119864. private _getNextFrameBuffer;
  119865. /**
  119866. * Creates an effect renderer
  119867. * @param engine the engine to use for rendering
  119868. * @param options defines the options of the effect renderer
  119869. */
  119870. constructor(engine: Engine, options?: IEffectRendererOptions);
  119871. /**
  119872. * Sets the current viewport in normalized coordinates 0-1
  119873. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  119874. */
  119875. setViewport(viewport?: Viewport): void;
  119876. /**
  119877. * Binds the embedded attributes buffer to the effect.
  119878. * @param effect Defines the effect to bind the attributes for
  119879. */
  119880. bindBuffers(effect: Effect): void;
  119881. /**
  119882. * Sets the current effect wrapper to use during draw.
  119883. * The effect needs to be ready before calling this api.
  119884. * This also sets the default full screen position attribute.
  119885. * @param effectWrapper Defines the effect to draw with
  119886. */
  119887. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  119888. /**
  119889. * Draws a full screen quad.
  119890. */
  119891. draw(): void;
  119892. /**
  119893. * renders one or more effects to a specified texture
  119894. * @param effectWrappers list of effects to renderer
  119895. * @param outputTexture texture to draw to, if null it will render to the screen
  119896. */
  119897. render(effectWrappers: Array<EffectWrapper> | EffectWrapper, outputTexture?: Nullable<Texture>): void;
  119898. /**
  119899. * Disposes of the effect renderer
  119900. */
  119901. dispose(): void;
  119902. }
  119903. /**
  119904. * Options to create an EffectWrapper
  119905. */
  119906. interface EffectWrapperCreationOptions {
  119907. /**
  119908. * Engine to use to create the effect
  119909. */
  119910. engine: Engine;
  119911. /**
  119912. * Fragment shader for the effect
  119913. */
  119914. fragmentShader: string;
  119915. /**
  119916. * Vertex shader for the effect
  119917. */
  119918. vertexShader?: string;
  119919. /**
  119920. * Attributes to use in the shader
  119921. */
  119922. attributeNames?: Array<string>;
  119923. /**
  119924. * Uniforms to use in the shader
  119925. */
  119926. uniformNames?: Array<string>;
  119927. /**
  119928. * Texture sampler names to use in the shader
  119929. */
  119930. samplerNames?: Array<string>;
  119931. /**
  119932. * The friendly name of the effect displayed in Spector.
  119933. */
  119934. name?: string;
  119935. }
  119936. /**
  119937. * Wraps an effect to be used for rendering
  119938. */
  119939. export class EffectWrapper {
  119940. /**
  119941. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  119942. */
  119943. onApplyObservable: Observable<{}>;
  119944. /**
  119945. * The underlying effect
  119946. */
  119947. effect: Effect;
  119948. /**
  119949. * Creates an effect to be renderer
  119950. * @param creationOptions options to create the effect
  119951. */
  119952. constructor(creationOptions: EffectWrapperCreationOptions);
  119953. /**
  119954. * Disposes of the effect wrapper
  119955. */
  119956. dispose(): void;
  119957. }
  119958. }
  119959. declare module BABYLON {
  119960. /**
  119961. * Helper class to push actions to a pool of workers.
  119962. */
  119963. export class WorkerPool implements IDisposable {
  119964. private _workerInfos;
  119965. private _pendingActions;
  119966. /**
  119967. * Constructor
  119968. * @param workers Array of workers to use for actions
  119969. */
  119970. constructor(workers: Array<Worker>);
  119971. /**
  119972. * Terminates all workers and clears any pending actions.
  119973. */
  119974. dispose(): void;
  119975. /**
  119976. * Pushes an action to the worker pool. If all the workers are active, the action will be
  119977. * pended until a worker has completed its action.
  119978. * @param action The action to perform. Call onComplete when the action is complete.
  119979. */
  119980. push(action: (worker: Worker, onComplete: () => void) => void): void;
  119981. private _execute;
  119982. }
  119983. }
  119984. declare module BABYLON {
  119985. /**
  119986. * Configuration for Draco compression
  119987. */
  119988. export interface IDracoCompressionConfiguration {
  119989. /**
  119990. * Configuration for the decoder.
  119991. */
  119992. decoder: {
  119993. /**
  119994. * The url to the WebAssembly module.
  119995. */
  119996. wasmUrl?: string;
  119997. /**
  119998. * The url to the WebAssembly binary.
  119999. */
  120000. wasmBinaryUrl?: string;
  120001. /**
  120002. * The url to the fallback JavaScript module.
  120003. */
  120004. fallbackUrl?: string;
  120005. };
  120006. }
  120007. /**
  120008. * Draco compression (https://google.github.io/draco/)
  120009. *
  120010. * This class wraps the Draco module.
  120011. *
  120012. * **Encoder**
  120013. *
  120014. * The encoder is not currently implemented.
  120015. *
  120016. * **Decoder**
  120017. *
  120018. * 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.
  120019. *
  120020. * To update the configuration, use the following code:
  120021. * ```javascript
  120022. * DracoCompression.Configuration = {
  120023. * decoder: {
  120024. * wasmUrl: "<url to the WebAssembly library>",
  120025. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  120026. * fallbackUrl: "<url to the fallback JavaScript library>",
  120027. * }
  120028. * };
  120029. * ```
  120030. *
  120031. * 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.
  120032. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  120033. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  120034. *
  120035. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  120036. * ```javascript
  120037. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  120038. * ```
  120039. *
  120040. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  120041. */
  120042. export class DracoCompression implements IDisposable {
  120043. private _workerPoolPromise?;
  120044. private _decoderModulePromise?;
  120045. /**
  120046. * The configuration. Defaults to the following urls:
  120047. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  120048. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  120049. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  120050. */
  120051. static Configuration: IDracoCompressionConfiguration;
  120052. /**
  120053. * Returns true if the decoder configuration is available.
  120054. */
  120055. static readonly DecoderAvailable: boolean;
  120056. /**
  120057. * Default number of workers to create when creating the draco compression object.
  120058. */
  120059. static DefaultNumWorkers: number;
  120060. private static GetDefaultNumWorkers;
  120061. private static _Default;
  120062. /**
  120063. * Default instance for the draco compression object.
  120064. */
  120065. static readonly Default: DracoCompression;
  120066. /**
  120067. * Constructor
  120068. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  120069. */
  120070. constructor(numWorkers?: number);
  120071. /**
  120072. * Stop all async operations and release resources.
  120073. */
  120074. dispose(): void;
  120075. /**
  120076. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  120077. * @returns a promise that resolves when ready
  120078. */
  120079. whenReadyAsync(): Promise<void>;
  120080. /**
  120081. * Decode Draco compressed mesh data to vertex data.
  120082. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  120083. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  120084. * @returns A promise that resolves with the decoded vertex data
  120085. */
  120086. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  120087. [kind: string]: number;
  120088. }): Promise<VertexData>;
  120089. }
  120090. }
  120091. declare module BABYLON {
  120092. /**
  120093. * Class for building Constructive Solid Geometry
  120094. */
  120095. export class CSG {
  120096. private polygons;
  120097. /**
  120098. * The world matrix
  120099. */
  120100. matrix: Matrix;
  120101. /**
  120102. * Stores the position
  120103. */
  120104. position: Vector3;
  120105. /**
  120106. * Stores the rotation
  120107. */
  120108. rotation: Vector3;
  120109. /**
  120110. * Stores the rotation quaternion
  120111. */
  120112. rotationQuaternion: Nullable<Quaternion>;
  120113. /**
  120114. * Stores the scaling vector
  120115. */
  120116. scaling: Vector3;
  120117. /**
  120118. * Convert the Mesh to CSG
  120119. * @param mesh The Mesh to convert to CSG
  120120. * @returns A new CSG from the Mesh
  120121. */
  120122. static FromMesh(mesh: Mesh): CSG;
  120123. /**
  120124. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  120125. * @param polygons Polygons used to construct a CSG solid
  120126. */
  120127. private static FromPolygons;
  120128. /**
  120129. * Clones, or makes a deep copy, of the CSG
  120130. * @returns A new CSG
  120131. */
  120132. clone(): CSG;
  120133. /**
  120134. * Unions this CSG with another CSG
  120135. * @param csg The CSG to union against this CSG
  120136. * @returns The unioned CSG
  120137. */
  120138. union(csg: CSG): CSG;
  120139. /**
  120140. * Unions this CSG with another CSG in place
  120141. * @param csg The CSG to union against this CSG
  120142. */
  120143. unionInPlace(csg: CSG): void;
  120144. /**
  120145. * Subtracts this CSG with another CSG
  120146. * @param csg The CSG to subtract against this CSG
  120147. * @returns A new CSG
  120148. */
  120149. subtract(csg: CSG): CSG;
  120150. /**
  120151. * Subtracts this CSG with another CSG in place
  120152. * @param csg The CSG to subtact against this CSG
  120153. */
  120154. subtractInPlace(csg: CSG): void;
  120155. /**
  120156. * Intersect this CSG with another CSG
  120157. * @param csg The CSG to intersect against this CSG
  120158. * @returns A new CSG
  120159. */
  120160. intersect(csg: CSG): CSG;
  120161. /**
  120162. * Intersects this CSG with another CSG in place
  120163. * @param csg The CSG to intersect against this CSG
  120164. */
  120165. intersectInPlace(csg: CSG): void;
  120166. /**
  120167. * Return a new CSG solid with solid and empty space switched. This solid is
  120168. * not modified.
  120169. * @returns A new CSG solid with solid and empty space switched
  120170. */
  120171. inverse(): CSG;
  120172. /**
  120173. * Inverses the CSG in place
  120174. */
  120175. inverseInPlace(): void;
  120176. /**
  120177. * This is used to keep meshes transformations so they can be restored
  120178. * when we build back a Babylon Mesh
  120179. * NB : All CSG operations are performed in world coordinates
  120180. * @param csg The CSG to copy the transform attributes from
  120181. * @returns This CSG
  120182. */
  120183. copyTransformAttributes(csg: CSG): CSG;
  120184. /**
  120185. * Build Raw mesh from CSG
  120186. * Coordinates here are in world space
  120187. * @param name The name of the mesh geometry
  120188. * @param scene The Scene
  120189. * @param keepSubMeshes Specifies if the submeshes should be kept
  120190. * @returns A new Mesh
  120191. */
  120192. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  120193. /**
  120194. * Build Mesh from CSG taking material and transforms into account
  120195. * @param name The name of the Mesh
  120196. * @param material The material of the Mesh
  120197. * @param scene The Scene
  120198. * @param keepSubMeshes Specifies if submeshes should be kept
  120199. * @returns The new Mesh
  120200. */
  120201. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  120202. }
  120203. }
  120204. declare module BABYLON {
  120205. /**
  120206. * Class used to create a trail following a mesh
  120207. */
  120208. export class TrailMesh extends Mesh {
  120209. private _generator;
  120210. private _autoStart;
  120211. private _running;
  120212. private _diameter;
  120213. private _length;
  120214. private _sectionPolygonPointsCount;
  120215. private _sectionVectors;
  120216. private _sectionNormalVectors;
  120217. private _beforeRenderObserver;
  120218. /**
  120219. * @constructor
  120220. * @param name The value used by scene.getMeshByName() to do a lookup.
  120221. * @param generator The mesh to generate a trail.
  120222. * @param scene The scene to add this mesh to.
  120223. * @param diameter Diameter of trailing mesh. Default is 1.
  120224. * @param length Length of trailing mesh. Default is 60.
  120225. * @param autoStart Automatically start trailing mesh. Default true.
  120226. */
  120227. constructor(name: string, generator: AbstractMesh, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  120228. /**
  120229. * "TrailMesh"
  120230. * @returns "TrailMesh"
  120231. */
  120232. getClassName(): string;
  120233. private _createMesh;
  120234. /**
  120235. * Start trailing mesh.
  120236. */
  120237. start(): void;
  120238. /**
  120239. * Stop trailing mesh.
  120240. */
  120241. stop(): void;
  120242. /**
  120243. * Update trailing mesh geometry.
  120244. */
  120245. update(): void;
  120246. /**
  120247. * Returns a new TrailMesh object.
  120248. * @param name is a string, the name given to the new mesh
  120249. * @param newGenerator use new generator object for cloned trail mesh
  120250. * @returns a new mesh
  120251. */
  120252. clone(name: string | undefined, newGenerator: AbstractMesh): TrailMesh;
  120253. /**
  120254. * Serializes this trail mesh
  120255. * @param serializationObject object to write serialization to
  120256. */
  120257. serialize(serializationObject: any): void;
  120258. /**
  120259. * Parses a serialized trail mesh
  120260. * @param parsedMesh the serialized mesh
  120261. * @param scene the scene to create the trail mesh in
  120262. * @returns the created trail mesh
  120263. */
  120264. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  120265. }
  120266. }
  120267. declare module BABYLON {
  120268. /**
  120269. * Class containing static functions to help procedurally build meshes
  120270. */
  120271. export class TiledBoxBuilder {
  120272. /**
  120273. * Creates a box mesh
  120274. * 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)
  120275. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  120276. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  120277. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  120278. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  120279. * @param name defines the name of the mesh
  120280. * @param options defines the options used to create the mesh
  120281. * @param scene defines the hosting scene
  120282. * @returns the box mesh
  120283. */
  120284. static CreateTiledBox(name: string, options: {
  120285. pattern?: number;
  120286. width?: number;
  120287. height?: number;
  120288. depth?: number;
  120289. tileSize?: number;
  120290. tileWidth?: number;
  120291. tileHeight?: number;
  120292. alignHorizontal?: number;
  120293. alignVertical?: number;
  120294. faceUV?: Vector4[];
  120295. faceColors?: Color4[];
  120296. sideOrientation?: number;
  120297. updatable?: boolean;
  120298. }, scene?: Nullable<Scene>): Mesh;
  120299. }
  120300. }
  120301. declare module BABYLON {
  120302. /**
  120303. * Class containing static functions to help procedurally build meshes
  120304. */
  120305. export class TorusKnotBuilder {
  120306. /**
  120307. * Creates a torus knot mesh
  120308. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  120309. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  120310. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  120311. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  120312. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  120313. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  120314. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  120315. * @param name defines the name of the mesh
  120316. * @param options defines the options used to create the mesh
  120317. * @param scene defines the hosting scene
  120318. * @returns the torus knot mesh
  120319. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  120320. */
  120321. static CreateTorusKnot(name: string, options: {
  120322. radius?: number;
  120323. tube?: number;
  120324. radialSegments?: number;
  120325. tubularSegments?: number;
  120326. p?: number;
  120327. q?: number;
  120328. updatable?: boolean;
  120329. sideOrientation?: number;
  120330. frontUVs?: Vector4;
  120331. backUVs?: Vector4;
  120332. }, scene: any): Mesh;
  120333. }
  120334. }
  120335. declare module BABYLON {
  120336. /**
  120337. * Polygon
  120338. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  120339. */
  120340. export class Polygon {
  120341. /**
  120342. * Creates a rectangle
  120343. * @param xmin bottom X coord
  120344. * @param ymin bottom Y coord
  120345. * @param xmax top X coord
  120346. * @param ymax top Y coord
  120347. * @returns points that make the resulting rectation
  120348. */
  120349. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  120350. /**
  120351. * Creates a circle
  120352. * @param radius radius of circle
  120353. * @param cx scale in x
  120354. * @param cy scale in y
  120355. * @param numberOfSides number of sides that make up the circle
  120356. * @returns points that make the resulting circle
  120357. */
  120358. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  120359. /**
  120360. * Creates a polygon from input string
  120361. * @param input Input polygon data
  120362. * @returns the parsed points
  120363. */
  120364. static Parse(input: string): Vector2[];
  120365. /**
  120366. * Starts building a polygon from x and y coordinates
  120367. * @param x x coordinate
  120368. * @param y y coordinate
  120369. * @returns the started path2
  120370. */
  120371. static StartingAt(x: number, y: number): Path2;
  120372. }
  120373. /**
  120374. * Builds a polygon
  120375. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  120376. */
  120377. export class PolygonMeshBuilder {
  120378. private _points;
  120379. private _outlinepoints;
  120380. private _holes;
  120381. private _name;
  120382. private _scene;
  120383. private _epoints;
  120384. private _eholes;
  120385. private _addToepoint;
  120386. /**
  120387. * Babylon reference to the earcut plugin.
  120388. */
  120389. bjsEarcut: any;
  120390. /**
  120391. * Creates a PolygonMeshBuilder
  120392. * @param name name of the builder
  120393. * @param contours Path of the polygon
  120394. * @param scene scene to add to when creating the mesh
  120395. * @param earcutInjection can be used to inject your own earcut reference
  120396. */
  120397. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  120398. /**
  120399. * Adds a whole within the polygon
  120400. * @param hole Array of points defining the hole
  120401. * @returns this
  120402. */
  120403. addHole(hole: Vector2[]): PolygonMeshBuilder;
  120404. /**
  120405. * Creates the polygon
  120406. * @param updatable If the mesh should be updatable
  120407. * @param depth The depth of the mesh created
  120408. * @returns the created mesh
  120409. */
  120410. build(updatable?: boolean, depth?: number): Mesh;
  120411. /**
  120412. * Creates the polygon
  120413. * @param depth The depth of the mesh created
  120414. * @returns the created VertexData
  120415. */
  120416. buildVertexData(depth?: number): VertexData;
  120417. /**
  120418. * Adds a side to the polygon
  120419. * @param positions points that make the polygon
  120420. * @param normals normals of the polygon
  120421. * @param uvs uvs of the polygon
  120422. * @param indices indices of the polygon
  120423. * @param bounds bounds of the polygon
  120424. * @param points points of the polygon
  120425. * @param depth depth of the polygon
  120426. * @param flip flip of the polygon
  120427. */
  120428. private addSide;
  120429. }
  120430. }
  120431. declare module BABYLON {
  120432. /**
  120433. * Class containing static functions to help procedurally build meshes
  120434. */
  120435. export class PolygonBuilder {
  120436. /**
  120437. * Creates a polygon mesh
  120438. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  120439. * * 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
  120440. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  120441. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  120442. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  120443. * * Remember you can only change the shape positions, not their number when updating a polygon
  120444. * @param name defines the name of the mesh
  120445. * @param options defines the options used to create the mesh
  120446. * @param scene defines the hosting scene
  120447. * @param earcutInjection can be used to inject your own earcut reference
  120448. * @returns the polygon mesh
  120449. */
  120450. static CreatePolygon(name: string, options: {
  120451. shape: Vector3[];
  120452. holes?: Vector3[][];
  120453. depth?: number;
  120454. faceUV?: Vector4[];
  120455. faceColors?: Color4[];
  120456. updatable?: boolean;
  120457. sideOrientation?: number;
  120458. frontUVs?: Vector4;
  120459. backUVs?: Vector4;
  120460. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  120461. /**
  120462. * Creates an extruded polygon mesh, with depth in the Y direction.
  120463. * * 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)
  120464. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  120465. * @param name defines the name of the mesh
  120466. * @param options defines the options used to create the mesh
  120467. * @param scene defines the hosting scene
  120468. * @param earcutInjection can be used to inject your own earcut reference
  120469. * @returns the polygon mesh
  120470. */
  120471. static ExtrudePolygon(name: string, options: {
  120472. shape: Vector3[];
  120473. holes?: Vector3[][];
  120474. depth?: number;
  120475. faceUV?: Vector4[];
  120476. faceColors?: Color4[];
  120477. updatable?: boolean;
  120478. sideOrientation?: number;
  120479. frontUVs?: Vector4;
  120480. backUVs?: Vector4;
  120481. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  120482. }
  120483. }
  120484. declare module BABYLON {
  120485. /**
  120486. * Class containing static functions to help procedurally build meshes
  120487. */
  120488. export class LatheBuilder {
  120489. /**
  120490. * Creates lathe mesh.
  120491. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  120492. * * 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
  120493. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  120494. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  120495. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  120496. * * 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
  120497. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  120498. * * 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
  120499. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  120500. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  120501. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  120502. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  120503. * @param name defines the name of the mesh
  120504. * @param options defines the options used to create the mesh
  120505. * @param scene defines the hosting scene
  120506. * @returns the lathe mesh
  120507. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  120508. */
  120509. static CreateLathe(name: string, options: {
  120510. shape: Vector3[];
  120511. radius?: number;
  120512. tessellation?: number;
  120513. clip?: number;
  120514. arc?: number;
  120515. closed?: boolean;
  120516. updatable?: boolean;
  120517. sideOrientation?: number;
  120518. frontUVs?: Vector4;
  120519. backUVs?: Vector4;
  120520. cap?: number;
  120521. invertUV?: boolean;
  120522. }, scene?: Nullable<Scene>): Mesh;
  120523. }
  120524. }
  120525. declare module BABYLON {
  120526. /**
  120527. * Class containing static functions to help procedurally build meshes
  120528. */
  120529. export class TiledPlaneBuilder {
  120530. /**
  120531. * Creates a tiled plane mesh
  120532. * * The parameter `pattern` will, depending on value, do nothing or
  120533. * * * flip (reflect about central vertical) alternate tiles across and up
  120534. * * * flip every tile on alternate rows
  120535. * * * rotate (180 degs) alternate tiles across and up
  120536. * * * rotate every tile on alternate rows
  120537. * * * flip and rotate alternate tiles across and up
  120538. * * * flip and rotate every tile on alternate rows
  120539. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  120540. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  120541. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  120542. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  120543. * * 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)
  120544. * * 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)
  120545. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  120546. * @param name defines the name of the mesh
  120547. * @param options defines the options used to create the mesh
  120548. * @param scene defines the hosting scene
  120549. * @returns the box mesh
  120550. */
  120551. static CreateTiledPlane(name: string, options: {
  120552. pattern?: number;
  120553. tileSize?: number;
  120554. tileWidth?: number;
  120555. tileHeight?: number;
  120556. size?: number;
  120557. width?: number;
  120558. height?: number;
  120559. alignHorizontal?: number;
  120560. alignVertical?: number;
  120561. sideOrientation?: number;
  120562. frontUVs?: Vector4;
  120563. backUVs?: Vector4;
  120564. updatable?: boolean;
  120565. }, scene?: Nullable<Scene>): Mesh;
  120566. }
  120567. }
  120568. declare module BABYLON {
  120569. /**
  120570. * Class containing static functions to help procedurally build meshes
  120571. */
  120572. export class TubeBuilder {
  120573. /**
  120574. * Creates a tube mesh.
  120575. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  120576. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  120577. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  120578. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  120579. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  120580. * * 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)
  120581. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  120582. * * 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
  120583. * * 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
  120584. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  120585. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  120586. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  120587. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  120588. * @param name defines the name of the mesh
  120589. * @param options defines the options used to create the mesh
  120590. * @param scene defines the hosting scene
  120591. * @returns the tube mesh
  120592. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  120593. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  120594. */
  120595. static CreateTube(name: string, options: {
  120596. path: Vector3[];
  120597. radius?: number;
  120598. tessellation?: number;
  120599. radiusFunction?: {
  120600. (i: number, distance: number): number;
  120601. };
  120602. cap?: number;
  120603. arc?: number;
  120604. updatable?: boolean;
  120605. sideOrientation?: number;
  120606. frontUVs?: Vector4;
  120607. backUVs?: Vector4;
  120608. instance?: Mesh;
  120609. invertUV?: boolean;
  120610. }, scene?: Nullable<Scene>): Mesh;
  120611. }
  120612. }
  120613. declare module BABYLON {
  120614. /**
  120615. * Class containing static functions to help procedurally build meshes
  120616. */
  120617. export class IcoSphereBuilder {
  120618. /**
  120619. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  120620. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  120621. * * 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`)
  120622. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  120623. * * 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
  120624. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  120625. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  120626. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  120627. * @param name defines the name of the mesh
  120628. * @param options defines the options used to create the mesh
  120629. * @param scene defines the hosting scene
  120630. * @returns the icosahedron mesh
  120631. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  120632. */
  120633. static CreateIcoSphere(name: string, options: {
  120634. radius?: number;
  120635. radiusX?: number;
  120636. radiusY?: number;
  120637. radiusZ?: number;
  120638. flat?: boolean;
  120639. subdivisions?: number;
  120640. sideOrientation?: number;
  120641. frontUVs?: Vector4;
  120642. backUVs?: Vector4;
  120643. updatable?: boolean;
  120644. }, scene?: Nullable<Scene>): Mesh;
  120645. }
  120646. }
  120647. declare module BABYLON {
  120648. /**
  120649. * Class containing static functions to help procedurally build meshes
  120650. */
  120651. export class DecalBuilder {
  120652. /**
  120653. * Creates a decal mesh.
  120654. * 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
  120655. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  120656. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  120657. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  120658. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  120659. * @param name defines the name of the mesh
  120660. * @param sourceMesh defines the mesh where the decal must be applied
  120661. * @param options defines the options used to create the mesh
  120662. * @param scene defines the hosting scene
  120663. * @returns the decal mesh
  120664. * @see https://doc.babylonjs.com/how_to/decals
  120665. */
  120666. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  120667. position?: Vector3;
  120668. normal?: Vector3;
  120669. size?: Vector3;
  120670. angle?: number;
  120671. }): Mesh;
  120672. }
  120673. }
  120674. declare module BABYLON {
  120675. /**
  120676. * Class containing static functions to help procedurally build meshes
  120677. */
  120678. export class MeshBuilder {
  120679. /**
  120680. * Creates a box mesh
  120681. * * The parameter `size` sets the size (float) of each box side (default 1)
  120682. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  120683. * * 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)
  120684. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  120685. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  120686. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  120687. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  120688. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  120689. * @param name defines the name of the mesh
  120690. * @param options defines the options used to create the mesh
  120691. * @param scene defines the hosting scene
  120692. * @returns the box mesh
  120693. */
  120694. static CreateBox(name: string, options: {
  120695. size?: number;
  120696. width?: number;
  120697. height?: number;
  120698. depth?: number;
  120699. faceUV?: Vector4[];
  120700. faceColors?: Color4[];
  120701. sideOrientation?: number;
  120702. frontUVs?: Vector4;
  120703. backUVs?: Vector4;
  120704. updatable?: boolean;
  120705. }, scene?: Nullable<Scene>): Mesh;
  120706. /**
  120707. * Creates a tiled box mesh
  120708. * * faceTiles sets the pattern, tile size and number of tiles for a face
  120709. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  120710. * @param name defines the name of the mesh
  120711. * @param options defines the options used to create the mesh
  120712. * @param scene defines the hosting scene
  120713. * @returns the tiled box mesh
  120714. */
  120715. static CreateTiledBox(name: string, options: {
  120716. pattern?: number;
  120717. size?: number;
  120718. width?: number;
  120719. height?: number;
  120720. depth: number;
  120721. tileSize?: number;
  120722. tileWidth?: number;
  120723. tileHeight?: number;
  120724. faceUV?: Vector4[];
  120725. faceColors?: Color4[];
  120726. alignHorizontal?: number;
  120727. alignVertical?: number;
  120728. sideOrientation?: number;
  120729. updatable?: boolean;
  120730. }, scene?: Nullable<Scene>): Mesh;
  120731. /**
  120732. * Creates a sphere mesh
  120733. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  120734. * * 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`)
  120735. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  120736. * * 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
  120737. * * 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)
  120738. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  120739. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  120740. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  120741. * @param name defines the name of the mesh
  120742. * @param options defines the options used to create the mesh
  120743. * @param scene defines the hosting scene
  120744. * @returns the sphere mesh
  120745. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  120746. */
  120747. static CreateSphere(name: string, options: {
  120748. segments?: number;
  120749. diameter?: number;
  120750. diameterX?: number;
  120751. diameterY?: number;
  120752. diameterZ?: number;
  120753. arc?: number;
  120754. slice?: number;
  120755. sideOrientation?: number;
  120756. frontUVs?: Vector4;
  120757. backUVs?: Vector4;
  120758. updatable?: boolean;
  120759. }, scene?: Nullable<Scene>): Mesh;
  120760. /**
  120761. * Creates a plane polygonal mesh. By default, this is a disc
  120762. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  120763. * * 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
  120764. * * 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
  120765. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  120766. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  120767. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  120768. * @param name defines the name of the mesh
  120769. * @param options defines the options used to create the mesh
  120770. * @param scene defines the hosting scene
  120771. * @returns the plane polygonal mesh
  120772. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  120773. */
  120774. static CreateDisc(name: string, options: {
  120775. radius?: number;
  120776. tessellation?: number;
  120777. arc?: number;
  120778. updatable?: boolean;
  120779. sideOrientation?: number;
  120780. frontUVs?: Vector4;
  120781. backUVs?: Vector4;
  120782. }, scene?: Nullable<Scene>): Mesh;
  120783. /**
  120784. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  120785. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  120786. * * 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`)
  120787. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  120788. * * 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
  120789. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  120790. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  120791. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  120792. * @param name defines the name of the mesh
  120793. * @param options defines the options used to create the mesh
  120794. * @param scene defines the hosting scene
  120795. * @returns the icosahedron mesh
  120796. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  120797. */
  120798. static CreateIcoSphere(name: string, options: {
  120799. radius?: number;
  120800. radiusX?: number;
  120801. radiusY?: number;
  120802. radiusZ?: number;
  120803. flat?: boolean;
  120804. subdivisions?: number;
  120805. sideOrientation?: number;
  120806. frontUVs?: Vector4;
  120807. backUVs?: Vector4;
  120808. updatable?: boolean;
  120809. }, scene?: Nullable<Scene>): Mesh;
  120810. /**
  120811. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  120812. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  120813. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  120814. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  120815. * * 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
  120816. * * 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
  120817. * * 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
  120818. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  120819. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  120820. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  120821. * * 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
  120822. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  120823. * * 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
  120824. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  120825. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  120826. * @param name defines the name of the mesh
  120827. * @param options defines the options used to create the mesh
  120828. * @param scene defines the hosting scene
  120829. * @returns the ribbon mesh
  120830. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  120831. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  120832. */
  120833. static CreateRibbon(name: string, options: {
  120834. pathArray: Vector3[][];
  120835. closeArray?: boolean;
  120836. closePath?: boolean;
  120837. offset?: number;
  120838. updatable?: boolean;
  120839. sideOrientation?: number;
  120840. frontUVs?: Vector4;
  120841. backUVs?: Vector4;
  120842. instance?: Mesh;
  120843. invertUV?: boolean;
  120844. uvs?: Vector2[];
  120845. colors?: Color4[];
  120846. }, scene?: Nullable<Scene>): Mesh;
  120847. /**
  120848. * Creates a cylinder or a cone mesh
  120849. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  120850. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  120851. * * 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.
  120852. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  120853. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  120854. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  120855. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  120856. * * 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).
  120857. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  120858. * * 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).
  120859. * * 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
  120860. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  120861. * * 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
  120862. * * 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.
  120863. * * If `enclose` is false, a ring surface is one element.
  120864. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  120865. * * 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
  120866. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  120867. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  120868. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  120869. * @param name defines the name of the mesh
  120870. * @param options defines the options used to create the mesh
  120871. * @param scene defines the hosting scene
  120872. * @returns the cylinder mesh
  120873. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  120874. */
  120875. static CreateCylinder(name: string, options: {
  120876. height?: number;
  120877. diameterTop?: number;
  120878. diameterBottom?: number;
  120879. diameter?: number;
  120880. tessellation?: number;
  120881. subdivisions?: number;
  120882. arc?: number;
  120883. faceColors?: Color4[];
  120884. faceUV?: Vector4[];
  120885. updatable?: boolean;
  120886. hasRings?: boolean;
  120887. enclose?: boolean;
  120888. cap?: number;
  120889. sideOrientation?: number;
  120890. frontUVs?: Vector4;
  120891. backUVs?: Vector4;
  120892. }, scene?: Nullable<Scene>): Mesh;
  120893. /**
  120894. * Creates a torus mesh
  120895. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  120896. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  120897. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  120898. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  120899. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  120900. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  120901. * @param name defines the name of the mesh
  120902. * @param options defines the options used to create the mesh
  120903. * @param scene defines the hosting scene
  120904. * @returns the torus mesh
  120905. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  120906. */
  120907. static CreateTorus(name: string, options: {
  120908. diameter?: number;
  120909. thickness?: number;
  120910. tessellation?: number;
  120911. updatable?: boolean;
  120912. sideOrientation?: number;
  120913. frontUVs?: Vector4;
  120914. backUVs?: Vector4;
  120915. }, scene?: Nullable<Scene>): Mesh;
  120916. /**
  120917. * Creates a torus knot mesh
  120918. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  120919. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  120920. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  120921. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  120922. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  120923. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  120924. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  120925. * @param name defines the name of the mesh
  120926. * @param options defines the options used to create the mesh
  120927. * @param scene defines the hosting scene
  120928. * @returns the torus knot mesh
  120929. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  120930. */
  120931. static CreateTorusKnot(name: string, options: {
  120932. radius?: number;
  120933. tube?: number;
  120934. radialSegments?: number;
  120935. tubularSegments?: number;
  120936. p?: number;
  120937. q?: number;
  120938. updatable?: boolean;
  120939. sideOrientation?: number;
  120940. frontUVs?: Vector4;
  120941. backUVs?: Vector4;
  120942. }, scene?: Nullable<Scene>): Mesh;
  120943. /**
  120944. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  120945. * * 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
  120946. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  120947. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  120948. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  120949. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  120950. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  120951. * * 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
  120952. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  120953. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  120954. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  120955. * @param name defines the name of the new line system
  120956. * @param options defines the options used to create the line system
  120957. * @param scene defines the hosting scene
  120958. * @returns a new line system mesh
  120959. */
  120960. static CreateLineSystem(name: string, options: {
  120961. lines: Vector3[][];
  120962. updatable?: boolean;
  120963. instance?: Nullable<LinesMesh>;
  120964. colors?: Nullable<Color4[][]>;
  120965. useVertexAlpha?: boolean;
  120966. }, scene: Nullable<Scene>): LinesMesh;
  120967. /**
  120968. * Creates a line mesh
  120969. * 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
  120970. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  120971. * * The parameter `points` is an array successive Vector3
  120972. * * 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
  120973. * * The optional parameter `colors` is an array of successive Color4, one per line point
  120974. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  120975. * * When updating an instance, remember that only point positions can change, not the number of points
  120976. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  120977. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  120978. * @param name defines the name of the new line system
  120979. * @param options defines the options used to create the line system
  120980. * @param scene defines the hosting scene
  120981. * @returns a new line mesh
  120982. */
  120983. static CreateLines(name: string, options: {
  120984. points: Vector3[];
  120985. updatable?: boolean;
  120986. instance?: Nullable<LinesMesh>;
  120987. colors?: Color4[];
  120988. useVertexAlpha?: boolean;
  120989. }, scene?: Nullable<Scene>): LinesMesh;
  120990. /**
  120991. * Creates a dashed line mesh
  120992. * * 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
  120993. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  120994. * * The parameter `points` is an array successive Vector3
  120995. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  120996. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  120997. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  120998. * * 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
  120999. * * When updating an instance, remember that only point positions can change, not the number of points
  121000. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  121001. * @param name defines the name of the mesh
  121002. * @param options defines the options used to create the mesh
  121003. * @param scene defines the hosting scene
  121004. * @returns the dashed line mesh
  121005. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  121006. */
  121007. static CreateDashedLines(name: string, options: {
  121008. points: Vector3[];
  121009. dashSize?: number;
  121010. gapSize?: number;
  121011. dashNb?: number;
  121012. updatable?: boolean;
  121013. instance?: LinesMesh;
  121014. }, scene?: Nullable<Scene>): LinesMesh;
  121015. /**
  121016. * 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.
  121017. * * 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.
  121018. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  121019. * * 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.
  121020. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  121021. * * 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
  121022. * * 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
  121023. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  121024. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  121025. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  121026. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  121027. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  121028. * @param name defines the name of the mesh
  121029. * @param options defines the options used to create the mesh
  121030. * @param scene defines the hosting scene
  121031. * @returns the extruded shape mesh
  121032. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  121033. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  121034. */
  121035. static ExtrudeShape(name: string, options: {
  121036. shape: Vector3[];
  121037. path: Vector3[];
  121038. scale?: number;
  121039. rotation?: number;
  121040. cap?: number;
  121041. updatable?: boolean;
  121042. sideOrientation?: number;
  121043. frontUVs?: Vector4;
  121044. backUVs?: Vector4;
  121045. instance?: Mesh;
  121046. invertUV?: boolean;
  121047. }, scene?: Nullable<Scene>): Mesh;
  121048. /**
  121049. * Creates an custom extruded shape mesh.
  121050. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  121051. * * 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.
  121052. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  121053. * * 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
  121054. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  121055. * * 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
  121056. * * It must returns a float value that will be the scale value applied to the shape on each path point
  121057. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  121058. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  121059. * * 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
  121060. * * 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
  121061. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  121062. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  121063. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  121064. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  121065. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  121066. * @param name defines the name of the mesh
  121067. * @param options defines the options used to create the mesh
  121068. * @param scene defines the hosting scene
  121069. * @returns the custom extruded shape mesh
  121070. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  121071. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  121072. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  121073. */
  121074. static ExtrudeShapeCustom(name: string, options: {
  121075. shape: Vector3[];
  121076. path: Vector3[];
  121077. scaleFunction?: any;
  121078. rotationFunction?: any;
  121079. ribbonCloseArray?: boolean;
  121080. ribbonClosePath?: boolean;
  121081. cap?: number;
  121082. updatable?: boolean;
  121083. sideOrientation?: number;
  121084. frontUVs?: Vector4;
  121085. backUVs?: Vector4;
  121086. instance?: Mesh;
  121087. invertUV?: boolean;
  121088. }, scene?: Nullable<Scene>): Mesh;
  121089. /**
  121090. * Creates lathe mesh.
  121091. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  121092. * * 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
  121093. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  121094. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  121095. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  121096. * * 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
  121097. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  121098. * * 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
  121099. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  121100. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  121101. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  121102. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  121103. * @param name defines the name of the mesh
  121104. * @param options defines the options used to create the mesh
  121105. * @param scene defines the hosting scene
  121106. * @returns the lathe mesh
  121107. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  121108. */
  121109. static CreateLathe(name: string, options: {
  121110. shape: Vector3[];
  121111. radius?: number;
  121112. tessellation?: number;
  121113. clip?: number;
  121114. arc?: number;
  121115. closed?: boolean;
  121116. updatable?: boolean;
  121117. sideOrientation?: number;
  121118. frontUVs?: Vector4;
  121119. backUVs?: Vector4;
  121120. cap?: number;
  121121. invertUV?: boolean;
  121122. }, scene?: Nullable<Scene>): Mesh;
  121123. /**
  121124. * Creates a tiled plane mesh
  121125. * * You can set a limited pattern arrangement with the tiles
  121126. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  121127. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  121128. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  121129. * @param name defines the name of the mesh
  121130. * @param options defines the options used to create the mesh
  121131. * @param scene defines the hosting scene
  121132. * @returns the plane mesh
  121133. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  121134. */
  121135. static CreateTiledPlane(name: string, options: {
  121136. pattern?: number;
  121137. tileSize?: number;
  121138. tileWidth?: number;
  121139. tileHeight?: number;
  121140. size?: number;
  121141. width?: number;
  121142. height?: number;
  121143. alignHorizontal?: number;
  121144. alignVertical?: number;
  121145. sideOrientation?: number;
  121146. frontUVs?: Vector4;
  121147. backUVs?: Vector4;
  121148. updatable?: boolean;
  121149. }, scene?: Nullable<Scene>): Mesh;
  121150. /**
  121151. * Creates a plane mesh
  121152. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  121153. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  121154. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  121155. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  121156. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  121157. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  121158. * @param name defines the name of the mesh
  121159. * @param options defines the options used to create the mesh
  121160. * @param scene defines the hosting scene
  121161. * @returns the plane mesh
  121162. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  121163. */
  121164. static CreatePlane(name: string, options: {
  121165. size?: number;
  121166. width?: number;
  121167. height?: number;
  121168. sideOrientation?: number;
  121169. frontUVs?: Vector4;
  121170. backUVs?: Vector4;
  121171. updatable?: boolean;
  121172. sourcePlane?: Plane;
  121173. }, scene?: Nullable<Scene>): Mesh;
  121174. /**
  121175. * Creates a ground mesh
  121176. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  121177. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  121178. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  121179. * @param name defines the name of the mesh
  121180. * @param options defines the options used to create the mesh
  121181. * @param scene defines the hosting scene
  121182. * @returns the ground mesh
  121183. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  121184. */
  121185. static CreateGround(name: string, options: {
  121186. width?: number;
  121187. height?: number;
  121188. subdivisions?: number;
  121189. subdivisionsX?: number;
  121190. subdivisionsY?: number;
  121191. updatable?: boolean;
  121192. }, scene?: Nullable<Scene>): Mesh;
  121193. /**
  121194. * Creates a tiled ground mesh
  121195. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  121196. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  121197. * * 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
  121198. * * 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
  121199. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  121200. * @param name defines the name of the mesh
  121201. * @param options defines the options used to create the mesh
  121202. * @param scene defines the hosting scene
  121203. * @returns the tiled ground mesh
  121204. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  121205. */
  121206. static CreateTiledGround(name: string, options: {
  121207. xmin: number;
  121208. zmin: number;
  121209. xmax: number;
  121210. zmax: number;
  121211. subdivisions?: {
  121212. w: number;
  121213. h: number;
  121214. };
  121215. precision?: {
  121216. w: number;
  121217. h: number;
  121218. };
  121219. updatable?: boolean;
  121220. }, scene?: Nullable<Scene>): Mesh;
  121221. /**
  121222. * Creates a ground mesh from a height map
  121223. * * The parameter `url` sets the URL of the height map image resource.
  121224. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  121225. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  121226. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  121227. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  121228. * * 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.
  121229. * * 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).
  121230. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  121231. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  121232. * @param name defines the name of the mesh
  121233. * @param url defines the url to the height map
  121234. * @param options defines the options used to create the mesh
  121235. * @param scene defines the hosting scene
  121236. * @returns the ground mesh
  121237. * @see https://doc.babylonjs.com/babylon101/height_map
  121238. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  121239. */
  121240. static CreateGroundFromHeightMap(name: string, url: string, options: {
  121241. width?: number;
  121242. height?: number;
  121243. subdivisions?: number;
  121244. minHeight?: number;
  121245. maxHeight?: number;
  121246. colorFilter?: Color3;
  121247. alphaFilter?: number;
  121248. updatable?: boolean;
  121249. onReady?: (mesh: GroundMesh) => void;
  121250. }, scene?: Nullable<Scene>): GroundMesh;
  121251. /**
  121252. * Creates a polygon mesh
  121253. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  121254. * * 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
  121255. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  121256. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  121257. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  121258. * * Remember you can only change the shape positions, not their number when updating a polygon
  121259. * @param name defines the name of the mesh
  121260. * @param options defines the options used to create the mesh
  121261. * @param scene defines the hosting scene
  121262. * @param earcutInjection can be used to inject your own earcut reference
  121263. * @returns the polygon mesh
  121264. */
  121265. static CreatePolygon(name: string, options: {
  121266. shape: Vector3[];
  121267. holes?: Vector3[][];
  121268. depth?: number;
  121269. faceUV?: Vector4[];
  121270. faceColors?: Color4[];
  121271. updatable?: boolean;
  121272. sideOrientation?: number;
  121273. frontUVs?: Vector4;
  121274. backUVs?: Vector4;
  121275. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  121276. /**
  121277. * Creates an extruded polygon mesh, with depth in the Y direction.
  121278. * * 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)
  121279. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  121280. * @param name defines the name of the mesh
  121281. * @param options defines the options used to create the mesh
  121282. * @param scene defines the hosting scene
  121283. * @param earcutInjection can be used to inject your own earcut reference
  121284. * @returns the polygon mesh
  121285. */
  121286. static ExtrudePolygon(name: string, options: {
  121287. shape: Vector3[];
  121288. holes?: Vector3[][];
  121289. depth?: number;
  121290. faceUV?: Vector4[];
  121291. faceColors?: Color4[];
  121292. updatable?: boolean;
  121293. sideOrientation?: number;
  121294. frontUVs?: Vector4;
  121295. backUVs?: Vector4;
  121296. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  121297. /**
  121298. * Creates a tube mesh.
  121299. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  121300. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  121301. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  121302. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  121303. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  121304. * * 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)
  121305. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  121306. * * 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
  121307. * * 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
  121308. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  121309. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  121310. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  121311. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  121312. * @param name defines the name of the mesh
  121313. * @param options defines the options used to create the mesh
  121314. * @param scene defines the hosting scene
  121315. * @returns the tube mesh
  121316. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  121317. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  121318. */
  121319. static CreateTube(name: string, options: {
  121320. path: Vector3[];
  121321. radius?: number;
  121322. tessellation?: number;
  121323. radiusFunction?: {
  121324. (i: number, distance: number): number;
  121325. };
  121326. cap?: number;
  121327. arc?: number;
  121328. updatable?: boolean;
  121329. sideOrientation?: number;
  121330. frontUVs?: Vector4;
  121331. backUVs?: Vector4;
  121332. instance?: Mesh;
  121333. invertUV?: boolean;
  121334. }, scene?: Nullable<Scene>): Mesh;
  121335. /**
  121336. * Creates a polyhedron mesh
  121337. * * 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
  121338. * * The parameter `size` (positive float, default 1) sets the polygon size
  121339. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  121340. * * 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`
  121341. * * 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
  121342. * * 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)`)
  121343. * * 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
  121344. * * 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
  121345. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  121346. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  121347. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  121348. * @param name defines the name of the mesh
  121349. * @param options defines the options used to create the mesh
  121350. * @param scene defines the hosting scene
  121351. * @returns the polyhedron mesh
  121352. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  121353. */
  121354. static CreatePolyhedron(name: string, options: {
  121355. type?: number;
  121356. size?: number;
  121357. sizeX?: number;
  121358. sizeY?: number;
  121359. sizeZ?: number;
  121360. custom?: any;
  121361. faceUV?: Vector4[];
  121362. faceColors?: Color4[];
  121363. flat?: boolean;
  121364. updatable?: boolean;
  121365. sideOrientation?: number;
  121366. frontUVs?: Vector4;
  121367. backUVs?: Vector4;
  121368. }, scene?: Nullable<Scene>): Mesh;
  121369. /**
  121370. * Creates a decal mesh.
  121371. * 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
  121372. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  121373. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  121374. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  121375. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  121376. * @param name defines the name of the mesh
  121377. * @param sourceMesh defines the mesh where the decal must be applied
  121378. * @param options defines the options used to create the mesh
  121379. * @param scene defines the hosting scene
  121380. * @returns the decal mesh
  121381. * @see https://doc.babylonjs.com/how_to/decals
  121382. */
  121383. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  121384. position?: Vector3;
  121385. normal?: Vector3;
  121386. size?: Vector3;
  121387. angle?: number;
  121388. }): Mesh;
  121389. }
  121390. }
  121391. declare module BABYLON {
  121392. /**
  121393. * A simplifier interface for future simplification implementations
  121394. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  121395. */
  121396. export interface ISimplifier {
  121397. /**
  121398. * Simplification of a given mesh according to the given settings.
  121399. * Since this requires computation, it is assumed that the function runs async.
  121400. * @param settings The settings of the simplification, including quality and distance
  121401. * @param successCallback A callback that will be called after the mesh was simplified.
  121402. * @param errorCallback in case of an error, this callback will be called. optional.
  121403. */
  121404. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  121405. }
  121406. /**
  121407. * Expected simplification settings.
  121408. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  121409. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  121410. */
  121411. export interface ISimplificationSettings {
  121412. /**
  121413. * Gets or sets the expected quality
  121414. */
  121415. quality: number;
  121416. /**
  121417. * Gets or sets the distance when this optimized version should be used
  121418. */
  121419. distance: number;
  121420. /**
  121421. * Gets an already optimized mesh
  121422. */
  121423. optimizeMesh?: boolean;
  121424. }
  121425. /**
  121426. * Class used to specify simplification options
  121427. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  121428. */
  121429. export class SimplificationSettings implements ISimplificationSettings {
  121430. /** expected quality */
  121431. quality: number;
  121432. /** distance when this optimized version should be used */
  121433. distance: number;
  121434. /** already optimized mesh */
  121435. optimizeMesh?: boolean | undefined;
  121436. /**
  121437. * Creates a SimplificationSettings
  121438. * @param quality expected quality
  121439. * @param distance distance when this optimized version should be used
  121440. * @param optimizeMesh already optimized mesh
  121441. */
  121442. constructor(
  121443. /** expected quality */
  121444. quality: number,
  121445. /** distance when this optimized version should be used */
  121446. distance: number,
  121447. /** already optimized mesh */
  121448. optimizeMesh?: boolean | undefined);
  121449. }
  121450. /**
  121451. * Interface used to define a simplification task
  121452. */
  121453. export interface ISimplificationTask {
  121454. /**
  121455. * Array of settings
  121456. */
  121457. settings: Array<ISimplificationSettings>;
  121458. /**
  121459. * Simplification type
  121460. */
  121461. simplificationType: SimplificationType;
  121462. /**
  121463. * Mesh to simplify
  121464. */
  121465. mesh: Mesh;
  121466. /**
  121467. * Callback called on success
  121468. */
  121469. successCallback?: () => void;
  121470. /**
  121471. * Defines if parallel processing can be used
  121472. */
  121473. parallelProcessing: boolean;
  121474. }
  121475. /**
  121476. * Queue used to order the simplification tasks
  121477. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  121478. */
  121479. export class SimplificationQueue {
  121480. private _simplificationArray;
  121481. /**
  121482. * Gets a boolean indicating that the process is still running
  121483. */
  121484. running: boolean;
  121485. /**
  121486. * Creates a new queue
  121487. */
  121488. constructor();
  121489. /**
  121490. * Adds a new simplification task
  121491. * @param task defines a task to add
  121492. */
  121493. addTask(task: ISimplificationTask): void;
  121494. /**
  121495. * Execute next task
  121496. */
  121497. executeNext(): void;
  121498. /**
  121499. * Execute a simplification task
  121500. * @param task defines the task to run
  121501. */
  121502. runSimplification(task: ISimplificationTask): void;
  121503. private getSimplifier;
  121504. }
  121505. /**
  121506. * The implemented types of simplification
  121507. * At the moment only Quadratic Error Decimation is implemented
  121508. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  121509. */
  121510. export enum SimplificationType {
  121511. /** Quadratic error decimation */
  121512. QUADRATIC = 0
  121513. }
  121514. }
  121515. declare module BABYLON {
  121516. interface Scene {
  121517. /** @hidden (Backing field) */
  121518. _simplificationQueue: SimplificationQueue;
  121519. /**
  121520. * Gets or sets the simplification queue attached to the scene
  121521. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  121522. */
  121523. simplificationQueue: SimplificationQueue;
  121524. }
  121525. interface Mesh {
  121526. /**
  121527. * Simplify the mesh according to the given array of settings.
  121528. * Function will return immediately and will simplify async
  121529. * @param settings a collection of simplification settings
  121530. * @param parallelProcessing should all levels calculate parallel or one after the other
  121531. * @param simplificationType the type of simplification to run
  121532. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  121533. * @returns the current mesh
  121534. */
  121535. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  121536. }
  121537. /**
  121538. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  121539. * created in a scene
  121540. */
  121541. export class SimplicationQueueSceneComponent implements ISceneComponent {
  121542. /**
  121543. * The component name helpfull to identify the component in the list of scene components.
  121544. */
  121545. readonly name: string;
  121546. /**
  121547. * The scene the component belongs to.
  121548. */
  121549. scene: Scene;
  121550. /**
  121551. * Creates a new instance of the component for the given scene
  121552. * @param scene Defines the scene to register the component in
  121553. */
  121554. constructor(scene: Scene);
  121555. /**
  121556. * Registers the component in a given scene
  121557. */
  121558. register(): void;
  121559. /**
  121560. * Rebuilds the elements related to this component in case of
  121561. * context lost for instance.
  121562. */
  121563. rebuild(): void;
  121564. /**
  121565. * Disposes the component and the associated ressources
  121566. */
  121567. dispose(): void;
  121568. private _beforeCameraUpdate;
  121569. }
  121570. }
  121571. declare module BABYLON {
  121572. /**
  121573. * Navigation plugin interface to add navigation constrained by a navigation mesh
  121574. */
  121575. export interface INavigationEnginePlugin {
  121576. /**
  121577. * plugin name
  121578. */
  121579. name: string;
  121580. /**
  121581. * Creates a navigation mesh
  121582. * @param meshes array of all the geometry used to compute the navigatio mesh
  121583. * @param parameters bunch of parameters used to filter geometry
  121584. */
  121585. createMavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  121586. /**
  121587. * Create a navigation mesh debug mesh
  121588. * @param scene is where the mesh will be added
  121589. * @returns debug display mesh
  121590. */
  121591. createDebugNavMesh(scene: Scene): Mesh;
  121592. /**
  121593. * Get a navigation mesh constrained position, closest to the parameter position
  121594. * @param position world position
  121595. * @returns the closest point to position constrained by the navigation mesh
  121596. */
  121597. getClosestPoint(position: Vector3): Vector3;
  121598. /**
  121599. * Get a navigation mesh constrained position, within a particular radius
  121600. * @param position world position
  121601. * @param maxRadius the maximum distance to the constrained world position
  121602. * @returns the closest point to position constrained by the navigation mesh
  121603. */
  121604. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  121605. /**
  121606. * Compute the final position from a segment made of destination-position
  121607. * @param position world position
  121608. * @param destination world position
  121609. * @returns the resulting point along the navmesh
  121610. */
  121611. moveAlong(position: Vector3, destination: Vector3): Vector3;
  121612. /**
  121613. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  121614. * @param start world position
  121615. * @param end world position
  121616. * @returns array containing world position composing the path
  121617. */
  121618. computePath(start: Vector3, end: Vector3): Vector3[];
  121619. /**
  121620. * If this plugin is supported
  121621. * @returns true if plugin is supported
  121622. */
  121623. isSupported(): boolean;
  121624. /**
  121625. * Create a new Crowd so you can add agents
  121626. * @param maxAgents the maximum agent count in the crowd
  121627. * @param maxAgentRadius the maximum radius an agent can have
  121628. * @param scene to attach the crowd to
  121629. * @returns the crowd you can add agents to
  121630. */
  121631. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  121632. /**
  121633. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  121634. * The queries will try to find a solution within those bounds
  121635. * default is (1,1,1)
  121636. * @param extent x,y,z value that define the extent around the queries point of reference
  121637. */
  121638. setDefaultQueryExtent(extent: Vector3): void;
  121639. /**
  121640. * Get the Bounding box extent specified by setDefaultQueryExtent
  121641. * @returns the box extent values
  121642. */
  121643. getDefaultQueryExtent(): Vector3;
  121644. /**
  121645. * Release all resources
  121646. */
  121647. dispose(): void;
  121648. }
  121649. /**
  121650. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  121651. */
  121652. export interface ICrowd {
  121653. /**
  121654. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  121655. * You can attach anything to that node. The node position is updated in the scene update tick.
  121656. * @param pos world position that will be constrained by the navigation mesh
  121657. * @param parameters agent parameters
  121658. * @param transform hooked to the agent that will be update by the scene
  121659. * @returns agent index
  121660. */
  121661. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  121662. /**
  121663. * Returns the agent position in world space
  121664. * @param index agent index returned by addAgent
  121665. * @returns world space position
  121666. */
  121667. getAgentPosition(index: number): Vector3;
  121668. /**
  121669. * Gets the agent velocity in world space
  121670. * @param index agent index returned by addAgent
  121671. * @returns world space velocity
  121672. */
  121673. getAgentVelocity(index: number): Vector3;
  121674. /**
  121675. * remove a particular agent previously created
  121676. * @param index agent index returned by addAgent
  121677. */
  121678. removeAgent(index: number): void;
  121679. /**
  121680. * get the list of all agents attached to this crowd
  121681. * @returns list of agent indices
  121682. */
  121683. getAgents(): number[];
  121684. /**
  121685. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  121686. * @param deltaTime in seconds
  121687. */
  121688. update(deltaTime: number): void;
  121689. /**
  121690. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  121691. * @param index agent index returned by addAgent
  121692. * @param destination targeted world position
  121693. */
  121694. agentGoto(index: number, destination: Vector3): void;
  121695. /**
  121696. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  121697. * The queries will try to find a solution within those bounds
  121698. * default is (1,1,1)
  121699. * @param extent x,y,z value that define the extent around the queries point of reference
  121700. */
  121701. setDefaultQueryExtent(extent: Vector3): void;
  121702. /**
  121703. * Get the Bounding box extent specified by setDefaultQueryExtent
  121704. * @returns the box extent values
  121705. */
  121706. getDefaultQueryExtent(): Vector3;
  121707. /**
  121708. * Release all resources
  121709. */
  121710. dispose(): void;
  121711. }
  121712. /**
  121713. * Configures an agent
  121714. */
  121715. export interface IAgentParameters {
  121716. /**
  121717. * Agent radius. [Limit: >= 0]
  121718. */
  121719. radius: number;
  121720. /**
  121721. * Agent height. [Limit: > 0]
  121722. */
  121723. height: number;
  121724. /**
  121725. * Maximum allowed acceleration. [Limit: >= 0]
  121726. */
  121727. maxAcceleration: number;
  121728. /**
  121729. * Maximum allowed speed. [Limit: >= 0]
  121730. */
  121731. maxSpeed: number;
  121732. /**
  121733. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  121734. */
  121735. collisionQueryRange: number;
  121736. /**
  121737. * The path visibility optimization range. [Limit: > 0]
  121738. */
  121739. pathOptimizationRange: number;
  121740. /**
  121741. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  121742. */
  121743. separationWeight: number;
  121744. }
  121745. /**
  121746. * Configures the navigation mesh creation
  121747. */
  121748. export interface INavMeshParameters {
  121749. /**
  121750. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  121751. */
  121752. cs: number;
  121753. /**
  121754. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  121755. */
  121756. ch: number;
  121757. /**
  121758. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  121759. */
  121760. walkableSlopeAngle: number;
  121761. /**
  121762. * Minimum floor to 'ceiling' height that will still allow the floor area to
  121763. * be considered walkable. [Limit: >= 3] [Units: vx]
  121764. */
  121765. walkableHeight: number;
  121766. /**
  121767. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  121768. */
  121769. walkableClimb: number;
  121770. /**
  121771. * The distance to erode/shrink the walkable area of the heightfield away from
  121772. * obstructions. [Limit: >=0] [Units: vx]
  121773. */
  121774. walkableRadius: number;
  121775. /**
  121776. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  121777. */
  121778. maxEdgeLen: number;
  121779. /**
  121780. * The maximum distance a simplfied contour's border edges should deviate
  121781. * the original raw contour. [Limit: >=0] [Units: vx]
  121782. */
  121783. maxSimplificationError: number;
  121784. /**
  121785. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  121786. */
  121787. minRegionArea: number;
  121788. /**
  121789. * Any regions with a span count smaller than this value will, if possible,
  121790. * be merged with larger regions. [Limit: >=0] [Units: vx]
  121791. */
  121792. mergeRegionArea: number;
  121793. /**
  121794. * The maximum number of vertices allowed for polygons generated during the
  121795. * contour to polygon conversion process. [Limit: >= 3]
  121796. */
  121797. maxVertsPerPoly: number;
  121798. /**
  121799. * Sets the sampling distance to use when generating the detail mesh.
  121800. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  121801. */
  121802. detailSampleDist: number;
  121803. /**
  121804. * The maximum distance the detail mesh surface should deviate from heightfield
  121805. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  121806. */
  121807. detailSampleMaxError: number;
  121808. }
  121809. }
  121810. declare module BABYLON {
  121811. /**
  121812. * RecastJS navigation plugin
  121813. */
  121814. export class RecastJSPlugin implements INavigationEnginePlugin {
  121815. /**
  121816. * Reference to the Recast library
  121817. */
  121818. bjsRECAST: any;
  121819. /**
  121820. * plugin name
  121821. */
  121822. name: string;
  121823. /**
  121824. * the first navmesh created. We might extend this to support multiple navmeshes
  121825. */
  121826. navMesh: any;
  121827. /**
  121828. * Initializes the recastJS plugin
  121829. * @param recastInjection can be used to inject your own recast reference
  121830. */
  121831. constructor(recastInjection?: any);
  121832. /**
  121833. * Creates a navigation mesh
  121834. * @param meshes array of all the geometry used to compute the navigatio mesh
  121835. * @param parameters bunch of parameters used to filter geometry
  121836. */
  121837. createMavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  121838. /**
  121839. * Create a navigation mesh debug mesh
  121840. * @param scene is where the mesh will be added
  121841. * @returns debug display mesh
  121842. */
  121843. createDebugNavMesh(scene: Scene): Mesh;
  121844. /**
  121845. * Get a navigation mesh constrained position, closest to the parameter position
  121846. * @param position world position
  121847. * @returns the closest point to position constrained by the navigation mesh
  121848. */
  121849. getClosestPoint(position: Vector3): Vector3;
  121850. /**
  121851. * Get a navigation mesh constrained position, within a particular radius
  121852. * @param position world position
  121853. * @param maxRadius the maximum distance to the constrained world position
  121854. * @returns the closest point to position constrained by the navigation mesh
  121855. */
  121856. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  121857. /**
  121858. * Compute the final position from a segment made of destination-position
  121859. * @param position world position
  121860. * @param destination world position
  121861. * @returns the resulting point along the navmesh
  121862. */
  121863. moveAlong(position: Vector3, destination: Vector3): Vector3;
  121864. /**
  121865. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  121866. * @param start world position
  121867. * @param end world position
  121868. * @returns array containing world position composing the path
  121869. */
  121870. computePath(start: Vector3, end: Vector3): Vector3[];
  121871. /**
  121872. * Create a new Crowd so you can add agents
  121873. * @param maxAgents the maximum agent count in the crowd
  121874. * @param maxAgentRadius the maximum radius an agent can have
  121875. * @param scene to attach the crowd to
  121876. * @returns the crowd you can add agents to
  121877. */
  121878. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  121879. /**
  121880. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  121881. * The queries will try to find a solution within those bounds
  121882. * default is (1,1,1)
  121883. * @param extent x,y,z value that define the extent around the queries point of reference
  121884. */
  121885. setDefaultQueryExtent(extent: Vector3): void;
  121886. /**
  121887. * Get the Bounding box extent specified by setDefaultQueryExtent
  121888. * @returns the box extent values
  121889. */
  121890. getDefaultQueryExtent(): Vector3;
  121891. /**
  121892. * Disposes
  121893. */
  121894. dispose(): void;
  121895. /**
  121896. * If this plugin is supported
  121897. * @returns true if plugin is supported
  121898. */
  121899. isSupported(): boolean;
  121900. }
  121901. /**
  121902. * Recast detour crowd implementation
  121903. */
  121904. export class RecastJSCrowd implements ICrowd {
  121905. /**
  121906. * Recast/detour plugin
  121907. */
  121908. bjsRECASTPlugin: RecastJSPlugin;
  121909. /**
  121910. * Link to the detour crowd
  121911. */
  121912. recastCrowd: any;
  121913. /**
  121914. * One transform per agent
  121915. */
  121916. transforms: TransformNode[];
  121917. /**
  121918. * All agents created
  121919. */
  121920. agents: number[];
  121921. /**
  121922. * Link to the scene is kept to unregister the crowd from the scene
  121923. */
  121924. private _scene;
  121925. /**
  121926. * Observer for crowd updates
  121927. */
  121928. private _onBeforeAnimationsObserver;
  121929. /**
  121930. * Constructor
  121931. * @param plugin recastJS plugin
  121932. * @param maxAgents the maximum agent count in the crowd
  121933. * @param maxAgentRadius the maximum radius an agent can have
  121934. * @param scene to attach the crowd to
  121935. * @returns the crowd you can add agents to
  121936. */
  121937. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  121938. /**
  121939. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  121940. * You can attach anything to that node. The node position is updated in the scene update tick.
  121941. * @param pos world position that will be constrained by the navigation mesh
  121942. * @param parameters agent parameters
  121943. * @param transform hooked to the agent that will be update by the scene
  121944. * @returns agent index
  121945. */
  121946. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  121947. /**
  121948. * Returns the agent position in world space
  121949. * @param index agent index returned by addAgent
  121950. * @returns world space position
  121951. */
  121952. getAgentPosition(index: number): Vector3;
  121953. /**
  121954. * Returns the agent velocity in world space
  121955. * @param index agent index returned by addAgent
  121956. * @returns world space velocity
  121957. */
  121958. getAgentVelocity(index: number): Vector3;
  121959. /**
  121960. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  121961. * @param index agent index returned by addAgent
  121962. * @param destination targeted world position
  121963. */
  121964. agentGoto(index: number, destination: Vector3): void;
  121965. /**
  121966. * remove a particular agent previously created
  121967. * @param index agent index returned by addAgent
  121968. */
  121969. removeAgent(index: number): void;
  121970. /**
  121971. * get the list of all agents attached to this crowd
  121972. * @returns list of agent indices
  121973. */
  121974. getAgents(): number[];
  121975. /**
  121976. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  121977. * @param deltaTime in seconds
  121978. */
  121979. update(deltaTime: number): void;
  121980. /**
  121981. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  121982. * The queries will try to find a solution within those bounds
  121983. * default is (1,1,1)
  121984. * @param extent x,y,z value that define the extent around the queries point of reference
  121985. */
  121986. setDefaultQueryExtent(extent: Vector3): void;
  121987. /**
  121988. * Get the Bounding box extent specified by setDefaultQueryExtent
  121989. * @returns the box extent values
  121990. */
  121991. getDefaultQueryExtent(): Vector3;
  121992. /**
  121993. * Release all resources
  121994. */
  121995. dispose(): void;
  121996. }
  121997. }
  121998. declare module BABYLON {
  121999. /**
  122000. * Class used to enable access to IndexedDB
  122001. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  122002. */
  122003. export class Database implements IOfflineProvider {
  122004. private _callbackManifestChecked;
  122005. private _currentSceneUrl;
  122006. private _db;
  122007. private _enableSceneOffline;
  122008. private _enableTexturesOffline;
  122009. private _manifestVersionFound;
  122010. private _mustUpdateRessources;
  122011. private _hasReachedQuota;
  122012. private _isSupported;
  122013. private _idbFactory;
  122014. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  122015. private static IsUASupportingBlobStorage;
  122016. /**
  122017. * Gets a boolean indicating if Database storate is enabled (off by default)
  122018. */
  122019. static IDBStorageEnabled: boolean;
  122020. /**
  122021. * Gets a boolean indicating if scene must be saved in the database
  122022. */
  122023. readonly enableSceneOffline: boolean;
  122024. /**
  122025. * Gets a boolean indicating if textures must be saved in the database
  122026. */
  122027. readonly enableTexturesOffline: boolean;
  122028. /**
  122029. * Creates a new Database
  122030. * @param urlToScene defines the url to load the scene
  122031. * @param callbackManifestChecked defines the callback to use when manifest is checked
  122032. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  122033. */
  122034. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  122035. private static _ParseURL;
  122036. private static _ReturnFullUrlLocation;
  122037. private _checkManifestFile;
  122038. /**
  122039. * Open the database and make it available
  122040. * @param successCallback defines the callback to call on success
  122041. * @param errorCallback defines the callback to call on error
  122042. */
  122043. open(successCallback: () => void, errorCallback: () => void): void;
  122044. /**
  122045. * Loads an image from the database
  122046. * @param url defines the url to load from
  122047. * @param image defines the target DOM image
  122048. */
  122049. loadImage(url: string, image: HTMLImageElement): void;
  122050. private _loadImageFromDBAsync;
  122051. private _saveImageIntoDBAsync;
  122052. private _checkVersionFromDB;
  122053. private _loadVersionFromDBAsync;
  122054. private _saveVersionIntoDBAsync;
  122055. /**
  122056. * Loads a file from database
  122057. * @param url defines the URL to load from
  122058. * @param sceneLoaded defines a callback to call on success
  122059. * @param progressCallBack defines a callback to call when progress changed
  122060. * @param errorCallback defines a callback to call on error
  122061. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  122062. */
  122063. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  122064. private _loadFileAsync;
  122065. private _saveFileAsync;
  122066. /**
  122067. * Validates if xhr data is correct
  122068. * @param xhr defines the request to validate
  122069. * @param dataType defines the expected data type
  122070. * @returns true if data is correct
  122071. */
  122072. private static _ValidateXHRData;
  122073. }
  122074. }
  122075. declare module BABYLON {
  122076. /** @hidden */
  122077. export var gpuUpdateParticlesPixelShader: {
  122078. name: string;
  122079. shader: string;
  122080. };
  122081. }
  122082. declare module BABYLON {
  122083. /** @hidden */
  122084. export var gpuUpdateParticlesVertexShader: {
  122085. name: string;
  122086. shader: string;
  122087. };
  122088. }
  122089. declare module BABYLON {
  122090. /** @hidden */
  122091. export var clipPlaneFragmentDeclaration2: {
  122092. name: string;
  122093. shader: string;
  122094. };
  122095. }
  122096. declare module BABYLON {
  122097. /** @hidden */
  122098. export var gpuRenderParticlesPixelShader: {
  122099. name: string;
  122100. shader: string;
  122101. };
  122102. }
  122103. declare module BABYLON {
  122104. /** @hidden */
  122105. export var clipPlaneVertexDeclaration2: {
  122106. name: string;
  122107. shader: string;
  122108. };
  122109. }
  122110. declare module BABYLON {
  122111. /** @hidden */
  122112. export var gpuRenderParticlesVertexShader: {
  122113. name: string;
  122114. shader: string;
  122115. };
  122116. }
  122117. declare module BABYLON {
  122118. /**
  122119. * This represents a GPU particle system in Babylon
  122120. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  122121. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  122122. */
  122123. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  122124. /**
  122125. * The layer mask we are rendering the particles through.
  122126. */
  122127. layerMask: number;
  122128. private _capacity;
  122129. private _activeCount;
  122130. private _currentActiveCount;
  122131. private _accumulatedCount;
  122132. private _renderEffect;
  122133. private _updateEffect;
  122134. private _buffer0;
  122135. private _buffer1;
  122136. private _spriteBuffer;
  122137. private _updateVAO;
  122138. private _renderVAO;
  122139. private _targetIndex;
  122140. private _sourceBuffer;
  122141. private _targetBuffer;
  122142. private _engine;
  122143. private _currentRenderId;
  122144. private _started;
  122145. private _stopped;
  122146. private _timeDelta;
  122147. private _randomTexture;
  122148. private _randomTexture2;
  122149. private _attributesStrideSize;
  122150. private _updateEffectOptions;
  122151. private _randomTextureSize;
  122152. private _actualFrame;
  122153. private readonly _rawTextureWidth;
  122154. /**
  122155. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  122156. */
  122157. static readonly IsSupported: boolean;
  122158. /**
  122159. * An event triggered when the system is disposed.
  122160. */
  122161. onDisposeObservable: Observable<GPUParticleSystem>;
  122162. /**
  122163. * Gets the maximum number of particles active at the same time.
  122164. * @returns The max number of active particles.
  122165. */
  122166. getCapacity(): number;
  122167. /**
  122168. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  122169. * to override the particles.
  122170. */
  122171. forceDepthWrite: boolean;
  122172. /**
  122173. * Gets or set the number of active particles
  122174. */
  122175. activeParticleCount: number;
  122176. private _preWarmDone;
  122177. /**
  122178. * Is this system ready to be used/rendered
  122179. * @return true if the system is ready
  122180. */
  122181. isReady(): boolean;
  122182. /**
  122183. * Gets if the system has been started. (Note: this will still be true after stop is called)
  122184. * @returns True if it has been started, otherwise false.
  122185. */
  122186. isStarted(): boolean;
  122187. /**
  122188. * Starts the particle system and begins to emit
  122189. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  122190. */
  122191. start(delay?: number): void;
  122192. /**
  122193. * Stops the particle system.
  122194. */
  122195. stop(): void;
  122196. /**
  122197. * Remove all active particles
  122198. */
  122199. reset(): void;
  122200. /**
  122201. * Returns the string "GPUParticleSystem"
  122202. * @returns a string containing the class name
  122203. */
  122204. getClassName(): string;
  122205. private _colorGradientsTexture;
  122206. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  122207. /**
  122208. * Adds a new color gradient
  122209. * @param gradient defines the gradient to use (between 0 and 1)
  122210. * @param color1 defines the color to affect to the specified gradient
  122211. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  122212. * @returns the current particle system
  122213. */
  122214. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  122215. /**
  122216. * Remove a specific color gradient
  122217. * @param gradient defines the gradient to remove
  122218. * @returns the current particle system
  122219. */
  122220. removeColorGradient(gradient: number): GPUParticleSystem;
  122221. private _angularSpeedGradientsTexture;
  122222. private _sizeGradientsTexture;
  122223. private _velocityGradientsTexture;
  122224. private _limitVelocityGradientsTexture;
  122225. private _dragGradientsTexture;
  122226. private _addFactorGradient;
  122227. /**
  122228. * Adds a new size gradient
  122229. * @param gradient defines the gradient to use (between 0 and 1)
  122230. * @param factor defines the size factor to affect to the specified gradient
  122231. * @returns the current particle system
  122232. */
  122233. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  122234. /**
  122235. * Remove a specific size gradient
  122236. * @param gradient defines the gradient to remove
  122237. * @returns the current particle system
  122238. */
  122239. removeSizeGradient(gradient: number): GPUParticleSystem;
  122240. /**
  122241. * Adds a new angular speed gradient
  122242. * @param gradient defines the gradient to use (between 0 and 1)
  122243. * @param factor defines the angular speed to affect to the specified gradient
  122244. * @returns the current particle system
  122245. */
  122246. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  122247. /**
  122248. * Remove a specific angular speed gradient
  122249. * @param gradient defines the gradient to remove
  122250. * @returns the current particle system
  122251. */
  122252. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  122253. /**
  122254. * Adds a new velocity gradient
  122255. * @param gradient defines the gradient to use (between 0 and 1)
  122256. * @param factor defines the velocity to affect to the specified gradient
  122257. * @returns the current particle system
  122258. */
  122259. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  122260. /**
  122261. * Remove a specific velocity gradient
  122262. * @param gradient defines the gradient to remove
  122263. * @returns the current particle system
  122264. */
  122265. removeVelocityGradient(gradient: number): GPUParticleSystem;
  122266. /**
  122267. * Adds a new limit velocity gradient
  122268. * @param gradient defines the gradient to use (between 0 and 1)
  122269. * @param factor defines the limit velocity value to affect to the specified gradient
  122270. * @returns the current particle system
  122271. */
  122272. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  122273. /**
  122274. * Remove a specific limit velocity gradient
  122275. * @param gradient defines the gradient to remove
  122276. * @returns the current particle system
  122277. */
  122278. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  122279. /**
  122280. * Adds a new drag gradient
  122281. * @param gradient defines the gradient to use (between 0 and 1)
  122282. * @param factor defines the drag value to affect to the specified gradient
  122283. * @returns the current particle system
  122284. */
  122285. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  122286. /**
  122287. * Remove a specific drag gradient
  122288. * @param gradient defines the gradient to remove
  122289. * @returns the current particle system
  122290. */
  122291. removeDragGradient(gradient: number): GPUParticleSystem;
  122292. /**
  122293. * Not supported by GPUParticleSystem
  122294. * @param gradient defines the gradient to use (between 0 and 1)
  122295. * @param factor defines the emit rate value to affect to the specified gradient
  122296. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  122297. * @returns the current particle system
  122298. */
  122299. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  122300. /**
  122301. * Not supported by GPUParticleSystem
  122302. * @param gradient defines the gradient to remove
  122303. * @returns the current particle system
  122304. */
  122305. removeEmitRateGradient(gradient: number): IParticleSystem;
  122306. /**
  122307. * Not supported by GPUParticleSystem
  122308. * @param gradient defines the gradient to use (between 0 and 1)
  122309. * @param factor defines the start size value to affect to the specified gradient
  122310. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  122311. * @returns the current particle system
  122312. */
  122313. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  122314. /**
  122315. * Not supported by GPUParticleSystem
  122316. * @param gradient defines the gradient to remove
  122317. * @returns the current particle system
  122318. */
  122319. removeStartSizeGradient(gradient: number): IParticleSystem;
  122320. /**
  122321. * Not supported by GPUParticleSystem
  122322. * @param gradient defines the gradient to use (between 0 and 1)
  122323. * @param min defines the color remap minimal range
  122324. * @param max defines the color remap maximal range
  122325. * @returns the current particle system
  122326. */
  122327. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  122328. /**
  122329. * Not supported by GPUParticleSystem
  122330. * @param gradient defines the gradient to remove
  122331. * @returns the current particle system
  122332. */
  122333. removeColorRemapGradient(): IParticleSystem;
  122334. /**
  122335. * Not supported by GPUParticleSystem
  122336. * @param gradient defines the gradient to use (between 0 and 1)
  122337. * @param min defines the alpha remap minimal range
  122338. * @param max defines the alpha remap maximal range
  122339. * @returns the current particle system
  122340. */
  122341. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  122342. /**
  122343. * Not supported by GPUParticleSystem
  122344. * @param gradient defines the gradient to remove
  122345. * @returns the current particle system
  122346. */
  122347. removeAlphaRemapGradient(): IParticleSystem;
  122348. /**
  122349. * Not supported by GPUParticleSystem
  122350. * @param gradient defines the gradient to use (between 0 and 1)
  122351. * @param color defines the color to affect to the specified gradient
  122352. * @returns the current particle system
  122353. */
  122354. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  122355. /**
  122356. * Not supported by GPUParticleSystem
  122357. * @param gradient defines the gradient to remove
  122358. * @returns the current particle system
  122359. */
  122360. removeRampGradient(): IParticleSystem;
  122361. /**
  122362. * Not supported by GPUParticleSystem
  122363. * @returns the list of ramp gradients
  122364. */
  122365. getRampGradients(): Nullable<Array<Color3Gradient>>;
  122366. /**
  122367. * Not supported by GPUParticleSystem
  122368. * Gets or sets a boolean indicating that ramp gradients must be used
  122369. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  122370. */
  122371. useRampGradients: boolean;
  122372. /**
  122373. * Not supported by GPUParticleSystem
  122374. * @param gradient defines the gradient to use (between 0 and 1)
  122375. * @param factor defines the life time factor to affect to the specified gradient
  122376. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  122377. * @returns the current particle system
  122378. */
  122379. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  122380. /**
  122381. * Not supported by GPUParticleSystem
  122382. * @param gradient defines the gradient to remove
  122383. * @returns the current particle system
  122384. */
  122385. removeLifeTimeGradient(gradient: number): IParticleSystem;
  122386. /**
  122387. * Instantiates a GPU particle system.
  122388. * 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.
  122389. * @param name The name of the particle system
  122390. * @param options The options used to create the system
  122391. * @param scene The scene the particle system belongs to
  122392. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  122393. */
  122394. constructor(name: string, options: Partial<{
  122395. capacity: number;
  122396. randomTextureSize: number;
  122397. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  122398. protected _reset(): void;
  122399. private _createUpdateVAO;
  122400. private _createRenderVAO;
  122401. private _initialize;
  122402. /** @hidden */
  122403. _recreateUpdateEffect(): void;
  122404. /** @hidden */
  122405. _recreateRenderEffect(): void;
  122406. /**
  122407. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  122408. * @param preWarm defines if we are in the pre-warmimg phase
  122409. */
  122410. animate(preWarm?: boolean): void;
  122411. private _createFactorGradientTexture;
  122412. private _createSizeGradientTexture;
  122413. private _createAngularSpeedGradientTexture;
  122414. private _createVelocityGradientTexture;
  122415. private _createLimitVelocityGradientTexture;
  122416. private _createDragGradientTexture;
  122417. private _createColorGradientTexture;
  122418. /**
  122419. * Renders the particle system in its current state
  122420. * @param preWarm defines if the system should only update the particles but not render them
  122421. * @returns the current number of particles
  122422. */
  122423. render(preWarm?: boolean): number;
  122424. /**
  122425. * Rebuilds the particle system
  122426. */
  122427. rebuild(): void;
  122428. private _releaseBuffers;
  122429. private _releaseVAOs;
  122430. /**
  122431. * Disposes the particle system and free the associated resources
  122432. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  122433. */
  122434. dispose(disposeTexture?: boolean): void;
  122435. /**
  122436. * Clones the particle system.
  122437. * @param name The name of the cloned object
  122438. * @param newEmitter The new emitter to use
  122439. * @returns the cloned particle system
  122440. */
  122441. clone(name: string, newEmitter: any): GPUParticleSystem;
  122442. /**
  122443. * Serializes the particle system to a JSON object.
  122444. * @returns the JSON object
  122445. */
  122446. serialize(): any;
  122447. /**
  122448. * Parses a JSON object to create a GPU particle system.
  122449. * @param parsedParticleSystem The JSON object to parse
  122450. * @param scene The scene to create the particle system in
  122451. * @param rootUrl The root url to use to load external dependencies like texture
  122452. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  122453. * @returns the parsed GPU particle system
  122454. */
  122455. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  122456. }
  122457. }
  122458. declare module BABYLON {
  122459. /**
  122460. * Represents a set of particle systems working together to create a specific effect
  122461. */
  122462. export class ParticleSystemSet implements IDisposable {
  122463. private _emitterCreationOptions;
  122464. private _emitterNode;
  122465. /**
  122466. * Gets the particle system list
  122467. */
  122468. systems: IParticleSystem[];
  122469. /**
  122470. * Gets the emitter node used with this set
  122471. */
  122472. readonly emitterNode: Nullable<TransformNode>;
  122473. /**
  122474. * Creates a new emitter mesh as a sphere
  122475. * @param options defines the options used to create the sphere
  122476. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  122477. * @param scene defines the hosting scene
  122478. */
  122479. setEmitterAsSphere(options: {
  122480. diameter: number;
  122481. segments: number;
  122482. color: Color3;
  122483. }, renderingGroupId: number, scene: Scene): void;
  122484. /**
  122485. * Starts all particle systems of the set
  122486. * @param emitter defines an optional mesh to use as emitter for the particle systems
  122487. */
  122488. start(emitter?: AbstractMesh): void;
  122489. /**
  122490. * Release all associated resources
  122491. */
  122492. dispose(): void;
  122493. /**
  122494. * Serialize the set into a JSON compatible object
  122495. * @returns a JSON compatible representation of the set
  122496. */
  122497. serialize(): any;
  122498. /**
  122499. * Parse a new ParticleSystemSet from a serialized source
  122500. * @param data defines a JSON compatible representation of the set
  122501. * @param scene defines the hosting scene
  122502. * @param gpu defines if we want GPU particles or CPU particles
  122503. * @returns a new ParticleSystemSet
  122504. */
  122505. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  122506. }
  122507. }
  122508. declare module BABYLON {
  122509. /**
  122510. * This class is made for on one-liner static method to help creating particle system set.
  122511. */
  122512. export class ParticleHelper {
  122513. /**
  122514. * Gets or sets base Assets URL
  122515. */
  122516. static BaseAssetsUrl: string;
  122517. /**
  122518. * Create a default particle system that you can tweak
  122519. * @param emitter defines the emitter to use
  122520. * @param capacity defines the system capacity (default is 500 particles)
  122521. * @param scene defines the hosting scene
  122522. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  122523. * @returns the new Particle system
  122524. */
  122525. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  122526. /**
  122527. * This is the main static method (one-liner) of this helper to create different particle systems
  122528. * @param type This string represents the type to the particle system to create
  122529. * @param scene The scene where the particle system should live
  122530. * @param gpu If the system will use gpu
  122531. * @returns the ParticleSystemSet created
  122532. */
  122533. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  122534. /**
  122535. * Static function used to export a particle system to a ParticleSystemSet variable.
  122536. * Please note that the emitter shape is not exported
  122537. * @param systems defines the particle systems to export
  122538. * @returns the created particle system set
  122539. */
  122540. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  122541. }
  122542. }
  122543. declare module BABYLON {
  122544. interface Engine {
  122545. /**
  122546. * Create an effect to use with particle systems.
  122547. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  122548. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  122549. * @param uniformsNames defines a list of attribute names
  122550. * @param samplers defines an array of string used to represent textures
  122551. * @param defines defines the string containing the defines to use to compile the shaders
  122552. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  122553. * @param onCompiled defines a function to call when the effect creation is successful
  122554. * @param onError defines a function to call when the effect creation has failed
  122555. * @returns the new Effect
  122556. */
  122557. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  122558. }
  122559. interface Mesh {
  122560. /**
  122561. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  122562. * @returns an array of IParticleSystem
  122563. */
  122564. getEmittedParticleSystems(): IParticleSystem[];
  122565. /**
  122566. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  122567. * @returns an array of IParticleSystem
  122568. */
  122569. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  122570. }
  122571. /**
  122572. * @hidden
  122573. */
  122574. export var _IDoNeedToBeInTheBuild: number;
  122575. }
  122576. declare module BABYLON {
  122577. interface Scene {
  122578. /** @hidden (Backing field) */
  122579. _physicsEngine: Nullable<IPhysicsEngine>;
  122580. /**
  122581. * Gets the current physics engine
  122582. * @returns a IPhysicsEngine or null if none attached
  122583. */
  122584. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  122585. /**
  122586. * Enables physics to the current scene
  122587. * @param gravity defines the scene's gravity for the physics engine
  122588. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  122589. * @return a boolean indicating if the physics engine was initialized
  122590. */
  122591. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  122592. /**
  122593. * Disables and disposes the physics engine associated with the scene
  122594. */
  122595. disablePhysicsEngine(): void;
  122596. /**
  122597. * Gets a boolean indicating if there is an active physics engine
  122598. * @returns a boolean indicating if there is an active physics engine
  122599. */
  122600. isPhysicsEnabled(): boolean;
  122601. /**
  122602. * Deletes a physics compound impostor
  122603. * @param compound defines the compound to delete
  122604. */
  122605. deleteCompoundImpostor(compound: any): void;
  122606. /**
  122607. * An event triggered when physic simulation is about to be run
  122608. */
  122609. onBeforePhysicsObservable: Observable<Scene>;
  122610. /**
  122611. * An event triggered when physic simulation has been done
  122612. */
  122613. onAfterPhysicsObservable: Observable<Scene>;
  122614. }
  122615. interface AbstractMesh {
  122616. /** @hidden */
  122617. _physicsImpostor: Nullable<PhysicsImpostor>;
  122618. /**
  122619. * Gets or sets impostor used for physic simulation
  122620. * @see http://doc.babylonjs.com/features/physics_engine
  122621. */
  122622. physicsImpostor: Nullable<PhysicsImpostor>;
  122623. /**
  122624. * Gets the current physics impostor
  122625. * @see http://doc.babylonjs.com/features/physics_engine
  122626. * @returns a physics impostor or null
  122627. */
  122628. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  122629. /** Apply a physic impulse to the mesh
  122630. * @param force defines the force to apply
  122631. * @param contactPoint defines where to apply the force
  122632. * @returns the current mesh
  122633. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  122634. */
  122635. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  122636. /**
  122637. * Creates a physic joint between two meshes
  122638. * @param otherMesh defines the other mesh to use
  122639. * @param pivot1 defines the pivot to use on this mesh
  122640. * @param pivot2 defines the pivot to use on the other mesh
  122641. * @param options defines additional options (can be plugin dependent)
  122642. * @returns the current mesh
  122643. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  122644. */
  122645. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  122646. /** @hidden */
  122647. _disposePhysicsObserver: Nullable<Observer<Node>>;
  122648. }
  122649. /**
  122650. * Defines the physics engine scene component responsible to manage a physics engine
  122651. */
  122652. export class PhysicsEngineSceneComponent implements ISceneComponent {
  122653. /**
  122654. * The component name helpful to identify the component in the list of scene components.
  122655. */
  122656. readonly name: string;
  122657. /**
  122658. * The scene the component belongs to.
  122659. */
  122660. scene: Scene;
  122661. /**
  122662. * Creates a new instance of the component for the given scene
  122663. * @param scene Defines the scene to register the component in
  122664. */
  122665. constructor(scene: Scene);
  122666. /**
  122667. * Registers the component in a given scene
  122668. */
  122669. register(): void;
  122670. /**
  122671. * Rebuilds the elements related to this component in case of
  122672. * context lost for instance.
  122673. */
  122674. rebuild(): void;
  122675. /**
  122676. * Disposes the component and the associated ressources
  122677. */
  122678. dispose(): void;
  122679. }
  122680. }
  122681. declare module BABYLON {
  122682. /**
  122683. * A helper for physics simulations
  122684. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  122685. */
  122686. export class PhysicsHelper {
  122687. private _scene;
  122688. private _physicsEngine;
  122689. /**
  122690. * Initializes the Physics helper
  122691. * @param scene Babylon.js scene
  122692. */
  122693. constructor(scene: Scene);
  122694. /**
  122695. * Applies a radial explosion impulse
  122696. * @param origin the origin of the explosion
  122697. * @param radiusOrEventOptions the radius or the options of radial explosion
  122698. * @param strength the explosion strength
  122699. * @param falloff possible options: Constant & Linear. Defaults to Constant
  122700. * @returns A physics radial explosion event, or null
  122701. */
  122702. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  122703. /**
  122704. * Applies a radial explosion force
  122705. * @param origin the origin of the explosion
  122706. * @param radiusOrEventOptions the radius or the options of radial explosion
  122707. * @param strength the explosion strength
  122708. * @param falloff possible options: Constant & Linear. Defaults to Constant
  122709. * @returns A physics radial explosion event, or null
  122710. */
  122711. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  122712. /**
  122713. * Creates a gravitational field
  122714. * @param origin the origin of the explosion
  122715. * @param radiusOrEventOptions the radius or the options of radial explosion
  122716. * @param strength the explosion strength
  122717. * @param falloff possible options: Constant & Linear. Defaults to Constant
  122718. * @returns A physics gravitational field event, or null
  122719. */
  122720. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  122721. /**
  122722. * Creates a physics updraft event
  122723. * @param origin the origin of the updraft
  122724. * @param radiusOrEventOptions the radius or the options of the updraft
  122725. * @param strength the strength of the updraft
  122726. * @param height the height of the updraft
  122727. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  122728. * @returns A physics updraft event, or null
  122729. */
  122730. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  122731. /**
  122732. * Creates a physics vortex event
  122733. * @param origin the of the vortex
  122734. * @param radiusOrEventOptions the radius or the options of the vortex
  122735. * @param strength the strength of the vortex
  122736. * @param height the height of the vortex
  122737. * @returns a Physics vortex event, or null
  122738. * A physics vortex event or null
  122739. */
  122740. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  122741. }
  122742. /**
  122743. * Represents a physics radial explosion event
  122744. */
  122745. class PhysicsRadialExplosionEvent {
  122746. private _scene;
  122747. private _options;
  122748. private _sphere;
  122749. private _dataFetched;
  122750. /**
  122751. * Initializes a radial explosioin event
  122752. * @param _scene BabylonJS scene
  122753. * @param _options The options for the vortex event
  122754. */
  122755. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  122756. /**
  122757. * Returns the data related to the radial explosion event (sphere).
  122758. * @returns The radial explosion event data
  122759. */
  122760. getData(): PhysicsRadialExplosionEventData;
  122761. /**
  122762. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  122763. * @param impostor A physics imposter
  122764. * @param origin the origin of the explosion
  122765. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  122766. */
  122767. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  122768. /**
  122769. * Triggers affecterd impostors callbacks
  122770. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  122771. */
  122772. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  122773. /**
  122774. * Disposes the sphere.
  122775. * @param force Specifies if the sphere should be disposed by force
  122776. */
  122777. dispose(force?: boolean): void;
  122778. /*** Helpers ***/
  122779. private _prepareSphere;
  122780. private _intersectsWithSphere;
  122781. }
  122782. /**
  122783. * Represents a gravitational field event
  122784. */
  122785. class PhysicsGravitationalFieldEvent {
  122786. private _physicsHelper;
  122787. private _scene;
  122788. private _origin;
  122789. private _options;
  122790. private _tickCallback;
  122791. private _sphere;
  122792. private _dataFetched;
  122793. /**
  122794. * Initializes the physics gravitational field event
  122795. * @param _physicsHelper A physics helper
  122796. * @param _scene BabylonJS scene
  122797. * @param _origin The origin position of the gravitational field event
  122798. * @param _options The options for the vortex event
  122799. */
  122800. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  122801. /**
  122802. * Returns the data related to the gravitational field event (sphere).
  122803. * @returns A gravitational field event
  122804. */
  122805. getData(): PhysicsGravitationalFieldEventData;
  122806. /**
  122807. * Enables the gravitational field.
  122808. */
  122809. enable(): void;
  122810. /**
  122811. * Disables the gravitational field.
  122812. */
  122813. disable(): void;
  122814. /**
  122815. * Disposes the sphere.
  122816. * @param force The force to dispose from the gravitational field event
  122817. */
  122818. dispose(force?: boolean): void;
  122819. private _tick;
  122820. }
  122821. /**
  122822. * Represents a physics updraft event
  122823. */
  122824. class PhysicsUpdraftEvent {
  122825. private _scene;
  122826. private _origin;
  122827. private _options;
  122828. private _physicsEngine;
  122829. private _originTop;
  122830. private _originDirection;
  122831. private _tickCallback;
  122832. private _cylinder;
  122833. private _cylinderPosition;
  122834. private _dataFetched;
  122835. /**
  122836. * Initializes the physics updraft event
  122837. * @param _scene BabylonJS scene
  122838. * @param _origin The origin position of the updraft
  122839. * @param _options The options for the updraft event
  122840. */
  122841. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  122842. /**
  122843. * Returns the data related to the updraft event (cylinder).
  122844. * @returns A physics updraft event
  122845. */
  122846. getData(): PhysicsUpdraftEventData;
  122847. /**
  122848. * Enables the updraft.
  122849. */
  122850. enable(): void;
  122851. /**
  122852. * Disables the updraft.
  122853. */
  122854. disable(): void;
  122855. /**
  122856. * Disposes the cylinder.
  122857. * @param force Specifies if the updraft should be disposed by force
  122858. */
  122859. dispose(force?: boolean): void;
  122860. private getImpostorHitData;
  122861. private _tick;
  122862. /*** Helpers ***/
  122863. private _prepareCylinder;
  122864. private _intersectsWithCylinder;
  122865. }
  122866. /**
  122867. * Represents a physics vortex event
  122868. */
  122869. class PhysicsVortexEvent {
  122870. private _scene;
  122871. private _origin;
  122872. private _options;
  122873. private _physicsEngine;
  122874. private _originTop;
  122875. private _tickCallback;
  122876. private _cylinder;
  122877. private _cylinderPosition;
  122878. private _dataFetched;
  122879. /**
  122880. * Initializes the physics vortex event
  122881. * @param _scene The BabylonJS scene
  122882. * @param _origin The origin position of the vortex
  122883. * @param _options The options for the vortex event
  122884. */
  122885. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  122886. /**
  122887. * Returns the data related to the vortex event (cylinder).
  122888. * @returns The physics vortex event data
  122889. */
  122890. getData(): PhysicsVortexEventData;
  122891. /**
  122892. * Enables the vortex.
  122893. */
  122894. enable(): void;
  122895. /**
  122896. * Disables the cortex.
  122897. */
  122898. disable(): void;
  122899. /**
  122900. * Disposes the sphere.
  122901. * @param force
  122902. */
  122903. dispose(force?: boolean): void;
  122904. private getImpostorHitData;
  122905. private _tick;
  122906. /*** Helpers ***/
  122907. private _prepareCylinder;
  122908. private _intersectsWithCylinder;
  122909. }
  122910. /**
  122911. * Options fot the radial explosion event
  122912. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  122913. */
  122914. export class PhysicsRadialExplosionEventOptions {
  122915. /**
  122916. * The radius of the sphere for the radial explosion.
  122917. */
  122918. radius: number;
  122919. /**
  122920. * The strenth of the explosion.
  122921. */
  122922. strength: number;
  122923. /**
  122924. * The strenght of the force in correspondence to the distance of the affected object
  122925. */
  122926. falloff: PhysicsRadialImpulseFalloff;
  122927. /**
  122928. * Sphere options for the radial explosion.
  122929. */
  122930. sphere: {
  122931. segments: number;
  122932. diameter: number;
  122933. };
  122934. /**
  122935. * Sphere options for the radial explosion.
  122936. */
  122937. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  122938. }
  122939. /**
  122940. * Options fot the updraft event
  122941. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  122942. */
  122943. export class PhysicsUpdraftEventOptions {
  122944. /**
  122945. * The radius of the cylinder for the vortex
  122946. */
  122947. radius: number;
  122948. /**
  122949. * The strenth of the updraft.
  122950. */
  122951. strength: number;
  122952. /**
  122953. * The height of the cylinder for the updraft.
  122954. */
  122955. height: number;
  122956. /**
  122957. * The mode for the the updraft.
  122958. */
  122959. updraftMode: PhysicsUpdraftMode;
  122960. }
  122961. /**
  122962. * Options fot the vortex event
  122963. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  122964. */
  122965. export class PhysicsVortexEventOptions {
  122966. /**
  122967. * The radius of the cylinder for the vortex
  122968. */
  122969. radius: number;
  122970. /**
  122971. * The strenth of the vortex.
  122972. */
  122973. strength: number;
  122974. /**
  122975. * The height of the cylinder for the vortex.
  122976. */
  122977. height: number;
  122978. /**
  122979. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  122980. */
  122981. centripetalForceThreshold: number;
  122982. /**
  122983. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  122984. */
  122985. centripetalForceMultiplier: number;
  122986. /**
  122987. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  122988. */
  122989. centrifugalForceMultiplier: number;
  122990. /**
  122991. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  122992. */
  122993. updraftForceMultiplier: number;
  122994. }
  122995. /**
  122996. * The strenght of the force in correspondence to the distance of the affected object
  122997. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  122998. */
  122999. export enum PhysicsRadialImpulseFalloff {
  123000. /** Defines that impulse is constant in strength across it's whole radius */
  123001. Constant = 0,
  123002. /** Defines that impulse gets weaker if it's further from the origin */
  123003. Linear = 1
  123004. }
  123005. /**
  123006. * The strength of the force in correspondence to the distance of the affected object
  123007. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  123008. */
  123009. export enum PhysicsUpdraftMode {
  123010. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  123011. Center = 0,
  123012. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  123013. Perpendicular = 1
  123014. }
  123015. /**
  123016. * Interface for a physics hit data
  123017. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  123018. */
  123019. export interface PhysicsHitData {
  123020. /**
  123021. * The force applied at the contact point
  123022. */
  123023. force: Vector3;
  123024. /**
  123025. * The contact point
  123026. */
  123027. contactPoint: Vector3;
  123028. /**
  123029. * The distance from the origin to the contact point
  123030. */
  123031. distanceFromOrigin: number;
  123032. }
  123033. /**
  123034. * Interface for radial explosion event data
  123035. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  123036. */
  123037. export interface PhysicsRadialExplosionEventData {
  123038. /**
  123039. * A sphere used for the radial explosion event
  123040. */
  123041. sphere: Mesh;
  123042. }
  123043. /**
  123044. * Interface for gravitational field event data
  123045. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  123046. */
  123047. export interface PhysicsGravitationalFieldEventData {
  123048. /**
  123049. * A sphere mesh used for the gravitational field event
  123050. */
  123051. sphere: Mesh;
  123052. }
  123053. /**
  123054. * Interface for updraft event data
  123055. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  123056. */
  123057. export interface PhysicsUpdraftEventData {
  123058. /**
  123059. * A cylinder used for the updraft event
  123060. */
  123061. cylinder: Mesh;
  123062. }
  123063. /**
  123064. * Interface for vortex event data
  123065. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  123066. */
  123067. export interface PhysicsVortexEventData {
  123068. /**
  123069. * A cylinder used for the vortex event
  123070. */
  123071. cylinder: Mesh;
  123072. }
  123073. /**
  123074. * Interface for an affected physics impostor
  123075. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  123076. */
  123077. export interface PhysicsAffectedImpostorWithData {
  123078. /**
  123079. * The impostor affected by the effect
  123080. */
  123081. impostor: PhysicsImpostor;
  123082. /**
  123083. * The data about the hit/horce from the explosion
  123084. */
  123085. hitData: PhysicsHitData;
  123086. }
  123087. }
  123088. declare module BABYLON {
  123089. /** @hidden */
  123090. export var blackAndWhitePixelShader: {
  123091. name: string;
  123092. shader: string;
  123093. };
  123094. }
  123095. declare module BABYLON {
  123096. /**
  123097. * Post process used to render in black and white
  123098. */
  123099. export class BlackAndWhitePostProcess extends PostProcess {
  123100. /**
  123101. * Linear about to convert he result to black and white (default: 1)
  123102. */
  123103. degree: number;
  123104. /**
  123105. * Creates a black and white post process
  123106. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  123107. * @param name The name of the effect.
  123108. * @param options The required width/height ratio to downsize to before computing the render pass.
  123109. * @param camera The camera to apply the render pass to.
  123110. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  123111. * @param engine The engine which the post process will be applied. (default: current engine)
  123112. * @param reusable If the post process can be reused on the same frame. (default: false)
  123113. */
  123114. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  123115. }
  123116. }
  123117. declare module BABYLON {
  123118. /**
  123119. * This represents a set of one or more post processes in Babylon.
  123120. * A post process can be used to apply a shader to a texture after it is rendered.
  123121. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  123122. */
  123123. export class PostProcessRenderEffect {
  123124. private _postProcesses;
  123125. private _getPostProcesses;
  123126. private _singleInstance;
  123127. private _cameras;
  123128. private _indicesForCamera;
  123129. /**
  123130. * Name of the effect
  123131. * @hidden
  123132. */
  123133. _name: string;
  123134. /**
  123135. * Instantiates a post process render effect.
  123136. * A post process can be used to apply a shader to a texture after it is rendered.
  123137. * @param engine The engine the effect is tied to
  123138. * @param name The name of the effect
  123139. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  123140. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  123141. */
  123142. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  123143. /**
  123144. * Checks if all the post processes in the effect are supported.
  123145. */
  123146. readonly isSupported: boolean;
  123147. /**
  123148. * Updates the current state of the effect
  123149. * @hidden
  123150. */
  123151. _update(): void;
  123152. /**
  123153. * Attaches the effect on cameras
  123154. * @param cameras The camera to attach to.
  123155. * @hidden
  123156. */
  123157. _attachCameras(cameras: Camera): void;
  123158. /**
  123159. * Attaches the effect on cameras
  123160. * @param cameras The camera to attach to.
  123161. * @hidden
  123162. */
  123163. _attachCameras(cameras: Camera[]): void;
  123164. /**
  123165. * Detaches the effect on cameras
  123166. * @param cameras The camera to detatch from.
  123167. * @hidden
  123168. */
  123169. _detachCameras(cameras: Camera): void;
  123170. /**
  123171. * Detatches the effect on cameras
  123172. * @param cameras The camera to detatch from.
  123173. * @hidden
  123174. */
  123175. _detachCameras(cameras: Camera[]): void;
  123176. /**
  123177. * Enables the effect on given cameras
  123178. * @param cameras The camera to enable.
  123179. * @hidden
  123180. */
  123181. _enable(cameras: Camera): void;
  123182. /**
  123183. * Enables the effect on given cameras
  123184. * @param cameras The camera to enable.
  123185. * @hidden
  123186. */
  123187. _enable(cameras: Nullable<Camera[]>): void;
  123188. /**
  123189. * Disables the effect on the given cameras
  123190. * @param cameras The camera to disable.
  123191. * @hidden
  123192. */
  123193. _disable(cameras: Camera): void;
  123194. /**
  123195. * Disables the effect on the given cameras
  123196. * @param cameras The camera to disable.
  123197. * @hidden
  123198. */
  123199. _disable(cameras: Nullable<Camera[]>): void;
  123200. /**
  123201. * Gets a list of the post processes contained in the effect.
  123202. * @param camera The camera to get the post processes on.
  123203. * @returns The list of the post processes in the effect.
  123204. */
  123205. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  123206. }
  123207. }
  123208. declare module BABYLON {
  123209. /** @hidden */
  123210. export var extractHighlightsPixelShader: {
  123211. name: string;
  123212. shader: string;
  123213. };
  123214. }
  123215. declare module BABYLON {
  123216. /**
  123217. * 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.
  123218. */
  123219. export class ExtractHighlightsPostProcess extends PostProcess {
  123220. /**
  123221. * The luminance threshold, pixels below this value will be set to black.
  123222. */
  123223. threshold: number;
  123224. /** @hidden */
  123225. _exposure: number;
  123226. /**
  123227. * Post process which has the input texture to be used when performing highlight extraction
  123228. * @hidden
  123229. */
  123230. _inputPostProcess: Nullable<PostProcess>;
  123231. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  123232. }
  123233. }
  123234. declare module BABYLON {
  123235. /** @hidden */
  123236. export var bloomMergePixelShader: {
  123237. name: string;
  123238. shader: string;
  123239. };
  123240. }
  123241. declare module BABYLON {
  123242. /**
  123243. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  123244. */
  123245. export class BloomMergePostProcess extends PostProcess {
  123246. /** Weight of the bloom to be added to the original input. */
  123247. weight: number;
  123248. /**
  123249. * Creates a new instance of @see BloomMergePostProcess
  123250. * @param name The name of the effect.
  123251. * @param originalFromInput Post process which's input will be used for the merge.
  123252. * @param blurred Blurred highlights post process which's output will be used.
  123253. * @param weight Weight of the bloom to be added to the original input.
  123254. * @param options The required width/height ratio to downsize to before computing the render pass.
  123255. * @param camera The camera to apply the render pass to.
  123256. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  123257. * @param engine The engine which the post process will be applied. (default: current engine)
  123258. * @param reusable If the post process can be reused on the same frame. (default: false)
  123259. * @param textureType Type of textures used when performing the post process. (default: 0)
  123260. * @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)
  123261. */
  123262. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  123263. /** Weight of the bloom to be added to the original input. */
  123264. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  123265. }
  123266. }
  123267. declare module BABYLON {
  123268. /**
  123269. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  123270. */
  123271. export class BloomEffect extends PostProcessRenderEffect {
  123272. private bloomScale;
  123273. /**
  123274. * @hidden Internal
  123275. */
  123276. _effects: Array<PostProcess>;
  123277. /**
  123278. * @hidden Internal
  123279. */
  123280. _downscale: ExtractHighlightsPostProcess;
  123281. private _blurX;
  123282. private _blurY;
  123283. private _merge;
  123284. /**
  123285. * The luminance threshold to find bright areas of the image to bloom.
  123286. */
  123287. threshold: number;
  123288. /**
  123289. * The strength of the bloom.
  123290. */
  123291. weight: number;
  123292. /**
  123293. * Specifies the size of the bloom blur kernel, relative to the final output size
  123294. */
  123295. kernel: number;
  123296. /**
  123297. * Creates a new instance of @see BloomEffect
  123298. * @param scene The scene the effect belongs to.
  123299. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  123300. * @param bloomKernel The size of the kernel to be used when applying the blur.
  123301. * @param bloomWeight The the strength of bloom.
  123302. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  123303. * @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)
  123304. */
  123305. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  123306. /**
  123307. * Disposes each of the internal effects for a given camera.
  123308. * @param camera The camera to dispose the effect on.
  123309. */
  123310. disposeEffects(camera: Camera): void;
  123311. /**
  123312. * @hidden Internal
  123313. */
  123314. _updateEffects(): void;
  123315. /**
  123316. * Internal
  123317. * @returns if all the contained post processes are ready.
  123318. * @hidden
  123319. */
  123320. _isReady(): boolean;
  123321. }
  123322. }
  123323. declare module BABYLON {
  123324. /** @hidden */
  123325. export var chromaticAberrationPixelShader: {
  123326. name: string;
  123327. shader: string;
  123328. };
  123329. }
  123330. declare module BABYLON {
  123331. /**
  123332. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  123333. */
  123334. export class ChromaticAberrationPostProcess extends PostProcess {
  123335. /**
  123336. * The amount of seperation of rgb channels (default: 30)
  123337. */
  123338. aberrationAmount: number;
  123339. /**
  123340. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  123341. */
  123342. radialIntensity: number;
  123343. /**
  123344. * 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))
  123345. */
  123346. direction: Vector2;
  123347. /**
  123348. * 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))
  123349. */
  123350. centerPosition: Vector2;
  123351. /**
  123352. * Creates a new instance ChromaticAberrationPostProcess
  123353. * @param name The name of the effect.
  123354. * @param screenWidth The width of the screen to apply the effect on.
  123355. * @param screenHeight The height of the screen to apply the effect on.
  123356. * @param options The required width/height ratio to downsize to before computing the render pass.
  123357. * @param camera The camera to apply the render pass to.
  123358. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  123359. * @param engine The engine which the post process will be applied. (default: current engine)
  123360. * @param reusable If the post process can be reused on the same frame. (default: false)
  123361. * @param textureType Type of textures used when performing the post process. (default: 0)
  123362. * @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)
  123363. */
  123364. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  123365. }
  123366. }
  123367. declare module BABYLON {
  123368. /** @hidden */
  123369. export var circleOfConfusionPixelShader: {
  123370. name: string;
  123371. shader: string;
  123372. };
  123373. }
  123374. declare module BABYLON {
  123375. /**
  123376. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  123377. */
  123378. export class CircleOfConfusionPostProcess extends PostProcess {
  123379. /**
  123380. * 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.
  123381. */
  123382. lensSize: number;
  123383. /**
  123384. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  123385. */
  123386. fStop: number;
  123387. /**
  123388. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  123389. */
  123390. focusDistance: number;
  123391. /**
  123392. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  123393. */
  123394. focalLength: number;
  123395. private _depthTexture;
  123396. /**
  123397. * Creates a new instance CircleOfConfusionPostProcess
  123398. * @param name The name of the effect.
  123399. * @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.
  123400. * @param options The required width/height ratio to downsize to before computing the render pass.
  123401. * @param camera The camera to apply the render pass to.
  123402. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  123403. * @param engine The engine which the post process will be applied. (default: current engine)
  123404. * @param reusable If the post process can be reused on the same frame. (default: false)
  123405. * @param textureType Type of textures used when performing the post process. (default: 0)
  123406. * @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)
  123407. */
  123408. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  123409. /**
  123410. * 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.
  123411. */
  123412. depthTexture: RenderTargetTexture;
  123413. }
  123414. }
  123415. declare module BABYLON {
  123416. /** @hidden */
  123417. export var colorCorrectionPixelShader: {
  123418. name: string;
  123419. shader: string;
  123420. };
  123421. }
  123422. declare module BABYLON {
  123423. /**
  123424. *
  123425. * This post-process allows the modification of rendered colors by using
  123426. * a 'look-up table' (LUT). This effect is also called Color Grading.
  123427. *
  123428. * The object needs to be provided an url to a texture containing the color
  123429. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  123430. * Use an image editing software to tweak the LUT to match your needs.
  123431. *
  123432. * For an example of a color LUT, see here:
  123433. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  123434. * For explanations on color grading, see here:
  123435. * @see http://udn.epicgames.com/Three/ColorGrading.html
  123436. *
  123437. */
  123438. export class ColorCorrectionPostProcess extends PostProcess {
  123439. private _colorTableTexture;
  123440. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  123441. }
  123442. }
  123443. declare module BABYLON {
  123444. /** @hidden */
  123445. export var convolutionPixelShader: {
  123446. name: string;
  123447. shader: string;
  123448. };
  123449. }
  123450. declare module BABYLON {
  123451. /**
  123452. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  123453. * input texture to perform effects such as edge detection or sharpening
  123454. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  123455. */
  123456. export class ConvolutionPostProcess extends PostProcess {
  123457. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  123458. kernel: number[];
  123459. /**
  123460. * Creates a new instance ConvolutionPostProcess
  123461. * @param name The name of the effect.
  123462. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  123463. * @param options The required width/height ratio to downsize to before computing the render pass.
  123464. * @param camera The camera to apply the render pass to.
  123465. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  123466. * @param engine The engine which the post process will be applied. (default: current engine)
  123467. * @param reusable If the post process can be reused on the same frame. (default: false)
  123468. * @param textureType Type of textures used when performing the post process. (default: 0)
  123469. */
  123470. constructor(name: string,
  123471. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  123472. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  123473. /**
  123474. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  123475. */
  123476. static EdgeDetect0Kernel: number[];
  123477. /**
  123478. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  123479. */
  123480. static EdgeDetect1Kernel: number[];
  123481. /**
  123482. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  123483. */
  123484. static EdgeDetect2Kernel: number[];
  123485. /**
  123486. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  123487. */
  123488. static SharpenKernel: number[];
  123489. /**
  123490. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  123491. */
  123492. static EmbossKernel: number[];
  123493. /**
  123494. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  123495. */
  123496. static GaussianKernel: number[];
  123497. }
  123498. }
  123499. declare module BABYLON {
  123500. /**
  123501. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  123502. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  123503. * based on samples that have a large difference in distance than the center pixel.
  123504. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  123505. */
  123506. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  123507. direction: Vector2;
  123508. /**
  123509. * Creates a new instance CircleOfConfusionPostProcess
  123510. * @param name The name of the effect.
  123511. * @param scene The scene the effect belongs to.
  123512. * @param direction The direction the blur should be applied.
  123513. * @param kernel The size of the kernel used to blur.
  123514. * @param options The required width/height ratio to downsize to before computing the render pass.
  123515. * @param camera The camera to apply the render pass to.
  123516. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  123517. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  123518. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  123519. * @param engine The engine which the post process will be applied. (default: current engine)
  123520. * @param reusable If the post process can be reused on the same frame. (default: false)
  123521. * @param textureType Type of textures used when performing the post process. (default: 0)
  123522. * @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)
  123523. */
  123524. 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);
  123525. }
  123526. }
  123527. declare module BABYLON {
  123528. /** @hidden */
  123529. export var depthOfFieldMergePixelShader: {
  123530. name: string;
  123531. shader: string;
  123532. };
  123533. }
  123534. declare module BABYLON {
  123535. /**
  123536. * Options to be set when merging outputs from the default pipeline.
  123537. */
  123538. export class DepthOfFieldMergePostProcessOptions {
  123539. /**
  123540. * The original image to merge on top of
  123541. */
  123542. originalFromInput: PostProcess;
  123543. /**
  123544. * Parameters to perform the merge of the depth of field effect
  123545. */
  123546. depthOfField?: {
  123547. circleOfConfusion: PostProcess;
  123548. blurSteps: Array<PostProcess>;
  123549. };
  123550. /**
  123551. * Parameters to perform the merge of bloom effect
  123552. */
  123553. bloom?: {
  123554. blurred: PostProcess;
  123555. weight: number;
  123556. };
  123557. }
  123558. /**
  123559. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  123560. */
  123561. export class DepthOfFieldMergePostProcess extends PostProcess {
  123562. private blurSteps;
  123563. /**
  123564. * Creates a new instance of DepthOfFieldMergePostProcess
  123565. * @param name The name of the effect.
  123566. * @param originalFromInput Post process which's input will be used for the merge.
  123567. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  123568. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  123569. * @param options The required width/height ratio to downsize to before computing the render pass.
  123570. * @param camera The camera to apply the render pass to.
  123571. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  123572. * @param engine The engine which the post process will be applied. (default: current engine)
  123573. * @param reusable If the post process can be reused on the same frame. (default: false)
  123574. * @param textureType Type of textures used when performing the post process. (default: 0)
  123575. * @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)
  123576. */
  123577. 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);
  123578. /**
  123579. * Updates the effect with the current post process compile time values and recompiles the shader.
  123580. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  123581. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  123582. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  123583. * @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
  123584. * @param onCompiled Called when the shader has been compiled.
  123585. * @param onError Called if there is an error when compiling a shader.
  123586. */
  123587. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  123588. }
  123589. }
  123590. declare module BABYLON {
  123591. /**
  123592. * Specifies the level of max blur that should be applied when using the depth of field effect
  123593. */
  123594. export enum DepthOfFieldEffectBlurLevel {
  123595. /**
  123596. * Subtle blur
  123597. */
  123598. Low = 0,
  123599. /**
  123600. * Medium blur
  123601. */
  123602. Medium = 1,
  123603. /**
  123604. * Large blur
  123605. */
  123606. High = 2
  123607. }
  123608. /**
  123609. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  123610. */
  123611. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  123612. private _circleOfConfusion;
  123613. /**
  123614. * @hidden Internal, blurs from high to low
  123615. */
  123616. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  123617. private _depthOfFieldBlurY;
  123618. private _dofMerge;
  123619. /**
  123620. * @hidden Internal post processes in depth of field effect
  123621. */
  123622. _effects: Array<PostProcess>;
  123623. /**
  123624. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  123625. */
  123626. focalLength: number;
  123627. /**
  123628. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  123629. */
  123630. fStop: number;
  123631. /**
  123632. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  123633. */
  123634. focusDistance: number;
  123635. /**
  123636. * 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.
  123637. */
  123638. lensSize: number;
  123639. /**
  123640. * Creates a new instance DepthOfFieldEffect
  123641. * @param scene The scene the effect belongs to.
  123642. * @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.
  123643. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  123644. * @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)
  123645. */
  123646. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  123647. /**
  123648. * Get the current class name of the current effet
  123649. * @returns "DepthOfFieldEffect"
  123650. */
  123651. getClassName(): string;
  123652. /**
  123653. * 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.
  123654. */
  123655. depthTexture: RenderTargetTexture;
  123656. /**
  123657. * Disposes each of the internal effects for a given camera.
  123658. * @param camera The camera to dispose the effect on.
  123659. */
  123660. disposeEffects(camera: Camera): void;
  123661. /**
  123662. * @hidden Internal
  123663. */
  123664. _updateEffects(): void;
  123665. /**
  123666. * Internal
  123667. * @returns if all the contained post processes are ready.
  123668. * @hidden
  123669. */
  123670. _isReady(): boolean;
  123671. }
  123672. }
  123673. declare module BABYLON {
  123674. /** @hidden */
  123675. export var displayPassPixelShader: {
  123676. name: string;
  123677. shader: string;
  123678. };
  123679. }
  123680. declare module BABYLON {
  123681. /**
  123682. * DisplayPassPostProcess which produces an output the same as it's input
  123683. */
  123684. export class DisplayPassPostProcess extends PostProcess {
  123685. /**
  123686. * Creates the DisplayPassPostProcess
  123687. * @param name The name of the effect.
  123688. * @param options The required width/height ratio to downsize to before computing the render pass.
  123689. * @param camera The camera to apply the render pass to.
  123690. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  123691. * @param engine The engine which the post process will be applied. (default: current engine)
  123692. * @param reusable If the post process can be reused on the same frame. (default: false)
  123693. */
  123694. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  123695. }
  123696. }
  123697. declare module BABYLON {
  123698. /** @hidden */
  123699. export var filterPixelShader: {
  123700. name: string;
  123701. shader: string;
  123702. };
  123703. }
  123704. declare module BABYLON {
  123705. /**
  123706. * Applies a kernel filter to the image
  123707. */
  123708. export class FilterPostProcess extends PostProcess {
  123709. /** The matrix to be applied to the image */
  123710. kernelMatrix: Matrix;
  123711. /**
  123712. *
  123713. * @param name The name of the effect.
  123714. * @param kernelMatrix The matrix to be applied to the image
  123715. * @param options The required width/height ratio to downsize to before computing the render pass.
  123716. * @param camera The camera to apply the render pass to.
  123717. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  123718. * @param engine The engine which the post process will be applied. (default: current engine)
  123719. * @param reusable If the post process can be reused on the same frame. (default: false)
  123720. */
  123721. constructor(name: string,
  123722. /** The matrix to be applied to the image */
  123723. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  123724. }
  123725. }
  123726. declare module BABYLON {
  123727. /** @hidden */
  123728. export var fxaaPixelShader: {
  123729. name: string;
  123730. shader: string;
  123731. };
  123732. }
  123733. declare module BABYLON {
  123734. /** @hidden */
  123735. export var fxaaVertexShader: {
  123736. name: string;
  123737. shader: string;
  123738. };
  123739. }
  123740. declare module BABYLON {
  123741. /**
  123742. * Fxaa post process
  123743. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  123744. */
  123745. export class FxaaPostProcess extends PostProcess {
  123746. /** @hidden */
  123747. texelWidth: number;
  123748. /** @hidden */
  123749. texelHeight: number;
  123750. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  123751. private _getDefines;
  123752. }
  123753. }
  123754. declare module BABYLON {
  123755. /** @hidden */
  123756. export var grainPixelShader: {
  123757. name: string;
  123758. shader: string;
  123759. };
  123760. }
  123761. declare module BABYLON {
  123762. /**
  123763. * The GrainPostProcess adds noise to the image at mid luminance levels
  123764. */
  123765. export class GrainPostProcess extends PostProcess {
  123766. /**
  123767. * The intensity of the grain added (default: 30)
  123768. */
  123769. intensity: number;
  123770. /**
  123771. * If the grain should be randomized on every frame
  123772. */
  123773. animated: boolean;
  123774. /**
  123775. * Creates a new instance of @see GrainPostProcess
  123776. * @param name The name of the effect.
  123777. * @param options The required width/height ratio to downsize to before computing the render pass.
  123778. * @param camera The camera to apply the render pass to.
  123779. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  123780. * @param engine The engine which the post process will be applied. (default: current engine)
  123781. * @param reusable If the post process can be reused on the same frame. (default: false)
  123782. * @param textureType Type of textures used when performing the post process. (default: 0)
  123783. * @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)
  123784. */
  123785. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  123786. }
  123787. }
  123788. declare module BABYLON {
  123789. /** @hidden */
  123790. export var highlightsPixelShader: {
  123791. name: string;
  123792. shader: string;
  123793. };
  123794. }
  123795. declare module BABYLON {
  123796. /**
  123797. * Extracts highlights from the image
  123798. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  123799. */
  123800. export class HighlightsPostProcess extends PostProcess {
  123801. /**
  123802. * Extracts highlights from the image
  123803. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  123804. * @param name The name of the effect.
  123805. * @param options The required width/height ratio to downsize to before computing the render pass.
  123806. * @param camera The camera to apply the render pass to.
  123807. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  123808. * @param engine The engine which the post process will be applied. (default: current engine)
  123809. * @param reusable If the post process can be reused on the same frame. (default: false)
  123810. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  123811. */
  123812. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  123813. }
  123814. }
  123815. declare module BABYLON {
  123816. /** @hidden */
  123817. export var mrtFragmentDeclaration: {
  123818. name: string;
  123819. shader: string;
  123820. };
  123821. }
  123822. declare module BABYLON {
  123823. /** @hidden */
  123824. export var geometryPixelShader: {
  123825. name: string;
  123826. shader: string;
  123827. };
  123828. }
  123829. declare module BABYLON {
  123830. /** @hidden */
  123831. export var geometryVertexShader: {
  123832. name: string;
  123833. shader: string;
  123834. };
  123835. }
  123836. declare module BABYLON {
  123837. /** @hidden */
  123838. interface ISavedTransformationMatrix {
  123839. world: Matrix;
  123840. viewProjection: Matrix;
  123841. }
  123842. /**
  123843. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  123844. */
  123845. export class GeometryBufferRenderer {
  123846. /**
  123847. * Constant used to retrieve the position texture index in the G-Buffer textures array
  123848. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  123849. */
  123850. static readonly POSITION_TEXTURE_TYPE: number;
  123851. /**
  123852. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  123853. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  123854. */
  123855. static readonly VELOCITY_TEXTURE_TYPE: number;
  123856. /**
  123857. * Dictionary used to store the previous transformation matrices of each rendered mesh
  123858. * in order to compute objects velocities when enableVelocity is set to "true"
  123859. * @hidden
  123860. */
  123861. _previousTransformationMatrices: {
  123862. [index: number]: ISavedTransformationMatrix;
  123863. };
  123864. /**
  123865. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  123866. * in order to compute objects velocities when enableVelocity is set to "true"
  123867. * @hidden
  123868. */
  123869. _previousBonesTransformationMatrices: {
  123870. [index: number]: Float32Array;
  123871. };
  123872. /**
  123873. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  123874. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  123875. */
  123876. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  123877. private _scene;
  123878. private _multiRenderTarget;
  123879. private _ratio;
  123880. private _enablePosition;
  123881. private _enableVelocity;
  123882. private _positionIndex;
  123883. private _velocityIndex;
  123884. protected _effect: Effect;
  123885. protected _cachedDefines: string;
  123886. /**
  123887. * Set the render list (meshes to be rendered) used in the G buffer.
  123888. */
  123889. renderList: Mesh[];
  123890. /**
  123891. * Gets wether or not G buffer are supported by the running hardware.
  123892. * This requires draw buffer supports
  123893. */
  123894. readonly isSupported: boolean;
  123895. /**
  123896. * Returns the index of the given texture type in the G-Buffer textures array
  123897. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  123898. * @returns the index of the given texture type in the G-Buffer textures array
  123899. */
  123900. getTextureIndex(textureType: number): number;
  123901. /**
  123902. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  123903. */
  123904. /**
  123905. * Sets whether or not objects positions are enabled for the G buffer.
  123906. */
  123907. enablePosition: boolean;
  123908. /**
  123909. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  123910. */
  123911. /**
  123912. * Sets wether or not objects velocities are enabled for the G buffer.
  123913. */
  123914. enableVelocity: boolean;
  123915. /**
  123916. * Gets the scene associated with the buffer.
  123917. */
  123918. readonly scene: Scene;
  123919. /**
  123920. * Gets the ratio used by the buffer during its creation.
  123921. * How big is the buffer related to the main canvas.
  123922. */
  123923. readonly ratio: number;
  123924. /** @hidden */
  123925. static _SceneComponentInitialization: (scene: Scene) => void;
  123926. /**
  123927. * Creates a new G Buffer for the scene
  123928. * @param scene The scene the buffer belongs to
  123929. * @param ratio How big is the buffer related to the main canvas.
  123930. */
  123931. constructor(scene: Scene, ratio?: number);
  123932. /**
  123933. * Checks wether everything is ready to render a submesh to the G buffer.
  123934. * @param subMesh the submesh to check readiness for
  123935. * @param useInstances is the mesh drawn using instance or not
  123936. * @returns true if ready otherwise false
  123937. */
  123938. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  123939. /**
  123940. * Gets the current underlying G Buffer.
  123941. * @returns the buffer
  123942. */
  123943. getGBuffer(): MultiRenderTarget;
  123944. /**
  123945. * Gets the number of samples used to render the buffer (anti aliasing).
  123946. */
  123947. /**
  123948. * Sets the number of samples used to render the buffer (anti aliasing).
  123949. */
  123950. samples: number;
  123951. /**
  123952. * Disposes the renderer and frees up associated resources.
  123953. */
  123954. dispose(): void;
  123955. protected _createRenderTargets(): void;
  123956. private _copyBonesTransformationMatrices;
  123957. }
  123958. }
  123959. declare module BABYLON {
  123960. interface Scene {
  123961. /** @hidden (Backing field) */
  123962. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  123963. /**
  123964. * Gets or Sets the current geometry buffer associated to the scene.
  123965. */
  123966. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  123967. /**
  123968. * Enables a GeometryBufferRender and associates it with the scene
  123969. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  123970. * @returns the GeometryBufferRenderer
  123971. */
  123972. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  123973. /**
  123974. * Disables the GeometryBufferRender associated with the scene
  123975. */
  123976. disableGeometryBufferRenderer(): void;
  123977. }
  123978. /**
  123979. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  123980. * in several rendering techniques.
  123981. */
  123982. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  123983. /**
  123984. * The component name helpful to identify the component in the list of scene components.
  123985. */
  123986. readonly name: string;
  123987. /**
  123988. * The scene the component belongs to.
  123989. */
  123990. scene: Scene;
  123991. /**
  123992. * Creates a new instance of the component for the given scene
  123993. * @param scene Defines the scene to register the component in
  123994. */
  123995. constructor(scene: Scene);
  123996. /**
  123997. * Registers the component in a given scene
  123998. */
  123999. register(): void;
  124000. /**
  124001. * Rebuilds the elements related to this component in case of
  124002. * context lost for instance.
  124003. */
  124004. rebuild(): void;
  124005. /**
  124006. * Disposes the component and the associated ressources
  124007. */
  124008. dispose(): void;
  124009. private _gatherRenderTargets;
  124010. }
  124011. }
  124012. declare module BABYLON {
  124013. /** @hidden */
  124014. export var motionBlurPixelShader: {
  124015. name: string;
  124016. shader: string;
  124017. };
  124018. }
  124019. declare module BABYLON {
  124020. /**
  124021. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  124022. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  124023. * As an example, all you have to do is to create the post-process:
  124024. * var mb = new BABYLON.MotionBlurPostProcess(
  124025. * 'mb', // The name of the effect.
  124026. * scene, // The scene containing the objects to blur according to their velocity.
  124027. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  124028. * camera // The camera to apply the render pass to.
  124029. * );
  124030. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  124031. */
  124032. export class MotionBlurPostProcess extends PostProcess {
  124033. /**
  124034. * Defines how much the image is blurred by the movement. Default value is equal to 1
  124035. */
  124036. motionStrength: number;
  124037. /**
  124038. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  124039. */
  124040. /**
  124041. * Sets the number of iterations to be used for motion blur quality
  124042. */
  124043. motionBlurSamples: number;
  124044. private _motionBlurSamples;
  124045. private _geometryBufferRenderer;
  124046. /**
  124047. * Creates a new instance MotionBlurPostProcess
  124048. * @param name The name of the effect.
  124049. * @param scene The scene containing the objects to blur according to their velocity.
  124050. * @param options The required width/height ratio to downsize to before computing the render pass.
  124051. * @param camera The camera to apply the render pass to.
  124052. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  124053. * @param engine The engine which the post process will be applied. (default: current engine)
  124054. * @param reusable If the post process can be reused on the same frame. (default: false)
  124055. * @param textureType Type of textures used when performing the post process. (default: 0)
  124056. * @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)
  124057. */
  124058. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  124059. /**
  124060. * Excludes the given skinned mesh from computing bones velocities.
  124061. * 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.
  124062. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  124063. */
  124064. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  124065. /**
  124066. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  124067. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  124068. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  124069. */
  124070. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  124071. /**
  124072. * Disposes the post process.
  124073. * @param camera The camera to dispose the post process on.
  124074. */
  124075. dispose(camera?: Camera): void;
  124076. }
  124077. }
  124078. declare module BABYLON {
  124079. /** @hidden */
  124080. export var refractionPixelShader: {
  124081. name: string;
  124082. shader: string;
  124083. };
  124084. }
  124085. declare module BABYLON {
  124086. /**
  124087. * Post process which applies a refractin texture
  124088. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  124089. */
  124090. export class RefractionPostProcess extends PostProcess {
  124091. /** the base color of the refraction (used to taint the rendering) */
  124092. color: Color3;
  124093. /** simulated refraction depth */
  124094. depth: number;
  124095. /** the coefficient of the base color (0 to remove base color tainting) */
  124096. colorLevel: number;
  124097. private _refTexture;
  124098. private _ownRefractionTexture;
  124099. /**
  124100. * Gets or sets the refraction texture
  124101. * Please note that you are responsible for disposing the texture if you set it manually
  124102. */
  124103. refractionTexture: Texture;
  124104. /**
  124105. * Initializes the RefractionPostProcess
  124106. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  124107. * @param name The name of the effect.
  124108. * @param refractionTextureUrl Url of the refraction texture to use
  124109. * @param color the base color of the refraction (used to taint the rendering)
  124110. * @param depth simulated refraction depth
  124111. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  124112. * @param camera The camera to apply the render pass to.
  124113. * @param options The required width/height ratio to downsize to before computing the render pass.
  124114. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  124115. * @param engine The engine which the post process will be applied. (default: current engine)
  124116. * @param reusable If the post process can be reused on the same frame. (default: false)
  124117. */
  124118. constructor(name: string, refractionTextureUrl: string,
  124119. /** the base color of the refraction (used to taint the rendering) */
  124120. color: Color3,
  124121. /** simulated refraction depth */
  124122. depth: number,
  124123. /** the coefficient of the base color (0 to remove base color tainting) */
  124124. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  124125. /**
  124126. * Disposes of the post process
  124127. * @param camera Camera to dispose post process on
  124128. */
  124129. dispose(camera: Camera): void;
  124130. }
  124131. }
  124132. declare module BABYLON {
  124133. /** @hidden */
  124134. export var sharpenPixelShader: {
  124135. name: string;
  124136. shader: string;
  124137. };
  124138. }
  124139. declare module BABYLON {
  124140. /**
  124141. * The SharpenPostProcess applies a sharpen kernel to every pixel
  124142. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  124143. */
  124144. export class SharpenPostProcess extends PostProcess {
  124145. /**
  124146. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  124147. */
  124148. colorAmount: number;
  124149. /**
  124150. * How much sharpness should be applied (default: 0.3)
  124151. */
  124152. edgeAmount: number;
  124153. /**
  124154. * Creates a new instance ConvolutionPostProcess
  124155. * @param name The name of the effect.
  124156. * @param options The required width/height ratio to downsize to before computing the render pass.
  124157. * @param camera The camera to apply the render pass to.
  124158. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  124159. * @param engine The engine which the post process will be applied. (default: current engine)
  124160. * @param reusable If the post process can be reused on the same frame. (default: false)
  124161. * @param textureType Type of textures used when performing the post process. (default: 0)
  124162. * @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)
  124163. */
  124164. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  124165. }
  124166. }
  124167. declare module BABYLON {
  124168. /**
  124169. * PostProcessRenderPipeline
  124170. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  124171. */
  124172. export class PostProcessRenderPipeline {
  124173. private engine;
  124174. private _renderEffects;
  124175. private _renderEffectsForIsolatedPass;
  124176. /**
  124177. * List of inspectable custom properties (used by the Inspector)
  124178. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  124179. */
  124180. inspectableCustomProperties: IInspectable[];
  124181. /**
  124182. * @hidden
  124183. */
  124184. protected _cameras: Camera[];
  124185. /** @hidden */
  124186. _name: string;
  124187. /**
  124188. * Gets pipeline name
  124189. */
  124190. readonly name: string;
  124191. /**
  124192. * Initializes a PostProcessRenderPipeline
  124193. * @param engine engine to add the pipeline to
  124194. * @param name name of the pipeline
  124195. */
  124196. constructor(engine: Engine, name: string);
  124197. /**
  124198. * Gets the class name
  124199. * @returns "PostProcessRenderPipeline"
  124200. */
  124201. getClassName(): string;
  124202. /**
  124203. * If all the render effects in the pipeline are supported
  124204. */
  124205. readonly isSupported: boolean;
  124206. /**
  124207. * Adds an effect to the pipeline
  124208. * @param renderEffect the effect to add
  124209. */
  124210. addEffect(renderEffect: PostProcessRenderEffect): void;
  124211. /** @hidden */
  124212. _rebuild(): void;
  124213. /** @hidden */
  124214. _enableEffect(renderEffectName: string, cameras: Camera): void;
  124215. /** @hidden */
  124216. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  124217. /** @hidden */
  124218. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  124219. /** @hidden */
  124220. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  124221. /** @hidden */
  124222. _attachCameras(cameras: Camera, unique: boolean): void;
  124223. /** @hidden */
  124224. _attachCameras(cameras: Camera[], unique: boolean): void;
  124225. /** @hidden */
  124226. _detachCameras(cameras: Camera): void;
  124227. /** @hidden */
  124228. _detachCameras(cameras: Nullable<Camera[]>): void;
  124229. /** @hidden */
  124230. _update(): void;
  124231. /** @hidden */
  124232. _reset(): void;
  124233. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  124234. /**
  124235. * Disposes of the pipeline
  124236. */
  124237. dispose(): void;
  124238. }
  124239. }
  124240. declare module BABYLON {
  124241. /**
  124242. * PostProcessRenderPipelineManager class
  124243. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  124244. */
  124245. export class PostProcessRenderPipelineManager {
  124246. private _renderPipelines;
  124247. /**
  124248. * Initializes a PostProcessRenderPipelineManager
  124249. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  124250. */
  124251. constructor();
  124252. /**
  124253. * Gets the list of supported render pipelines
  124254. */
  124255. readonly supportedPipelines: PostProcessRenderPipeline[];
  124256. /**
  124257. * Adds a pipeline to the manager
  124258. * @param renderPipeline The pipeline to add
  124259. */
  124260. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  124261. /**
  124262. * Attaches a camera to the pipeline
  124263. * @param renderPipelineName The name of the pipeline to attach to
  124264. * @param cameras the camera to attach
  124265. * @param unique if the camera can be attached multiple times to the pipeline
  124266. */
  124267. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  124268. /**
  124269. * Detaches a camera from the pipeline
  124270. * @param renderPipelineName The name of the pipeline to detach from
  124271. * @param cameras the camera to detach
  124272. */
  124273. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  124274. /**
  124275. * Enables an effect by name on a pipeline
  124276. * @param renderPipelineName the name of the pipeline to enable the effect in
  124277. * @param renderEffectName the name of the effect to enable
  124278. * @param cameras the cameras that the effect should be enabled on
  124279. */
  124280. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  124281. /**
  124282. * Disables an effect by name on a pipeline
  124283. * @param renderPipelineName the name of the pipeline to disable the effect in
  124284. * @param renderEffectName the name of the effect to disable
  124285. * @param cameras the cameras that the effect should be disabled on
  124286. */
  124287. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  124288. /**
  124289. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  124290. */
  124291. update(): void;
  124292. /** @hidden */
  124293. _rebuild(): void;
  124294. /**
  124295. * Disposes of the manager and pipelines
  124296. */
  124297. dispose(): void;
  124298. }
  124299. }
  124300. declare module BABYLON {
  124301. interface Scene {
  124302. /** @hidden (Backing field) */
  124303. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  124304. /**
  124305. * Gets the postprocess render pipeline manager
  124306. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  124307. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  124308. */
  124309. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  124310. }
  124311. /**
  124312. * Defines the Render Pipeline scene component responsible to rendering pipelines
  124313. */
  124314. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  124315. /**
  124316. * The component name helpfull to identify the component in the list of scene components.
  124317. */
  124318. readonly name: string;
  124319. /**
  124320. * The scene the component belongs to.
  124321. */
  124322. scene: Scene;
  124323. /**
  124324. * Creates a new instance of the component for the given scene
  124325. * @param scene Defines the scene to register the component in
  124326. */
  124327. constructor(scene: Scene);
  124328. /**
  124329. * Registers the component in a given scene
  124330. */
  124331. register(): void;
  124332. /**
  124333. * Rebuilds the elements related to this component in case of
  124334. * context lost for instance.
  124335. */
  124336. rebuild(): void;
  124337. /**
  124338. * Disposes the component and the associated ressources
  124339. */
  124340. dispose(): void;
  124341. private _gatherRenderTargets;
  124342. }
  124343. }
  124344. declare module BABYLON {
  124345. /**
  124346. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  124347. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  124348. */
  124349. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  124350. private _scene;
  124351. private _camerasToBeAttached;
  124352. /**
  124353. * ID of the sharpen post process,
  124354. */
  124355. private readonly SharpenPostProcessId;
  124356. /**
  124357. * @ignore
  124358. * ID of the image processing post process;
  124359. */
  124360. readonly ImageProcessingPostProcessId: string;
  124361. /**
  124362. * @ignore
  124363. * ID of the Fast Approximate Anti-Aliasing post process;
  124364. */
  124365. readonly FxaaPostProcessId: string;
  124366. /**
  124367. * ID of the chromatic aberration post process,
  124368. */
  124369. private readonly ChromaticAberrationPostProcessId;
  124370. /**
  124371. * ID of the grain post process
  124372. */
  124373. private readonly GrainPostProcessId;
  124374. /**
  124375. * Sharpen post process which will apply a sharpen convolution to enhance edges
  124376. */
  124377. sharpen: SharpenPostProcess;
  124378. private _sharpenEffect;
  124379. private bloom;
  124380. /**
  124381. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  124382. */
  124383. depthOfField: DepthOfFieldEffect;
  124384. /**
  124385. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  124386. */
  124387. fxaa: FxaaPostProcess;
  124388. /**
  124389. * Image post processing pass used to perform operations such as tone mapping or color grading.
  124390. */
  124391. imageProcessing: ImageProcessingPostProcess;
  124392. /**
  124393. * Chromatic aberration post process which will shift rgb colors in the image
  124394. */
  124395. chromaticAberration: ChromaticAberrationPostProcess;
  124396. private _chromaticAberrationEffect;
  124397. /**
  124398. * Grain post process which add noise to the image
  124399. */
  124400. grain: GrainPostProcess;
  124401. private _grainEffect;
  124402. /**
  124403. * Glow post process which adds a glow to emissive areas of the image
  124404. */
  124405. private _glowLayer;
  124406. /**
  124407. * Animations which can be used to tweak settings over a period of time
  124408. */
  124409. animations: Animation[];
  124410. private _imageProcessingConfigurationObserver;
  124411. private _sharpenEnabled;
  124412. private _bloomEnabled;
  124413. private _depthOfFieldEnabled;
  124414. private _depthOfFieldBlurLevel;
  124415. private _fxaaEnabled;
  124416. private _imageProcessingEnabled;
  124417. private _defaultPipelineTextureType;
  124418. private _bloomScale;
  124419. private _chromaticAberrationEnabled;
  124420. private _grainEnabled;
  124421. private _buildAllowed;
  124422. /**
  124423. * Gets active scene
  124424. */
  124425. readonly scene: Scene;
  124426. /**
  124427. * Enable or disable the sharpen process from the pipeline
  124428. */
  124429. sharpenEnabled: boolean;
  124430. private _resizeObserver;
  124431. private _hardwareScaleLevel;
  124432. private _bloomKernel;
  124433. /**
  124434. * Specifies the size of the bloom blur kernel, relative to the final output size
  124435. */
  124436. bloomKernel: number;
  124437. /**
  124438. * Specifies the weight of the bloom in the final rendering
  124439. */
  124440. private _bloomWeight;
  124441. /**
  124442. * Specifies the luma threshold for the area that will be blurred by the bloom
  124443. */
  124444. private _bloomThreshold;
  124445. private _hdr;
  124446. /**
  124447. * The strength of the bloom.
  124448. */
  124449. bloomWeight: number;
  124450. /**
  124451. * The strength of the bloom.
  124452. */
  124453. bloomThreshold: number;
  124454. /**
  124455. * The scale of the bloom, lower value will provide better performance.
  124456. */
  124457. bloomScale: number;
  124458. /**
  124459. * Enable or disable the bloom from the pipeline
  124460. */
  124461. bloomEnabled: boolean;
  124462. private _rebuildBloom;
  124463. /**
  124464. * If the depth of field is enabled.
  124465. */
  124466. depthOfFieldEnabled: boolean;
  124467. /**
  124468. * Blur level of the depth of field effect. (Higher blur will effect performance)
  124469. */
  124470. depthOfFieldBlurLevel: DepthOfFieldEffectBlurLevel;
  124471. /**
  124472. * If the anti aliasing is enabled.
  124473. */
  124474. fxaaEnabled: boolean;
  124475. private _samples;
  124476. /**
  124477. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  124478. */
  124479. samples: number;
  124480. /**
  124481. * If image processing is enabled.
  124482. */
  124483. imageProcessingEnabled: boolean;
  124484. /**
  124485. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  124486. */
  124487. glowLayerEnabled: boolean;
  124488. /**
  124489. * Gets the glow layer (or null if not defined)
  124490. */
  124491. readonly glowLayer: Nullable<GlowLayer>;
  124492. /**
  124493. * Enable or disable the chromaticAberration process from the pipeline
  124494. */
  124495. chromaticAberrationEnabled: boolean;
  124496. /**
  124497. * Enable or disable the grain process from the pipeline
  124498. */
  124499. grainEnabled: boolean;
  124500. /**
  124501. * @constructor
  124502. * @param name - The rendering pipeline name (default: "")
  124503. * @param hdr - If high dynamic range textures should be used (default: true)
  124504. * @param scene - The scene linked to this pipeline (default: the last created scene)
  124505. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  124506. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  124507. */
  124508. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  124509. /**
  124510. * Get the class name
  124511. * @returns "DefaultRenderingPipeline"
  124512. */
  124513. getClassName(): string;
  124514. /**
  124515. * Force the compilation of the entire pipeline.
  124516. */
  124517. prepare(): void;
  124518. private _hasCleared;
  124519. private _prevPostProcess;
  124520. private _prevPrevPostProcess;
  124521. private _setAutoClearAndTextureSharing;
  124522. private _depthOfFieldSceneObserver;
  124523. private _buildPipeline;
  124524. private _disposePostProcesses;
  124525. /**
  124526. * Adds a camera to the pipeline
  124527. * @param camera the camera to be added
  124528. */
  124529. addCamera(camera: Camera): void;
  124530. /**
  124531. * Removes a camera from the pipeline
  124532. * @param camera the camera to remove
  124533. */
  124534. removeCamera(camera: Camera): void;
  124535. /**
  124536. * Dispose of the pipeline and stop all post processes
  124537. */
  124538. dispose(): void;
  124539. /**
  124540. * Serialize the rendering pipeline (Used when exporting)
  124541. * @returns the serialized object
  124542. */
  124543. serialize(): any;
  124544. /**
  124545. * Parse the serialized pipeline
  124546. * @param source Source pipeline.
  124547. * @param scene The scene to load the pipeline to.
  124548. * @param rootUrl The URL of the serialized pipeline.
  124549. * @returns An instantiated pipeline from the serialized object.
  124550. */
  124551. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  124552. }
  124553. }
  124554. declare module BABYLON {
  124555. /** @hidden */
  124556. export var lensHighlightsPixelShader: {
  124557. name: string;
  124558. shader: string;
  124559. };
  124560. }
  124561. declare module BABYLON {
  124562. /** @hidden */
  124563. export var depthOfFieldPixelShader: {
  124564. name: string;
  124565. shader: string;
  124566. };
  124567. }
  124568. declare module BABYLON {
  124569. /**
  124570. * BABYLON.JS Chromatic Aberration GLSL Shader
  124571. * Author: Olivier Guyot
  124572. * Separates very slightly R, G and B colors on the edges of the screen
  124573. * Inspired by Francois Tarlier & Martins Upitis
  124574. */
  124575. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  124576. /**
  124577. * @ignore
  124578. * The chromatic aberration PostProcess id in the pipeline
  124579. */
  124580. LensChromaticAberrationEffect: string;
  124581. /**
  124582. * @ignore
  124583. * The highlights enhancing PostProcess id in the pipeline
  124584. */
  124585. HighlightsEnhancingEffect: string;
  124586. /**
  124587. * @ignore
  124588. * The depth-of-field PostProcess id in the pipeline
  124589. */
  124590. LensDepthOfFieldEffect: string;
  124591. private _scene;
  124592. private _depthTexture;
  124593. private _grainTexture;
  124594. private _chromaticAberrationPostProcess;
  124595. private _highlightsPostProcess;
  124596. private _depthOfFieldPostProcess;
  124597. private _edgeBlur;
  124598. private _grainAmount;
  124599. private _chromaticAberration;
  124600. private _distortion;
  124601. private _highlightsGain;
  124602. private _highlightsThreshold;
  124603. private _dofDistance;
  124604. private _dofAperture;
  124605. private _dofDarken;
  124606. private _dofPentagon;
  124607. private _blurNoise;
  124608. /**
  124609. * @constructor
  124610. *
  124611. * Effect parameters are as follow:
  124612. * {
  124613. * chromatic_aberration: number; // from 0 to x (1 for realism)
  124614. * edge_blur: number; // from 0 to x (1 for realism)
  124615. * distortion: number; // from 0 to x (1 for realism)
  124616. * grain_amount: number; // from 0 to 1
  124617. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  124618. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  124619. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  124620. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  124621. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  124622. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  124623. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  124624. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  124625. * }
  124626. * Note: if an effect parameter is unset, effect is disabled
  124627. *
  124628. * @param name The rendering pipeline name
  124629. * @param parameters - An object containing all parameters (see above)
  124630. * @param scene The scene linked to this pipeline
  124631. * @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)
  124632. * @param cameras The array of cameras that the rendering pipeline will be attached to
  124633. */
  124634. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  124635. /**
  124636. * Get the class name
  124637. * @returns "LensRenderingPipeline"
  124638. */
  124639. getClassName(): string;
  124640. /**
  124641. * Gets associated scene
  124642. */
  124643. readonly scene: Scene;
  124644. /**
  124645. * Gets or sets the edge blur
  124646. */
  124647. edgeBlur: number;
  124648. /**
  124649. * Gets or sets the grain amount
  124650. */
  124651. grainAmount: number;
  124652. /**
  124653. * Gets or sets the chromatic aberration amount
  124654. */
  124655. chromaticAberration: number;
  124656. /**
  124657. * Gets or sets the depth of field aperture
  124658. */
  124659. dofAperture: number;
  124660. /**
  124661. * Gets or sets the edge distortion
  124662. */
  124663. edgeDistortion: number;
  124664. /**
  124665. * Gets or sets the depth of field distortion
  124666. */
  124667. dofDistortion: number;
  124668. /**
  124669. * Gets or sets the darken out of focus amount
  124670. */
  124671. darkenOutOfFocus: number;
  124672. /**
  124673. * Gets or sets a boolean indicating if blur noise is enabled
  124674. */
  124675. blurNoise: boolean;
  124676. /**
  124677. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  124678. */
  124679. pentagonBokeh: boolean;
  124680. /**
  124681. * Gets or sets the highlight grain amount
  124682. */
  124683. highlightsGain: number;
  124684. /**
  124685. * Gets or sets the highlight threshold
  124686. */
  124687. highlightsThreshold: number;
  124688. /**
  124689. * Sets the amount of blur at the edges
  124690. * @param amount blur amount
  124691. */
  124692. setEdgeBlur(amount: number): void;
  124693. /**
  124694. * Sets edge blur to 0
  124695. */
  124696. disableEdgeBlur(): void;
  124697. /**
  124698. * Sets the amout of grain
  124699. * @param amount Amount of grain
  124700. */
  124701. setGrainAmount(amount: number): void;
  124702. /**
  124703. * Set grain amount to 0
  124704. */
  124705. disableGrain(): void;
  124706. /**
  124707. * Sets the chromatic aberration amount
  124708. * @param amount amount of chromatic aberration
  124709. */
  124710. setChromaticAberration(amount: number): void;
  124711. /**
  124712. * Sets chromatic aberration amount to 0
  124713. */
  124714. disableChromaticAberration(): void;
  124715. /**
  124716. * Sets the EdgeDistortion amount
  124717. * @param amount amount of EdgeDistortion
  124718. */
  124719. setEdgeDistortion(amount: number): void;
  124720. /**
  124721. * Sets edge distortion to 0
  124722. */
  124723. disableEdgeDistortion(): void;
  124724. /**
  124725. * Sets the FocusDistance amount
  124726. * @param amount amount of FocusDistance
  124727. */
  124728. setFocusDistance(amount: number): void;
  124729. /**
  124730. * Disables depth of field
  124731. */
  124732. disableDepthOfField(): void;
  124733. /**
  124734. * Sets the Aperture amount
  124735. * @param amount amount of Aperture
  124736. */
  124737. setAperture(amount: number): void;
  124738. /**
  124739. * Sets the DarkenOutOfFocus amount
  124740. * @param amount amount of DarkenOutOfFocus
  124741. */
  124742. setDarkenOutOfFocus(amount: number): void;
  124743. private _pentagonBokehIsEnabled;
  124744. /**
  124745. * Creates a pentagon bokeh effect
  124746. */
  124747. enablePentagonBokeh(): void;
  124748. /**
  124749. * Disables the pentagon bokeh effect
  124750. */
  124751. disablePentagonBokeh(): void;
  124752. /**
  124753. * Enables noise blur
  124754. */
  124755. enableNoiseBlur(): void;
  124756. /**
  124757. * Disables noise blur
  124758. */
  124759. disableNoiseBlur(): void;
  124760. /**
  124761. * Sets the HighlightsGain amount
  124762. * @param amount amount of HighlightsGain
  124763. */
  124764. setHighlightsGain(amount: number): void;
  124765. /**
  124766. * Sets the HighlightsThreshold amount
  124767. * @param amount amount of HighlightsThreshold
  124768. */
  124769. setHighlightsThreshold(amount: number): void;
  124770. /**
  124771. * Disables highlights
  124772. */
  124773. disableHighlights(): void;
  124774. /**
  124775. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  124776. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  124777. */
  124778. dispose(disableDepthRender?: boolean): void;
  124779. private _createChromaticAberrationPostProcess;
  124780. private _createHighlightsPostProcess;
  124781. private _createDepthOfFieldPostProcess;
  124782. private _createGrainTexture;
  124783. }
  124784. }
  124785. declare module BABYLON {
  124786. /** @hidden */
  124787. export var ssao2PixelShader: {
  124788. name: string;
  124789. shader: string;
  124790. };
  124791. }
  124792. declare module BABYLON {
  124793. /** @hidden */
  124794. export var ssaoCombinePixelShader: {
  124795. name: string;
  124796. shader: string;
  124797. };
  124798. }
  124799. declare module BABYLON {
  124800. /**
  124801. * Render pipeline to produce ssao effect
  124802. */
  124803. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  124804. /**
  124805. * @ignore
  124806. * The PassPostProcess id in the pipeline that contains the original scene color
  124807. */
  124808. SSAOOriginalSceneColorEffect: string;
  124809. /**
  124810. * @ignore
  124811. * The SSAO PostProcess id in the pipeline
  124812. */
  124813. SSAORenderEffect: string;
  124814. /**
  124815. * @ignore
  124816. * The horizontal blur PostProcess id in the pipeline
  124817. */
  124818. SSAOBlurHRenderEffect: string;
  124819. /**
  124820. * @ignore
  124821. * The vertical blur PostProcess id in the pipeline
  124822. */
  124823. SSAOBlurVRenderEffect: string;
  124824. /**
  124825. * @ignore
  124826. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  124827. */
  124828. SSAOCombineRenderEffect: string;
  124829. /**
  124830. * The output strength of the SSAO post-process. Default value is 1.0.
  124831. */
  124832. totalStrength: number;
  124833. /**
  124834. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  124835. */
  124836. maxZ: number;
  124837. /**
  124838. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  124839. */
  124840. minZAspect: number;
  124841. private _samples;
  124842. /**
  124843. * Number of samples used for the SSAO calculations. Default value is 8
  124844. */
  124845. samples: number;
  124846. private _textureSamples;
  124847. /**
  124848. * Number of samples to use for antialiasing
  124849. */
  124850. textureSamples: number;
  124851. /**
  124852. * Ratio object used for SSAO ratio and blur ratio
  124853. */
  124854. private _ratio;
  124855. /**
  124856. * Dynamically generated sphere sampler.
  124857. */
  124858. private _sampleSphere;
  124859. /**
  124860. * Blur filter offsets
  124861. */
  124862. private _samplerOffsets;
  124863. private _expensiveBlur;
  124864. /**
  124865. * If bilateral blur should be used
  124866. */
  124867. expensiveBlur: boolean;
  124868. /**
  124869. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  124870. */
  124871. radius: number;
  124872. /**
  124873. * The base color of the SSAO post-process
  124874. * The final result is "base + ssao" between [0, 1]
  124875. */
  124876. base: number;
  124877. /**
  124878. * Support test.
  124879. */
  124880. static readonly IsSupported: boolean;
  124881. private _scene;
  124882. private _depthTexture;
  124883. private _normalTexture;
  124884. private _randomTexture;
  124885. private _originalColorPostProcess;
  124886. private _ssaoPostProcess;
  124887. private _blurHPostProcess;
  124888. private _blurVPostProcess;
  124889. private _ssaoCombinePostProcess;
  124890. private _firstUpdate;
  124891. /**
  124892. * Gets active scene
  124893. */
  124894. readonly scene: Scene;
  124895. /**
  124896. * @constructor
  124897. * @param name The rendering pipeline name
  124898. * @param scene The scene linked to this pipeline
  124899. * @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 }
  124900. * @param cameras The array of cameras that the rendering pipeline will be attached to
  124901. */
  124902. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  124903. /**
  124904. * Get the class name
  124905. * @returns "SSAO2RenderingPipeline"
  124906. */
  124907. getClassName(): string;
  124908. /**
  124909. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  124910. */
  124911. dispose(disableGeometryBufferRenderer?: boolean): void;
  124912. private _createBlurPostProcess;
  124913. /** @hidden */
  124914. _rebuild(): void;
  124915. private _bits;
  124916. private _radicalInverse_VdC;
  124917. private _hammersley;
  124918. private _hemisphereSample_uniform;
  124919. private _generateHemisphere;
  124920. private _createSSAOPostProcess;
  124921. private _createSSAOCombinePostProcess;
  124922. private _createRandomTexture;
  124923. /**
  124924. * Serialize the rendering pipeline (Used when exporting)
  124925. * @returns the serialized object
  124926. */
  124927. serialize(): any;
  124928. /**
  124929. * Parse the serialized pipeline
  124930. * @param source Source pipeline.
  124931. * @param scene The scene to load the pipeline to.
  124932. * @param rootUrl The URL of the serialized pipeline.
  124933. * @returns An instantiated pipeline from the serialized object.
  124934. */
  124935. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  124936. }
  124937. }
  124938. declare module BABYLON {
  124939. /** @hidden */
  124940. export var ssaoPixelShader: {
  124941. name: string;
  124942. shader: string;
  124943. };
  124944. }
  124945. declare module BABYLON {
  124946. /**
  124947. * Render pipeline to produce ssao effect
  124948. */
  124949. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  124950. /**
  124951. * @ignore
  124952. * The PassPostProcess id in the pipeline that contains the original scene color
  124953. */
  124954. SSAOOriginalSceneColorEffect: string;
  124955. /**
  124956. * @ignore
  124957. * The SSAO PostProcess id in the pipeline
  124958. */
  124959. SSAORenderEffect: string;
  124960. /**
  124961. * @ignore
  124962. * The horizontal blur PostProcess id in the pipeline
  124963. */
  124964. SSAOBlurHRenderEffect: string;
  124965. /**
  124966. * @ignore
  124967. * The vertical blur PostProcess id in the pipeline
  124968. */
  124969. SSAOBlurVRenderEffect: string;
  124970. /**
  124971. * @ignore
  124972. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  124973. */
  124974. SSAOCombineRenderEffect: string;
  124975. /**
  124976. * The output strength of the SSAO post-process. Default value is 1.0.
  124977. */
  124978. totalStrength: number;
  124979. /**
  124980. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  124981. */
  124982. radius: number;
  124983. /**
  124984. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  124985. * Must not be equal to fallOff and superior to fallOff.
  124986. * Default value is 0.0075
  124987. */
  124988. area: number;
  124989. /**
  124990. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  124991. * Must not be equal to area and inferior to area.
  124992. * Default value is 0.000001
  124993. */
  124994. fallOff: number;
  124995. /**
  124996. * The base color of the SSAO post-process
  124997. * The final result is "base + ssao" between [0, 1]
  124998. */
  124999. base: number;
  125000. private _scene;
  125001. private _depthTexture;
  125002. private _randomTexture;
  125003. private _originalColorPostProcess;
  125004. private _ssaoPostProcess;
  125005. private _blurHPostProcess;
  125006. private _blurVPostProcess;
  125007. private _ssaoCombinePostProcess;
  125008. private _firstUpdate;
  125009. /**
  125010. * Gets active scene
  125011. */
  125012. readonly scene: Scene;
  125013. /**
  125014. * @constructor
  125015. * @param name - The rendering pipeline name
  125016. * @param scene - The scene linked to this pipeline
  125017. * @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 }
  125018. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  125019. */
  125020. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  125021. /**
  125022. * Get the class name
  125023. * @returns "SSAORenderingPipeline"
  125024. */
  125025. getClassName(): string;
  125026. /**
  125027. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  125028. */
  125029. dispose(disableDepthRender?: boolean): void;
  125030. private _createBlurPostProcess;
  125031. /** @hidden */
  125032. _rebuild(): void;
  125033. private _createSSAOPostProcess;
  125034. private _createSSAOCombinePostProcess;
  125035. private _createRandomTexture;
  125036. }
  125037. }
  125038. declare module BABYLON {
  125039. /** @hidden */
  125040. export var standardPixelShader: {
  125041. name: string;
  125042. shader: string;
  125043. };
  125044. }
  125045. declare module BABYLON {
  125046. /**
  125047. * Standard rendering pipeline
  125048. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  125049. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  125050. */
  125051. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  125052. /**
  125053. * Public members
  125054. */
  125055. /**
  125056. * Post-process which contains the original scene color before the pipeline applies all the effects
  125057. */
  125058. originalPostProcess: Nullable<PostProcess>;
  125059. /**
  125060. * Post-process used to down scale an image x4
  125061. */
  125062. downSampleX4PostProcess: Nullable<PostProcess>;
  125063. /**
  125064. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  125065. */
  125066. brightPassPostProcess: Nullable<PostProcess>;
  125067. /**
  125068. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  125069. */
  125070. blurHPostProcesses: PostProcess[];
  125071. /**
  125072. * Post-process array storing all the vertical blur post-processes used by the pipeline
  125073. */
  125074. blurVPostProcesses: PostProcess[];
  125075. /**
  125076. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  125077. */
  125078. textureAdderPostProcess: Nullable<PostProcess>;
  125079. /**
  125080. * Post-process used to create volumetric lighting effect
  125081. */
  125082. volumetricLightPostProcess: Nullable<PostProcess>;
  125083. /**
  125084. * Post-process used to smooth the previous volumetric light post-process on the X axis
  125085. */
  125086. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  125087. /**
  125088. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  125089. */
  125090. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  125091. /**
  125092. * Post-process used to merge the volumetric light effect and the real scene color
  125093. */
  125094. volumetricLightMergePostProces: Nullable<PostProcess>;
  125095. /**
  125096. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  125097. */
  125098. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  125099. /**
  125100. * Base post-process used to calculate the average luminance of the final image for HDR
  125101. */
  125102. luminancePostProcess: Nullable<PostProcess>;
  125103. /**
  125104. * Post-processes used to create down sample post-processes in order to get
  125105. * the average luminance of the final image for HDR
  125106. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  125107. */
  125108. luminanceDownSamplePostProcesses: PostProcess[];
  125109. /**
  125110. * Post-process used to create a HDR effect (light adaptation)
  125111. */
  125112. hdrPostProcess: Nullable<PostProcess>;
  125113. /**
  125114. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  125115. */
  125116. textureAdderFinalPostProcess: Nullable<PostProcess>;
  125117. /**
  125118. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  125119. */
  125120. lensFlareFinalPostProcess: Nullable<PostProcess>;
  125121. /**
  125122. * Post-process used to merge the final HDR post-process and the real scene color
  125123. */
  125124. hdrFinalPostProcess: Nullable<PostProcess>;
  125125. /**
  125126. * Post-process used to create a lens flare effect
  125127. */
  125128. lensFlarePostProcess: Nullable<PostProcess>;
  125129. /**
  125130. * Post-process that merges the result of the lens flare post-process and the real scene color
  125131. */
  125132. lensFlareComposePostProcess: Nullable<PostProcess>;
  125133. /**
  125134. * Post-process used to create a motion blur effect
  125135. */
  125136. motionBlurPostProcess: Nullable<PostProcess>;
  125137. /**
  125138. * Post-process used to create a depth of field effect
  125139. */
  125140. depthOfFieldPostProcess: Nullable<PostProcess>;
  125141. /**
  125142. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  125143. */
  125144. fxaaPostProcess: Nullable<FxaaPostProcess>;
  125145. /**
  125146. * Represents the brightness threshold in order to configure the illuminated surfaces
  125147. */
  125148. brightThreshold: number;
  125149. /**
  125150. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  125151. */
  125152. blurWidth: number;
  125153. /**
  125154. * Sets if the blur for highlighted surfaces must be only horizontal
  125155. */
  125156. horizontalBlur: boolean;
  125157. /**
  125158. * Gets the overall exposure used by the pipeline
  125159. */
  125160. /**
  125161. * Sets the overall exposure used by the pipeline
  125162. */
  125163. exposure: number;
  125164. /**
  125165. * Texture used typically to simulate "dirty" on camera lens
  125166. */
  125167. lensTexture: Nullable<Texture>;
  125168. /**
  125169. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  125170. */
  125171. volumetricLightCoefficient: number;
  125172. /**
  125173. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  125174. */
  125175. volumetricLightPower: number;
  125176. /**
  125177. * Used the set the blur intensity to smooth the volumetric lights
  125178. */
  125179. volumetricLightBlurScale: number;
  125180. /**
  125181. * Light (spot or directional) used to generate the volumetric lights rays
  125182. * The source light must have a shadow generate so the pipeline can get its
  125183. * depth map
  125184. */
  125185. sourceLight: Nullable<SpotLight | DirectionalLight>;
  125186. /**
  125187. * For eye adaptation, represents the minimum luminance the eye can see
  125188. */
  125189. hdrMinimumLuminance: number;
  125190. /**
  125191. * For eye adaptation, represents the decrease luminance speed
  125192. */
  125193. hdrDecreaseRate: number;
  125194. /**
  125195. * For eye adaptation, represents the increase luminance speed
  125196. */
  125197. hdrIncreaseRate: number;
  125198. /**
  125199. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  125200. */
  125201. /**
  125202. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  125203. */
  125204. hdrAutoExposure: boolean;
  125205. /**
  125206. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  125207. */
  125208. lensColorTexture: Nullable<Texture>;
  125209. /**
  125210. * The overall strengh for the lens flare effect
  125211. */
  125212. lensFlareStrength: number;
  125213. /**
  125214. * Dispersion coefficient for lens flare ghosts
  125215. */
  125216. lensFlareGhostDispersal: number;
  125217. /**
  125218. * Main lens flare halo width
  125219. */
  125220. lensFlareHaloWidth: number;
  125221. /**
  125222. * Based on the lens distortion effect, defines how much the lens flare result
  125223. * is distorted
  125224. */
  125225. lensFlareDistortionStrength: number;
  125226. /**
  125227. * Configures the blur intensity used for for lens flare (halo)
  125228. */
  125229. lensFlareBlurWidth: number;
  125230. /**
  125231. * Lens star texture must be used to simulate rays on the flares and is available
  125232. * in the documentation
  125233. */
  125234. lensStarTexture: Nullable<Texture>;
  125235. /**
  125236. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  125237. * flare effect by taking account of the dirt texture
  125238. */
  125239. lensFlareDirtTexture: Nullable<Texture>;
  125240. /**
  125241. * Represents the focal length for the depth of field effect
  125242. */
  125243. depthOfFieldDistance: number;
  125244. /**
  125245. * Represents the blur intensity for the blurred part of the depth of field effect
  125246. */
  125247. depthOfFieldBlurWidth: number;
  125248. /**
  125249. * Gets how much the image is blurred by the movement while using the motion blur post-process
  125250. */
  125251. /**
  125252. * Sets how much the image is blurred by the movement while using the motion blur post-process
  125253. */
  125254. motionStrength: number;
  125255. /**
  125256. * Gets wether or not the motion blur post-process is object based or screen based.
  125257. */
  125258. /**
  125259. * Sets wether or not the motion blur post-process should be object based or screen based
  125260. */
  125261. objectBasedMotionBlur: boolean;
  125262. /**
  125263. * List of animations for the pipeline (IAnimatable implementation)
  125264. */
  125265. animations: Animation[];
  125266. /**
  125267. * Private members
  125268. */
  125269. private _scene;
  125270. private _currentDepthOfFieldSource;
  125271. private _basePostProcess;
  125272. private _fixedExposure;
  125273. private _currentExposure;
  125274. private _hdrAutoExposure;
  125275. private _hdrCurrentLuminance;
  125276. private _motionStrength;
  125277. private _isObjectBasedMotionBlur;
  125278. private _floatTextureType;
  125279. private _camerasToBeAttached;
  125280. private _ratio;
  125281. private _bloomEnabled;
  125282. private _depthOfFieldEnabled;
  125283. private _vlsEnabled;
  125284. private _lensFlareEnabled;
  125285. private _hdrEnabled;
  125286. private _motionBlurEnabled;
  125287. private _fxaaEnabled;
  125288. private _motionBlurSamples;
  125289. private _volumetricLightStepsCount;
  125290. private _samples;
  125291. /**
  125292. * @ignore
  125293. * Specifies if the bloom pipeline is enabled
  125294. */
  125295. BloomEnabled: boolean;
  125296. /**
  125297. * @ignore
  125298. * Specifies if the depth of field pipeline is enabed
  125299. */
  125300. DepthOfFieldEnabled: boolean;
  125301. /**
  125302. * @ignore
  125303. * Specifies if the lens flare pipeline is enabed
  125304. */
  125305. LensFlareEnabled: boolean;
  125306. /**
  125307. * @ignore
  125308. * Specifies if the HDR pipeline is enabled
  125309. */
  125310. HDREnabled: boolean;
  125311. /**
  125312. * @ignore
  125313. * Specifies if the volumetric lights scattering effect is enabled
  125314. */
  125315. VLSEnabled: boolean;
  125316. /**
  125317. * @ignore
  125318. * Specifies if the motion blur effect is enabled
  125319. */
  125320. MotionBlurEnabled: boolean;
  125321. /**
  125322. * Specifies if anti-aliasing is enabled
  125323. */
  125324. fxaaEnabled: boolean;
  125325. /**
  125326. * Specifies the number of steps used to calculate the volumetric lights
  125327. * Typically in interval [50, 200]
  125328. */
  125329. volumetricLightStepsCount: number;
  125330. /**
  125331. * Specifies the number of samples used for the motion blur effect
  125332. * Typically in interval [16, 64]
  125333. */
  125334. motionBlurSamples: number;
  125335. /**
  125336. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  125337. */
  125338. samples: number;
  125339. /**
  125340. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  125341. * @constructor
  125342. * @param name The rendering pipeline name
  125343. * @param scene The scene linked to this pipeline
  125344. * @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)
  125345. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  125346. * @param cameras The array of cameras that the rendering pipeline will be attached to
  125347. */
  125348. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  125349. private _buildPipeline;
  125350. private _createDownSampleX4PostProcess;
  125351. private _createBrightPassPostProcess;
  125352. private _createBlurPostProcesses;
  125353. private _createTextureAdderPostProcess;
  125354. private _createVolumetricLightPostProcess;
  125355. private _createLuminancePostProcesses;
  125356. private _createHdrPostProcess;
  125357. private _createLensFlarePostProcess;
  125358. private _createDepthOfFieldPostProcess;
  125359. private _createMotionBlurPostProcess;
  125360. private _getDepthTexture;
  125361. private _disposePostProcesses;
  125362. /**
  125363. * Dispose of the pipeline and stop all post processes
  125364. */
  125365. dispose(): void;
  125366. /**
  125367. * Serialize the rendering pipeline (Used when exporting)
  125368. * @returns the serialized object
  125369. */
  125370. serialize(): any;
  125371. /**
  125372. * Parse the serialized pipeline
  125373. * @param source Source pipeline.
  125374. * @param scene The scene to load the pipeline to.
  125375. * @param rootUrl The URL of the serialized pipeline.
  125376. * @returns An instantiated pipeline from the serialized object.
  125377. */
  125378. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  125379. /**
  125380. * Luminance steps
  125381. */
  125382. static LuminanceSteps: number;
  125383. }
  125384. }
  125385. declare module BABYLON {
  125386. /** @hidden */
  125387. export var tonemapPixelShader: {
  125388. name: string;
  125389. shader: string;
  125390. };
  125391. }
  125392. declare module BABYLON {
  125393. /** Defines operator used for tonemapping */
  125394. export enum TonemappingOperator {
  125395. /** Hable */
  125396. Hable = 0,
  125397. /** Reinhard */
  125398. Reinhard = 1,
  125399. /** HejiDawson */
  125400. HejiDawson = 2,
  125401. /** Photographic */
  125402. Photographic = 3
  125403. }
  125404. /**
  125405. * Defines a post process to apply tone mapping
  125406. */
  125407. export class TonemapPostProcess extends PostProcess {
  125408. private _operator;
  125409. /** Defines the required exposure adjustement */
  125410. exposureAdjustment: number;
  125411. /**
  125412. * Creates a new TonemapPostProcess
  125413. * @param name defines the name of the postprocess
  125414. * @param _operator defines the operator to use
  125415. * @param exposureAdjustment defines the required exposure adjustement
  125416. * @param camera defines the camera to use (can be null)
  125417. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  125418. * @param engine defines the hosting engine (can be ignore if camera is set)
  125419. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  125420. */
  125421. constructor(name: string, _operator: TonemappingOperator,
  125422. /** Defines the required exposure adjustement */
  125423. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  125424. }
  125425. }
  125426. declare module BABYLON {
  125427. /** @hidden */
  125428. export var depthVertexShader: {
  125429. name: string;
  125430. shader: string;
  125431. };
  125432. }
  125433. declare module BABYLON {
  125434. /** @hidden */
  125435. export var volumetricLightScatteringPixelShader: {
  125436. name: string;
  125437. shader: string;
  125438. };
  125439. }
  125440. declare module BABYLON {
  125441. /** @hidden */
  125442. export var volumetricLightScatteringPassVertexShader: {
  125443. name: string;
  125444. shader: string;
  125445. };
  125446. }
  125447. declare module BABYLON {
  125448. /** @hidden */
  125449. export var volumetricLightScatteringPassPixelShader: {
  125450. name: string;
  125451. shader: string;
  125452. };
  125453. }
  125454. declare module BABYLON {
  125455. /**
  125456. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  125457. */
  125458. export class VolumetricLightScatteringPostProcess extends PostProcess {
  125459. private _volumetricLightScatteringPass;
  125460. private _volumetricLightScatteringRTT;
  125461. private _viewPort;
  125462. private _screenCoordinates;
  125463. private _cachedDefines;
  125464. /**
  125465. * If not undefined, the mesh position is computed from the attached node position
  125466. */
  125467. attachedNode: {
  125468. position: Vector3;
  125469. };
  125470. /**
  125471. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  125472. */
  125473. customMeshPosition: Vector3;
  125474. /**
  125475. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  125476. */
  125477. useCustomMeshPosition: boolean;
  125478. /**
  125479. * If the post-process should inverse the light scattering direction
  125480. */
  125481. invert: boolean;
  125482. /**
  125483. * The internal mesh used by the post-process
  125484. */
  125485. mesh: Mesh;
  125486. /**
  125487. * @hidden
  125488. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  125489. */
  125490. useDiffuseColor: boolean;
  125491. /**
  125492. * Array containing the excluded meshes not rendered in the internal pass
  125493. */
  125494. excludedMeshes: AbstractMesh[];
  125495. /**
  125496. * Controls the overall intensity of the post-process
  125497. */
  125498. exposure: number;
  125499. /**
  125500. * Dissipates each sample's contribution in range [0, 1]
  125501. */
  125502. decay: number;
  125503. /**
  125504. * Controls the overall intensity of each sample
  125505. */
  125506. weight: number;
  125507. /**
  125508. * Controls the density of each sample
  125509. */
  125510. density: number;
  125511. /**
  125512. * @constructor
  125513. * @param name The post-process name
  125514. * @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)
  125515. * @param camera The camera that the post-process will be attached to
  125516. * @param mesh The mesh used to create the light scattering
  125517. * @param samples The post-process quality, default 100
  125518. * @param samplingModeThe post-process filtering mode
  125519. * @param engine The babylon engine
  125520. * @param reusable If the post-process is reusable
  125521. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  125522. */
  125523. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  125524. /**
  125525. * Returns the string "VolumetricLightScatteringPostProcess"
  125526. * @returns "VolumetricLightScatteringPostProcess"
  125527. */
  125528. getClassName(): string;
  125529. private _isReady;
  125530. /**
  125531. * Sets the new light position for light scattering effect
  125532. * @param position The new custom light position
  125533. */
  125534. setCustomMeshPosition(position: Vector3): void;
  125535. /**
  125536. * Returns the light position for light scattering effect
  125537. * @return Vector3 The custom light position
  125538. */
  125539. getCustomMeshPosition(): Vector3;
  125540. /**
  125541. * Disposes the internal assets and detaches the post-process from the camera
  125542. */
  125543. dispose(camera: Camera): void;
  125544. /**
  125545. * Returns the render target texture used by the post-process
  125546. * @return the render target texture used by the post-process
  125547. */
  125548. getPass(): RenderTargetTexture;
  125549. private _meshExcluded;
  125550. private _createPass;
  125551. private _updateMeshScreenCoordinates;
  125552. /**
  125553. * Creates a default mesh for the Volumeric Light Scattering post-process
  125554. * @param name The mesh name
  125555. * @param scene The scene where to create the mesh
  125556. * @return the default mesh
  125557. */
  125558. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  125559. }
  125560. }
  125561. declare module BABYLON {
  125562. interface Scene {
  125563. /** @hidden (Backing field) */
  125564. _boundingBoxRenderer: BoundingBoxRenderer;
  125565. /** @hidden (Backing field) */
  125566. _forceShowBoundingBoxes: boolean;
  125567. /**
  125568. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  125569. */
  125570. forceShowBoundingBoxes: boolean;
  125571. /**
  125572. * Gets the bounding box renderer associated with the scene
  125573. * @returns a BoundingBoxRenderer
  125574. */
  125575. getBoundingBoxRenderer(): BoundingBoxRenderer;
  125576. }
  125577. interface AbstractMesh {
  125578. /** @hidden (Backing field) */
  125579. _showBoundingBox: boolean;
  125580. /**
  125581. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  125582. */
  125583. showBoundingBox: boolean;
  125584. }
  125585. /**
  125586. * Component responsible of rendering the bounding box of the meshes in a scene.
  125587. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  125588. */
  125589. export class BoundingBoxRenderer implements ISceneComponent {
  125590. /**
  125591. * The component name helpfull to identify the component in the list of scene components.
  125592. */
  125593. readonly name: string;
  125594. /**
  125595. * The scene the component belongs to.
  125596. */
  125597. scene: Scene;
  125598. /**
  125599. * Color of the bounding box lines placed in front of an object
  125600. */
  125601. frontColor: Color3;
  125602. /**
  125603. * Color of the bounding box lines placed behind an object
  125604. */
  125605. backColor: Color3;
  125606. /**
  125607. * Defines if the renderer should show the back lines or not
  125608. */
  125609. showBackLines: boolean;
  125610. /**
  125611. * @hidden
  125612. */
  125613. renderList: SmartArray<BoundingBox>;
  125614. private _colorShader;
  125615. private _vertexBuffers;
  125616. private _indexBuffer;
  125617. private _fillIndexBuffer;
  125618. private _fillIndexData;
  125619. /**
  125620. * Instantiates a new bounding box renderer in a scene.
  125621. * @param scene the scene the renderer renders in
  125622. */
  125623. constructor(scene: Scene);
  125624. /**
  125625. * Registers the component in a given scene
  125626. */
  125627. register(): void;
  125628. private _evaluateSubMesh;
  125629. private _activeMesh;
  125630. private _prepareRessources;
  125631. private _createIndexBuffer;
  125632. /**
  125633. * Rebuilds the elements related to this component in case of
  125634. * context lost for instance.
  125635. */
  125636. rebuild(): void;
  125637. /**
  125638. * @hidden
  125639. */
  125640. reset(): void;
  125641. /**
  125642. * Render the bounding boxes of a specific rendering group
  125643. * @param renderingGroupId defines the rendering group to render
  125644. */
  125645. render(renderingGroupId: number): void;
  125646. /**
  125647. * In case of occlusion queries, we can render the occlusion bounding box through this method
  125648. * @param mesh Define the mesh to render the occlusion bounding box for
  125649. */
  125650. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  125651. /**
  125652. * Dispose and release the resources attached to this renderer.
  125653. */
  125654. dispose(): void;
  125655. }
  125656. }
  125657. declare module BABYLON {
  125658. /** @hidden */
  125659. export var depthPixelShader: {
  125660. name: string;
  125661. shader: string;
  125662. };
  125663. }
  125664. declare module BABYLON {
  125665. /**
  125666. * This represents a depth renderer in Babylon.
  125667. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  125668. */
  125669. export class DepthRenderer {
  125670. private _scene;
  125671. private _depthMap;
  125672. private _effect;
  125673. private readonly _storeNonLinearDepth;
  125674. private readonly _clearColor;
  125675. /** Get if the depth renderer is using packed depth or not */
  125676. readonly isPacked: boolean;
  125677. private _cachedDefines;
  125678. private _camera;
  125679. /**
  125680. * Specifiess that the depth renderer will only be used within
  125681. * the camera it is created for.
  125682. * This can help forcing its rendering during the camera processing.
  125683. */
  125684. useOnlyInActiveCamera: boolean;
  125685. /** @hidden */
  125686. static _SceneComponentInitialization: (scene: Scene) => void;
  125687. /**
  125688. * Instantiates a depth renderer
  125689. * @param scene The scene the renderer belongs to
  125690. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  125691. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  125692. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  125693. */
  125694. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  125695. /**
  125696. * Creates the depth rendering effect and checks if the effect is ready.
  125697. * @param subMesh The submesh to be used to render the depth map of
  125698. * @param useInstances If multiple world instances should be used
  125699. * @returns if the depth renderer is ready to render the depth map
  125700. */
  125701. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  125702. /**
  125703. * Gets the texture which the depth map will be written to.
  125704. * @returns The depth map texture
  125705. */
  125706. getDepthMap(): RenderTargetTexture;
  125707. /**
  125708. * Disposes of the depth renderer.
  125709. */
  125710. dispose(): void;
  125711. }
  125712. }
  125713. declare module BABYLON {
  125714. interface Scene {
  125715. /** @hidden (Backing field) */
  125716. _depthRenderer: {
  125717. [id: string]: DepthRenderer;
  125718. };
  125719. /**
  125720. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  125721. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  125722. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  125723. * @returns the created depth renderer
  125724. */
  125725. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean): DepthRenderer;
  125726. /**
  125727. * Disables a depth renderer for a given camera
  125728. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  125729. */
  125730. disableDepthRenderer(camera?: Nullable<Camera>): void;
  125731. }
  125732. /**
  125733. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  125734. * in several rendering techniques.
  125735. */
  125736. export class DepthRendererSceneComponent implements ISceneComponent {
  125737. /**
  125738. * The component name helpfull to identify the component in the list of scene components.
  125739. */
  125740. readonly name: string;
  125741. /**
  125742. * The scene the component belongs to.
  125743. */
  125744. scene: Scene;
  125745. /**
  125746. * Creates a new instance of the component for the given scene
  125747. * @param scene Defines the scene to register the component in
  125748. */
  125749. constructor(scene: Scene);
  125750. /**
  125751. * Registers the component in a given scene
  125752. */
  125753. register(): void;
  125754. /**
  125755. * Rebuilds the elements related to this component in case of
  125756. * context lost for instance.
  125757. */
  125758. rebuild(): void;
  125759. /**
  125760. * Disposes the component and the associated ressources
  125761. */
  125762. dispose(): void;
  125763. private _gatherRenderTargets;
  125764. private _gatherActiveCameraRenderTargets;
  125765. }
  125766. }
  125767. declare module BABYLON {
  125768. /** @hidden */
  125769. export var outlinePixelShader: {
  125770. name: string;
  125771. shader: string;
  125772. };
  125773. }
  125774. declare module BABYLON {
  125775. /** @hidden */
  125776. export var outlineVertexShader: {
  125777. name: string;
  125778. shader: string;
  125779. };
  125780. }
  125781. declare module BABYLON {
  125782. interface Scene {
  125783. /** @hidden */
  125784. _outlineRenderer: OutlineRenderer;
  125785. /**
  125786. * Gets the outline renderer associated with the scene
  125787. * @returns a OutlineRenderer
  125788. */
  125789. getOutlineRenderer(): OutlineRenderer;
  125790. }
  125791. interface AbstractMesh {
  125792. /** @hidden (Backing field) */
  125793. _renderOutline: boolean;
  125794. /**
  125795. * Gets or sets a boolean indicating if the outline must be rendered as well
  125796. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  125797. */
  125798. renderOutline: boolean;
  125799. /** @hidden (Backing field) */
  125800. _renderOverlay: boolean;
  125801. /**
  125802. * Gets or sets a boolean indicating if the overlay must be rendered as well
  125803. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  125804. */
  125805. renderOverlay: boolean;
  125806. }
  125807. /**
  125808. * This class is responsible to draw bothe outline/overlay of meshes.
  125809. * It should not be used directly but through the available method on mesh.
  125810. */
  125811. export class OutlineRenderer implements ISceneComponent {
  125812. /**
  125813. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  125814. */
  125815. private static _StencilReference;
  125816. /**
  125817. * The name of the component. Each component must have a unique name.
  125818. */
  125819. name: string;
  125820. /**
  125821. * The scene the component belongs to.
  125822. */
  125823. scene: Scene;
  125824. /**
  125825. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  125826. */
  125827. zOffset: number;
  125828. private _engine;
  125829. private _effect;
  125830. private _cachedDefines;
  125831. private _savedDepthWrite;
  125832. /**
  125833. * Instantiates a new outline renderer. (There could be only one per scene).
  125834. * @param scene Defines the scene it belongs to
  125835. */
  125836. constructor(scene: Scene);
  125837. /**
  125838. * Register the component to one instance of a scene.
  125839. */
  125840. register(): void;
  125841. /**
  125842. * Rebuilds the elements related to this component in case of
  125843. * context lost for instance.
  125844. */
  125845. rebuild(): void;
  125846. /**
  125847. * Disposes the component and the associated ressources.
  125848. */
  125849. dispose(): void;
  125850. /**
  125851. * Renders the outline in the canvas.
  125852. * @param subMesh Defines the sumesh to render
  125853. * @param batch Defines the batch of meshes in case of instances
  125854. * @param useOverlay Defines if the rendering is for the overlay or the outline
  125855. */
  125856. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  125857. /**
  125858. * Returns whether or not the outline renderer is ready for a given submesh.
  125859. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  125860. * @param subMesh Defines the submesh to check readyness for
  125861. * @param useInstances Defines wheter wee are trying to render instances or not
  125862. * @returns true if ready otherwise false
  125863. */
  125864. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  125865. private _beforeRenderingMesh;
  125866. private _afterRenderingMesh;
  125867. }
  125868. }
  125869. declare module BABYLON {
  125870. /**
  125871. * Class used to manage multiple sprites of different sizes on the same spritesheet
  125872. * @see http://doc.babylonjs.com/babylon101/sprites
  125873. */
  125874. export class SpritePackedManager extends SpriteManager {
  125875. /** defines the packed manager's name */
  125876. name: string;
  125877. /**
  125878. * Creates a new sprite manager from a packed sprite sheet
  125879. * @param name defines the manager's name
  125880. * @param imgUrl defines the sprite sheet url
  125881. * @param capacity defines the maximum allowed number of sprites
  125882. * @param scene defines the hosting scene
  125883. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  125884. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  125885. * @param samplingMode defines the smapling mode to use with spritesheet
  125886. * @param fromPacked set to true; do not alter
  125887. */
  125888. constructor(
  125889. /** defines the packed manager's name */
  125890. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  125891. }
  125892. }
  125893. declare module BABYLON {
  125894. /**
  125895. * Defines the list of states available for a task inside a AssetsManager
  125896. */
  125897. export enum AssetTaskState {
  125898. /**
  125899. * Initialization
  125900. */
  125901. INIT = 0,
  125902. /**
  125903. * Running
  125904. */
  125905. RUNNING = 1,
  125906. /**
  125907. * Done
  125908. */
  125909. DONE = 2,
  125910. /**
  125911. * Error
  125912. */
  125913. ERROR = 3
  125914. }
  125915. /**
  125916. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  125917. */
  125918. export abstract class AbstractAssetTask {
  125919. /**
  125920. * Task name
  125921. */ name: string;
  125922. /**
  125923. * Callback called when the task is successful
  125924. */
  125925. onSuccess: (task: any) => void;
  125926. /**
  125927. * Callback called when the task is not successful
  125928. */
  125929. onError: (task: any, message?: string, exception?: any) => void;
  125930. /**
  125931. * Creates a new AssetsManager
  125932. * @param name defines the name of the task
  125933. */
  125934. constructor(
  125935. /**
  125936. * Task name
  125937. */ name: string);
  125938. private _isCompleted;
  125939. private _taskState;
  125940. private _errorObject;
  125941. /**
  125942. * Get if the task is completed
  125943. */
  125944. readonly isCompleted: boolean;
  125945. /**
  125946. * Gets the current state of the task
  125947. */
  125948. readonly taskState: AssetTaskState;
  125949. /**
  125950. * Gets the current error object (if task is in error)
  125951. */
  125952. readonly errorObject: {
  125953. message?: string;
  125954. exception?: any;
  125955. };
  125956. /**
  125957. * Internal only
  125958. * @hidden
  125959. */
  125960. _setErrorObject(message?: string, exception?: any): void;
  125961. /**
  125962. * Execute the current task
  125963. * @param scene defines the scene where you want your assets to be loaded
  125964. * @param onSuccess is a callback called when the task is successfully executed
  125965. * @param onError is a callback called if an error occurs
  125966. */
  125967. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  125968. /**
  125969. * Execute the current task
  125970. * @param scene defines the scene where you want your assets to be loaded
  125971. * @param onSuccess is a callback called when the task is successfully executed
  125972. * @param onError is a callback called if an error occurs
  125973. */
  125974. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  125975. /**
  125976. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  125977. * This can be used with failed tasks that have the reason for failure fixed.
  125978. */
  125979. reset(): void;
  125980. private onErrorCallback;
  125981. private onDoneCallback;
  125982. }
  125983. /**
  125984. * Define the interface used by progress events raised during assets loading
  125985. */
  125986. export interface IAssetsProgressEvent {
  125987. /**
  125988. * Defines the number of remaining tasks to process
  125989. */
  125990. remainingCount: number;
  125991. /**
  125992. * Defines the total number of tasks
  125993. */
  125994. totalCount: number;
  125995. /**
  125996. * Defines the task that was just processed
  125997. */
  125998. task: AbstractAssetTask;
  125999. }
  126000. /**
  126001. * Class used to share progress information about assets loading
  126002. */
  126003. export class AssetsProgressEvent implements IAssetsProgressEvent {
  126004. /**
  126005. * Defines the number of remaining tasks to process
  126006. */
  126007. remainingCount: number;
  126008. /**
  126009. * Defines the total number of tasks
  126010. */
  126011. totalCount: number;
  126012. /**
  126013. * Defines the task that was just processed
  126014. */
  126015. task: AbstractAssetTask;
  126016. /**
  126017. * Creates a AssetsProgressEvent
  126018. * @param remainingCount defines the number of remaining tasks to process
  126019. * @param totalCount defines the total number of tasks
  126020. * @param task defines the task that was just processed
  126021. */
  126022. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  126023. }
  126024. /**
  126025. * Define a task used by AssetsManager to load meshes
  126026. */
  126027. export class MeshAssetTask extends AbstractAssetTask {
  126028. /**
  126029. * Defines the name of the task
  126030. */
  126031. name: string;
  126032. /**
  126033. * Defines the list of mesh's names you want to load
  126034. */
  126035. meshesNames: any;
  126036. /**
  126037. * Defines the root url to use as a base to load your meshes and associated resources
  126038. */
  126039. rootUrl: string;
  126040. /**
  126041. * Defines the filename of the scene to load from
  126042. */
  126043. sceneFilename: string;
  126044. /**
  126045. * Gets the list of loaded meshes
  126046. */
  126047. loadedMeshes: Array<AbstractMesh>;
  126048. /**
  126049. * Gets the list of loaded particle systems
  126050. */
  126051. loadedParticleSystems: Array<IParticleSystem>;
  126052. /**
  126053. * Gets the list of loaded skeletons
  126054. */
  126055. loadedSkeletons: Array<Skeleton>;
  126056. /**
  126057. * Gets the list of loaded animation groups
  126058. */
  126059. loadedAnimationGroups: Array<AnimationGroup>;
  126060. /**
  126061. * Callback called when the task is successful
  126062. */
  126063. onSuccess: (task: MeshAssetTask) => void;
  126064. /**
  126065. * Callback called when the task is successful
  126066. */
  126067. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  126068. /**
  126069. * Creates a new MeshAssetTask
  126070. * @param name defines the name of the task
  126071. * @param meshesNames defines the list of mesh's names you want to load
  126072. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  126073. * @param sceneFilename defines the filename of the scene to load from
  126074. */
  126075. constructor(
  126076. /**
  126077. * Defines the name of the task
  126078. */
  126079. name: string,
  126080. /**
  126081. * Defines the list of mesh's names you want to load
  126082. */
  126083. meshesNames: any,
  126084. /**
  126085. * Defines the root url to use as a base to load your meshes and associated resources
  126086. */
  126087. rootUrl: string,
  126088. /**
  126089. * Defines the filename of the scene to load from
  126090. */
  126091. sceneFilename: string);
  126092. /**
  126093. * Execute the current task
  126094. * @param scene defines the scene where you want your assets to be loaded
  126095. * @param onSuccess is a callback called when the task is successfully executed
  126096. * @param onError is a callback called if an error occurs
  126097. */
  126098. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  126099. }
  126100. /**
  126101. * Define a task used by AssetsManager to load text content
  126102. */
  126103. export class TextFileAssetTask extends AbstractAssetTask {
  126104. /**
  126105. * Defines the name of the task
  126106. */
  126107. name: string;
  126108. /**
  126109. * Defines the location of the file to load
  126110. */
  126111. url: string;
  126112. /**
  126113. * Gets the loaded text string
  126114. */
  126115. text: string;
  126116. /**
  126117. * Callback called when the task is successful
  126118. */
  126119. onSuccess: (task: TextFileAssetTask) => void;
  126120. /**
  126121. * Callback called when the task is successful
  126122. */
  126123. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  126124. /**
  126125. * Creates a new TextFileAssetTask object
  126126. * @param name defines the name of the task
  126127. * @param url defines the location of the file to load
  126128. */
  126129. constructor(
  126130. /**
  126131. * Defines the name of the task
  126132. */
  126133. name: string,
  126134. /**
  126135. * Defines the location of the file to load
  126136. */
  126137. url: string);
  126138. /**
  126139. * Execute the current task
  126140. * @param scene defines the scene where you want your assets to be loaded
  126141. * @param onSuccess is a callback called when the task is successfully executed
  126142. * @param onError is a callback called if an error occurs
  126143. */
  126144. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  126145. }
  126146. /**
  126147. * Define a task used by AssetsManager to load binary data
  126148. */
  126149. export class BinaryFileAssetTask extends AbstractAssetTask {
  126150. /**
  126151. * Defines the name of the task
  126152. */
  126153. name: string;
  126154. /**
  126155. * Defines the location of the file to load
  126156. */
  126157. url: string;
  126158. /**
  126159. * Gets the lodaded data (as an array buffer)
  126160. */
  126161. data: ArrayBuffer;
  126162. /**
  126163. * Callback called when the task is successful
  126164. */
  126165. onSuccess: (task: BinaryFileAssetTask) => void;
  126166. /**
  126167. * Callback called when the task is successful
  126168. */
  126169. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  126170. /**
  126171. * Creates a new BinaryFileAssetTask object
  126172. * @param name defines the name of the new task
  126173. * @param url defines the location of the file to load
  126174. */
  126175. constructor(
  126176. /**
  126177. * Defines the name of the task
  126178. */
  126179. name: string,
  126180. /**
  126181. * Defines the location of the file to load
  126182. */
  126183. url: string);
  126184. /**
  126185. * Execute the current task
  126186. * @param scene defines the scene where you want your assets to be loaded
  126187. * @param onSuccess is a callback called when the task is successfully executed
  126188. * @param onError is a callback called if an error occurs
  126189. */
  126190. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  126191. }
  126192. /**
  126193. * Define a task used by AssetsManager to load images
  126194. */
  126195. export class ImageAssetTask extends AbstractAssetTask {
  126196. /**
  126197. * Defines the name of the task
  126198. */
  126199. name: string;
  126200. /**
  126201. * Defines the location of the image to load
  126202. */
  126203. url: string;
  126204. /**
  126205. * Gets the loaded images
  126206. */
  126207. image: HTMLImageElement;
  126208. /**
  126209. * Callback called when the task is successful
  126210. */
  126211. onSuccess: (task: ImageAssetTask) => void;
  126212. /**
  126213. * Callback called when the task is successful
  126214. */
  126215. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  126216. /**
  126217. * Creates a new ImageAssetTask
  126218. * @param name defines the name of the task
  126219. * @param url defines the location of the image to load
  126220. */
  126221. constructor(
  126222. /**
  126223. * Defines the name of the task
  126224. */
  126225. name: string,
  126226. /**
  126227. * Defines the location of the image to load
  126228. */
  126229. url: string);
  126230. /**
  126231. * Execute the current task
  126232. * @param scene defines the scene where you want your assets to be loaded
  126233. * @param onSuccess is a callback called when the task is successfully executed
  126234. * @param onError is a callback called if an error occurs
  126235. */
  126236. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  126237. }
  126238. /**
  126239. * Defines the interface used by texture loading tasks
  126240. */
  126241. export interface ITextureAssetTask<TEX extends BaseTexture> {
  126242. /**
  126243. * Gets the loaded texture
  126244. */
  126245. texture: TEX;
  126246. }
  126247. /**
  126248. * Define a task used by AssetsManager to load 2D textures
  126249. */
  126250. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  126251. /**
  126252. * Defines the name of the task
  126253. */
  126254. name: string;
  126255. /**
  126256. * Defines the location of the file to load
  126257. */
  126258. url: string;
  126259. /**
  126260. * Defines if mipmap should not be generated (default is false)
  126261. */
  126262. noMipmap?: boolean | undefined;
  126263. /**
  126264. * Defines if texture must be inverted on Y axis (default is false)
  126265. */
  126266. invertY?: boolean | undefined;
  126267. /**
  126268. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  126269. */
  126270. samplingMode: number;
  126271. /**
  126272. * Gets the loaded texture
  126273. */
  126274. texture: Texture;
  126275. /**
  126276. * Callback called when the task is successful
  126277. */
  126278. onSuccess: (task: TextureAssetTask) => void;
  126279. /**
  126280. * Callback called when the task is successful
  126281. */
  126282. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  126283. /**
  126284. * Creates a new TextureAssetTask object
  126285. * @param name defines the name of the task
  126286. * @param url defines the location of the file to load
  126287. * @param noMipmap defines if mipmap should not be generated (default is false)
  126288. * @param invertY defines if texture must be inverted on Y axis (default is false)
  126289. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  126290. */
  126291. constructor(
  126292. /**
  126293. * Defines the name of the task
  126294. */
  126295. name: string,
  126296. /**
  126297. * Defines the location of the file to load
  126298. */
  126299. url: string,
  126300. /**
  126301. * Defines if mipmap should not be generated (default is false)
  126302. */
  126303. noMipmap?: boolean | undefined,
  126304. /**
  126305. * Defines if texture must be inverted on Y axis (default is false)
  126306. */
  126307. invertY?: boolean | undefined,
  126308. /**
  126309. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  126310. */
  126311. samplingMode?: number);
  126312. /**
  126313. * Execute the current task
  126314. * @param scene defines the scene where you want your assets to be loaded
  126315. * @param onSuccess is a callback called when the task is successfully executed
  126316. * @param onError is a callback called if an error occurs
  126317. */
  126318. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  126319. }
  126320. /**
  126321. * Define a task used by AssetsManager to load cube textures
  126322. */
  126323. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  126324. /**
  126325. * Defines the name of the task
  126326. */
  126327. name: string;
  126328. /**
  126329. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  126330. */
  126331. url: string;
  126332. /**
  126333. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  126334. */
  126335. extensions?: string[] | undefined;
  126336. /**
  126337. * Defines if mipmaps should not be generated (default is false)
  126338. */
  126339. noMipmap?: boolean | undefined;
  126340. /**
  126341. * Defines the explicit list of files (undefined by default)
  126342. */
  126343. files?: string[] | undefined;
  126344. /**
  126345. * Gets the loaded texture
  126346. */
  126347. texture: CubeTexture;
  126348. /**
  126349. * Callback called when the task is successful
  126350. */
  126351. onSuccess: (task: CubeTextureAssetTask) => void;
  126352. /**
  126353. * Callback called when the task is successful
  126354. */
  126355. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  126356. /**
  126357. * Creates a new CubeTextureAssetTask
  126358. * @param name defines the name of the task
  126359. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  126360. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  126361. * @param noMipmap defines if mipmaps should not be generated (default is false)
  126362. * @param files defines the explicit list of files (undefined by default)
  126363. */
  126364. constructor(
  126365. /**
  126366. * Defines the name of the task
  126367. */
  126368. name: string,
  126369. /**
  126370. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  126371. */
  126372. url: string,
  126373. /**
  126374. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  126375. */
  126376. extensions?: string[] | undefined,
  126377. /**
  126378. * Defines if mipmaps should not be generated (default is false)
  126379. */
  126380. noMipmap?: boolean | undefined,
  126381. /**
  126382. * Defines the explicit list of files (undefined by default)
  126383. */
  126384. files?: string[] | undefined);
  126385. /**
  126386. * Execute the current task
  126387. * @param scene defines the scene where you want your assets to be loaded
  126388. * @param onSuccess is a callback called when the task is successfully executed
  126389. * @param onError is a callback called if an error occurs
  126390. */
  126391. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  126392. }
  126393. /**
  126394. * Define a task used by AssetsManager to load HDR cube textures
  126395. */
  126396. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  126397. /**
  126398. * Defines the name of the task
  126399. */
  126400. name: string;
  126401. /**
  126402. * Defines the location of the file to load
  126403. */
  126404. url: string;
  126405. /**
  126406. * Defines the desired size (the more it increases the longer the generation will be)
  126407. */
  126408. size: number;
  126409. /**
  126410. * Defines if mipmaps should not be generated (default is false)
  126411. */
  126412. noMipmap: boolean;
  126413. /**
  126414. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  126415. */
  126416. generateHarmonics: boolean;
  126417. /**
  126418. * 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)
  126419. */
  126420. gammaSpace: boolean;
  126421. /**
  126422. * Internal Use Only
  126423. */
  126424. reserved: boolean;
  126425. /**
  126426. * Gets the loaded texture
  126427. */
  126428. texture: HDRCubeTexture;
  126429. /**
  126430. * Callback called when the task is successful
  126431. */
  126432. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  126433. /**
  126434. * Callback called when the task is successful
  126435. */
  126436. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  126437. /**
  126438. * Creates a new HDRCubeTextureAssetTask object
  126439. * @param name defines the name of the task
  126440. * @param url defines the location of the file to load
  126441. * @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.
  126442. * @param noMipmap defines if mipmaps should not be generated (default is false)
  126443. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  126444. * @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)
  126445. * @param reserved Internal use only
  126446. */
  126447. constructor(
  126448. /**
  126449. * Defines the name of the task
  126450. */
  126451. name: string,
  126452. /**
  126453. * Defines the location of the file to load
  126454. */
  126455. url: string,
  126456. /**
  126457. * Defines the desired size (the more it increases the longer the generation will be)
  126458. */
  126459. size: number,
  126460. /**
  126461. * Defines if mipmaps should not be generated (default is false)
  126462. */
  126463. noMipmap?: boolean,
  126464. /**
  126465. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  126466. */
  126467. generateHarmonics?: boolean,
  126468. /**
  126469. * 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)
  126470. */
  126471. gammaSpace?: boolean,
  126472. /**
  126473. * Internal Use Only
  126474. */
  126475. reserved?: boolean);
  126476. /**
  126477. * Execute the current task
  126478. * @param scene defines the scene where you want your assets to be loaded
  126479. * @param onSuccess is a callback called when the task is successfully executed
  126480. * @param onError is a callback called if an error occurs
  126481. */
  126482. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  126483. }
  126484. /**
  126485. * Define a task used by AssetsManager to load Equirectangular cube textures
  126486. */
  126487. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  126488. /**
  126489. * Defines the name of the task
  126490. */
  126491. name: string;
  126492. /**
  126493. * Defines the location of the file to load
  126494. */
  126495. url: string;
  126496. /**
  126497. * Defines the desired size (the more it increases the longer the generation will be)
  126498. */
  126499. size: number;
  126500. /**
  126501. * Defines if mipmaps should not be generated (default is false)
  126502. */
  126503. noMipmap: boolean;
  126504. /**
  126505. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  126506. * but the standard material would require them in Gamma space) (default is true)
  126507. */
  126508. gammaSpace: boolean;
  126509. /**
  126510. * Gets the loaded texture
  126511. */
  126512. texture: EquiRectangularCubeTexture;
  126513. /**
  126514. * Callback called when the task is successful
  126515. */
  126516. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  126517. /**
  126518. * Callback called when the task is successful
  126519. */
  126520. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  126521. /**
  126522. * Creates a new EquiRectangularCubeTextureAssetTask object
  126523. * @param name defines the name of the task
  126524. * @param url defines the location of the file to load
  126525. * @param size defines the desired size (the more it increases the longer the generation will be)
  126526. * If the size is omitted this implies you are using a preprocessed cubemap.
  126527. * @param noMipmap defines if mipmaps should not be generated (default is false)
  126528. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  126529. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  126530. * (default is true)
  126531. */
  126532. constructor(
  126533. /**
  126534. * Defines the name of the task
  126535. */
  126536. name: string,
  126537. /**
  126538. * Defines the location of the file to load
  126539. */
  126540. url: string,
  126541. /**
  126542. * Defines the desired size (the more it increases the longer the generation will be)
  126543. */
  126544. size: number,
  126545. /**
  126546. * Defines if mipmaps should not be generated (default is false)
  126547. */
  126548. noMipmap?: boolean,
  126549. /**
  126550. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  126551. * but the standard material would require them in Gamma space) (default is true)
  126552. */
  126553. gammaSpace?: boolean);
  126554. /**
  126555. * Execute the current task
  126556. * @param scene defines the scene where you want your assets to be loaded
  126557. * @param onSuccess is a callback called when the task is successfully executed
  126558. * @param onError is a callback called if an error occurs
  126559. */
  126560. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  126561. }
  126562. /**
  126563. * This class can be used to easily import assets into a scene
  126564. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  126565. */
  126566. export class AssetsManager {
  126567. private _scene;
  126568. private _isLoading;
  126569. protected _tasks: AbstractAssetTask[];
  126570. protected _waitingTasksCount: number;
  126571. protected _totalTasksCount: number;
  126572. /**
  126573. * Callback called when all tasks are processed
  126574. */
  126575. onFinish: (tasks: AbstractAssetTask[]) => void;
  126576. /**
  126577. * Callback called when a task is successful
  126578. */
  126579. onTaskSuccess: (task: AbstractAssetTask) => void;
  126580. /**
  126581. * Callback called when a task had an error
  126582. */
  126583. onTaskError: (task: AbstractAssetTask) => void;
  126584. /**
  126585. * Callback called when a task is done (whatever the result is)
  126586. */
  126587. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  126588. /**
  126589. * Observable called when all tasks are processed
  126590. */
  126591. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  126592. /**
  126593. * Observable called when a task had an error
  126594. */
  126595. onTaskErrorObservable: Observable<AbstractAssetTask>;
  126596. /**
  126597. * Observable called when all tasks were executed
  126598. */
  126599. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  126600. /**
  126601. * Observable called when a task is done (whatever the result is)
  126602. */
  126603. onProgressObservable: Observable<IAssetsProgressEvent>;
  126604. /**
  126605. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  126606. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  126607. */
  126608. useDefaultLoadingScreen: boolean;
  126609. /**
  126610. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  126611. * when all assets have been downloaded.
  126612. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  126613. */
  126614. autoHideLoadingUI: boolean;
  126615. /**
  126616. * Creates a new AssetsManager
  126617. * @param scene defines the scene to work on
  126618. */
  126619. constructor(scene: Scene);
  126620. /**
  126621. * Add a MeshAssetTask to the list of active tasks
  126622. * @param taskName defines the name of the new task
  126623. * @param meshesNames defines the name of meshes to load
  126624. * @param rootUrl defines the root url to use to locate files
  126625. * @param sceneFilename defines the filename of the scene file
  126626. * @returns a new MeshAssetTask object
  126627. */
  126628. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  126629. /**
  126630. * Add a TextFileAssetTask to the list of active tasks
  126631. * @param taskName defines the name of the new task
  126632. * @param url defines the url of the file to load
  126633. * @returns a new TextFileAssetTask object
  126634. */
  126635. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  126636. /**
  126637. * Add a BinaryFileAssetTask to the list of active tasks
  126638. * @param taskName defines the name of the new task
  126639. * @param url defines the url of the file to load
  126640. * @returns a new BinaryFileAssetTask object
  126641. */
  126642. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  126643. /**
  126644. * Add a ImageAssetTask to the list of active tasks
  126645. * @param taskName defines the name of the new task
  126646. * @param url defines the url of the file to load
  126647. * @returns a new ImageAssetTask object
  126648. */
  126649. addImageTask(taskName: string, url: string): ImageAssetTask;
  126650. /**
  126651. * Add a TextureAssetTask to the list of active tasks
  126652. * @param taskName defines the name of the new task
  126653. * @param url defines the url of the file to load
  126654. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  126655. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  126656. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  126657. * @returns a new TextureAssetTask object
  126658. */
  126659. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  126660. /**
  126661. * Add a CubeTextureAssetTask to the list of active tasks
  126662. * @param taskName defines the name of the new task
  126663. * @param url defines the url of the file to load
  126664. * @param extensions defines the extension to use to load the cube map (can be null)
  126665. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  126666. * @param files defines the list of files to load (can be null)
  126667. * @returns a new CubeTextureAssetTask object
  126668. */
  126669. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  126670. /**
  126671. *
  126672. * Add a HDRCubeTextureAssetTask to the list of active tasks
  126673. * @param taskName defines the name of the new task
  126674. * @param url defines the url of the file to load
  126675. * @param size defines the size you want for the cubemap (can be null)
  126676. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  126677. * @param generateHarmonics defines if you want to automatically generate (true by default)
  126678. * @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)
  126679. * @param reserved Internal use only
  126680. * @returns a new HDRCubeTextureAssetTask object
  126681. */
  126682. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  126683. /**
  126684. *
  126685. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  126686. * @param taskName defines the name of the new task
  126687. * @param url defines the url of the file to load
  126688. * @param size defines the size you want for the cubemap (can be null)
  126689. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  126690. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  126691. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  126692. * @returns a new EquiRectangularCubeTextureAssetTask object
  126693. */
  126694. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  126695. /**
  126696. * Remove a task from the assets manager.
  126697. * @param task the task to remove
  126698. */
  126699. removeTask(task: AbstractAssetTask): void;
  126700. private _decreaseWaitingTasksCount;
  126701. private _runTask;
  126702. /**
  126703. * Reset the AssetsManager and remove all tasks
  126704. * @return the current instance of the AssetsManager
  126705. */
  126706. reset(): AssetsManager;
  126707. /**
  126708. * Start the loading process
  126709. * @return the current instance of the AssetsManager
  126710. */
  126711. load(): AssetsManager;
  126712. /**
  126713. * Start the loading process as an async operation
  126714. * @return a promise returning the list of failed tasks
  126715. */
  126716. loadAsync(): Promise<void>;
  126717. }
  126718. }
  126719. declare module BABYLON {
  126720. /**
  126721. * Wrapper class for promise with external resolve and reject.
  126722. */
  126723. export class Deferred<T> {
  126724. /**
  126725. * The promise associated with this deferred object.
  126726. */
  126727. readonly promise: Promise<T>;
  126728. private _resolve;
  126729. private _reject;
  126730. /**
  126731. * The resolve method of the promise associated with this deferred object.
  126732. */
  126733. readonly resolve: (value?: T | PromiseLike<T> | undefined) => void;
  126734. /**
  126735. * The reject method of the promise associated with this deferred object.
  126736. */
  126737. readonly reject: (reason?: any) => void;
  126738. /**
  126739. * Constructor for this deferred object.
  126740. */
  126741. constructor();
  126742. }
  126743. }
  126744. declare module BABYLON {
  126745. /**
  126746. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  126747. */
  126748. export class MeshExploder {
  126749. private _centerMesh;
  126750. private _meshes;
  126751. private _meshesOrigins;
  126752. private _toCenterVectors;
  126753. private _scaledDirection;
  126754. private _newPosition;
  126755. private _centerPosition;
  126756. /**
  126757. * Explodes meshes from a center mesh.
  126758. * @param meshes The meshes to explode.
  126759. * @param centerMesh The mesh to be center of explosion.
  126760. */
  126761. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  126762. private _setCenterMesh;
  126763. /**
  126764. * Get class name
  126765. * @returns "MeshExploder"
  126766. */
  126767. getClassName(): string;
  126768. /**
  126769. * "Exploded meshes"
  126770. * @returns Array of meshes with the centerMesh at index 0.
  126771. */
  126772. getMeshes(): Array<Mesh>;
  126773. /**
  126774. * Explodes meshes giving a specific direction
  126775. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  126776. */
  126777. explode(direction?: number): void;
  126778. }
  126779. }
  126780. declare module BABYLON {
  126781. /**
  126782. * Class used to help managing file picking and drag'n'drop
  126783. */
  126784. export class FilesInput {
  126785. /**
  126786. * List of files ready to be loaded
  126787. */
  126788. static readonly FilesToLoad: {
  126789. [key: string]: File;
  126790. };
  126791. /**
  126792. * Callback called when a file is processed
  126793. */
  126794. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  126795. private _engine;
  126796. private _currentScene;
  126797. private _sceneLoadedCallback;
  126798. private _progressCallback;
  126799. private _additionalRenderLoopLogicCallback;
  126800. private _textureLoadingCallback;
  126801. private _startingProcessingFilesCallback;
  126802. private _onReloadCallback;
  126803. private _errorCallback;
  126804. private _elementToMonitor;
  126805. private _sceneFileToLoad;
  126806. private _filesToLoad;
  126807. /**
  126808. * Creates a new FilesInput
  126809. * @param engine defines the rendering engine
  126810. * @param scene defines the hosting scene
  126811. * @param sceneLoadedCallback callback called when scene is loaded
  126812. * @param progressCallback callback called to track progress
  126813. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  126814. * @param textureLoadingCallback callback called when a texture is loading
  126815. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  126816. * @param onReloadCallback callback called when a reload is requested
  126817. * @param errorCallback callback call if an error occurs
  126818. */
  126819. 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);
  126820. private _dragEnterHandler;
  126821. private _dragOverHandler;
  126822. private _dropHandler;
  126823. /**
  126824. * Calls this function to listen to drag'n'drop events on a specific DOM element
  126825. * @param elementToMonitor defines the DOM element to track
  126826. */
  126827. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  126828. /**
  126829. * Release all associated resources
  126830. */
  126831. dispose(): void;
  126832. private renderFunction;
  126833. private drag;
  126834. private drop;
  126835. private _traverseFolder;
  126836. private _processFiles;
  126837. /**
  126838. * Load files from a drop event
  126839. * @param event defines the drop event to use as source
  126840. */
  126841. loadFiles(event: any): void;
  126842. private _processReload;
  126843. /**
  126844. * Reload the current scene from the loaded files
  126845. */
  126846. reload(): void;
  126847. }
  126848. }
  126849. declare module BABYLON {
  126850. /**
  126851. * Defines the root class used to create scene optimization to use with SceneOptimizer
  126852. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  126853. */
  126854. export class SceneOptimization {
  126855. /**
  126856. * Defines the priority of this optimization (0 by default which means first in the list)
  126857. */
  126858. priority: number;
  126859. /**
  126860. * Gets a string describing the action executed by the current optimization
  126861. * @returns description string
  126862. */
  126863. getDescription(): string;
  126864. /**
  126865. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  126866. * @param scene defines the current scene where to apply this optimization
  126867. * @param optimizer defines the current optimizer
  126868. * @returns true if everything that can be done was applied
  126869. */
  126870. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  126871. /**
  126872. * Creates the SceneOptimization object
  126873. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  126874. * @param desc defines the description associated with the optimization
  126875. */
  126876. constructor(
  126877. /**
  126878. * Defines the priority of this optimization (0 by default which means first in the list)
  126879. */
  126880. priority?: number);
  126881. }
  126882. /**
  126883. * Defines an optimization used to reduce the size of render target textures
  126884. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  126885. */
  126886. export class TextureOptimization extends SceneOptimization {
  126887. /**
  126888. * Defines the priority of this optimization (0 by default which means first in the list)
  126889. */
  126890. priority: number;
  126891. /**
  126892. * 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
  126893. */
  126894. maximumSize: number;
  126895. /**
  126896. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  126897. */
  126898. step: number;
  126899. /**
  126900. * Gets a string describing the action executed by the current optimization
  126901. * @returns description string
  126902. */
  126903. getDescription(): string;
  126904. /**
  126905. * Creates the TextureOptimization object
  126906. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  126907. * @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
  126908. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  126909. */
  126910. constructor(
  126911. /**
  126912. * Defines the priority of this optimization (0 by default which means first in the list)
  126913. */
  126914. priority?: number,
  126915. /**
  126916. * 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
  126917. */
  126918. maximumSize?: number,
  126919. /**
  126920. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  126921. */
  126922. step?: number);
  126923. /**
  126924. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  126925. * @param scene defines the current scene where to apply this optimization
  126926. * @param optimizer defines the current optimizer
  126927. * @returns true if everything that can be done was applied
  126928. */
  126929. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  126930. }
  126931. /**
  126932. * Defines an optimization used to increase or decrease the rendering resolution
  126933. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  126934. */
  126935. export class HardwareScalingOptimization extends SceneOptimization {
  126936. /**
  126937. * Defines the priority of this optimization (0 by default which means first in the list)
  126938. */
  126939. priority: number;
  126940. /**
  126941. * Defines the maximum scale to use (2 by default)
  126942. */
  126943. maximumScale: number;
  126944. /**
  126945. * Defines the step to use between two passes (0.5 by default)
  126946. */
  126947. step: number;
  126948. private _currentScale;
  126949. private _directionOffset;
  126950. /**
  126951. * Gets a string describing the action executed by the current optimization
  126952. * @return description string
  126953. */
  126954. getDescription(): string;
  126955. /**
  126956. * Creates the HardwareScalingOptimization object
  126957. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  126958. * @param maximumScale defines the maximum scale to use (2 by default)
  126959. * @param step defines the step to use between two passes (0.5 by default)
  126960. */
  126961. constructor(
  126962. /**
  126963. * Defines the priority of this optimization (0 by default which means first in the list)
  126964. */
  126965. priority?: number,
  126966. /**
  126967. * Defines the maximum scale to use (2 by default)
  126968. */
  126969. maximumScale?: number,
  126970. /**
  126971. * Defines the step to use between two passes (0.5 by default)
  126972. */
  126973. step?: number);
  126974. /**
  126975. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  126976. * @param scene defines the current scene where to apply this optimization
  126977. * @param optimizer defines the current optimizer
  126978. * @returns true if everything that can be done was applied
  126979. */
  126980. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  126981. }
  126982. /**
  126983. * Defines an optimization used to remove shadows
  126984. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  126985. */
  126986. export class ShadowsOptimization extends SceneOptimization {
  126987. /**
  126988. * Gets a string describing the action executed by the current optimization
  126989. * @return description string
  126990. */
  126991. getDescription(): string;
  126992. /**
  126993. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  126994. * @param scene defines the current scene where to apply this optimization
  126995. * @param optimizer defines the current optimizer
  126996. * @returns true if everything that can be done was applied
  126997. */
  126998. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  126999. }
  127000. /**
  127001. * Defines an optimization used to turn post-processes off
  127002. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  127003. */
  127004. export class PostProcessesOptimization extends SceneOptimization {
  127005. /**
  127006. * Gets a string describing the action executed by the current optimization
  127007. * @return description string
  127008. */
  127009. getDescription(): string;
  127010. /**
  127011. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  127012. * @param scene defines the current scene where to apply this optimization
  127013. * @param optimizer defines the current optimizer
  127014. * @returns true if everything that can be done was applied
  127015. */
  127016. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  127017. }
  127018. /**
  127019. * Defines an optimization used to turn lens flares off
  127020. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  127021. */
  127022. export class LensFlaresOptimization extends SceneOptimization {
  127023. /**
  127024. * Gets a string describing the action executed by the current optimization
  127025. * @return description string
  127026. */
  127027. getDescription(): string;
  127028. /**
  127029. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  127030. * @param scene defines the current scene where to apply this optimization
  127031. * @param optimizer defines the current optimizer
  127032. * @returns true if everything that can be done was applied
  127033. */
  127034. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  127035. }
  127036. /**
  127037. * Defines an optimization based on user defined callback.
  127038. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  127039. */
  127040. export class CustomOptimization extends SceneOptimization {
  127041. /**
  127042. * Callback called to apply the custom optimization.
  127043. */
  127044. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  127045. /**
  127046. * Callback called to get custom description
  127047. */
  127048. onGetDescription: () => string;
  127049. /**
  127050. * Gets a string describing the action executed by the current optimization
  127051. * @returns description string
  127052. */
  127053. getDescription(): string;
  127054. /**
  127055. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  127056. * @param scene defines the current scene where to apply this optimization
  127057. * @param optimizer defines the current optimizer
  127058. * @returns true if everything that can be done was applied
  127059. */
  127060. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  127061. }
  127062. /**
  127063. * Defines an optimization used to turn particles off
  127064. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  127065. */
  127066. export class ParticlesOptimization extends SceneOptimization {
  127067. /**
  127068. * Gets a string describing the action executed by the current optimization
  127069. * @return description string
  127070. */
  127071. getDescription(): string;
  127072. /**
  127073. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  127074. * @param scene defines the current scene where to apply this optimization
  127075. * @param optimizer defines the current optimizer
  127076. * @returns true if everything that can be done was applied
  127077. */
  127078. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  127079. }
  127080. /**
  127081. * Defines an optimization used to turn render targets off
  127082. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  127083. */
  127084. export class RenderTargetsOptimization extends SceneOptimization {
  127085. /**
  127086. * Gets a string describing the action executed by the current optimization
  127087. * @return description string
  127088. */
  127089. getDescription(): string;
  127090. /**
  127091. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  127092. * @param scene defines the current scene where to apply this optimization
  127093. * @param optimizer defines the current optimizer
  127094. * @returns true if everything that can be done was applied
  127095. */
  127096. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  127097. }
  127098. /**
  127099. * Defines an optimization used to merge meshes with compatible materials
  127100. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  127101. */
  127102. export class MergeMeshesOptimization extends SceneOptimization {
  127103. private static _UpdateSelectionTree;
  127104. /**
  127105. * Gets or sets a boolean which defines if optimization octree has to be updated
  127106. */
  127107. /**
  127108. * Gets or sets a boolean which defines if optimization octree has to be updated
  127109. */
  127110. static UpdateSelectionTree: boolean;
  127111. /**
  127112. * Gets a string describing the action executed by the current optimization
  127113. * @return description string
  127114. */
  127115. getDescription(): string;
  127116. private _canBeMerged;
  127117. /**
  127118. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  127119. * @param scene defines the current scene where to apply this optimization
  127120. * @param optimizer defines the current optimizer
  127121. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  127122. * @returns true if everything that can be done was applied
  127123. */
  127124. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  127125. }
  127126. /**
  127127. * Defines a list of options used by SceneOptimizer
  127128. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  127129. */
  127130. export class SceneOptimizerOptions {
  127131. /**
  127132. * Defines the target frame rate to reach (60 by default)
  127133. */
  127134. targetFrameRate: number;
  127135. /**
  127136. * Defines the interval between two checkes (2000ms by default)
  127137. */
  127138. trackerDuration: number;
  127139. /**
  127140. * Gets the list of optimizations to apply
  127141. */
  127142. optimizations: SceneOptimization[];
  127143. /**
  127144. * Creates a new list of options used by SceneOptimizer
  127145. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  127146. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  127147. */
  127148. constructor(
  127149. /**
  127150. * Defines the target frame rate to reach (60 by default)
  127151. */
  127152. targetFrameRate?: number,
  127153. /**
  127154. * Defines the interval between two checkes (2000ms by default)
  127155. */
  127156. trackerDuration?: number);
  127157. /**
  127158. * Add a new optimization
  127159. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  127160. * @returns the current SceneOptimizerOptions
  127161. */
  127162. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  127163. /**
  127164. * Add a new custom optimization
  127165. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  127166. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  127167. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  127168. * @returns the current SceneOptimizerOptions
  127169. */
  127170. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  127171. /**
  127172. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  127173. * @param targetFrameRate defines the target frame rate (60 by default)
  127174. * @returns a SceneOptimizerOptions object
  127175. */
  127176. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  127177. /**
  127178. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  127179. * @param targetFrameRate defines the target frame rate (60 by default)
  127180. * @returns a SceneOptimizerOptions object
  127181. */
  127182. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  127183. /**
  127184. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  127185. * @param targetFrameRate defines the target frame rate (60 by default)
  127186. * @returns a SceneOptimizerOptions object
  127187. */
  127188. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  127189. }
  127190. /**
  127191. * Class used to run optimizations in order to reach a target frame rate
  127192. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  127193. */
  127194. export class SceneOptimizer implements IDisposable {
  127195. private _isRunning;
  127196. private _options;
  127197. private _scene;
  127198. private _currentPriorityLevel;
  127199. private _targetFrameRate;
  127200. private _trackerDuration;
  127201. private _currentFrameRate;
  127202. private _sceneDisposeObserver;
  127203. private _improvementMode;
  127204. /**
  127205. * Defines an observable called when the optimizer reaches the target frame rate
  127206. */
  127207. onSuccessObservable: Observable<SceneOptimizer>;
  127208. /**
  127209. * Defines an observable called when the optimizer enables an optimization
  127210. */
  127211. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  127212. /**
  127213. * Defines an observable called when the optimizer is not able to reach the target frame rate
  127214. */
  127215. onFailureObservable: Observable<SceneOptimizer>;
  127216. /**
  127217. * Gets a boolean indicating if the optimizer is in improvement mode
  127218. */
  127219. readonly isInImprovementMode: boolean;
  127220. /**
  127221. * Gets the current priority level (0 at start)
  127222. */
  127223. readonly currentPriorityLevel: number;
  127224. /**
  127225. * Gets the current frame rate checked by the SceneOptimizer
  127226. */
  127227. readonly currentFrameRate: number;
  127228. /**
  127229. * Gets or sets the current target frame rate (60 by default)
  127230. */
  127231. /**
  127232. * Gets or sets the current target frame rate (60 by default)
  127233. */
  127234. targetFrameRate: number;
  127235. /**
  127236. * Gets or sets the current interval between two checks (every 2000ms by default)
  127237. */
  127238. /**
  127239. * Gets or sets the current interval between two checks (every 2000ms by default)
  127240. */
  127241. trackerDuration: number;
  127242. /**
  127243. * Gets the list of active optimizations
  127244. */
  127245. readonly optimizations: SceneOptimization[];
  127246. /**
  127247. * Creates a new SceneOptimizer
  127248. * @param scene defines the scene to work on
  127249. * @param options defines the options to use with the SceneOptimizer
  127250. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  127251. * @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)
  127252. */
  127253. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  127254. /**
  127255. * Stops the current optimizer
  127256. */
  127257. stop(): void;
  127258. /**
  127259. * Reset the optimizer to initial step (current priority level = 0)
  127260. */
  127261. reset(): void;
  127262. /**
  127263. * Start the optimizer. By default it will try to reach a specific framerate
  127264. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  127265. */
  127266. start(): void;
  127267. private _checkCurrentState;
  127268. /**
  127269. * Release all resources
  127270. */
  127271. dispose(): void;
  127272. /**
  127273. * Helper function to create a SceneOptimizer with one single line of code
  127274. * @param scene defines the scene to work on
  127275. * @param options defines the options to use with the SceneOptimizer
  127276. * @param onSuccess defines a callback to call on success
  127277. * @param onFailure defines a callback to call on failure
  127278. * @returns the new SceneOptimizer object
  127279. */
  127280. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  127281. }
  127282. }
  127283. declare module BABYLON {
  127284. /**
  127285. * Class used to serialize a scene into a string
  127286. */
  127287. export class SceneSerializer {
  127288. /**
  127289. * Clear cache used by a previous serialization
  127290. */
  127291. static ClearCache(): void;
  127292. /**
  127293. * Serialize a scene into a JSON compatible object
  127294. * @param scene defines the scene to serialize
  127295. * @returns a JSON compatible object
  127296. */
  127297. static Serialize(scene: Scene): any;
  127298. /**
  127299. * Serialize a mesh into a JSON compatible object
  127300. * @param toSerialize defines the mesh to serialize
  127301. * @param withParents defines if parents must be serialized as well
  127302. * @param withChildren defines if children must be serialized as well
  127303. * @returns a JSON compatible object
  127304. */
  127305. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  127306. }
  127307. }
  127308. declare module BABYLON {
  127309. /**
  127310. * Class used to host texture specific utilities
  127311. */
  127312. export class TextureTools {
  127313. /**
  127314. * Uses the GPU to create a copy texture rescaled at a given size
  127315. * @param texture Texture to copy from
  127316. * @param width defines the desired width
  127317. * @param height defines the desired height
  127318. * @param useBilinearMode defines if bilinear mode has to be used
  127319. * @return the generated texture
  127320. */
  127321. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  127322. }
  127323. }
  127324. declare module BABYLON {
  127325. /**
  127326. * This represents the different options available for the video capture.
  127327. */
  127328. export interface VideoRecorderOptions {
  127329. /** Defines the mime type of the video. */
  127330. mimeType: string;
  127331. /** Defines the FPS the video should be recorded at. */
  127332. fps: number;
  127333. /** Defines the chunk size for the recording data. */
  127334. recordChunckSize: number;
  127335. /** The audio tracks to attach to the recording. */
  127336. audioTracks?: MediaStreamTrack[];
  127337. }
  127338. /**
  127339. * This can help with recording videos from BabylonJS.
  127340. * This is based on the available WebRTC functionalities of the browser.
  127341. *
  127342. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  127343. */
  127344. export class VideoRecorder {
  127345. private static readonly _defaultOptions;
  127346. /**
  127347. * Returns whether or not the VideoRecorder is available in your browser.
  127348. * @param engine Defines the Babylon Engine.
  127349. * @returns true if supported otherwise false.
  127350. */
  127351. static IsSupported(engine: Engine): boolean;
  127352. private readonly _options;
  127353. private _canvas;
  127354. private _mediaRecorder;
  127355. private _recordedChunks;
  127356. private _fileName;
  127357. private _resolve;
  127358. private _reject;
  127359. /**
  127360. * True when a recording is already in progress.
  127361. */
  127362. readonly isRecording: boolean;
  127363. /**
  127364. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  127365. * @param engine Defines the BabylonJS Engine you wish to record.
  127366. * @param options Defines options that can be used to customize the capture.
  127367. */
  127368. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  127369. /**
  127370. * Stops the current recording before the default capture timeout passed in the startRecording function.
  127371. */
  127372. stopRecording(): void;
  127373. /**
  127374. * Starts recording the canvas for a max duration specified in parameters.
  127375. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  127376. * If null no automatic download will start and you can rely on the promise to get the data back.
  127377. * @param maxDuration Defines the maximum recording time in seconds.
  127378. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  127379. * @return A promise callback at the end of the recording with the video data in Blob.
  127380. */
  127381. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  127382. /**
  127383. * Releases internal resources used during the recording.
  127384. */
  127385. dispose(): void;
  127386. private _handleDataAvailable;
  127387. private _handleError;
  127388. private _handleStop;
  127389. }
  127390. }
  127391. declare module BABYLON {
  127392. /**
  127393. * Class containing a set of static utilities functions for screenshots
  127394. */
  127395. export class ScreenshotTools {
  127396. /**
  127397. * Captures a screenshot of the current rendering
  127398. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  127399. * @param engine defines the rendering engine
  127400. * @param camera defines the source camera
  127401. * @param size This parameter can be set to a single number or to an object with the
  127402. * following (optional) properties: precision, width, height. If a single number is passed,
  127403. * it will be used for both width and height. If an object is passed, the screenshot size
  127404. * will be derived from the parameters. The precision property is a multiplier allowing
  127405. * rendering at a higher or lower resolution
  127406. * @param successCallback defines the callback receives a single parameter which contains the
  127407. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  127408. * src parameter of an <img> to display it
  127409. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  127410. * Check your browser for supported MIME types
  127411. */
  127412. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  127413. /**
  127414. * Captures a screenshot of the current rendering
  127415. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  127416. * @param engine defines the rendering engine
  127417. * @param camera defines the source camera
  127418. * @param size This parameter can be set to a single number or to an object with the
  127419. * following (optional) properties: precision, width, height. If a single number is passed,
  127420. * it will be used for both width and height. If an object is passed, the screenshot size
  127421. * will be derived from the parameters. The precision property is a multiplier allowing
  127422. * rendering at a higher or lower resolution
  127423. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  127424. * Check your browser for supported MIME types
  127425. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  127426. * to the src parameter of an <img> to display it
  127427. */
  127428. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  127429. /**
  127430. * Generates an image screenshot from the specified camera.
  127431. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  127432. * @param engine The engine to use for rendering
  127433. * @param camera The camera to use for rendering
  127434. * @param size This parameter can be set to a single number or to an object with the
  127435. * following (optional) properties: precision, width, height. If a single number is passed,
  127436. * it will be used for both width and height. If an object is passed, the screenshot size
  127437. * will be derived from the parameters. The precision property is a multiplier allowing
  127438. * rendering at a higher or lower resolution
  127439. * @param successCallback The callback receives a single parameter which contains the
  127440. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  127441. * src parameter of an <img> to display it
  127442. * @param mimeType The MIME type of the screenshot image (default: image/png).
  127443. * Check your browser for supported MIME types
  127444. * @param samples Texture samples (default: 1)
  127445. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  127446. * @param fileName A name for for the downloaded file.
  127447. */
  127448. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  127449. /**
  127450. * Generates an image screenshot from the specified camera.
  127451. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  127452. * @param engine The engine to use for rendering
  127453. * @param camera The camera to use for rendering
  127454. * @param size This parameter can be set to a single number or to an object with the
  127455. * following (optional) properties: precision, width, height. If a single number is passed,
  127456. * it will be used for both width and height. If an object is passed, the screenshot size
  127457. * will be derived from the parameters. The precision property is a multiplier allowing
  127458. * rendering at a higher or lower resolution
  127459. * @param mimeType The MIME type of the screenshot image (default: image/png).
  127460. * Check your browser for supported MIME types
  127461. * @param samples Texture samples (default: 1)
  127462. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  127463. * @param fileName A name for for the downloaded file.
  127464. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  127465. * to the src parameter of an <img> to display it
  127466. */
  127467. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  127468. /**
  127469. * Gets height and width for screenshot size
  127470. * @private
  127471. */
  127472. private static _getScreenshotSize;
  127473. }
  127474. }
  127475. declare module BABYLON {
  127476. /**
  127477. * A cursor which tracks a point on a path
  127478. */
  127479. export class PathCursor {
  127480. private path;
  127481. /**
  127482. * Stores path cursor callbacks for when an onchange event is triggered
  127483. */
  127484. private _onchange;
  127485. /**
  127486. * The value of the path cursor
  127487. */
  127488. value: number;
  127489. /**
  127490. * The animation array of the path cursor
  127491. */
  127492. animations: Animation[];
  127493. /**
  127494. * Initializes the path cursor
  127495. * @param path The path to track
  127496. */
  127497. constructor(path: Path2);
  127498. /**
  127499. * Gets the cursor point on the path
  127500. * @returns A point on the path cursor at the cursor location
  127501. */
  127502. getPoint(): Vector3;
  127503. /**
  127504. * Moves the cursor ahead by the step amount
  127505. * @param step The amount to move the cursor forward
  127506. * @returns This path cursor
  127507. */
  127508. moveAhead(step?: number): PathCursor;
  127509. /**
  127510. * Moves the cursor behind by the step amount
  127511. * @param step The amount to move the cursor back
  127512. * @returns This path cursor
  127513. */
  127514. moveBack(step?: number): PathCursor;
  127515. /**
  127516. * Moves the cursor by the step amount
  127517. * If the step amount is greater than one, an exception is thrown
  127518. * @param step The amount to move the cursor
  127519. * @returns This path cursor
  127520. */
  127521. move(step: number): PathCursor;
  127522. /**
  127523. * Ensures that the value is limited between zero and one
  127524. * @returns This path cursor
  127525. */
  127526. private ensureLimits;
  127527. /**
  127528. * Runs onchange callbacks on change (used by the animation engine)
  127529. * @returns This path cursor
  127530. */
  127531. private raiseOnChange;
  127532. /**
  127533. * Executes a function on change
  127534. * @param f A path cursor onchange callback
  127535. * @returns This path cursor
  127536. */
  127537. onchange(f: (cursor: PathCursor) => void): PathCursor;
  127538. }
  127539. }
  127540. declare module BABYLON {
  127541. /** @hidden */
  127542. export var blurPixelShader: {
  127543. name: string;
  127544. shader: string;
  127545. };
  127546. }
  127547. declare module BABYLON {
  127548. /** @hidden */
  127549. export var pointCloudVertexDeclaration: {
  127550. name: string;
  127551. shader: string;
  127552. };
  127553. }
  127554. // Mixins
  127555. interface Window {
  127556. mozIndexedDB: IDBFactory;
  127557. webkitIndexedDB: IDBFactory;
  127558. msIndexedDB: IDBFactory;
  127559. webkitURL: typeof URL;
  127560. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  127561. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  127562. WebGLRenderingContext: WebGLRenderingContext;
  127563. MSGesture: MSGesture;
  127564. CANNON: any;
  127565. AudioContext: AudioContext;
  127566. webkitAudioContext: AudioContext;
  127567. PointerEvent: any;
  127568. Math: Math;
  127569. Uint8Array: Uint8ArrayConstructor;
  127570. Float32Array: Float32ArrayConstructor;
  127571. mozURL: typeof URL;
  127572. msURL: typeof URL;
  127573. VRFrameData: any; // WebVR, from specs 1.1
  127574. DracoDecoderModule: any;
  127575. setImmediate(handler: (...args: any[]) => void): number;
  127576. }
  127577. interface HTMLCanvasElement {
  127578. requestPointerLock(): void;
  127579. msRequestPointerLock?(): void;
  127580. mozRequestPointerLock?(): void;
  127581. webkitRequestPointerLock?(): void;
  127582. /** Track wether a record is in progress */
  127583. isRecording: boolean;
  127584. /** Capture Stream method defined by some browsers */
  127585. captureStream(fps?: number): MediaStream;
  127586. }
  127587. interface CanvasRenderingContext2D {
  127588. msImageSmoothingEnabled: boolean;
  127589. }
  127590. interface MouseEvent {
  127591. mozMovementX: number;
  127592. mozMovementY: number;
  127593. webkitMovementX: number;
  127594. webkitMovementY: number;
  127595. msMovementX: number;
  127596. msMovementY: number;
  127597. }
  127598. interface Navigator {
  127599. mozGetVRDevices: (any: any) => any;
  127600. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  127601. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  127602. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  127603. webkitGetGamepads(): Gamepad[];
  127604. msGetGamepads(): Gamepad[];
  127605. webkitGamepads(): Gamepad[];
  127606. }
  127607. interface HTMLVideoElement {
  127608. mozSrcObject: any;
  127609. }
  127610. interface Math {
  127611. fround(x: number): number;
  127612. imul(a: number, b: number): number;
  127613. }
  127614. interface WebGLRenderingContext {
  127615. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  127616. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  127617. vertexAttribDivisor(index: number, divisor: number): void;
  127618. createVertexArray(): any;
  127619. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  127620. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  127621. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  127622. renderbufferStorageMultisample(target: number, samples: number, internalformat: number, width: number, height: number): void;
  127623. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  127624. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  127625. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  127626. // Queries
  127627. createQuery(): WebGLQuery;
  127628. deleteQuery(query: WebGLQuery): void;
  127629. beginQuery(target: number, query: WebGLQuery): void;
  127630. endQuery(target: number): void;
  127631. getQueryParameter(query: WebGLQuery, pname: number): any;
  127632. getQuery(target: number, pname: number): any;
  127633. MAX_SAMPLES: number;
  127634. RGBA8: number;
  127635. READ_FRAMEBUFFER: number;
  127636. DRAW_FRAMEBUFFER: number;
  127637. UNIFORM_BUFFER: number;
  127638. HALF_FLOAT_OES: number;
  127639. RGBA16F: number;
  127640. RGBA32F: number;
  127641. R32F: number;
  127642. RG32F: number;
  127643. RGB32F: number;
  127644. R16F: number;
  127645. RG16F: number;
  127646. RGB16F: number;
  127647. RED: number;
  127648. RG: number;
  127649. R8: number;
  127650. RG8: number;
  127651. UNSIGNED_INT_24_8: number;
  127652. DEPTH24_STENCIL8: number;
  127653. /* Multiple Render Targets */
  127654. drawBuffers(buffers: number[]): void;
  127655. readBuffer(src: number): void;
  127656. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  127657. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  127658. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  127659. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  127660. // Occlusion Query
  127661. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  127662. ANY_SAMPLES_PASSED: number;
  127663. QUERY_RESULT_AVAILABLE: number;
  127664. QUERY_RESULT: number;
  127665. }
  127666. interface WebGLProgram {
  127667. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  127668. }
  127669. interface EXT_disjoint_timer_query {
  127670. QUERY_COUNTER_BITS_EXT: number;
  127671. TIME_ELAPSED_EXT: number;
  127672. TIMESTAMP_EXT: number;
  127673. GPU_DISJOINT_EXT: number;
  127674. QUERY_RESULT_EXT: number;
  127675. QUERY_RESULT_AVAILABLE_EXT: number;
  127676. queryCounterEXT(query: WebGLQuery, target: number): void;
  127677. createQueryEXT(): WebGLQuery;
  127678. beginQueryEXT(target: number, query: WebGLQuery): void;
  127679. endQueryEXT(target: number): void;
  127680. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  127681. deleteQueryEXT(query: WebGLQuery): void;
  127682. }
  127683. interface WebGLUniformLocation {
  127684. _currentState: any;
  127685. }
  127686. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  127687. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  127688. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  127689. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  127690. interface WebGLRenderingContext {
  127691. readonly RASTERIZER_DISCARD: number;
  127692. readonly DEPTH_COMPONENT24: number;
  127693. readonly TEXTURE_3D: number;
  127694. readonly TEXTURE_2D_ARRAY: number;
  127695. readonly TEXTURE_COMPARE_FUNC: number;
  127696. readonly TEXTURE_COMPARE_MODE: number;
  127697. readonly COMPARE_REF_TO_TEXTURE: number;
  127698. readonly TEXTURE_WRAP_R: number;
  127699. readonly HALF_FLOAT: number;
  127700. readonly RGB8: number;
  127701. readonly RED_INTEGER: number;
  127702. readonly RG_INTEGER: number;
  127703. readonly RGB_INTEGER: number;
  127704. readonly RGBA_INTEGER: number;
  127705. readonly R8_SNORM: number;
  127706. readonly RG8_SNORM: number;
  127707. readonly RGB8_SNORM: number;
  127708. readonly RGBA8_SNORM: number;
  127709. readonly R8I: number;
  127710. readonly RG8I: number;
  127711. readonly RGB8I: number;
  127712. readonly RGBA8I: number;
  127713. readonly R8UI: number;
  127714. readonly RG8UI: number;
  127715. readonly RGB8UI: number;
  127716. readonly RGBA8UI: number;
  127717. readonly R16I: number;
  127718. readonly RG16I: number;
  127719. readonly RGB16I: number;
  127720. readonly RGBA16I: number;
  127721. readonly R16UI: number;
  127722. readonly RG16UI: number;
  127723. readonly RGB16UI: number;
  127724. readonly RGBA16UI: number;
  127725. readonly R32I: number;
  127726. readonly RG32I: number;
  127727. readonly RGB32I: number;
  127728. readonly RGBA32I: number;
  127729. readonly R32UI: number;
  127730. readonly RG32UI: number;
  127731. readonly RGB32UI: number;
  127732. readonly RGBA32UI: number;
  127733. readonly RGB10_A2UI: number;
  127734. readonly R11F_G11F_B10F: number;
  127735. readonly RGB9_E5: number;
  127736. readonly RGB10_A2: number;
  127737. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  127738. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  127739. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  127740. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  127741. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  127742. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  127743. 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;
  127744. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  127745. readonly TRANSFORM_FEEDBACK: number;
  127746. readonly INTERLEAVED_ATTRIBS: number;
  127747. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  127748. createTransformFeedback(): WebGLTransformFeedback;
  127749. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  127750. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  127751. beginTransformFeedback(primitiveMode: number): void;
  127752. endTransformFeedback(): void;
  127753. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  127754. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  127755. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  127756. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  127757. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  127758. }
  127759. interface ImageBitmap {
  127760. readonly width: number;
  127761. readonly height: number;
  127762. close(): void;
  127763. }
  127764. interface WebGLQuery extends WebGLObject {
  127765. }
  127766. declare var WebGLQuery: {
  127767. prototype: WebGLQuery;
  127768. new(): WebGLQuery;
  127769. };
  127770. interface WebGLSampler extends WebGLObject {
  127771. }
  127772. declare var WebGLSampler: {
  127773. prototype: WebGLSampler;
  127774. new(): WebGLSampler;
  127775. };
  127776. interface WebGLSync extends WebGLObject {
  127777. }
  127778. declare var WebGLSync: {
  127779. prototype: WebGLSync;
  127780. new(): WebGLSync;
  127781. };
  127782. interface WebGLTransformFeedback extends WebGLObject {
  127783. }
  127784. declare var WebGLTransformFeedback: {
  127785. prototype: WebGLTransformFeedback;
  127786. new(): WebGLTransformFeedback;
  127787. };
  127788. interface WebGLVertexArrayObject extends WebGLObject {
  127789. }
  127790. declare var WebGLVertexArrayObject: {
  127791. prototype: WebGLVertexArrayObject;
  127792. new(): WebGLVertexArrayObject;
  127793. };
  127794. // Type definitions for WebVR API
  127795. // Project: https://w3c.github.io/webvr/
  127796. // Definitions by: six a <https://github.com/lostfictions>
  127797. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  127798. interface VRDisplay extends EventTarget {
  127799. /**
  127800. * Dictionary of capabilities describing the VRDisplay.
  127801. */
  127802. readonly capabilities: VRDisplayCapabilities;
  127803. /**
  127804. * z-depth defining the far plane of the eye view frustum
  127805. * enables mapping of values in the render target depth
  127806. * attachment to scene coordinates. Initially set to 10000.0.
  127807. */
  127808. depthFar: number;
  127809. /**
  127810. * z-depth defining the near plane of the eye view frustum
  127811. * enables mapping of values in the render target depth
  127812. * attachment to scene coordinates. Initially set to 0.01.
  127813. */
  127814. depthNear: number;
  127815. /**
  127816. * An identifier for this distinct VRDisplay. Used as an
  127817. * association point in the Gamepad API.
  127818. */
  127819. readonly displayId: number;
  127820. /**
  127821. * A display name, a user-readable name identifying it.
  127822. */
  127823. readonly displayName: string;
  127824. readonly isConnected: boolean;
  127825. readonly isPresenting: boolean;
  127826. /**
  127827. * If this VRDisplay supports room-scale experiences, the optional
  127828. * stage attribute contains details on the room-scale parameters.
  127829. */
  127830. readonly stageParameters: VRStageParameters | null;
  127831. /**
  127832. * Passing the value returned by `requestAnimationFrame` to
  127833. * `cancelAnimationFrame` will unregister the callback.
  127834. * @param handle Define the hanle of the request to cancel
  127835. */
  127836. cancelAnimationFrame(handle: number): void;
  127837. /**
  127838. * Stops presenting to the VRDisplay.
  127839. * @returns a promise to know when it stopped
  127840. */
  127841. exitPresent(): Promise<void>;
  127842. /**
  127843. * Return the current VREyeParameters for the given eye.
  127844. * @param whichEye Define the eye we want the parameter for
  127845. * @returns the eye parameters
  127846. */
  127847. getEyeParameters(whichEye: string): VREyeParameters;
  127848. /**
  127849. * Populates the passed VRFrameData with the information required to render
  127850. * the current frame.
  127851. * @param frameData Define the data structure to populate
  127852. * @returns true if ok otherwise false
  127853. */
  127854. getFrameData(frameData: VRFrameData): boolean;
  127855. /**
  127856. * Get the layers currently being presented.
  127857. * @returns the list of VR layers
  127858. */
  127859. getLayers(): VRLayer[];
  127860. /**
  127861. * Return a VRPose containing the future predicted pose of the VRDisplay
  127862. * when the current frame will be presented. The value returned will not
  127863. * change until JavaScript has returned control to the browser.
  127864. *
  127865. * The VRPose will contain the position, orientation, velocity,
  127866. * and acceleration of each of these properties.
  127867. * @returns the pose object
  127868. */
  127869. getPose(): VRPose;
  127870. /**
  127871. * Return the current instantaneous pose of the VRDisplay, with no
  127872. * prediction applied.
  127873. * @returns the current instantaneous pose
  127874. */
  127875. getImmediatePose(): VRPose;
  127876. /**
  127877. * The callback passed to `requestAnimationFrame` will be called
  127878. * any time a new frame should be rendered. When the VRDisplay is
  127879. * presenting the callback will be called at the native refresh
  127880. * rate of the HMD. When not presenting this function acts
  127881. * identically to how window.requestAnimationFrame acts. Content should
  127882. * make no assumptions of frame rate or vsync behavior as the HMD runs
  127883. * asynchronously from other displays and at differing refresh rates.
  127884. * @param callback Define the eaction to run next frame
  127885. * @returns the request handle it
  127886. */
  127887. requestAnimationFrame(callback: FrameRequestCallback): number;
  127888. /**
  127889. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  127890. * Repeat calls while already presenting will update the VRLayers being displayed.
  127891. * @param layers Define the list of layer to present
  127892. * @returns a promise to know when the request has been fulfilled
  127893. */
  127894. requestPresent(layers: VRLayer[]): Promise<void>;
  127895. /**
  127896. * Reset the pose for this display, treating its current position and
  127897. * orientation as the "origin/zero" values. VRPose.position,
  127898. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  127899. * updated when calling resetPose(). This should be called in only
  127900. * sitting-space experiences.
  127901. */
  127902. resetPose(): void;
  127903. /**
  127904. * The VRLayer provided to the VRDisplay will be captured and presented
  127905. * in the HMD. Calling this function has the same effect on the source
  127906. * canvas as any other operation that uses its source image, and canvases
  127907. * created without preserveDrawingBuffer set to true will be cleared.
  127908. * @param pose Define the pose to submit
  127909. */
  127910. submitFrame(pose?: VRPose): void;
  127911. }
  127912. declare var VRDisplay: {
  127913. prototype: VRDisplay;
  127914. new(): VRDisplay;
  127915. };
  127916. interface VRLayer {
  127917. leftBounds?: number[] | Float32Array | null;
  127918. rightBounds?: number[] | Float32Array | null;
  127919. source?: HTMLCanvasElement | null;
  127920. }
  127921. interface VRDisplayCapabilities {
  127922. readonly canPresent: boolean;
  127923. readonly hasExternalDisplay: boolean;
  127924. readonly hasOrientation: boolean;
  127925. readonly hasPosition: boolean;
  127926. readonly maxLayers: number;
  127927. }
  127928. interface VREyeParameters {
  127929. /** @deprecated */
  127930. readonly fieldOfView: VRFieldOfView;
  127931. readonly offset: Float32Array;
  127932. readonly renderHeight: number;
  127933. readonly renderWidth: number;
  127934. }
  127935. interface VRFieldOfView {
  127936. readonly downDegrees: number;
  127937. readonly leftDegrees: number;
  127938. readonly rightDegrees: number;
  127939. readonly upDegrees: number;
  127940. }
  127941. interface VRFrameData {
  127942. readonly leftProjectionMatrix: Float32Array;
  127943. readonly leftViewMatrix: Float32Array;
  127944. readonly pose: VRPose;
  127945. readonly rightProjectionMatrix: Float32Array;
  127946. readonly rightViewMatrix: Float32Array;
  127947. readonly timestamp: number;
  127948. }
  127949. interface VRPose {
  127950. readonly angularAcceleration: Float32Array | null;
  127951. readonly angularVelocity: Float32Array | null;
  127952. readonly linearAcceleration: Float32Array | null;
  127953. readonly linearVelocity: Float32Array | null;
  127954. readonly orientation: Float32Array | null;
  127955. readonly position: Float32Array | null;
  127956. readonly timestamp: number;
  127957. }
  127958. interface VRStageParameters {
  127959. sittingToStandingTransform?: Float32Array;
  127960. sizeX?: number;
  127961. sizeY?: number;
  127962. }
  127963. interface Navigator {
  127964. getVRDisplays(): Promise<VRDisplay[]>;
  127965. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  127966. }
  127967. interface Window {
  127968. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  127969. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  127970. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  127971. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  127972. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  127973. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  127974. }
  127975. interface Gamepad {
  127976. readonly displayId: number;
  127977. }
  127978. type XRSessionMode =
  127979. | "inline"
  127980. | "immersive-vr"
  127981. | "immersive-ar";
  127982. type XRReferenceSpaceType =
  127983. | "viewer"
  127984. | "local"
  127985. | "local-floor"
  127986. | "bounded-floor"
  127987. | "unbounded";
  127988. type XREnvironmentBlendMode =
  127989. | "opaque"
  127990. | "additive"
  127991. | "alpha-blend";
  127992. type XRVisibilityState =
  127993. | "visible"
  127994. | "visible-blurred"
  127995. | "hidden";
  127996. type XRHandedness =
  127997. | "none"
  127998. | "left"
  127999. | "right";
  128000. type XRTargetRayMode =
  128001. | "gaze"
  128002. | "tracked-pointer"
  128003. | "screen";
  128004. type XREye =
  128005. | "none"
  128006. | "left"
  128007. | "right";
  128008. interface XRSpace extends EventTarget {
  128009. }
  128010. interface XRRenderState {
  128011. depthNear?: number;
  128012. depthFar?: number;
  128013. inlineVerticalFieldOfView?: number;
  128014. baseLayer?: XRWebGLLayer;
  128015. }
  128016. interface XRInputSource {
  128017. handedness: XRHandedness;
  128018. targetRayMode: XRTargetRayMode;
  128019. targetRaySpace: XRSpace;
  128020. gripSpace: XRSpace | undefined;
  128021. gamepad: Gamepad | undefined;
  128022. profiles: Array<string>;
  128023. }
  128024. interface XRSession {
  128025. addEventListener: Function;
  128026. requestReferenceSpace(type: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  128027. updateRenderState(XRRenderStateInit: XRRenderState): Promise<void>;
  128028. requestAnimationFrame: Function;
  128029. end(): Promise<void>;
  128030. renderState: XRRenderState;
  128031. inputSources: Array<XRInputSource>;
  128032. }
  128033. interface XRReferenceSpace extends XRSpace {
  128034. getOffsetReferenceSpace(originOffset: XRRigidTransform): XRReferenceSpace;
  128035. onreset: any;
  128036. }
  128037. interface XRFrame {
  128038. session: XRSession;
  128039. getViewerPose(referenceSpace: XRReferenceSpace): XRViewerPose | undefined;
  128040. getPose(space: XRSpace, baseSpace: XRSpace): XRPose | undefined;
  128041. }
  128042. interface XRViewerPose extends XRPose {
  128043. views: Array<XRView>;
  128044. }
  128045. interface XRPose {
  128046. transform: XRRigidTransform;
  128047. emulatedPosition: boolean;
  128048. }
  128049. declare var XRWebGLLayer: {
  128050. prototype: XRWebGLLayer;
  128051. new(session: XRSession, context: WebGLRenderingContext | undefined): XRWebGLLayer;
  128052. };
  128053. interface XRWebGLLayer {
  128054. framebuffer: WebGLFramebuffer;
  128055. framebufferWidth: number;
  128056. framebufferHeight: number;
  128057. getViewport: Function;
  128058. }
  128059. interface XRRigidTransform {
  128060. position: DOMPointReadOnly;
  128061. orientation: DOMPointReadOnly;
  128062. matrix: Float32Array;
  128063. inverse: XRRigidTransform;
  128064. }
  128065. interface XRView {
  128066. eye: XREye;
  128067. projectionMatrix: Float32Array;
  128068. transform: XRRigidTransform;
  128069. }
  128070. interface XRInputSourceChangeEvent {
  128071. session: XRSession;
  128072. removed: Array<XRInputSource>;
  128073. added: Array<XRInputSource>;
  128074. }